:root {
    --bg: #131113;
    --surface: #1b181b;
    --surface-2: #231f23;
    --line: #2d282d;
    --text: #ece8e8;
    --muted: #9b9397;
    --accent: #b8372f;
    --accent-hover: #cc4238;
    --accent-text: #e8776c;
    --ok: #6fb98a;
    --radius: 8px;
    --font: 'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }

.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* ── Connexion ─────────────────────────────────────────────── */
.login {
    min-height: 100%;
    display: grid;
    place-items: center;
    padding: 24px;
}
.login-box {
    width: 100%;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.login-box h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.form-error { color: var(--accent-text); min-height: 1.4em; font-size: 14px; }

/* ── Structure ─────────────────────────────────────────────── */
.app {
    display: grid;
    grid-template-columns: 68px 224px minmax(0, 1fr);
    height: 100%;
}

.rail {
    background: #0e0c0e;
    border-right: 1px solid var(--line);
    padding: 14px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    overflow-y: auto;
}
.rail-btn {
    position: relative;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 14px;
    background: var(--surface-2);
    color: var(--text);
    font: 600 15px var(--font);
    cursor: pointer;
    overflow: hidden;
    flex: none;
    transition: border-radius 0.15s, background 0.15s;
}
.rail-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rail-btn:hover { border-radius: 10px; background: var(--line); }
.rail-btn.active { border-radius: 10px; outline: 2px solid var(--accent); outline-offset: 2px; }

.nav {
    background: var(--surface);
    border-right: 1px solid var(--line);
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.nav-title {
    font-weight: 700;
    font-size: 16px;
    padding: 0 10px 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.nav-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.nav-sep { margin: 20px 10px 8px; font-size: 13px; color: var(--muted); }
.nav-item {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    color: var(--muted);
    font: 500 14px var(--font);
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--surface-2); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.nav-logout {
    margin-top: auto;
    background: none;
    border: none;
    color: var(--muted);
    font: 500 13px var(--font);
    text-align: left;
    padding: 8px 10px;
    cursor: pointer;
    border-radius: 6px;
}
.nav-logout:hover { color: var(--text); background: var(--surface-2); }

.main { padding: 30px 40px 60px; overflow-y: auto; min-width: 0; }
.page { max-width: 980px; }

.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.page-head img, .page-head .ph-icon { width: 44px; height: 44px; border-radius: 12px; object-fit: cover; background: var(--surface-2); }
.page-head h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.015em; line-height: 1.2; }
.page-head p { color: var(--muted); font-size: 14px; }

h2.section { font-size: 15px; font-weight: 650; margin: 34px 0 12px; }

/* ── Formulaires & boutons ─────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; color: var(--muted); }
.field small { font-size: 12px; color: var(--muted); }

input[type=text], input[type=password], input[type=number], input[type=search], input[type=url], select, textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--line);
    color: var(--text);
    font: 400 14px var(--font);
    padding: 9px 11px;
    border-radius: 6px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 72px; }
input[type=color] { width: 44px; height: 36px; padding: 2px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 14px; cursor: pointer; }

.btn {
    background: var(--accent);
    color: #fff;
    border: 1px solid transparent;
    font: 600 14px var(--font);
    padding: 9px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: transparent; color: var(--accent-text); border-color: #5a2a27; }
.btn.danger:hover { background: #2a1615; }
.btn.sm { padding: 5px 10px; font-size: 13px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }

/* ── Tableaux & listes ─────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; font-size: 13px; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: var(--surface); }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn + .btn { margin-left: 6px; }

.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); object-fit: cover; flex: none; display: grid; place-items: center; font-size: 12px; color: var(--muted); }
.who b { font-weight: 600; display: block; line-height: 1.25; }
.who small { color: var(--muted); font-size: 12px; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 10px 28px; }
.kv dt { color: var(--muted); }
.kv dd { font-weight: 500; }
.yes { color: var(--ok); }
.no { color: var(--accent-text); }

.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.badge.warn { background: #33201e; color: var(--accent-text); }

.empty { color: var(--muted); padding: 28px 0; }
.notice { background: var(--surface); border-left: 3px solid var(--accent); padding: 12px 16px; border-radius: 0 6px 6px 0; color: var(--muted); font-size: 14px; margin-bottom: 18px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab { background: none; border: none; color: var(--muted); font: 500 14px var(--font); padding: 9px 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* ── Musique ───────────────────────────────────────────────── */
.now { display: flex; gap: 18px; align-items: center; padding: 18px; background: var(--surface); border-radius: var(--radius); margin-bottom: 18px; }
.now img { width: 96px; height: 96px; border-radius: 8px; object-fit: cover; background: var(--surface-2); flex: none; }
.now h3 { font-size: 17px; font-weight: 650; line-height: 1.3; margin-bottom: 2px; }
.now a { color: inherit; text-decoration: none; }
.now a:hover { text-decoration: underline; }
.queue { list-style: none; }
.queue li { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.queue .pos { width: 26px; color: var(--muted); font-size: 13px; text-align: right; }
.queue .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue .d { color: var(--muted); font-size: 13px; }

/* ── Embeds ────────────────────────────────────────────────── */
.compose { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 36px; align-items: start; }
.preview-label { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.discord-msg { background: #313338; border-radius: 8px; padding: 16px; color: #dbdee1; font-size: 15px; }
.discord-msg .content { margin-bottom: 8px; white-space: pre-wrap; word-break: break-word; }
.embed-prev { background: #2b2d31; border-left: 4px solid var(--accent); border-radius: 4px; padding: 10px 14px 12px; max-width: 420px; position: relative; }
.embed-prev .et { font-weight: 650; color: #fff; margin-bottom: 4px; word-break: break-word; }
.embed-prev .ed { font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.embed-prev .ef { font-size: 12px; color: #b5bac1; margin-top: 8px; }
.embed-prev img.big { max-width: 100%; border-radius: 4px; margin-top: 10px; display: block; }
.embed-prev img.thumb { position: absolute; top: 10px; right: 12px; width: 56px; height: 56px; border-radius: 4px; object-fit: cover; }

/* ── Système ───────────────────────────────────────────────── */
.meter { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 28px; margin-bottom: 8px; }
.stat-row .k { color: var(--muted); font-size: 13px; }
.stat-row .v { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }

/* ── Dialog & toasts ───────────────────────────────────────── */
.dlg { margin: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); padding: 0; width: min(440px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(0, 0, 0, 0.6); }
.dlg-body { padding: 24px; }
.dlg-body h3 { font-size: 18px; margin-bottom: 6px; }
.dlg-body > p { margin-bottom: 16px; font-size: 14px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--surface-2); border: 1px solid var(--line); border-left: 3px solid var(--ok); padding: 10px 14px; border-radius: 6px; font-size: 14px; max-width: 360px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4); }
.toast.error { border-left-color: var(--accent); }

/* ── Mobile ────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; grid-template-rows: auto auto minmax(0, 1fr); }
    .rail { flex-direction: row; border-right: none; border-bottom: 1px solid var(--line); padding: 10px 14px; overflow-x: auto; overflow-y: hidden; justify-content: flex-start; }
    .nav { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px; border-right: none; border-bottom: 1px solid var(--line); padding: 8px 12px; overflow: visible; }
    .nav-title, .nav-sep { display: none; }
    .nav-list { flex-direction: row; flex-wrap: wrap; }
    .nav-item { width: auto; }
    .nav-logout { margin: 0 0 0 auto; }
    .main { padding: 22px 18px 50px; }
    .compose, .grid2 { grid-template-columns: 1fr; }
    .now { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
