@font-face { font-family: "Plex"; src: url(fonts/plex-sans-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex"; src: url(fonts/plex-sans-500.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex"; src: url(fonts/plex-sans-600.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "PlexMono"; src: url(fonts/plex-mono-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url(fonts/fraunces-600.woff2) format("woff2"); font-weight: 600; font-display: swap; }

:root {
  /* fjord at night: slate with a cold blue cast, one warm accent */
  --canvas: #161d24;
  --rail: #1b232b;
  --surface: #212a33;
  --raised: #29333d;
  --hover: #2f3a45;
  --hair: #33404b;
  --hair-soft: #2a343e;
  --text: #ebe7de;
  --text-2: #9ba7b0;
  --text-3: #6b7781;
  --fox: #ef8e3b;
  --fox-deep: #c96f24;
  --fox-wash: rgba(239, 142, 59, .12);
  --moss: #8fbf6a;
  --moss-wash: rgba(143, 191, 106, .12);
  --ice: #7fb3d5;
  --ember: #e0645a;
  --ember-wash: rgba(224, 100, 90, .12);
  --radius-s: 6px;
  --radius-m: 10px;
  --ui: "Plex", system-ui, sans-serif;
  --display: "Fraunces", Georgia, serif;
  --mono: "PlexMono", ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--canvas);
  color: var(--text);
  font: 400 15px/1.5 var(--ui);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
a { color: var(--fox); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--fox); outline-offset: 2px; border-radius: 4px; }
::selection { background: rgba(239, 142, 59, .35); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.rail {
  background: var(--rail);
  border-right: 1px solid var(--hair-soft);
  padding: 22px 0 18px;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.wordmark { padding: 0 22px 20px; display: flex; align-items: center; gap: 11px; }
.wordmark img { width: 26px; height: 26px; }
.wordmark b { font: 600 22px/1 var(--display); letter-spacing: -.01em; }
.wordmark small { display: block; color: var(--text-3); font-size: 12px; margin-top: 4px; }
.nav { display: flex; flex-direction: column; gap: 1px; padding: 6px 0; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 9px 22px; color: var(--text-2); text-decoration: none; font-weight: 500;
}
.nav a svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.nav a:hover { color: var(--text); background: var(--surface); }
.nav a[aria-current="page"] { color: var(--text); background: var(--surface); }
.nav a[aria-current="page"]::before { content: ""; position: absolute; left: 0; top: 6px; bottom: 6px; width: 3px; background: var(--fox); border-radius: 0 3px 3px 0; }
.nav .count { margin-left: auto; font-size: 12px; color: var(--text-3); }
.rail-foot { margin-top: auto; padding: 14px 22px 0; border-top: 1px solid var(--hair-soft); color: var(--text-3); font-size: 13px; }
.rail-foot button { background: none; border: 0; padding: 0; color: var(--text-2); cursor: pointer; }
.rail-foot button:hover { color: var(--text); }

.main { padding: 34px 44px 60px; max-width: 1180px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font: 600 26px/1.2 var(--ui); letter-spacing: -.015em; }
.page-head p { margin: 6px 0 0; color: var(--text-2); max-width: 62ch; }

/* ---------- hearth (overview header) ---------- */
.hearth {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 28px; align-items: end;
  padding: 6px 0 30px; border-bottom: 1px solid var(--hair);
}
.hearth h1 { margin: 0; font: 600 clamp(34px, 5vw, 54px)/1.05 var(--display); letter-spacing: -.02em; display: flex; align-items: center; gap: 18px; }
.hearth .line { margin-top: 14px; color: var(--text-2); font-size: 16px; display: flex; flex-wrap: wrap; gap: 6px 22px; }
.hearth .line strong { color: var(--text); font-weight: 500; }
.ember { flex: none; display: inline-block; width: 14px; height: 14px; border-radius: 50%; background: var(--text-3); margin-top: .12em; }
.ember.on { background: var(--fox); box-shadow: 0 0 0 0 rgba(239, 142, 59, .6); animation: glow 2.8s ease-in-out infinite; }
.ember.wait { background: var(--ice); }
.ember.off { background: var(--text-3); }
@keyframes glow { 0%, 100% { box-shadow: 0 0 0 0 rgba(239, 142, 59, .45); } 50% { box-shadow: 0 0 0 7px rgba(239, 142, 59, 0); } }
@media (prefers-reduced-motion: reduce) { .ember.on { animation: none; } }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- sections ---------- */
.section { padding: 26px 0; border-bottom: 1px solid var(--hair-soft); }
.section:last-child { border-bottom: 0; }
.section > h2 { margin: 0 0 4px; font: 600 16px/1.3 var(--ui); }
.section > .hint { margin: 0 0 18px; color: var(--text-2); font-size: 14px; max-width: 70ch; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 40px; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 22px 32px; margin: 0; }
.facts div { min-width: 0; }
.facts dt { color: var(--text-3); font-size: 13px; margin-bottom: 3px; }
.facts dd { margin: 0; font-size: 20px; font-weight: 500; letter-spacing: -.01em; overflow-wrap: anywhere; }
.facts dd small { font-size: 13px; color: var(--text-2); font-weight: 400; margin-left: 4px; }
.facts dd small.below { display: block; margin: 2px 0 0; }
.meter { height: 4px; background: var(--hair); border-radius: 2px; margin-top: 9px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--text-2); border-radius: 2px; }
.meter i.warn { background: var(--fox); }

/* ---------- rows / lists ---------- */
.rows { margin: 0; padding: 0; list-style: none; }
.row { display: flex; align-items: center; gap: 16px; padding: 13px 0; border-bottom: 1px solid var(--hair-soft); min-width: 0; }
.row:first-child { border-top: 1px solid var(--hair-soft); }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 500; overflow-wrap: anywhere; }
.row .sub { color: var(--text-2); font-size: 13.5px; margin-top: 2px; overflow-wrap: anywhere; }
.row .meta { color: var(--text-3); font-size: 13px; white-space: nowrap; }
.row .icon { width: 44px; height: 44px; border-radius: 8px; background: var(--raised); flex: none; object-fit: cover; }
.row.disabled .title, .row.disabled .icon { opacity: .5; }
.empty { padding: 30px 0; color: var(--text-2); }
.empty b { color: var(--text); font-weight: 500; display: block; margin-bottom: 4px; }

.tag { display: inline-block; font-size: 12px; line-height: 1; padding: 4px 7px; border-radius: 4px; background: var(--raised); color: var(--text-2); margin: 0 6px 0 0; white-space: nowrap; }
.tag.fox { background: var(--fox-wash); color: var(--fox); }
.tag.moss { background: var(--moss-wash); color: var(--moss); }
.tag.ember { background: var(--ember-wash); color: var(--ember); }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 15px; border-radius: var(--radius-s);
  border: 1px solid var(--hair); background: var(--surface); color: var(--text);
  font-weight: 500; font-size: 14px; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--fox); border-color: var(--fox); color: #1d1206; }
.btn.primary:hover { background: #f59c4f; }
.btn.danger { color: var(--ember); }
.btn.danger:hover { background: var(--ember-wash); border-color: rgba(224, 100, 90, .4); }
.btn.quiet { background: none; border-color: transparent; color: var(--text-2); padding: 0 10px; }
.btn.quiet:hover { color: var(--text); background: var(--surface); }
.btn.small { height: 30px; padding: 0 11px; font-size: 13px; }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.field { display: grid; gap: 6px; margin-bottom: 18px; align-content: start; }
[hidden] { display: none !important; }
.field > span { font-size: 14px; font-weight: 500; }
.field > small { color: var(--text-3); font-size: 13px; margin-top: -2px; }
.input, select.input, textarea.input {
  width: 100%; height: 38px; padding: 0 12px; border-radius: var(--radius-s);
  border: 1px solid var(--hair); background: var(--canvas); color: var(--text);
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.55; }
.input:hover { border-color: #405060; }
.input:focus { outline: none; border-color: var(--fox); box-shadow: 0 0 0 3px var(--fox-wash); }
select.input { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%239ba7b0' stroke-width='1.6'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.pw { position: relative; }
.pw .input { padding-right: 76px; }
.pw button { position: absolute; right: 4px; top: 4px; height: 30px; }

.switch { display: flex; align-items: flex-start; gap: 14px; padding: 12px 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .knob { flex: none; width: 38px; height: 22px; border-radius: 11px; background: var(--hair); position: relative; transition: background .15s; margin-top: 1px; }
.switch .knob::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--text); transition: transform .15s; }
.switch input:checked + .knob { background: var(--fox); }
.switch input:checked + .knob::after { transform: translateX(16px); background: #1d1206; }
.switch input:focus-visible + .knob { outline: 2px solid var(--fox); outline-offset: 2px; }
.switch b { display: block; font-weight: 500; }
.switch small { color: var(--text-2); font-size: 13.5px; }

.seg { display: inline-flex; border: 1px solid var(--hair); border-radius: var(--radius-s); overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 7px 12px; color: var(--text-2); cursor: pointer; font-size: 13.5px; border-right: 1px solid var(--hair); }
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--text); background: var(--surface); }
.seg button[aria-pressed="true"] { background: var(--raised); color: var(--text); }
.mod-grid { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 12px 18px; align-items: center; }
.mod-grid label { color: var(--text-2); font-size: 14px; }

.savebar {
  position: sticky; bottom: 16px; margin-top: 24px; display: flex; align-items: center; gap: 14px;
  padding: 12px 14px 12px 18px; background: var(--raised); border: 1px solid var(--hair); border-radius: var(--radius-m);
  box-shadow: 0 10px 30px rgba(5, 9, 12, .45);
}
.savebar p { margin: 0; flex: 1; color: var(--text-2); font-size: 14px; }

.notice { display: flex; gap: 14px; align-items: center; padding: 12px 16px; border-radius: var(--radius-m); background: var(--fox-wash); color: var(--text); margin-bottom: 22px; border: 1px solid rgba(239, 142, 59, .25); }
.notice p { margin: 0; flex: 1; font-size: 14px; }
.notice.info { background: rgba(127, 179, 213, .08); border-color: rgba(127, 179, 213, .22); }

.search { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.search .input { flex: 1; min-width: 200px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--hair); margin-bottom: 22px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs button { background: none; border: 0; padding: 10px 14px; color: var(--text-2); cursor: pointer; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--fox); }

/* ---------- log ---------- */
.log {
  background: #10161b; border: 1px solid var(--hair-soft); border-radius: var(--radius-m);
  font: 12.5px/1.6 var(--mono); color: #b8c2c9; padding: 14px 16px; height: 62vh; overflow: auto;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.log .w { color: #e5b77a; }
.log .e { color: #ef8c84; }
.log .j { color: var(--moss); }
.log .s { color: var(--ice); }
.log.short { height: 260px; }
.log-tools { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.log-tools .input { max-width: 280px; }

/* ---------- drop zone ---------- */
.log-tools h2 { margin: 0; font: 600 16px/1.3 var(--ui); }
.drop { display: block; margin-top: 8px; border: 1.5px dashed var(--hair); border-radius: var(--radius-m); padding: 26px; text-align: center; color: var(--text-2); cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--fox); background: var(--fox-wash); color: var(--text); }
.drop b { color: var(--text); font-weight: 500; }
.drop input { display: none; }
.progress { height: 4px; background: var(--hair); border-radius: 2px; overflow: hidden; margin-top: 14px; }
.progress i { display: block; height: 100%; background: var(--fox); width: 0; transition: width .2s; }

/* ---------- dialog ---------- */
dialog { border: 1px solid var(--hair); border-radius: 14px; background: var(--surface); color: var(--text); padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: 0 24px 60px rgba(4, 8, 11, .6); }
dialog::backdrop { background: rgba(8, 12, 15, .62); }
dialog .dlg-body { padding: 22px 24px 8px; max-height: 70vh; overflow: auto; }
dialog h3 { margin: 0 0 8px; font-size: 18px; font-weight: 600; }
dialog p { color: var(--text-2); margin: 0 0 14px; }
dialog .dlg-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px 20px; }
dialog.wide { width: min(900px, calc(100vw - 32px)); }
.joblog { font: 12.5px/1.6 var(--mono); background: #10161b; border-radius: 8px; padding: 12px 14px; max-height: 320px; overflow: auto; color: #b8c2c9; white-space: pre-wrap; overflow-wrap: anywhere; }
.code-out { display: flex; gap: 10px; align-items: center; background: var(--canvas); border: 1px solid var(--hair); border-radius: 8px; padding: 10px 12px; font: 15px var(--mono); margin-bottom: 12px; }
.code-out span { flex: 1; overflow-wrap: anywhere; }

/* ---------- toasts ---------- */
#toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 50; max-width: min(420px, calc(100vw - 40px)); }
.toast { background: var(--raised); border: 1px solid var(--hair); border-left: 3px solid var(--moss); padding: 11px 16px; border-radius: 8px; box-shadow: 0 10px 30px rgba(5, 9, 12, .5); font-size: 14px; animation: rise .18s ease-out; }
.toast.err { border-left-color: var(--ember); }
@keyframes rise { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr); }
.login-art { position: relative; overflow: hidden; background: #131a20; border-right: 1px solid var(--hair-soft); display: flex; flex-direction: column; justify-content: flex-end; padding: 48px; }
.login-art svg.ridge { position: absolute; inset: auto 0 0 0; width: 100%; height: 70%; }
.login-art h1 { position: relative; margin: 0; font: 600 clamp(48px, 7vw, 92px)/.95 var(--display); letter-spacing: -.03em; }
.login-art p { position: relative; color: var(--text-2); margin: 16px 0 0; max-width: 40ch; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.login-form form { width: 100%; max-width: 340px; }
.login-form h2 { margin: 0 0 6px; font-size: 22px; font-weight: 600; }
.login-form > form > p { color: var(--text-2); margin: 0 0 26px; }
.login-form .btn { width: 100%; height: 40px; margin-top: 6px; }
.form-error { color: var(--ember); font-size: 14px; min-height: 21px; margin: 4px 0 8px; }

.muted { color: var(--text-2); }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }
.right { margin-left: auto; }
.mt { margin-top: 18px; }
.inline-actions { display: flex; gap: 6px; flex: none; flex-wrap: wrap; justify-content: flex-end; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 44px; }
.cfg-list { max-height: 60vh; overflow: auto; }
.cfg-list button { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--hair-soft); padding: 10px 6px; color: var(--text-2); cursor: pointer; overflow-wrap: anywhere; }
.cfg-list button:hover { color: var(--text); background: var(--surface); }
.cfg-list button[aria-current="true"] { color: var(--text); background: var(--surface); box-shadow: inset 3px 0 var(--fox); }
.cfg-edit { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 24px; }
.cfg-edit textarea { font: 12.5px/1.6 var(--mono); min-height: 60vh; }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: sticky; height: auto; flex-direction: row; align-items: center; padding: 10px 16px; z-index: 10; border-right: 0; border-bottom: 1px solid var(--hair-soft); top: 0; }
  .wordmark { padding: 0 12px 0 0; }
  .wordmark small { display: none; }
  .wordmark b { font-size: 19px; }
  .nav { flex-direction: row; overflow-x: auto; padding: 0; scrollbar-width: none; }
  .nav a { padding: 8px 10px; }
  .nav a span, .nav .count { display: none; }
  .nav a[aria-current="page"]::before { left: 8px; right: 8px; top: auto; bottom: -10px; width: auto; height: 2px; }
  .rail-foot { display: none; }
  .main { padding: 24px 16px 60px; }
  .hearth { grid-template-columns: 1fr; }
  .split, .cfg-edit { grid-template-columns: 1fr; }
  .login { grid-template-columns: 1fr; }
  .login-art { min-height: 260px; padding: 28px 20px; }
  .mod-grid { grid-template-columns: 1fr; gap: 6px; }
  .mod-grid label { margin-top: 10px; }
  .row { flex-wrap: wrap; }
  .row .meta { white-space: normal; }
}
