/* ============================================================
   dst-dash — Don't Starve gothic storybook, dark only.
   Data-color tokens validated with the dataviz palette checker
   against the panel surface #241c12 (all checks pass; the one
   CVD warn — green vs gold at ΔE 7.3 — is mitigated everywhere
   by icon + text label; status never rides color alone).
   ============================================================ */

:root {
  --page:        #141009;
  --panel:       #241c12;   /* chart surface (validated against) */
  --panel-2:     #2b2216;
  --well:        #191308;
  --ink:         #e9dab2;
  --ink-2:       #b7a67c;
  --ink-3:       #8a7a58;
  --hairline:    #3a2f1d;
  --border:      #4a3b24;
  --red:         #8e2f26;   /* blood-red primary accent */
  --red-hi:      #a83a30;
  --gold:        #c9a24b;   /* antique gold secondary accent (chrome) */
  --gold-hi:     #dcb964;
  --frost:       #8fb0b5;   /* winter / frozen chrome tint */

  /* data tokens — validated set */
  --viz-series:  #b98a2c;   /* single-series marks: sparklines, season ring */
  --ok:          #2fa06f;
  --warn:        #c68520;
  --danger:      #c03a3a;
  --idle:        #7d7461;

  --serif: Georgia, "Palatino Linotype", "Book Antiqua", "Times New Roman", serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;

  --rx-a: 14px 9px 16px 8px / 9px 15px 8px 14px;
  --rx-b: 9px 15px 8px 14px / 14px 8px 15px 9px;
  --rx-btn: 10px 6px 11px 7px / 7px 10px 6px 11px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html { color-scheme: dark; }

body {
  background: var(--page);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.45;
  min-height: 100vh;
}

/* candlelit glow + vignette */
body::before {
  content: "";
  position: fixed; inset: 0;
  background:
    radial-gradient(1100px 480px at 50% -8%, rgba(201,162,75,.07), transparent 65%),
    radial-gradient(140% 110% at 50% 45%, transparent 52%, rgba(0,0,0,.52) 100%);
  pointer-events: none;
  z-index: 1;
}

#app, #loginWrap, #connBanner, #toasts, #modal { position: relative; z-index: 2; }

h1, h2, .card-title, .day-num, .login-title { letter-spacing: -0.02em; }

.label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--ink-3);
}
.dim { color: var(--ink-3); font-size: 12.5px; }

.ico { width: 1.15em; height: 1.15em; flex: none; display: inline-block; vertical-align: -0.2em; }

/* ---------- panels ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--rx-a);
  box-shadow: 1px 2px 0 rgba(0,0,0,.45), inset 0 1px 0 rgba(233,218,178,.04);
  padding: 16px 18px;
}
section.panel:nth-of-type(even), article.panel:nth-of-type(even) { border-radius: var(--rx-b); }

#app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 16px 30px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card-head {
  display: flex; align-items: baseline; gap: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--hairline);
  padding-bottom: 8px;
}
.card-title { font-size: 19px; color: var(--gold); font-weight: normal; }
.subtag {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .16em;
  color: var(--ink-3); margin-left: 2px;
}

/* ---------- boot / connection ---------- */
.bootnote {
  position: fixed; inset: 0; display: grid; place-items: center;
  color: var(--ink-3); font-style: italic; z-index: 0;
}
#connBanner {
  position: fixed; top: 10px; left: 50%; transform: translateX(-50%);
  z-index: 70;
  display: flex; align-items: center; gap: 8px;
  background: #3a1512; border: 1px solid var(--danger); color: #eecfc0;
  padding: 8px 16px; border-radius: var(--rx-btn);
  box-shadow: 1px 2px 0 rgba(0,0,0,.5);
  font-size: 13.5px;
}
#connBanner .ico { color: var(--danger); }

/* ---------- login ---------- */
#loginWrap {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
}
.login-card { width: min(360px, 92vw); text-align: center; padding: 30px 28px; }
.login-skull .ico { width: 44px; height: 44px; color: var(--gold); }
.login-title { font-size: 30px; color: var(--ink); margin-top: 6px; }
.login-sub { color: var(--ink-3); font-size: 13px; font-style: italic; margin: 4px 0 18px; }
#loginForm { display: flex; flex-direction: column; gap: 10px; }
.login-err { color: #d66a5e; font-size: 13px; min-height: 1.3em; font-style: italic; }
.shake { animation: shake .45s; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-9px); } 40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); } 80% { transform: translateX(4px); }
}

/* ---------- inputs ---------- */
input[type="text"], input[type="password"], textarea, select {
  font-family: var(--serif);
  font-size: 14px;
  color: var(--ink);
  background: var(--well);
  border: 1px solid var(--border);
  border-radius: 8px 5px 9px 6px / 6px 8px 5px 9px;
  padding: 8px 11px;
}
textarea { font-family: var(--mono); font-size: 12.5px; line-height: 1.55; }
input::placeholder, textarea::placeholder { color: var(--ink-3); font-style: italic; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--serif);
  font-size: 14px;
  color: var(--ink);
  background: #2e2415;
  border: 1px solid var(--border);
  border-radius: var(--rx-btn);
  box-shadow: 1px 2px 0 rgba(0,0,0,.4);
  padding: 8px 14px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
}
.btn:hover { background: #3a2d1a; border-color: var(--gold); }
.btn:active { transform: translate(1px,1px); box-shadow: none; }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn .ico { color: var(--gold); }
.btn-red { background: var(--red); border-color: #63201a; color: #f3e2c8; }
.btn-red:hover { background: var(--red-hi); border-color: #7c2a22; }
.btn-red .ico { color: #f3e2c8; }
.btn-amber { border-color: rgba(198,133,32,.6); }
.btn-amber .ico { color: var(--warn); }
.btn-green { border-color: rgba(47,160,111,.55); }
.btn-green .ico { color: var(--ok); }
.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn-ghost { background: none; border-color: transparent; box-shadow: none; }
.btn-ghost:hover { border-color: var(--border); background: var(--panel-2); }

/* ---------- header band ---------- */
.band {
  display: flex; align-items: center; gap: 26px; flex-wrap: wrap;
  padding: 18px 22px;
}
.band-title { min-width: 200px; }
.band-title h1 { font-size: 27px; color: var(--ink); }
.band-dots { display: flex; gap: 14px; margin-top: 8px; flex-wrap: wrap; }

.statdot { font-size: 12px; color: var(--ink-3); display: inline-flex; align-items: center; gap: 6px; }
.statdot i {
  width: 8px; height: 8px; border-radius: 50% 40% 50% 45%;
  background: var(--idle); box-shadow: 0 0 0 2px rgba(0,0,0,.25);
}
.statdot.on { color: var(--ink-2); }
.statdot.on i { background: var(--ok); box-shadow: 0 0 6px rgba(47,160,111,.5); }
.statdot.bad i { background: var(--danger); }

.band-day { text-align: center; }
.day-num {
  font-size: 58px; line-height: 1; color: var(--ink);
  text-shadow: 1px 2px 0 rgba(0,0,0,.55);
}

.band-cell { display: flex; align-items: center; gap: 10px; }
.cellval { font-size: 17px; }
.cellicon { display: inline-flex; }
.cellicon .ico, .ring-icon .ico { width: 25px; height: 25px; }
.flip svg { transform: scaleX(-1); }

/* season tint set: decorative chrome beside its text label */
.season-spring { color: var(--ok); }
.season-summer { color: var(--gold-hi); }
.season-autumn { color: var(--warn); }
.season-winter { color: var(--frost); }
.phase-day   { color: var(--gold-hi); }
.phase-dusk  { color: var(--warn); }
.phase-night { color: var(--frost); }
.moon-tint   { color: #d8cba4; }

.ring-wrap { position: relative; width: 48px; height: 48px; flex: none; }
.ring { width: 48px; height: 48px; display: block; }
.ring-track { fill: none; stroke: rgba(185,138,44,.18); stroke-width: 3; }
.ring-fill {
  fill: none; stroke: var(--viz-series); stroke-width: 3; stroke-linecap: round;
  stroke-dasharray: 125.7; stroke-dashoffset: 125.7;
  transition: stroke-dashoffset .6s ease;
}
.ring-icon { position: absolute; inset: 0; display: grid; place-items: center; }

.band-players { margin-left: auto; max-width: 300px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--ink-2);
  background: var(--panel-2); border: 1px solid var(--hairline);
  border-radius: 8px 5px 9px 6px / 6px 9px 5px 8px;
  padding: 3px 9px;
}
.chip .ico { width: .95em; height: .95em; color: var(--gold); }
.chip-frozen { color: var(--frost); border-color: rgba(143,176,181,.4); margin-top: 6px; }
.chip-frozen .ico { color: var(--frost); }
.nobody { font-style: italic; }

/* ---------- grid & shard cards ---------- */
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

.shardcard.down .card-title { color: var(--ink-3); }

.statuschip {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--ink-2);
}
.statuschip .dot {
  width: 9px; height: 9px; border-radius: 50% 42% 50% 46%;
  background: var(--idle);
}
.statuschip.good .dot { background: var(--ok); box-shadow: 0 0 7px rgba(47,160,111,.55); }
.statuschip.bad  .dot { background: var(--danger); box-shadow: 0 0 7px rgba(192,58,58,.5); }
.statuschip .ico { color: var(--danger); width: 1.05em; height: 1.05em; }

.statrow {
  display: grid; grid-template-columns: repeat(4, auto); gap: 8px 18px;
  justify-content: start;
  margin-bottom: 12px;
}
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-weight: normal; font-size: 16.5px; }

/* ---------- sparklines ---------- */
.sparkbox { margin-top: 2px; }
.sparkhead { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 3px; }
.spark { position: relative; height: 64px; border-radius: 4px; }
.spark:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.spark svg { display: block; width: 100%; height: 100%; }
.spark .sline { fill: none; stroke: var(--viz-series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark .sarea { fill: var(--viz-series); opacity: .1; }
.spark .sbase { stroke: var(--hairline); stroke-width: 1; }
.spark .sdot  { fill: var(--viz-series); stroke: var(--panel); stroke-width: 2; }
.spark .xhair { stroke: var(--ink-3); stroke-width: 1; }
.spark .hdot  { fill: var(--viz-series); stroke: var(--panel); stroke-width: 2; }
.spark-empty {
  height: 100%; display: grid; place-items: center;
  color: var(--ink-3); font-size: 12.5px; font-style: italic;
}
.spark-tip {
  position: absolute; top: -4px;
  transform: translate(-50%, -100%);
  background: #100c05; border: 1px solid var(--border);
  border-radius: 6px 4px 7px 5px / 5px 7px 4px 6px;
  padding: 4px 9px; font-size: 12px; white-space: nowrap;
  pointer-events: none; z-index: 5;
  box-shadow: 1px 2px 0 rgba(0,0,0,.5);
}
.spark-tip b { color: var(--ink); font-weight: normal; font-size: 13px; }
.spark-tip span { color: var(--ink-3); margin-left: 6px; }

/* ---------- meters ---------- */
.meter { margin-bottom: 13px; }
.meter-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 5px; }
.meter-val { font-weight: normal; font-size: 14.5px; }
.meter-track {
  height: 12px; border-radius: 6px 4px 7px 4px / 4px 6px 4px 7px;
  background: rgba(47,160,111,.14);
  overflow: hidden;
  transition: background .4s;
}
.meter-fill {
  height: 100%; width: 0;
  background: var(--ok);
  border-radius: 0 4px 4px 0;   /* rounded data-end, square at baseline */
  transition: width .6s ease, background .4s;
}
.meter.warn .meter-track { background: rgba(198,133,32,.14); }
.meter.warn .meter-fill { background: var(--warn); }
.meter.danger .meter-track { background: rgba(192,58,58,.16); }
.meter.danger .meter-fill { background: var(--danger); }

/* ---------- actions ---------- */
.btnrow { display: flex; flex-wrap: wrap; gap: 10px; }
.last-ann { margin-top: 10px; font-style: italic; }

/* ---------- restart banner ---------- */
.banner {
  position: sticky; top: 8px; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  background: #33260e;
  border: 1px solid var(--warn);
  color: #eed9a0;
  padding: 10px 14px;
  border-radius: var(--rx-btn);
  box-shadow: 1px 3px 0 rgba(0,0,0,.5);
}
.banner .ico { color: var(--warn); }
.banner .btn { margin-left: auto; }

/* ---------- mods ---------- */
.addrow { display: flex; gap: 10px; margin-bottom: 14px; }
.addrow input { flex: 1; max-width: 420px; }

.modgrid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(265px, 1fr));
  gap: 10px;
}
.modcard {
  display: flex; gap: 11px;
  background: var(--panel-2);
  border: 1px solid var(--hairline);
  border-radius: var(--rx-btn);
  padding: 10px;
  position: relative;
}
.modcard.off { opacity: .62; }
.modcard.pending { border-style: dashed; border-color: var(--border); }
.modthumb {
  width: 56px; height: 56px; flex: none;
  background: var(--well); border-radius: 7px 5px 8px 5px / 5px 8px 5px 7px;
  display: grid; place-items: center; overflow: hidden;
  color: var(--ink-3);
}
.modthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.modthumb .ico { width: 22px; height: 22px; }
.modbody { flex: 1; min-width: 0; }
.modname { font-size: 14.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modmeta { font-size: 12px; color: var(--ink-3); margin: 1px 0 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modtags { display: flex; gap: 5px; flex-wrap: wrap; }
.mtag {
  font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  border: 1px solid var(--hairline); color: var(--ink-3);
  border-radius: 5px; padding: 1px 6px;
}
.mtag.klei { color: var(--gold); border-color: rgba(201,162,75,.4); }
.mtag.pend { color: var(--warn); border-color: rgba(198,133,32,.45); }
.modside { display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; }
.modrm { color: var(--ink-3); }
.modrm:hover { color: #d66a5e; }
.modrm .ico { color: inherit; width: .95em; height: .95em; }

/* toggle switch */
.switch { position: relative; width: 40px; height: 22px; display: inline-block; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.switch .knob {
  position: absolute; inset: 0; pointer-events: none;
  background: var(--well); border: 1px solid var(--border); border-radius: 12px;
  transition: background .25s, border-color .25s;
}
.switch .knob::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50% 45% 50% 42%;
  background: var(--ink-3);
  transition: left .25s, background .25s;
}
.switch input:checked + .knob { background: rgba(47,160,111,.28); border-color: rgba(47,160,111,.6); }
.switch input:checked + .knob::after { left: 20px; background: var(--ok); }
.switch input:focus-visible + .knob { outline: 2px solid var(--gold); outline-offset: 2px; }
.switch input:disabled { cursor: default; }
.switch input:disabled + .knob { opacity: .5; }

/* advanced editor */
#advanced { margin-top: 16px; border-top: 1px solid var(--hairline); padding-top: 10px; }
#advanced summary {
  cursor: pointer; color: var(--ink-2); font-size: 13.5px;
  list-style-position: inside;
}
#advanced summary:hover { color: var(--gold); }
.rawbar { display: flex; align-items: center; gap: 9px; margin: 12px 0 8px; flex-wrap: wrap; }
#rawEditor { width: 100%; height: 300px; resize: vertical; }
.rawerror {
  margin-top: 8px; padding: 9px 12px;
  background: #331311; border: 1px solid var(--danger);
  border-radius: var(--rx-btn);
  color: #e8a89b; font-family: var(--mono); font-size: 12px;
  white-space: pre-wrap; word-break: break-word;
}

/* ---------- logs ---------- */
.loghead { flex-wrap: wrap; align-items: center; }
.logtabs { display: flex; gap: 6px; }
.tab {
  font-family: var(--serif); font-size: 13px;
  background: none; border: 1px solid transparent; color: var(--ink-3);
  padding: 4px 12px; cursor: pointer;
  border-radius: var(--rx-btn);
}
.tab:hover { color: var(--ink-2); }
.tab.on { color: var(--gold); border-color: var(--border); background: var(--panel-2); }
#logFilter { margin-left: auto; width: 190px; padding: 5px 10px; font-size: 13px; }
.ck { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-3); cursor: pointer; }
.ck input { accent-color: var(--gold); }

.logwell {
  background: var(--well);
  border: 1px solid var(--hairline);
  border-radius: 8px 12px 9px 12px / 12px 9px 12px 8px;
  height: 380px; overflow: auto;
  padding: 10px 13px;
  font-family: var(--mono); font-size: 12px; line-height: 1.55;
}
.logline { white-space: pre-wrap; word-break: break-word; color: var(--ink-2); }
.logline.join { color: var(--ok); }
.logline.leave { color: var(--warn); }
.logline.ann { color: var(--gold); }
.logline.err { color: #d66a5e; }
.logempty { color: var(--ink-3); font-style: italic; font-family: var(--serif); }

/* ---------- modal ---------- */
#modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(10,7,3,.74);
  display: grid; place-items: center;
  padding: 18px;
}
.modal-card { width: min(440px, 94vw); padding: 20px 22px; }
.modal-title { font-size: 19px; color: var(--gold); margin-bottom: 10px; }
.modal-body p { color: var(--ink-2); font-size: 14px; margin-bottom: 12px; }
.modal-row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.modal-body textarea { width: 100%; height: 90px; resize: none; font-family: var(--serif); font-size: 14px; }
.modal-body select, .modal-body input[type="text"] { width: 100%; }
.charcount { text-align: right; font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }
.confirm-word { margin-top: 10px; }

/* ---------- toasts ---------- */
#toasts {
  position: fixed; right: 16px; bottom: 16px; z-index: 80;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  background: #100c05; border: 1px solid var(--border);
  color: var(--ink);
  padding: 10px 15px; font-size: 13.5px;
  border-radius: var(--rx-btn);
  box-shadow: 1px 3px 0 rgba(0,0,0,.5);
  animation: toastin .25s ease;
  max-width: 340px;
}
.toast .ico { color: var(--ok); }
.toast.err { border-color: var(--danger); }
.toast.err .ico { color: var(--danger); }
.toast.out { opacity: 0; transition: opacity .3s; }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } }

.foot { text-align: center; font-style: italic; margin-top: 4px; }

/* ---------- responsive ---------- */
@media (max-width: 1050px) {
  .grid3 { grid-template-columns: 1fr 1fr; }
  .band-players { margin-left: 0; max-width: none; }
}
@media (max-width: 700px) {
  .grid3 { grid-template-columns: 1fr; }
  .band { gap: 16px; padding: 15px; }
  .day-num { font-size: 44px; }
  #logFilter { margin-left: 0; flex: 1; }
  .statrow { grid-template-columns: repeat(2, auto); }
}

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