:root {
  --bg: #0f1216;
  --surface: #171b21;
  --surface-2: #1e242c;
  --line: #2a323c;
  --text: #e6eaef;
  --muted: #8b97a6;
  --accent: #5b9dd9;
  --ok: #4ca96a;
  --warn: #d8a13a;
  --danger: #cf5a52;
  --steam: #6b7a8c;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h2, h3 { margin: 0 0 .5rem; font-weight: 600; }
h2 { font-size: 1.25rem; }
h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
p { margin: .4rem 0; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.hidden { display: none !important; }

/* ---------- top bar ---------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .85rem 1.25rem;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 600; }
.brand-mark {
  width: 10px; height: 18px; border-radius: 2px;
  background: linear-gradient(180deg, var(--accent), #2f6ea8);
}
.topbar-meta { display: flex; align-items: center; gap: .75rem; }
.chip {
  font-size: .75rem; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: .15rem .6rem;
}

/* ---------- layout ---------- */

.grid {
  display: grid; gap: 1rem; padding: 1.25rem;
  max-width: 1200px; margin: 0 auto;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem 1.1rem;
}
.card-status { grid-column: 1 / -1; }
.card-log { grid-column: 1 / -1; }

@media (min-width: 900px) {
  .card-status { grid-column: span 2; }
}

/* ---------- status ---------- */

.status-head { display: flex; align-items: center; gap: .9rem; margin-bottom: .9rem; }
.status-head h2 { margin: 0; }
.dot {
  width: 14px; height: 14px; border-radius: 50%; flex: 0 0 auto;
  box-shadow: 0 0 0 4px rgba(255,255,255,.04);
}
.dot-running { background: var(--ok); box-shadow: 0 0 0 4px rgba(76,169,106,.18); }
.dot-stopped { background: var(--muted); }
.dot-unknown { background: var(--line); }
.dot-busy { background: var(--warn); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

.facts { display: flex; flex-wrap: wrap; gap: 1.75rem; margin: 0; }
.facts dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.facts dd { margin: .15rem 0 0; font-size: 1.05rem; font-variant-numeric: tabular-nums; }

/* ---------- build ---------- */

.build-row { display: flex; align-items: center; gap: .75rem; margin: .4rem 0 .7rem; }
.build-box { flex: 1; background: var(--surface-2); border-radius: 8px; padding: .5rem .7rem; }
.build-caption { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.build-value { font-family: var(--mono); font-size: .95rem; }
.build-arrow { color: var(--muted); }

.badge { display: inline-block; font-size: .8rem; border-radius: 999px; padding: .2rem .7rem; }
.badge-muted { background: var(--surface-2); color: var(--muted); }
.badge-ok { background: rgba(76,169,106,.15); color: var(--ok); }
.badge-warn { background: rgba(216,161,58,.15); color: var(--warn); }

.warn-note {
  background: rgba(216,161,58,.1); border-left: 3px solid var(--warn);
  padding: .5rem .7rem; border-radius: 4px; font-size: .82rem; color: #e3c489;
}

/* ---------- buttons ---------- */

.btn {
  font: inherit; font-size: .9rem; cursor: pointer;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 7px; padding: .5rem .9rem;
  transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover:not(:disabled) { background: #273039; border-color: #3a4552; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #07121c; font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: #6cabe3; border-color: #6cabe3; }
.btn-danger { color: #e79a95; }
.btn-danger:hover:not(:disabled) { background: rgba(207,90,82,.16); border-color: var(--danger); }
.btn-ghost { background: transparent; }
.full { width: 100%; margin-top: .35rem; }
.button-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .7rem; }
.button-row .btn { flex: 1 1 auto; }

.busy { display: flex; align-items: center; gap: .5rem; color: var(--warn); font-size: .85rem; margin-top: .7rem; }
.spinner {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid rgba(216,161,58,.3); border-top-color: var(--warn);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- forms ---------- */

.switch { display: flex; align-items: center; gap: .5rem; font-size: .88rem; margin: .3rem 0; cursor: pointer; }
.switch.small { font-size: .8rem; color: var(--muted); }
.switch em { color: var(--muted); font-style: normal; }

.field-row { display: flex; flex-wrap: wrap; gap: .7rem; margin: .6rem 0; }
.field-row label { display: flex; flex-direction: column; gap: .25rem; font-size: .78rem; color: var(--muted); }

input[type="text"], input[type="number"], input[type="time"], select {
  font: inherit; font-size: .88rem; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 6px; padding: .4rem .55rem;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ---------- log ---------- */

.log-head { display: flex; align-items: center; justify-content: space-between; }
.log {
  font-family: var(--mono); font-size: .8rem; line-height: 1.55;
  background: #0c0f13; border: 1px solid var(--line); border-radius: 8px;
  padding: .6rem .75rem; height: 320px; overflow-y: auto;
}
.log-line { display: flex; gap: .7rem; white-space: pre-wrap; word-break: break-word; }
.log-time { color: #55606e; flex: 0 0 auto; }
.lvl-info { color: var(--text); }
.lvl-step { color: var(--accent); }
.lvl-ok { color: var(--ok); }
.lvl-warn { color: var(--warn); }
.lvl-error { color: var(--danger); }
.lvl-steam { color: var(--steam); }

/* ---------- backups ---------- */

.backups { display: flex; flex-direction: column; gap: .4rem; max-height: 220px; overflow-y: auto; }
.backup-run {
  background: var(--surface-2); border-radius: 6px; padding: .45rem .6rem; font-size: .82rem;
}
.backup-run .run-name { font-family: var(--mono); }
.backup-run .run-files { color: var(--muted); font-size: .75rem; }

/* ---------- dialog ---------- */

.dialog {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  padding: 0; max-width: 620px; width: calc(100% - 2rem);
}
.dialog::backdrop { background: rgba(0,0,0,.6); }
.dialog-inner { padding: 1.25rem; max-height: 80vh; overflow-y: auto; }
.dialog fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 .9rem; padding: .8rem .9rem; }
.dialog legend { font-size: .75rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 0 .35rem; }
.dialog label { display: flex; flex-direction: column; gap: .25rem; font-size: .8rem; color: var(--muted); margin-bottom: .6rem; }
.dialog label.switch { flex-direction: row; align-items: center; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .6rem; }

/* ---------- toast ---------- */

.toast {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 8px; padding: .6rem 1rem; font-size: .88rem;
  box-shadow: 0 8px 28px rgba(0,0,0,.45); z-index: 20;
}
.toast.err { border-color: var(--danger); color: #e79a95; }
.toast.ok { border-color: var(--ok); color: #8fd3a5; }

/* ---------- profile picker ---------- */

.topbar-centre { display: flex; align-items: center; gap: .6rem; }
.profile-picker { display: flex; align-items: center; gap: .45rem; }
.profile-picker select { min-width: 190px; }

/* ---------- tabs ---------- */

.tabs {
  display: flex; gap: .25rem; padding: 0 1.25rem;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 53px; z-index: 4;
}
.tab {
  font: inherit; font-size: .9rem; cursor: pointer;
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--muted); padding: .7rem 1rem;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- settings page ---------- */

.settings-page {
  max-width: 1000px; margin: 0 auto; padding: 1.25rem;
  display: flex; flex-direction: column; gap: 1rem;
}
.settings-intro code {
  font-family: var(--mono); font-size: .78rem;
  background: var(--surface-2); padding: .1rem .35rem; border-radius: 4px;
}
.settings-group { display: flex; flex-direction: column; gap: .15rem; }

.setting {
  display: grid;
  grid-template-columns: minmax(190px, 240px) 1fr;
  gap: .35rem 1.25rem;
  align-items: center;
  padding: .6rem 0;
  border-top: 1px solid var(--line);
}
.settings-group .setting:first-of-type { border-top: none; }

.setting-head { display: flex; align-items: center; gap: .4rem; }
.setting-label { font-size: .9rem; }

.setting-control { display: flex; align-items: center; gap: .7rem; }
.setting-slider { flex: 1; min-width: 120px; accent-color: var(--accent); }
.setting-box { flex: 0 0 auto; }
.setting-number { width: 110px; text-align: right; font-variant-numeric: tabular-nums; }
.setting-text { flex: 1; width: 100%; }
select.setting-box { min-width: 190px; }
.setting-unit { color: var(--muted); font-size: .8rem; width: 1.2rem; }

.setting-detail {
  grid-column: 2; margin: 0;
  font-size: .78rem; color: var(--muted); min-height: 1em;
}

/* ---------- info tooltip ---------- */

.info-wrap { position: relative; display: inline-flex; }
.info {
  width: 17px; height: 17px; border-radius: 50%; padding: 0;
  font: 600 11px/1 ui-serif, Georgia, serif; cursor: help;
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center;
}
.info:hover, .info:focus-visible { background: var(--accent); color: #07121c; border-color: var(--accent); outline: none; }

.tip {
  position: absolute; left: 50%; bottom: calc(100% + 9px);
  transform: translateX(-50%);
  width: 330px; max-width: 70vw;
  background: #0c0f13; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: .65rem .75rem; font-size: .8rem; line-height: 1.5;
  box-shadow: 0 10px 30px rgba(0,0,0,.55);
  opacity: 0; visibility: hidden; transition: opacity .12s;
  z-index: 30; pointer-events: none; font-weight: 400;
}
.tip::after {
  content: ''; position: absolute; top: 100%; left: 50%; margin-left: -6px;
  border: 6px solid transparent; border-top-color: var(--line);
}
.info-wrap:hover .tip, .info:focus-visible + .tip { opacity: 1; visibility: visible; }

.tip-warn {
  display: block; margin-top: .5rem; padding-top: .5rem;
  border-top: 1px solid var(--line);
  color: var(--warn); font-style: normal;
}

/* ---------- command preview + save bar ---------- */

.command {
  font-family: var(--mono); font-size: .76rem; line-height: 1.7;
  background: #0c0f13; border: 1px solid var(--line); border-radius: 8px;
  padding: .6rem .75rem; margin: 0; white-space: pre-wrap; word-break: break-word;
  color: #9fb4c9;
}

.settings-bar {
  position: sticky; bottom: 0;
  display: flex; align-items: center; gap: .75rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .7rem 1rem;
}
.settings-bar .spacer { flex: 1; }

.farewell {
  display: flex; align-items: center; justify-content: center;
  height: 100vh; text-align: center; color: var(--muted);
  font: 15px/1.8 system-ui, sans-serif;
}

@media (max-width: 760px) {
  .setting { grid-template-columns: 1fr; }
  .setting-detail { grid-column: 1; }
  .topbar { flex-wrap: wrap; }
}

/* ---------- mods tab ---------- */

.mods-list { display: flex; flex-direction: column; }

.mod-row {
  display: flex; align-items: center; gap: 1rem;
  padding: .7rem 0; border-top: 1px solid var(--line);
}
.mods-list .mod-row:first-child { border-top: none; }
.mod-disabled .mod-name, .mod-disabled .mod-meta { opacity: .5; }

.mod-main { flex: 1; min-width: 0; }
.mod-name { font-size: .95rem; }
.mod-meta {
  font-family: var(--mono); font-size: .74rem; color: var(--muted);
  margin-top: .2rem; word-break: break-all;
}
.mod-actions { display: flex; gap: .5rem; flex: 0 0 auto; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .3rem; padding: 1.75rem 1rem; margin-top: .6rem; cursor: pointer;
  border: 2px dashed var(--line); border-radius: var(--radius);
  background: var(--surface-2); transition: border-color .12s, background .12s;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone-over { border-color: var(--accent); background: rgba(91,157,217,.1); }

@media (max-width: 760px) {
  .mod-row { flex-direction: column; align-items: flex-start; }
}
