/* KFSelect: custom dropdowns (see static/js/kfselect.js) */
select.kfs-native { display: none !important; }

.kfs-btn {
    display: inline-flex; align-items: center; justify-content: space-between; gap: 10px;
    min-height: 40px; max-width: 100%; padding: 0 12px 0 14px;
    border: 1px solid var(--border, rgba(255, 255, 255, 0.12)); border-radius: 10px;
    background: var(--surface, #16161c); color: var(--text, #f5f5f7);
    font: 600 0.9rem var(--font-body, inherit); text-align: left; cursor: pointer;
    -webkit-tap-highlight-color: transparent; touch-action: manipulation;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.kfs-btn:hover:not(:disabled) { background: var(--surface-hover, #1e1e26); }
.kfs-btn:focus-visible, .kfs-btn.kfs-open { outline: 0; border-color: var(--accent, #6366f1); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.22); }
.kfs-btn:disabled { opacity: 0.5; cursor: default; }
.kfs-value { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kfs-chev { flex: none; width: 16px; height: 16px; color: var(--text-dim, #9aa0b4); transition: transform 0.18s ease; }
.kfs-btn.kfs-open .kfs-chev { transform: rotate(180deg); }

/* Where the old select sat inside a styled wrapper */
.gd-select > .i { display: none; }
.gd-select .kfs-btn { min-width: 150px; }
.gd-fgroup .kfs-btn { width: 100%; min-height: 38px; border-radius: 9px; background: #101010; font-weight: 500; }
.kfs-btn.pl-input { min-height: 38px; height: 38px; padding: 0 10px 0 12px; font-weight: 500; font-size: 0.86rem; background: rgba(255, 255, 255, 0.05); }

.kfs-backdrop { position: fixed; inset: 0; z-index: 99998; background: transparent; }
.kfs-backdrop.kfs-sheet-mode { background: rgba(0, 0, 0, 0.55); animation: kfs-fade 0.18s ease; }

.kfs-panel {
    position: fixed; z-index: 99999; display: flex; flex-direction: column;
    max-height: 420px; padding: 6px; outline: 0;
    background: #17171e; color: var(--text, #f5f5f7);
    border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 12px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.3);
    font-family: var(--font-body, inherit);
    opacity: 0; transform: translateY(-4px); transition: opacity 0.14s ease, transform 0.14s ease;
}
.kfs-panel.kfs-up { transform: translateY(4px); }
.kfs-panel.kfs-in { opacity: 1; transform: none; }
.kfs-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

.kfs-opt {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    min-height: 36px; padding: 8px 12px; border-radius: 8px;
    font-size: 0.9rem; line-height: 1.25; cursor: pointer; user-select: none;
}
.kfs-opt-text { min-width: 0; overflow-wrap: anywhere; }
.kfs-check { flex: none; width: 16px; height: 16px; color: var(--accent, #6366f1); visibility: hidden; }
.kfs-opt.kfs-active { background: rgba(255, 255, 255, 0.08); }
.kfs-opt.kfs-selected { color: #fff; font-weight: 600; }
.kfs-opt.kfs-selected .kfs-check { visibility: visible; }
.kfs-opt.kfs-disabled { opacity: 0.4; cursor: default; }
.kfs-group { padding: 10px 12px 4px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim, #9aa0b4); }
.kfs-empty { padding: 14px 12px; color: var(--text-dim, #9aa0b4); font-size: 0.88rem; text-align: center; }

.kfs-search { flex: none; display: flex; align-items: center; gap: 8px; margin: 2px 2px 6px; padding: 0 10px; height: 38px; border-radius: 9px; background: rgba(255, 255, 255, 0.06); color: var(--text-dim, #9aa0b4); }
.kfs-search svg { width: 16px; height: 16px; flex: none; }
.kfs-search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; color: var(--text, #f5f5f7); font: inherit; font-size: 16px; /* 16px: iOS doesn't zoom in */ }

/* Phones and short landscape windows: a centred card */
.kfs-panel.kfs-sheet {
    left: 50%; right: auto; top: 50%; bottom: auto; width: min(calc(100% - 28px), 440px);
    max-height: min(78dvh, 78vh, 620px);
    padding: 12px 10px 10px;
    border-radius: 20px;
    transform: translate(-50%, -50%) scale(0.95);
}
.kfs-panel.kfs-sheet.kfs-in { transform: translate(-50%, -50%); }
.kfs-grip { display: none; }
.kfs-title { flex: none; padding: 2px 8px 10px; font-weight: 700; font-size: 1rem; text-align: center; }
.kfs-sheet .kfs-opt { min-height: 48px; padding: 12px 14px; font-size: 1rem; border-radius: 10px; }
.kfs-sheet .kfs-search { height: 44px; }
@media (orientation: landscape) and (max-height: 500px) {
    .kfs-panel.kfs-sheet { max-height: calc(100dvh - 24px); width: min(calc(100% - 28px), 520px); }
    .kfs-sheet .kfs-opt { min-height: 42px; padding: 9px 14px; }
    .kfs-title { padding-bottom: 6px; }
}

@media (hover: none) { .kfs-opt.kfs-active:not(.kfs-selected) { background: transparent; } .kfs-opt:active { background: rgba(255, 255, 255, 0.1); } }
@media (prefers-reduced-motion: reduce) { .kfs-panel, .kfs-chev { transition: none; } .kfs-backdrop { animation: none; } }
@keyframes kfs-fade { from { opacity: 0; } }
