:root {
  --bg: #050805;
  --panel: rgba(8, 16, 8, 0.82);
  --fg: #33ff66;
  --fg-dim: #1d9a3c;
  --line: #12401f;
  --warn: #ffb000;
  --err: #ff3355;
  --glow: 0 0 6px rgba(51, 255, 102, 0.55);
  --bg-rgb: 5, 8, 5;
  color-scheme: dark;
}
:root[data-theme='amber'] { --fg: #ffb000; --fg-dim: #a06f00; --line: #43300a; --glow: 0 0 6px rgba(255,176,0,.55); --panel: rgba(18,12,4,.82); }
:root[data-theme='red']   { --fg: #ff3355; --fg-dim: #a01d36; --line: #43101b; --glow: 0 0 6px rgba(255,51,85,.55); --panel: rgba(18,6,8,.82); --warn: #ffb000; --err: #ff8899; }
:root[data-theme='cyan']  { --fg: #33e6ff; --fg-dim: #1d8a9a; --line: #10353f; --glow: 0 0 6px rgba(51,230,255,.55); --panel: rgba(4,14,18,.82); }
/* noir & blanc : aucune couleur, les niveaux WARN/ERR se distinguent par le style */
:root[data-theme='mono']  { --bg: #000; --bg-rgb: 0,0,0; --fg: #f0f0f0; --fg-dim: #8c8c8c; --line: #2b2b2b; --glow: 0 0 6px rgba(255,255,255,.3); --panel: rgba(10,10,10,.85); --warn: #c8c8c8; --err: #ffffff; }
:root[data-theme='mono'] .err { font-weight: bold; text-decoration: underline; }
:root[data-theme='mono'] .warn { font-style: italic; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', Consolas, 'Courier New', monospace;
  font-size: 13px;
  text-shadow: var(--glow);
}
.hidden { display: none !important; }
.dim { color: var(--fg-dim); }
.ok { color: var(--fg); }
.warn { color: var(--warn); }
.err { color: var(--err); }

#rain { position: fixed; inset: 0; z-index: 0; opacity: 0.16; }
.scanlines {
  position: fixed; inset: 0; z-index: 50; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0, rgba(0,0,0,0) 2px, rgba(0,0,0,.22) 3px);
  mix-blend-mode: multiply;
}

/* boot */
.boot { position: fixed; inset: 0; z-index: 40; background: var(--bg); padding: 40px; }
.boot pre { font-family: inherit; line-height: 1.5; white-space: pre-wrap; }

/* layout */
.app { position: relative; z-index: 2; display: flex; flex-direction: column; height: 100vh; }
.titlebar {
  -webkit-app-region: drag;
  display: flex; align-items: center; justify-content: space-between;
  height: 38px; padding: 0 10px 0 16px;
  border-bottom: 1px solid var(--line); background: var(--panel);
}
.brand { font-weight: bold; letter-spacing: 2px; }
.brand small { color: var(--fg-dim); font-weight: normal; letter-spacing: 0; }
.tb-right { display: flex; align-items: center; gap: 10px; -webkit-app-region: no-drag; }
.wbtn {
  background: none; border: 1px solid var(--line); color: var(--fg); font: inherit;
  width: 30px; height: 24px; cursor: pointer;
}
.wbtn:hover { background: var(--line); }
.wbtn.danger:hover { background: var(--err); color: #000; }
.pill { padding: 2px 10px; border: 1px solid var(--line); font-size: 12px; }
.pill.on { color: var(--fg); }
.pill.off { color: var(--warn); }
.blink { animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.body { flex: 1; display: flex; min-height: 0; }
.side {
  width: 210px; border-right: 1px solid var(--line); background: var(--panel);
  display: flex; flex-direction: column; padding: 12px 0;
}
.side button {
  background: none; border: none; color: var(--fg-dim); font: inherit; text-align: left;
  padding: 10px 18px; cursor: pointer; border-left: 3px solid transparent;
}
.side button:hover { color: var(--fg); background: rgba(255,255,255,.03); }
.side button.active { color: var(--fg); border-left-color: var(--fg); background: rgba(255,255,255,.05); }
.side-foot { margin-top: auto; padding: 12px 18px; font-size: 11px; line-height: 1.7; }

.view { flex: 1; overflow: auto; padding: 18px 22px; }
.view::-webkit-scrollbar, .logbox::-webkit-scrollbar, .termout::-webkit-scrollbar { width: 8px; }
.view::-webkit-scrollbar-thumb, .logbox::-webkit-scrollbar-thumb, .termout::-webkit-scrollbar-thumb { background: var(--line); }

h2 { font-size: 15px; letter-spacing: 2px; margin-bottom: 14px; }
h2::before { content: '> '; color: var(--fg-dim); }

.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g2 { grid-template-columns: 1.4fr 1fr; }
.card { border: 1px solid var(--line); background: var(--panel); padding: 14px; position: relative; }
.card::before, .card::after { content: ''; position: absolute; width: 8px; height: 8px; border: 1px solid var(--fg); }
.card::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.card::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }
.card .lbl { color: var(--fg-dim); font-size: 11px; letter-spacing: 1px; }
.card .big { font-size: 28px; margin-top: 6px; }
.card h3 { font-size: 12px; letter-spacing: 1.5px; color: var(--fg-dim); margin-bottom: 10px; }

.spark { width: 100%; height: 60px; display: block; margin-top: 8px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--fg-dim); font-weight: normal; font-size: 11px; letter-spacing: 1px; }
tr:hover td { background: rgba(255,255,255,.03); }

button.act, .btn {
  background: none; border: 1px solid var(--fg-dim); color: var(--fg); font: inherit;
  padding: 4px 10px; cursor: pointer;
}
button.act:hover, .btn:hover { background: var(--fg); color: #000; text-shadow: none; }
button.act.red:hover { background: var(--err); border-color: var(--err); }

input, select {
  background: #000; border: 1px solid var(--line); color: var(--fg); font: inherit;
  padding: 7px 10px; width: 100%; outline: none;
}
select option { background: #000; color: var(--fg); }
input:focus, select:focus { border-color: var(--fg); }
label { display: block; color: var(--fg-dim); font-size: 11px; letter-spacing: 1px; margin: 12px 0 5px; }

.toolbar { display: flex; gap: 10px; margin-bottom: 12px; }
.toolbar input { max-width: 320px; }

.logbox, .termout {
  border: 1px solid var(--line); background: rgba(0,0,0,.6);
  overflow: auto; padding: 10px 12px; line-height: 1.55; white-space: pre-wrap; word-break: break-word;
}
.logbox { height: calc(100vh - 190px); }
.termwrap { display: flex; flex-direction: column; height: calc(100vh - 150px); }
.termout { flex: 1; }
.termin { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-top: 0; padding: 6px 10px; background: #000; }
.termin input { border: 0; padding: 4px 0; }
.tag { display: inline-block; padding: 0 6px; border: 1px solid currentColor; font-size: 11px; }

.bar { height: 8px; background: var(--line); margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--fg); box-shadow: var(--glow); }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.note { color: var(--fg-dim); font-size: 12px; line-height: 1.6; margin-top: 10px; }

.w160 { max-width: 160px; }
.maxw { max-width: 640px; }
.mt16 { margin-top: 16px; }
.view > .grid, .view > .card { margin-top: 14px; }
.view > h2 + .grid, .view > h2 + .card, .view > .toolbar + .card { margin-top: 0; }

.botcard { margin-bottom: 14px; }
.bothead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.botname { font-size: 17px; letter-spacing: 1px; }
.botstats { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.botstats .lbl { display: block; color: var(--fg-dim); font-size: 11px; letter-spacing: 1px; }
.botstats b { font-weight: normal; font-size: 15px; }
details { margin-top: 10px; }
summary { cursor: pointer; color: var(--fg-dim); font-size: 12px; letter-spacing: 1px; }
summary:hover { color: var(--fg); }
.guildbox { max-height: 220px; overflow: auto; margin-top: 8px; border: 1px solid var(--line); background: rgba(0,0,0,.5); }
.grow { display: grid; grid-template-columns: 1.4fr 1fr 0.8fr; gap: 10px; padding: 5px 10px; border-bottom: 1px solid var(--line); }
.demo { border: 1px dashed var(--warn); color: var(--warn); padding: 8px 12px; margin-bottom: 14px; }

.chip { display: inline-block; padding: 1px 8px; margin: 1px 2px; border: 1px solid var(--line); font-size: 12px; }
.chip.on { color: var(--fg); border-color: var(--fg-dim); }
.chip.on::before { content: '● '; }
.chip.off { color: var(--fg-dim); }
.chip.off::before { content: '○ '; }
.tag.ok { color: var(--fg); }
.tag.warn { color: var(--warn); }
.tag.err { color: var(--err); }
.tag.dim { color: var(--fg-dim); }
td .dim { font-size: 11px; }
td button.act + button.act { margin-left: 6px; }

.view > h2.sect { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); }
h2.sect small { font-size: 12px; letter-spacing: 0; font-weight: normal; }
.botcard .row2 .card { padding: 10px 14px; }

/* ---------- mode web (navigateur / téléphone) ---------- */
html.web .titlebar { -webkit-app-region: no-drag; }

@media (max-width: 800px) {
  .app { height: 100vh; height: 100dvh; }
  .titlebar { padding: 0 10px; padding-top: env(safe-area-inset-top); height: auto; min-height: 38px; gap: 8px; }
  .brand small, #clock { display: none; }
  .pill { font-size: 11px; padding: 2px 6px; }
  .body { flex-direction: column; }
  .side {
    width: 100%; flex-direction: row; overflow-x: auto; padding: 0;
    border-right: 0; border-bottom: 1px solid var(--line); flex: 0 0 auto;
  }
  .side button { white-space: nowrap; padding: 10px 12px; border-left: 0; border-bottom: 3px solid transparent; }
  .side button.active { border-left-color: transparent; border-bottom-color: var(--fg); }
  .side-foot { display: none; }
  .view { padding: 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .g4 { grid-template-columns: repeat(2, 1fr); }
  .g2, .row2 { grid-template-columns: 1fr; }
  .card .big { font-size: 22px; }
  .card:has(table) { overflow-x: auto; }
  th, td { white-space: nowrap; }
  .toolbar { flex-wrap: wrap; }
  .toolbar input, .w160 { max-width: none; }
  .logbox { height: calc(100dvh - 250px); }
  .termwrap { height: calc(100dvh - 220px); }
  .grow { grid-template-columns: 1fr auto; }
  .grow .dim { display: none; }
  input, select { font-size: 16px; } /* évite le zoom automatique sur iPhone */
  .boot { padding: 20px; }
}


/* ---------- comptes, connexion, journal ---------- */
.wbtn.wide { width: 34px; }
.pill.who { color: var(--fg); }
.authwrap { position: fixed; inset: 0; z-index: 45; display: flex; align-items: center; justify-content: center; background: rgba(var(--bg-rgb), .92); padding: 16px; overflow: auto; }
.authbox { width: 100%; max-width: 400px; }
.authtitle { margin: 14px 0 4px; letter-spacing: 1px; }
.authgo { width: 100%; margin-top: 16px; padding: 9px; }
.secret { font-size: 15px; letter-spacing: 2px; word-break: break-all; border: 1px dashed var(--fg-dim); padding: 10px; margin: 8px 0; user-select: all; }
.tempbox { border: 1px solid var(--warn); color: var(--warn); padding: 10px 12px; margin-bottom: 14px; }
.tempbox b { user-select: all; font-size: 15px; letter-spacing: 1px; }
.jl { padding: 6px 4px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 150px 1fr auto; gap: 12px; align-items: baseline; }
.jl .t { color: var(--fg-dim); font-size: 11px; }
.jl small { color: var(--fg-dim); display: block; font-size: 11px; }
.jl .tag { white-space: nowrap; }
.formrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; align-items: end; }
.mini { max-width: 130px; display: inline-block; }
.toolbar select, .toolbar input[type=date] { max-width: 170px; }
@media (max-width: 800px) {
  .jl { grid-template-columns: 1fr; gap: 2px; }
  .who { display: none; }
}

.mt14 { margin-top: 14px !important; }
.mt8 { margin-top: 8px; }
.mt0 { margin-top: 0 !important; }
