/* ==========================================================================
   Archipelago Panel — mer de nuit, phare ambre, une couleur par monde
   ========================================================================== */

:root {
  color-scheme: dark;
  --abyss: #0d1b27;      /* fond */
  --deep: #112333;       /* barre du haut, sidebar */
  --hull: #162c40;       /* panneaux */
  --hull-2: #1c3550;     /* survols, champs */
  --rule: #26425c;       /* filets */
  --rule-soft: #1f3850;
  --foam: #dfe8ef;       /* texte */
  --mist: #93a9ba;       /* texte secondaire */
  --fog: #6b8396;        /* texte tertiaire */
  --beacon: #f2b544;     /* accent : le phare */
  --beacon-ink: #2a1c02;
  --sea: #3cc4a0;        /* en ligne / ok */
  --reef: #e8675d;       /* erreurs */
  --prog: #b095f2;       /* progression (couleur d'Archipelago) */
  --font: "Atkinson Next", "Segoe UI", system-ui, sans-serif;
  --mono: "Atkinson Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r-ctl: 6px;
  --r-panel: 10px;
  --topbar-h: 58px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--abyss);
  color: var(--foam);
  font: 400 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--beacon); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
h1, h2, h3 { margin: 0; line-height: 1.2; font-weight: 700; }
h1 { font-size: 26px; letter-spacing: -0.01em; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 0.6em; }
.muted { color: var(--mist); }
.faint { color: var(--fog); }
.small { font-size: 13px; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--beacon); outline-offset: 2px; }

/* ------------------------------------------------------------------ barre du haut */

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: grid; grid-template-columns: 220px 1fr auto; align-items: center;
  background: var(--deep);
  border-bottom: 1px solid var(--rule);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px; height: 100%;
  font-weight: 700; font-size: 16px; color: var(--foam);
}
.brand svg { flex: none; }

.lighthouse {
  display: flex; align-items: center; gap: 16px; min-width: 0;
  padding: 0 16px; height: 100%;
}
.beacon {
  position: relative; width: 12px; height: 12px; border-radius: 50%; flex: none;
  background: var(--fog);
}
.beacon[data-state="running"] { background: var(--sea); }
.beacon[data-state="starting"], .beacon[data-state="stopping"] { background: var(--beacon); }
.beacon[data-state="crashed"] { background: var(--reef); }
.beacon[data-state="running"]::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  border: 2px solid var(--sea); opacity: 0;
  animation: sweep 2.6s ease-out infinite;
}
@keyframes sweep { 0% { transform: scale(0.4); opacity: 0.9; } 100% { transform: scale(1.5); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .beacon::after { animation: none !important; opacity: 0.4 !important; } }

.ls-state { font-weight: 700; white-space: nowrap; }
.ls-seed { font-family: var(--mono); font-size: 13px; color: var(--mist); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ls-addr {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 13px; color: var(--foam);
  background: var(--hull); border: 1px solid var(--rule); border-radius: 999px;
  padding: 3px 10px; cursor: pointer; white-space: nowrap;
}
.ls-addr:hover { border-color: var(--beacon); }
.islands { display: flex; align-items: center; gap: 5px; }
.island {
  width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid var(--c, var(--fog)); background: transparent;
}
.island.on { background: var(--c); }
.island.goal { background: var(--c); box-shadow: 0 0 0 2px var(--deep), 0 0 0 3px var(--c); }
.ls-count { font-size: 13px; color: var(--mist); white-space: nowrap; }
.ls-job {
  font-size: 13px; color: var(--beacon); white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.spinner {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 0.8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.usermenu { position: relative; padding: 0 16px; }
.usermenu-btn {
  display: flex; align-items: center; gap: 8px; background: none; border: 0; color: var(--foam);
  font: inherit; cursor: pointer; padding: 6px 8px; border-radius: var(--r-ctl);
}
.usermenu-btn:hover { background: var(--hull); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--hull-2); font-weight: 700; font-size: 13px;
}
.menu {
  position: absolute; right: 16px; top: calc(100% + 4px); min-width: 220px;
  background: var(--hull); border: 1px solid var(--rule); border-radius: var(--r-panel);
  padding: 6px; box-shadow: 0 12px 30px rgba(3, 10, 18, 0.5);
}
.menu .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--rule); margin-bottom: 6px; }
.menu button {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: none;
  color: var(--foam); font: inherit; border-radius: var(--r-ctl); cursor: pointer;
}
.menu button:hover { background: var(--hull-2); }

/* ------------------------------------------------------------------ mise en page */

.layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
  background: var(--deep); border-right: 1px solid var(--rule);
  padding: 16px 10px; position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h));
}
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; margin-bottom: 2px; border-radius: var(--r-ctl);
  color: var(--mist); font-weight: 600;
}
.nav a:hover { background: var(--hull); color: var(--foam); text-decoration: none; }
.nav a.active { background: var(--hull); color: var(--foam); box-shadow: inset 3px 0 0 var(--beacon); }
.nav svg { width: 18px; height: 18px; flex: none; }

main { padding: 28px 32px 60px; min-width: 0; }
.page { max-width: 1240px; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-bottom: 22px;
}
.page-head p { margin: 6px 0 0; color: var(--mist); max-width: 70ch; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.panel {
  background: var(--hull); border: 1px solid var(--rule); border-radius: var(--r-panel);
  padding: 18px 20px; margin-bottom: 20px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.panel.flush { padding: 0; }
.panel.flush .panel-head { padding: 14px 20px 0; }
.grid-2 { display: grid; grid-template-columns: minmax(320px, 400px) 1fr; gap: 20px; align-items: start; }
.section-title { display: flex; align-items: baseline; gap: 10px; margin: 26px 0 10px; }
.section-title h2 { font-size: 16px; }

/* ------------------------------------------------------------------ contrôles */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: var(--r-ctl);
  border: 1px solid var(--rule); background: var(--hull-2); color: var(--foam);
  font: 600 14px/1 var(--font); cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--mist); text-decoration: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--beacon); border-color: var(--beacon); color: var(--beacon-ink); }
.btn.primary:hover { background: #f7c461; }
.btn.danger { color: #ffb4ad; border-color: #6b3434; background: #2a1d26; }
.btn.danger:hover { border-color: var(--reef); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--mist); }
.btn.ghost:hover { color: var(--foam); background: var(--hull-2); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn svg { width: 16px; height: 16px; }

input[type="text"], input[type="password"], input[type="number"], input[type="search"], select, textarea {
  height: 36px; padding: 0 10px; border-radius: var(--r-ctl);
  border: 1px solid var(--rule); background: var(--abyss); color: var(--foam);
  font: 400 14px var(--font); min-width: 0;
}
textarea { height: auto; padding: 8px 10px; font-family: var(--mono); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--beacon); }
input::placeholder { color: var(--fog); }
label.field { display: grid; gap: 5px; margin-bottom: 12px; font-size: 13px; color: var(--mist); font-weight: 600; }
label.field input, label.field select { width: 100%; }
.field-hint { font-weight: 400; color: var(--fog); order: 3; }
label.check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--beacon); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; }

/* ------------------------------------------------------------------ tableaux */

.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th {
  text-align: left; font-weight: 600; color: var(--mist); font-size: 13px;
  padding: 8px 12px; border-bottom: 1px solid var(--rule); white-space: nowrap;
}
table.list td .faint, table.list td .badge { white-space: nowrap; }
table.list td { padding: 9px 12px; border-bottom: 1px solid var(--rule-soft); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover td { background: rgba(28, 53, 80, 0.55); }
table.list td.actions-cell { text-align: right; white-space: nowrap; }
table.list .num { text-align: right; font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; }
.yaml-table { table-layout: fixed; min-width: 1060px; }
.yaml-table .check-cell { width: 42px; padding-right: 0; }
.yaml-table .c-player { width: 13%; }
.yaml-table .c-date { width: 118px; }
.yaml-table .c-act { width: 560px; }
.yaml-table td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.yaml-table td.check-cell, .yaml-table th.check-cell, .yaml-table td.actions-cell { overflow: visible; text-overflow: clip; }
tr.selected td { background: rgba(242, 181, 68, 0.06); }

/* actions de ligne : le destructif est séparé et en rouge */
.btn.danger-ghost { background: transparent; border-color: transparent; color: #ff9f97; }
.btn.danger-ghost:hover:not(:disabled) { background: rgba(232, 103, 93, 0.14); border-color: rgba(232, 103, 93, 0.45); }
.btn.icon-only { padding: 0 8px; }
.act-sep { display: inline-block; width: 1px; height: 18px; background: var(--rule); margin: 0 10px; vertical-align: middle; }
td.actions-cell > * { vertical-align: middle; }

.yaml-section { margin-bottom: 8px; border-radius: var(--r-panel); }
.yaml-section.over { outline: 2px dashed var(--beacon); outline-offset: 6px; }
.yaml-section .section-title { align-items: center; flex-wrap: wrap; row-gap: 4px; }
.section-title > .small { white-space: nowrap; }
.section-title h2 { display: flex; align-items: center; gap: 8px; }
.section-title h2 svg { width: 17px; height: 17px; color: var(--mist); }
.section-actions { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.empty.compact { padding: 12px 16px; text-align: left; }

.selection-bar {
  position: sticky; top: calc(var(--topbar-h) + 10px); z-index: 5;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 12px; margin-bottom: 14px;
  background: var(--hull-2); border: 1px solid rgba(242, 181, 68, 0.45); border-radius: var(--r-panel);
  box-shadow: 0 10px 24px rgba(3, 10, 18, 0.45);
}

/* droits des groupes */
.admin-check { padding: 10px 12px; margin-bottom: 14px; border: 1px solid var(--rule); border-radius: var(--r-ctl); align-items: flex-start; }
.perm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.perm-grid.disabled { opacity: 0.4; pointer-events: none; }
.perm-section { margin: 0; padding: 8px 12px 10px; border: 1px solid var(--rule); border-radius: var(--r-ctl); display: grid; gap: 6px; min-width: 0; align-content: start; }
.perm-section legend { padding: 0 4px; font-weight: 700; }
.check.perm { align-items: flex-start; font-size: 14px; }
.check.perm input, .admin-check input { margin-top: 2px; flex: none; }
.perm-hint { display: block; font-size: 12px; color: var(--fog); line-height: 1.35; }
.perm-summary { display: flex; flex-wrap: wrap; gap: 4px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-weight: 600; font-size: 13px;
}
.chip::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--fog)); flex: none; }
.badge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--hull-2); color: var(--mist); white-space: nowrap;
}
.badge.ok { background: rgba(60, 196, 160, 0.14); color: var(--sea); }
.badge.err { background: rgba(232, 103, 93, 0.15); color: #ffb0a8; }
.badge.warn { background: rgba(242, 181, 68, 0.14); color: var(--beacon); }
.badge.prog { background: rgba(176, 149, 242, 0.16); color: var(--prog); }

.progress { position: relative; height: 6px; border-radius: 3px; background: var(--abyss); min-width: 90px; overflow: hidden; }
.progress > span { position: absolute; inset: 0 auto 0 0; background: var(--c, var(--sea)); border-radius: 3px; }
.progress-label { font-size: 12px; color: var(--mist); font-variant-numeric: tabular-nums; }

.empty {
  padding: 28px 20px; text-align: center; color: var(--mist);
  border: 1px dashed var(--rule); border-radius: var(--r-panel);
}
.empty strong { display: block; color: var(--foam); margin-bottom: 4px; }

/* ------------------------------------------------------------------ accueil */

.harbor {
  display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center;
  padding: 26px 28px; margin-bottom: 24px;
  border: 1px solid var(--rule); border-radius: var(--r-panel);
  background:
    radial-gradient(600px 220px at 0% 0%, rgba(242, 181, 68, 0.08), transparent 70%),
    var(--hull);
}
.harbor h1 { font-size: 30px; margin-bottom: 8px; }
.harbor .connect { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.harbor .addr-big {
  font-family: var(--mono); font-size: 20px; font-weight: 600; color: var(--foam);
  background: var(--abyss); border: 1px solid var(--rule); border-radius: var(--r-ctl); padding: 6px 12px;
}
.harbor-actions { display: grid; gap: 8px; justify-items: end; }

/* ------------------------------------------------------------------ console */

.console-shell { display: grid; grid-template-rows: auto 1fr auto; height: calc(100vh - var(--topbar-h) - 150px); min-height: 420px; }
.console-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 12px; border-bottom: 1px solid var(--rule); }
.log {
  overflow: auto; padding: 10px 14px; background: #0a1520;
  font: 400 13px/1.55 var(--mono); white-space: pre-wrap; word-break: break-word;
}
.log:empty::before { content: "Rien pour l'instant. La sortie du serveur s'affiche ici dès qu'il démarre."; color: var(--fog); font-family: var(--font); }
.job-log:empty::before { content: "En attente du premier message…"; }
.log .ln { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px; }
.log .ts { color: var(--fog); user-select: none; white-space: nowrap; }
.log .cmd { color: var(--beacon); }
.log .sys { color: var(--mist); font-style: italic; }
.log .err { color: #ff9f97; }
.log .notice { color: #a9d9ff; }
.log .join { color: var(--sea); }
.log mark { background: rgba(242, 181, 68, 0.3); color: inherit; border-radius: 2px; }
.console-input { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--rule); background: var(--deep); border-radius: 0 0 var(--r-panel) var(--r-panel); }
.console-input input { flex: 1; font-family: var(--mono); }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.job-log { max-height: 420px; min-height: 160px; border-radius: var(--r-ctl); border: 1px solid var(--rule); }

/* ------------------------------------------------------------------ soluce */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--rule); margin-bottom: 16px; overflow-x: auto; }
.tabs button {
  border: 0; background: none; color: var(--mist); font: 600 14px var(--font);
  padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button:hover { color: var(--foam); }
.tabs button.active { color: var(--foam); border-bottom-color: var(--beacon); }
.searchbar { display: grid; grid-template-columns: 1fr repeat(3, auto) auto; gap: 8px; margin-bottom: 12px; }
.searchbar input[type="search"] { height: 42px; font-size: 16px; }
.searchbar select { height: 42px; }
.result-count { font-size: 13px; color: var(--mist); margin: 0 0 8px; }
.loc-name { font-weight: 600; }
.item-name { cursor: pointer; }
.item-name:hover { color: var(--beacon); }
tr.done td { color: var(--fog); }
tr.done .loc-name { text-decoration: line-through; text-decoration-color: rgba(147, 169, 186, 0.5); }
.detail-row td { background: var(--deep) !important; padding: 12px 16px 16px; }
.path { font-family: var(--mono); font-size: 12.5px; color: var(--mist); line-height: 1.7; margin: 6px 0 10px; }
.path div::before { content: "↳ "; color: var(--fog); }
.sphere { margin-bottom: 18px; }
.sphere h3 { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.raw { font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; color: var(--mist); max-height: 520px; overflow: auto; background: var(--abyss); padding: 12px; border-radius: var(--r-ctl); }
dl.opts { display: grid; grid-template-columns: minmax(180px, 40%) 1fr; gap: 3px 16px; margin: 8px 0 0; font-size: 13.5px; }
dl.opts dt { color: var(--mist); }
dl.opts dd { margin: 0; word-break: break-word; }
details.player { border-bottom: 1px solid var(--rule-soft); padding: 10px 0; }
details.player summary { cursor: pointer; display: flex; gap: 12px; align-items: center; list-style: none; }
details.player summary::-webkit-details-marker { display: none; }

/* ------------------------------------------------------------------ seeds */

.seed-card { border-bottom: 1px solid var(--rule-soft); padding: 14px 20px; }
.seed-card:last-child { border-bottom: 0; }
.seed-card.live { box-shadow: inset 3px 0 0 var(--sea); }
.seed-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.seed-name { font-family: var(--mono); font-weight: 600; font-size: 15px; }
.seed-label { font-weight: 700; font-size: 16px; }
.seed-meta .mono { font-size: 12.5px; }
.ls-seed.named { font-family: var(--font); font-size: 14px; color: var(--foam); }
.seed-meta { font-size: 13px; color: var(--mist); margin-top: 2px; }
.seed-players { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.seed-files { margin-top: 10px; font-size: 13px; }
.seed-files a { font-family: var(--mono); }
.yaml-pick { max-height: 300px; overflow: auto; border: 1px solid var(--rule); border-radius: var(--r-ctl); padding: 8px 10px; background: var(--abyss); margin-bottom: 14px; }
.yaml-pick .folder { font-size: 12px; color: var(--fog); margin: 8px 0 4px; font-weight: 600; }
.yaml-pick .folder:first-child { margin-top: 0; }
.yaml-pick label.check { padding: 3px 0; }
.yaml-pick .game { color: var(--fog); font-size: 12.5px; }

/* ------------------------------------------------------------------ éditeur */

.editor-shell { border: 1px solid var(--rule); border-radius: var(--r-panel); overflow: hidden; }
.editor-status { display: flex; justify-content: space-between; gap: 12px; padding: 8px 14px; background: var(--deep); border-top: 1px solid var(--rule); font-size: 13px; }
.CodeMirror {
  height: calc(100vh - var(--topbar-h) - 210px); min-height: 380px;
  background: #0a1520; color: var(--foam); font: 13.5px/1.55 var(--mono);
}
.CodeMirror-gutters { background: var(--deep); border-right: 1px solid var(--rule); }
.CodeMirror-linenumber { color: var(--fog); }
.CodeMirror-cursor { border-left: 2px solid var(--beacon); }
.CodeMirror-selected, .CodeMirror-focused .CodeMirror-selected { background: rgba(242, 181, 68, 0.18) !important; }
.CodeMirror-activeline-background { background: rgba(255, 255, 255, 0.03); }
.cm-s-default .cm-comment { color: #5f7a8f; }
.cm-s-default .cm-atom { color: #9fd3ff; }
.cm-s-default .cm-string { color: #a8e6c4; }
.cm-s-default .cm-number { color: #ffc98a; }
.cm-s-default .cm-keyword { color: var(--prog); }
.cm-s-default .cm-meta, .cm-s-default .cm-def { color: var(--beacon); }
.cm-s-default .cm-variable-2 { color: #9fd3ff; }
.CodeMirror-dialog { background: var(--deep); color: var(--foam); border-bottom: 1px solid var(--rule); }
.CodeMirror-dialog input { color: var(--foam); font-family: var(--mono); }
.cm-searching { background: rgba(242, 181, 68, 0.35); }
.err-line { background: rgba(232, 103, 93, 0.16); }

/* ------------------------------------------------------------------ modales & toasts */

.backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(4, 11, 18, 0.66);
  display: grid; place-items: center; padding: 20px;
}
.modal {
  width: min(520px, 100%); max-height: calc(100vh - 40px); overflow: auto;
  background: var(--hull); border: 1px solid var(--rule); border-radius: var(--r-panel);
  padding: 22px 24px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
.modal.wide { width: min(760px, 100%); }
.modal h2 { margin-bottom: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: grid; gap: 8px; }
.toast {
  background: var(--hull-2); border: 1px solid var(--rule); border-left: 3px solid var(--sea);
  padding: 10px 14px; border-radius: var(--r-ctl); max-width: 420px; font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.toast.err { border-left-color: var(--reef); }
.dropzone.over { outline: 2px dashed var(--beacon); outline-offset: 6px; border-radius: var(--r-panel); }
.form-error { color: #ffb0a8; font-size: 13px; margin-top: 6px; min-height: 1em; }

/* ------------------------------------------------------------------ connexion */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login {
  width: min(380px, 100%); background: var(--hull); border: 1px solid var(--rule);
  border-radius: var(--r-panel); padding: 30px 28px;
}
.login .brand { padding: 0; margin-bottom: 22px; font-size: 18px; }
.login .btn { width: 100%; height: 40px; margin-top: 6px; }

/* ------------------------------------------------------------------ responsive */

@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr; }
  .searchbar { grid-template-columns: 1fr 1fr; }
  .searchbar input[type="search"] { grid-column: 1 / -1; }
}
/* ------------------------------------------------------------------ configurateur de YAML */

.btn.cfg-open { background: rgba(242, 181, 68, 0.12); border-color: rgba(242, 181, 68, 0.45); color: var(--beacon); }
.btn.cfg-open:hover { background: rgba(242, 181, 68, 0.2); border-color: var(--beacon); }
body.drawer-open { overflow: hidden; }
body.drawer-open .toasts { bottom: 84px; }
.drawer-backdrop { position: fixed; inset: 0; z-index: 45; background: rgba(4, 11, 18, 0.55); display: flex; justify-content: flex-end; }
.drawer {
  width: min(880px, 100vw); height: 100%; display: grid; grid-template-rows: auto auto 1fr auto;
  background: var(--abyss); border-left: 1px solid var(--rule); box-shadow: -24px 0 60px rgba(0, 0, 0, 0.45);
  animation: drawer-in 0.18s ease-out;
}
@keyframes drawer-in { from { transform: translateX(40px); opacity: 0.4; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .drawer { animation: none; } }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 20px 10px; background: var(--deep); }
.drawer-head h2 { font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-head p { margin: 4px 0 0; }
.drawer-tools { padding: 10px 20px 14px; background: var(--deep); border-bottom: 1px solid var(--rule); }
.drawer-tools input[type="search"] { width: 100%; }
.drawer-body { overflow-y: auto; padding: 8px 20px 24px; overscroll-behavior: contain; }
.drawer-foot {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 20px; background: var(--deep); border-top: 1px solid var(--rule);
}
.drawer-status { color: var(--mist); max-width: 52ch; display: grid; gap: 2px; }
.drawer-status .dirty { color: var(--beacon); }
.check-ok { color: var(--sea); }
.check-err { color: #ffb0a8; overflow-wrap: anywhere; }
.check-run { display: inline-flex; align-items: center; gap: 6px; color: var(--beacon); }

.cfg-group { border-bottom: 1px solid var(--rule-soft); }
.cfg-group > summary {
  position: sticky; top: -8px; z-index: 1; display: flex; align-items: baseline; gap: 10px;
  padding: 12px 0 10px; background: var(--abyss); cursor: pointer; list-style: none;
}
.cfg-group > summary::-webkit-details-marker { display: none; }
.cfg-group > summary::before { content: "▸"; color: var(--fog); width: 12px; transition: transform 0.15s; }
.cfg-group[open] > summary::before { transform: rotate(90deg); }
.cfg-group-name { font-weight: 700; font-size: 15px; }

.cfg-opt {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 300px); gap: 8px 20px;
  padding: 12px 10px 12px 12px; margin: 0 -10px 0 -12px; border-left: 3px solid transparent; border-radius: 0 6px 6px 0;
}
.cfg-opt + .cfg-opt { border-top: 1px solid var(--rule-soft); }
.cfg-opt.changed { border-left-color: var(--prog); background: rgba(176, 149, 242, 0.05); }
.cfg-opt.wide { grid-template-columns: minmax(0, 1fr); }
.cfg-title { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.cfg-title label { font-weight: 600; }
.cfg-key { font-family: var(--mono); font-size: 12px; color: var(--fog); }
.cfg-flag { display: none; }
.cfg-opt.changed .cfg-flag { display: inline-flex; }
.cfg-doc {
  margin: 4px 0 0; color: var(--mist); font-size: 13px; line-height: 1.5; white-space: pre-line;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.cfg-doc.open { display: block; }
.linkish { background: none; border: 0; padding: 0; color: var(--beacon); cursor: pointer; font: inherit; }
.cfg-ctl { display: flex; align-items: flex-start; gap: 6px; min-width: 0; }
.cfg-ctl > :first-child { flex: 1; min-width: 0; }
.cfg-ctl select, .cfg-ctl input[type="text"], .cfg-ctl input[type="number"] { width: 100%; }
.cfg-reset { margin-left: auto; color: var(--mist); }
.cfg-reset:hover { color: var(--beacon); }
.ctl-stack > button { justify-self: start; }
.ctl-stack { display: grid; gap: 6px; min-width: 0; }
.range-row { display: flex; align-items: center; gap: 10px; }
.range-row input[type="range"] { flex: 1; accent-color: var(--beacon); min-width: 0; }
.range-row input.num, .counter-row input.num { width: 96px; flex: none; }
.cfg-raw { margin: 0; padding: 8px 10px; background: var(--deep); border-radius: var(--r-ctl); font: 12.5px/1.5 var(--mono); color: var(--mist); white-space: pre-wrap; max-height: 180px; overflow: auto; }
.weights { display: flex; flex-wrap: wrap; gap: 6px; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; height: 36px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; width: 40px; height: 22px; border-radius: 999px; background: var(--hull-2); border: 1px solid var(--rule); transition: background 0.15s; }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--mist); transition: transform 0.15s, background 0.15s; }
.switch input:checked + .switch-track { background: rgba(242, 181, 68, 0.3); border-color: var(--beacon); }
.switch input:checked + .switch-track::after { transform: translateX(18px); background: var(--beacon); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--beacon); outline-offset: 2px; }
.switch-text { font-size: 14px; }

.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 16px; }
.check-grid .check { font-size: 13.5px; align-items: flex-start; }
.check-grid .check input { margin-top: 2px; flex: none; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags:empty::before { content: "Rien pour l'instant"; color: var(--fog); font-size: 13px; }
.tag {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border-radius: 999px;
  background: var(--hull-2); border: 1px solid var(--rule); font-size: 13px;
}
.tag.bad { border-color: var(--reef); color: #ffb0a8; }
.tag button { border: 0; background: none; color: var(--mist); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 4px; border-radius: 50%; }
.tag button:hover { color: var(--foam); background: var(--hull); }
.counter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 16px; }
.counter-list { display: grid; gap: 4px; }
.counter-list:empty::before { content: "Rien pour l'instant"; color: var(--fog); font-size: 13px; }
.counter-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.counter-row span { overflow: hidden; text-overflow: ellipsis; }
.counter-row.bad span { color: #ffb0a8; }
.yaml-preview { max-height: 65vh; }

@media (max-width: 700px) {
  .cfg-opt { grid-template-columns: minmax(0, 1fr); }
  .drawer { display: block; overflow-y: auto; overscroll-behavior: contain; }
  .drawer-body { overflow: visible; }
  .drawer-foot { position: sticky; bottom: 0; z-index: 2; }
  .drawer-head, .drawer-tools, .drawer-body, .drawer-foot { padding-left: 14px; padding-right: 14px; }
  .drawer-foot .actions { width: 100%; justify-content: flex-end; }
}

/* ------------------------------------------------------------------ partie */

.it { font-weight: 600; }
.it-prog { color: var(--prog); }
.it-useful { color: #8fb8ff; }
.it-trap { color: #ff9f97; }
.it-filler { color: var(--foam); font-weight: 400; }

.live-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--sea);
  margin-right: 8px; vertical-align: middle; box-shadow: 0 0 0 3px rgba(60, 196, 160, 0.2);
}

/* la partie d'un coup d'œil : un segment par monde, large comme son nombre de checks */
.world-bar { margin-bottom: 18px; }
.world-bar-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 8px; font-size: 14px; }
.world-track { display: flex; gap: 3px; height: 14px; }
.world-seg { position: relative; min-width: 8px; border-radius: 4px; background: color-mix(in srgb, var(--c) 18%, var(--abyss)); overflow: hidden; }
.world-seg > span { position: absolute; inset: 0 auto 0 0; background: var(--c); }
.world-seg.goal { box-shadow: inset 0 0 0 1.5px var(--foam); }

.pcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 22px; }
.pcard {
  background: var(--hull); border: 1px solid var(--rule); border-radius: var(--r-panel);
  border-top: 3px solid var(--c); padding: 12px 14px; display: grid; gap: 6px; align-content: start;
}
.pcard-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 4px; }
.pcard-game { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meter {
  display: grid; grid-template-columns: 78px 1fr auto; align-items: center; gap: 8px;
  width: 100%; padding: 3px 4px; margin: 0 -4px; border: 0; border-radius: 4px; background: none;
  color: var(--foam); font: 400 13px var(--font); text-align: left;
}
button.meter { cursor: pointer; }
button.meter:hover { background: var(--hull-2); }
.meter .m-label { color: var(--mist); }
.meter .progress { min-width: 0; --c: inherit; }
.pcard .meter .progress > span { background: var(--c); }
.meter .m-num { font-variant-numeric: tabular-nums; color: var(--mist); font-size: 12.5px; }
.badge.ok-soft { background: rgba(60, 196, 160, 0.10); color: var(--sea); }

.loading { display: flex; align-items: center; gap: 8px; }
.result-count { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.legend { display: flex; gap: 14px; }
.legend .it::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: currentColor; margin-right: 6px; vertical-align: 1px; }
.tab-count { font-weight: 400; color: var(--fog); font-size: 13px; margin-left: 4px; }
.game-filters { grid-template-columns: 1fr repeat(3, auto) auto; }
.found-table { table-layout: fixed; min-width: 760px; }
.found-table .c-when { width: 122px; }
.th-sort { all: unset; cursor: pointer; font: inherit; color: inherit; border-radius: 4px; }
.th-sort:hover { color: var(--foam); }
.th-sort:focus-visible { outline: 2px solid var(--beacon); outline-offset: 2px; }
.found-table .c-who { width: 150px; }
.found-table td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.found-table td.when { font-variant-numeric: tabular-nums; }
.found-table .sep-row td { background: var(--deep) !important; color: var(--mist); font-size: 12.5px; padding: 6px 12px; }
.found-table tr.done td { opacity: 0.55; }
tr.fresh td { animation: fresh 4s ease-out; }
@keyframes fresh { from { background: rgba(242, 181, 68, 0.22); } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { tr.fresh td { animation: none; background: rgba(242, 181, 68, 0.12); } }

@media (max-width: 1100px) { .game-filters { grid-template-columns: 1fr 1fr; } .game-filters input[type="search"] { grid-column: 1 / -1; } }

@media (max-width: 700px) {
  .perm-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .topbar { grid-template-columns: auto 1fr auto; }
  .brand span { display: none; }
  .ls-seed, .ls-count { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .harbor > div { min-width: 0; }
  .harbor p { overflow-wrap: anywhere; }
  .harbor h1 { font-size: 24px; }
  .harbor .addr-big { font-size: 16px; }
  .grid-2 > * { min-width: 0; }
  .sidebar { position: static; height: auto; padding: 6px 8px; border-right: 0; border-bottom: 1px solid var(--rule); }
  .nav { display: flex; overflow-x: auto; gap: 2px; }
  .nav a { white-space: nowrap; margin: 0; }
  .nav a.active { box-shadow: inset 0 -2px 0 var(--beacon); }
  main { padding: 20px 16px 48px; }
  .harbor { grid-template-columns: 1fr; }
  .harbor-actions { justify-items: start; }
  .console-shell { height: calc(100vh - var(--topbar-h) - 190px); }
}
@media (max-width: 560px) {
  .ls-addr { display: none; }
  .lighthouse { gap: 10px; padding: 0 8px; }
  .searchbar { grid-template-columns: 1fr; }
}
