/* Low City — gestion à distance.
   Sombre, plein écran, pensé pour un téléphone tenu à une main. */

:root {
    --bg: #07080d;
    --bg-2: #0d1018;
    --surface: rgba(255, 255, 255, .055);
    --surface-2: rgba(255, 255, 255, .09);
    --line: rgba(255, 255, 255, .09);
    --text: #f3f5fa;
    --muted: #8c93a6;
    --accent: #4f7dff;
    --accent-2: #7a5cff;
    --good: #35c47a;
    --warn: #f0b429;
    --bad: #ff5a5a;
    --radius: 18px;
    --tab-h: 58px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
    overscroll-behavior-y: none;
}

body {
    background:
        radial-gradient(120% 60% at 50% 0%, #1b2030 0%, transparent 60%),
        var(--bg);
    min-height: 100vh;
}

h1, h2 { margin: 0; font-weight: 650; letter-spacing: -.02em; }
h1 { font-size: 26px; }
h2 { font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; font-weight: 600; }

code {
    font: 13px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
    background: var(--surface-2);
    padding: 1px 5px;
    border-radius: 6px;
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--bad); font-size: 14px; margin: 10px 0 0; }

/* ── Appairage ─────────────────────────────────────────────────────────── */

.pair {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: calc(var(--safe-t) + 24px) 16px calc(var(--safe-b) + 24px);
}

.pair-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 26px;
    padding: 26px 22px 22px;
    backdrop-filter: blur(20px);
}

.brand {
    width: 58px;
    height: 58px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    font-weight: 700;
    letter-spacing: -.04em;
    font-size: 22px;
    background: linear-gradient(160deg, #262c42, #12141c);
    border: 1px solid var(--line);
    margin-bottom: 16px;
}

.pair-card h1 { font-size: 28px; }
.pair-card p { margin: 6px 0 20px; }
.pair-card label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
.pair-card .hint { margin: 18px 0 0; font-size: 13px; color: var(--muted); line-height: 1.5; }

#pairCode { text-transform: uppercase; letter-spacing: .32em; font-size: 22px; text-align: center; }

/* ── Champs et boutons ─────────────────────────────────────────────────── */

input, textarea, select, button, a.primary {
    font-family: inherit;
    font-size: 16px;
    color: var(--text);
}

input[type=text], input:not([type]), input[type=number], input[type=search], textarea, select {
    width: 100%;
    background: rgba(0, 0, 0, .35);
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 12px 14px;
    outline: none;
}

input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: none; }

button, a.primary {
    border: 1px solid var(--line);
    background: var(--surface-2);
    border-radius: 13px;
    padding: 11px 14px;
    font-weight: 550;
    cursor: pointer;
    transition: transform .08s ease, opacity .15s ease;
}

button:active, a.primary:active { transform: scale(.97); }
button[disabled] { opacity: .45; }

.primary {
    width: 100%;
    margin-top: 16px;
    border: none;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    padding: 13px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    display: block;
}

.block { margin-top: 12px; }
.danger { color: var(--bad); border-color: rgba(255, 90, 90, .35); }
.ghost { background: transparent; }

.icon-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--surface);
}

.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: var(--text); stroke-width: 1.9; stroke-linecap: round; }

/* ── Structure ─────────────────────────────────────────────────────────── */

.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    padding: calc(var(--safe-t) + 14px) 16px 12px;
    background: linear-gradient(180deg, rgba(7, 8, 13, .96), rgba(7, 8, 13, .72));
    backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--line);
}

.eyebrow { font-size: 12px; color: var(--muted); letter-spacing: .04em; }

.view { display: none; padding: 14px 16px calc(var(--tab-h) + var(--safe-b) + 26px); }
.view.on { display: block; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 15px;
    margin-bottom: 13px;
}

.card > h2 { margin-bottom: 11px; }
.card > .primary:last-child { margin-bottom: 0; }
.card.search { padding: 10px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-bottom: 13px; }

.stat { display: flex; flex-direction: column; gap: 3px; padding: 14px 15px; }
.stat .k { font-size: 25px; font-weight: 680; letter-spacing: -.03em; }
.stat .l { font-size: 12px; color: var(--muted); }

.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.row-actions button { flex: 1 1 auto; min-width: calc(50% - 4px); }

/* ── Listes ────────────────────────────────────────────────────────────── */

.list { display: flex; flex-direction: column; }

.item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    background: none;
    border-left: none;
    border-right: none;
    border-top: none;
    border-radius: 0;
    width: 100%;
}

.item:last-child { border-bottom: none; }

.avatar {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 650;
    background: linear-gradient(150deg, #2a3048, #14161f);
    border: 1px solid var(--line);
}

.item .body { flex: 1; min-width: 0; }
.item .name { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .tail { font-size: 12px; color: var(--muted); text-align: right; flex: 0 0 auto; }

.list.compact .item { padding: 9px 4px; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.pill.on { color: var(--good); border-color: rgba(53, 196, 122, .35); }
.pill.off { color: var(--bad); border-color: rgba(255, 90, 90, .3); }

.empty { padding: 22px 4px; color: var(--muted); text-align: center; font-size: 14px; }

/* ── Réglages ──────────────────────────────────────────────────────────── */

.slider { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.slider input { flex: 1; accent-color: var(--accent); }
.slider output { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--muted); min-width: 66px; text-align: right; }

.switch { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); }
.switch:last-child { border-bottom: none; }
.switch input { width: 46px; height: 28px; appearance: none; background: var(--surface-2); border-radius: 999px; position: relative; transition: background .2s; }
.switch input:checked { background: var(--good); }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked::after { transform: translateX(18px); }

.seg { display: flex; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 4px; margin-bottom: 13px; }
.seg button { flex: 1; border: none; background: transparent; padding: 9px 6px; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--surface-2); color: var(--text); }

/* ── txAdmin ───────────────────────────────────────────────────────────── */

.frame-wrap {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
    height: 72vh;
}

#txFrame { width: 100%; height: 100%; border: 0; display: block; }

/* ── Onglets ───────────────────────────────────────────────────────────── */

.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 6;
    display: flex;
    padding-bottom: var(--safe-b);
    background: rgba(9, 10, 16, .82);
    backdrop-filter: blur(22px);
    border-top: 1px solid var(--line);
}

.tabbar button {
    flex: 1;
    border: none;
    background: none;
    border-radius: 0;
    padding: 8px 2px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 500;
    height: var(--tab-h);
}

.tabbar svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabbar button.on { color: var(--text); }

/* ── Fiche joueur ──────────────────────────────────────────────────────── */

.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet-back { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); backdrop-filter: blur(3px); }

.sheet-body {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 92vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--bg-2);
    border-top-left-radius: 26px;
    border-top-right-radius: 26px;
    border-top: 1px solid var(--line);
    padding: 8px 16px calc(var(--safe-b) + 24px);
    animation: rise .25s cubic-bezier(.2, .8, .2, 1);
}

@keyframes rise { from { transform: translateY(18%); opacity: .6; } to { transform: none; opacity: 1; } }

.sheet-grab { width: 42px; height: 5px; border-radius: 999px; background: var(--surface-2); margin: 6px auto 14px; }

.sheet h1 { font-size: 22px; }
.sheet .meta { color: var(--muted); font-size: 13px; margin: 4px 0 16px; }
.sheet .group { margin-bottom: 16px; }
.sheet .group > h2 { margin-bottom: 9px; }
.sheet .pair-row { display: flex; gap: 8px; }
.sheet .pair-row input, .sheet .pair-row select { flex: 1; }
.sheet .pair-row button { flex: 0 0 auto; margin: 0; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border-bottom: none; }
.kv span:last-child { color: var(--muted); text-align: right; word-break: break-all; }

/* ── Toast ─────────────────────────────────────────────────────────────── */

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--tab-h) + var(--safe-b) + 18px);
    transform: translateX(-50%);
    z-index: 40;
    max-width: calc(100vw - 32px);
    background: rgba(20, 23, 32, .96);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 16px;
    font-size: 14px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .55);
    animation: rise .2s ease;
}

.toast.good { border-color: rgba(53, 196, 122, .45); }
.toast.bad { border-color: rgba(255, 90, 90, .45); }
