/* RPG Mirror — design core. Shared by every page.
   Direction: a dark arcane instrument. Near-black ground, warm brass accent,
   one cool ember for "live". Motion is 120-220ms and never blocks a click. */

:root {
  /* ground */
  --bg:        #0b0c0f;
  --bg-2:      #101218;
  --panel:     #14161d;
  --panel-2:   #191c25;
  --line:      #262a35;
  --line-soft: #1d2029;

  /* ink */
  --ink:       #eceef2;
  --ink-2:     #a8aebc;
  --ink-3:     #6d7382;

  /* accents */
  --brass:     #d9a441;
  --brass-dim: #8a6a2c;
  --ember:     #4fd1c5;
  --blood:     #d9534f;
  --moss:      #6bbf72;

  --r-sm: 6px;
  --r:    10px;
  --r-lg: 16px;

  --t-fast: 120ms cubic-bezier(.2,.7,.3,1);
  --t:      180ms cubic-bezier(.2,.7,.3,1);
  --t-slow: 320ms cubic-bezier(.2,.7,.3,1);

  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 8px 28px rgba(0,0,0,.45);
  --glow:   0 0 0 1px rgba(217,164,65,.35), 0 0 24px -6px rgba(217,164,65,.5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 ui-sans-serif, -apple-system, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* a very quiet grain so the flat black has some tooth */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .35;
  background-image: radial-gradient(circle at 20% 10%, rgba(217,164,65,.05), transparent 45%),
                    radial-gradient(circle at 85% 80%, rgba(79,209,197,.04), transparent 40%);
}

h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.015em; font-weight: 650; }
h1 { font-size: 34px; }
h2 { font-size: 20px; }
h3 { font-size: 15px; }
p  { margin: 0 0 10px; color: var(--ink-2); }
a  { color: var(--brass); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.dim  { color: var(--ink-3); }
.tiny { font-size: 12px; }

/* ── buttons ─────────────────────────────────────────────── */
button, .btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  border-radius: var(--r);
  padding: 10px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  transition: background var(--t-fast), border-color var(--t-fast),
              transform var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}
button:hover, .btn:hover { border-color: var(--ink-3); background: #1f2330; }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: .4; cursor: not-allowed; transform: none; }
button:focus-visible, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--brass); outline-offset: 2px;
}

.btn-primary {
  background: linear-gradient(180deg, #e0af4d, var(--brass));
  border-color: #b7862f;
  color: #22190a;
}
.btn-primary:hover { background: linear-gradient(180deg, #ecbb59, #e0ab45); border-color: #d09b3c; }

.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--panel); }

.btn-lg { padding: 13px 22px; font-size: 16px; border-radius: var(--r); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: var(--r-sm); }
.btn-danger:hover { border-color: var(--blood); color: #ff9b97; }

/* ── surfaces ────────────────────────────────────────────── */
.card {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: 20px;
  position: relative;
  z-index: 1;
}

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 600;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--ink-2);
  background: var(--panel);
}
.chip .dot { width: 7px; height: 7px; border-radius: 99px; background: var(--ink-3); }
.chip.ok      { color: var(--moss);  border-color: #2c4a33; }
.chip.ok .dot { background: var(--moss); }
.chip.live    { color: var(--ember); border-color: #21474a; }
.chip.live .dot { background: var(--ember); animation: pulse 1.6s ease-in-out infinite; }
.chip.warn    { color: var(--brass); border-color: var(--brass-dim); }
.chip.warn .dot { background: var(--brass); }
.chip.bad     { color: #ff9b97; border-color: #5a2b29; }
.chip.bad .dot { background: var(--blood); }

@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.8); } }

/* ── inputs ──────────────────────────────────────────────── */
input[type=text], input[type=search], textarea, select {
  font: inherit;
  width: 100%;
  background: var(--bg-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 9px 11px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--brass);
  box-shadow: 0 0 0 3px rgba(217,164,65,.14);
}
textarea { resize: vertical; min-height: 72px; }
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.hint { font-size: 12px; color: var(--ink-3); margin-top: 5px; }

/* ── top bar, shared by setup and display ────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 22px;
  background: rgba(11,12,15,.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}
.brand { font-weight: 700; letter-spacing: -.02em; font-size: 16px; color: var(--ink); }
.brand span { color: var(--brass); }
.topbar .spacer { flex: 1; }

/* ── the model status chip + its explainer (never blocks anything) ── */
.model-wrap { position: relative; display: inline-flex; align-items: center; gap: 6px; }

.model-chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600;
  padding: 5px 12px 5px 8px;
  border: 1px solid var(--line); border-radius: 99px;
  background: var(--panel); color: var(--ink-2);
  position: relative; overflow: hidden;
  font-variant-numeric: tabular-nums;
  transition: color var(--t), border-color var(--t);
}
.model-chip .bar {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: rgba(217,164,65,.16); width: 0%;
  transition: width 260ms linear;
}
.model-chip > * { position: relative; }

/* a small ring that fills - reads as progress at a glance without reading the numbers */
.model-chip .ring { width: 15px; height: 15px; display: block; position: relative; }
.model-chip .ring svg { width: 15px; height: 15px; transform: rotate(-90deg); display: block; }
.model-chip .ring circle { fill: none; stroke-width: 3; }
.model-chip .ring .trk { stroke: var(--line); }
.model-chip .ring .prg { stroke: var(--brass); transition: stroke-dashoffset 260ms linear; }
.model-chip .ring .tick {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 10px; font-style: normal; color: var(--moss); opacity: 0;
  transition: opacity var(--t);
}
.model-chip.busy .ring .prg { stroke: var(--brass); }
.model-chip.ready { color: var(--moss); border-color: #2c4a33; }
.model-chip.ready .ring svg { opacity: 0; }
.model-chip.ready .ring .tick { opacity: 1; }
.model-chip.failed { color: #ff9b97; border-color: #5a2b29; cursor: pointer; }
.model-chip.failed .ring .prg { stroke: var(--blood); }

.model-info-btn {
  width: 21px; height: 21px; padding: 0; border-radius: 99px;
  font-size: 11px; font-weight: 800; font-style: italic;
  color: var(--ink-3); background: var(--panel); border: 1px solid var(--line);
  display: grid; place-items: center; line-height: 1;
}
.model-info-btn:hover { color: var(--brass); border-color: var(--brass-dim); }

.model-info {
  position: absolute; top: calc(100% + 9px); right: 0; z-index: 90;
  width: min(360px, calc(100vw - 32px));
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow);
  padding: 14px 16px 12px;
  animation: rise 180ms cubic-bezier(.2,.7,.3,1) both;
  text-align: left;
}
.mi-head { display: flex; align-items: center; margin-bottom: 10px; }
.mi-head b { flex: 1; font-size: 13.5px; }
.mi-close {
  background: none; border: none; color: var(--ink-3); font-size: 18px;
  padding: 0 2px; line-height: 1;
}
.mi-close:hover { color: var(--ink); background: none; }
.mi-row { margin-bottom: 11px; }
.mi-row h4 { margin: 0 0 3px; font-size: 12px; color: var(--brass); font-weight: 700; }
.mi-row p { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--ink-2); }
.mi-foot {
  margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line-soft);
  font-size: 12px; color: var(--ink-3);
}

/* ── motion utilities ────────────────────────────────────── */
.fade-in { animation: fadeIn var(--t-slow) both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.rise { animation: rise 420ms cubic-bezier(.2,.7,.3,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

.hidden { display: none !important; }

/* ── toast ───────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: var(--panel-2); border: 1px solid var(--line);
  color: var(--ink); padding: 10px 18px; border-radius: 99px;
  box-shadow: var(--shadow); z-index: 200;
  opacity: 0; pointer-events: none;
  transition: opacity var(--t), transform var(--t);
  font-size: 13.5px; font-weight: 600;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.version {
  position: fixed; right: 12px; bottom: 10px; z-index: 5;
  font-size: 11px; color: #3a3f4b; letter-spacing: .04em;
}
