/* ── Variables ────────────────────────────────────────────────── */
:root {
    --bg:           #0a0a0a;
    --card:         #1a1a1a;
    --border:       #2a2a2a;
    --primary:      #f5a623;
    --primary-dim:  rgba(245,166,35,.12);
    --text:         #ffffff;
    --muted:        #888888;
    --dim:          #444444;
    --danger:       #e53935;
    --success:      #43a047;
    --radius:       14px;
    --radius-sm:    8px;
}

/* ── Reset ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

button { cursor: pointer; font: inherit; }
a      { color: var(--primary); text-decoration: none; }
ul     { list-style: none; }

.hidden { display: none !important; }

/* ── Layout helpers ───────────────────────────────────────────── */
.page-center {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Home ─────────────────────────────────────────────────────── */
.home-wrap {
    width: 100%;
    max-width: 440px;
}

.home-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.app-title {
    font-size: clamp(2.4rem, 8vw, 3.2rem);
    font-weight: 900;
    color: var(--primary);
    letter-spacing: -.05em;
}

.app-sub {
    margin-top: .4rem;
    color: var(--muted);
    font-size: .9rem;
}

/* Mode cards */
.mode-cards {
    display: flex;
    flex-direction: column;
    gap: .875rem;
}

.mode-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .25rem;
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius);
    background: var(--card);
    border: 1px solid var(--border);
    text-align: left;
    transition: opacity .15s, transform .1s;
}
.mode-card:active { transform: scale(.98); opacity: .8; }
.mode-card--primary { background: var(--primary); border-color: var(--primary); }

.mode-card__icon  { font-size: 1.75rem; }
.mode-card__title { font-size: 1.2rem; font-weight: 700; color: var(--text); }
.mode-card__sub   { font-size: .8rem; color: rgba(255,255,255,.6); }

/* Alert */
.alert {
    background: rgba(229,57,53,.15);
    border: 1px solid rgba(229,57,53,.4);
    border-radius: var(--radius-sm);
    padding: .75rem 1rem;
    color: #f88;
    font-size: .9rem;
    margin-bottom: 1rem;
}

/* Join form */
.join-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-mode-header {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text);
}

/* ── Fields ───────────────────────────────────────────────────── */
.field        { display: flex; flex-direction: column; gap: .4rem; }
.field-label  { font-size: .75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.field-hint   { font-size: .78rem; color: var(--dim); line-height: 1.4; margin-top: .2rem; }

.field-input {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .75rem 1rem;
    color: var(--text);
    font-size: 1rem;
    outline: none;
    width: 100%;
    transition: border-color .15s;
}
.field-input:focus { border-color: var(--primary); }
.field-input::placeholder { color: var(--dim); }

/* Password row */
.pw-row   { display: flex; }
.pw-input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); border-right: none; }
.pw-eye   {
    width: 48px;
    background: var(--card);
    border: 1px solid var(--border);
    border-left: none;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 1rem;
    color: var(--muted);
    flex-shrink: 0;
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn-primary {
    background: var(--primary);
    color: var(--text);
    border: none;
    border-radius: var(--radius);
    padding: .9rem 1.5rem;
    font-size: 1rem;
    font-weight: 700;
    width: 100%;
    transition: opacity .15s;
}
.btn-primary:active { opacity: .8; }

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .75rem 1.5rem;
    font-size: .9rem;
    width: 100%;
    text-align: center;
    display: inline-block;
}

.btn-icon {
    width: 48px;
    height: 48px;
    background: var(--primary);
    color: var(--text);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1.6rem;
    font-weight: 300;
    line-height: 1;
    flex-shrink: 0;
}
.btn-icon:disabled { background: var(--border); }

/* ── Topbar ───────────────────────────────────────────────────── */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    flex-wrap: wrap;
}

.topbar__left {
    display: flex;
    align-items: baseline;
    gap: .5rem;
}
.topbar__app   { font-weight: 900; color: var(--primary); font-size: 1.1rem; letter-spacing: -.03em; }
.topbar__group {
    font-size: .8rem;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-dim);
    border-radius: 6px;
    padding: .15rem .5rem;
}

.topbar__right { display: flex; align-items: center; gap: .5rem; }

.topbar__password {
    font-size: .8rem;
    font-weight: 600;
    color: var(--muted);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: .15rem .5rem;
    letter-spacing: .02em;
}

.topbar__end-session {
    font-size: .78rem;
    color: var(--dim);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: .3rem .65rem;
    white-space: nowrap;
    transition: color .15s, border-color .15s;
}
.topbar__end-session:hover { color: var(--danger); border-color: var(--danger); }

.group-badge__sep {
    color: var(--dim);
    margin: 0 .1rem;
}

/* ── Tabs ─────────────────────────────────────────────────────── */
.tab-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-size: .85rem;
    padding: .4rem .75rem;
    transition: all .15s;
}
.tab-btn--active {
    background: var(--primary-dim);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}

.tab-section { flex: 1; display: flex; flex-direction: column; }

/* ── Setlist ──────────────────────────────────────────────────── */
.add-bar {
    display: flex;
    gap: .5rem;
    padding: .75rem;
    border-bottom: 1px solid var(--border);
}
.add-bar .field-input { border-radius: var(--radius-sm); }

.setlist {
    padding: .5rem;
    display: flex;
    flex-direction: column;
    gap: .35rem;
    overflow-y: auto;
}

.setlist-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    background: var(--card);
    border-radius: var(--radius);
    padding: .875rem 1rem;
    border: 1px solid transparent;
    transition: border-color .12s, background .12s;
}
.setlist-row--gig { cursor: pointer; }
.setlist-row--gig:active { opacity: .7; }
.setlist-row--active {
    background: var(--primary-dim);
    border-color: var(--primary);
}

.setlist-num {
    width: 28px;
    text-align: right;
    color: var(--muted);
    font-size: .85rem;
    flex-shrink: 0;
}
.setlist-num--active { color: var(--primary); font-weight: 700; }

.setlist-name {
    flex: 1;
    font-size: 1.05rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.setlist-actions { display: flex; gap: .3rem; }

.row-btn {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    background: var(--border);
    border: none;
    color: var(--text);
    font-size: .7rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.row-btn:disabled { opacity: .2; }
.row-btn--del     { background: rgba(229,57,53,.18); color: var(--danger); }

.playing-dot { color: var(--primary); font-size: .9rem; }

/* ── Search bar ───────────────────────────────────────────────── */
.search-bar {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .6rem .75rem;
    border-bottom: 1px solid var(--border);
}

.search-input {
    border-radius: var(--radius-sm);
    flex: 1;
}

.search-count {
    font-size: .78rem;
    color: var(--muted);
    white-space: nowrap;
    min-width: 6rem;
    text-align: right;
}

.topbar__count {
    font-size: .8rem;
    color: var(--muted);
}

/* ── Empty msg ────────────────────────────────────────────────── */
.empty-msg {
    text-align: center;
    color: var(--muted);
    font-size: .95rem;
    padding: 2rem;
    line-height: 1.6;
}

/* ── Song overlay (fullscreen) ────────────────────────────────── */
.song-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 4rem;
}

.song-overlay__text {
    font-size: clamp(2.5rem, 10vw, 8rem);
    font-weight: 900;
    color: var(--text);
    text-align: center;
    letter-spacing: -.04em;
    line-height: 1.1;
    word-break: break-word;
}

/* Larger in landscape */
@media (orientation: landscape) {
    .song-overlay__text {
        font-size: clamp(4rem, 16vw, 12rem);
    }
}

.song-overlay__exit {
    position: absolute;
    bottom: 1.25rem;
    right: 1.25rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,.1);
    border: none;
    color: var(--muted);
    font-size: 1rem;
    font-weight: 600;
    transition: background .15s;
}
.song-overlay__exit:hover { background: rgba(255,255,255,.2); }

.song-overlay__controls {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    display: flex;
    gap: .5rem;
}

.song-font-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,.1);
    border: none;
    color: var(--text);
    font-size: .95rem;
    font-weight: 700;
    transition: background .15s;
}
.song-font-btn:hover  { background: rgba(255,255,255,.2); }
.song-font-btn:active { background: rgba(255,255,255,.3); }

/* ── Receiver wait screen ─────────────────────────────────────── */
.wait-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .75rem;
    text-align: center;
    max-width: 320px;
}

/* CSS spinner */
.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .9s linear infinite;
    margin-bottom: .5rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

.wait-status {
    font-size: 1.3rem;
    font-weight: 600;
}

.group-badge {
    display: flex;
    align-items: center;
    gap: .4rem;
    background: var(--primary-dim);
    border: 1px solid rgba(245,166,35,.25);
    border-radius: var(--radius-sm);
    padding: .35rem .75rem;
    font-size: .85rem;
    color: var(--primary);
}

.wait-hint {
    font-size: .85rem;
    color: var(--muted);
    line-height: 1.5;
}
