/* Watertight -- design system for the browser UI.
   Canonical copy lives in /shared; sync.sh copies it into server/static.
   Edit it here, not in the copy. */

:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --line: #e2e6ec;
  --text: #14181f;
  --text-dim: #5c6675;
  --text-faint: #8b95a4;

  --accent: #2f6df6;
  --accent-soft: #e8f0ff;
  --ok: #1a8a5a;
  --ok-soft: #e4f5ec;
  --warn: #a8620a;
  --warn-soft: #fdf1e0;
  --bad: #c2352c;
  --bad-soft: #fdeceb;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --surface: #1c2027;
    --surface-2: #23282f;
    --line: #2e343d;
    --text: #eef1f5;
    --text-dim: #a3adbb;
    --text-faint: #78828f;

    --accent: #5b8dff;
    --accent-soft: #1d2a44;
    --ok: #46c88a;
    --ok-soft: #14301f;
    --warn: #e0a758;
    --warn-soft: #33260f;
    --bad: #f2736a;
    --bad-soft: #3a1c1a;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.28);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

/* ── Title bar ─────────────────────────────────────────────────────────── */

header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex: 0 0 auto;
}

header .brand {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

header .drop-icon { color: var(--accent); display: flex; }

header .spacer { flex: 1; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  cursor: default;
}

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); flex: 0 0 auto; }
.status[data-state="ok"]      .dot { background: var(--ok); }
.status[data-state="busy"]    .dot { background: var(--accent); animation: pulse 1.1s infinite; }
.status[data-state="offline"] .dot { background: var(--bad); }
@keyframes pulse { 50% { opacity: .25; } }

/* ── Layout ────────────────────────────────────────────────────────────── */

main {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
}

/* ── Dropzone ──────────────────────────────────────────────────────────── */

.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
  flex: 0 0 auto;
}

.dropzone:hover { border-color: var(--accent); }
.dropzone.hot {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: scale(1.005);
}
.dropzone.disabled { opacity: .55; pointer-events: none; }

.dropzone h2 {
  margin: 12px 0 4px;
  font-size: 16px;
  font-weight: 600;
}

.dropzone p { margin: 0; color: var(--text-dim); font-size: 13px; }
.dropzone .arrow { color: var(--accent); }
.dropzone input[type="file"] { display: none; }

/* Upload ceiling, stated before the user picks a file rather than after a
   rejected 413. web.js keeps the number in sync with the server's real cap. */
.upload-cap {
  margin: 0 0 8px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12.5px;
}

/* ── Cards ─────────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card > h3 {
  margin: 0;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 650;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card > h3 .file { color: var(--text-dim); font-weight: 450; font-family: var(--mono); font-size: 12px; }
.card .body { padding: 16px; }

/* ── Verdict banner ────────────────────────────────────────────────────── */

.verdict {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 14px;
}
.verdict .title { font-weight: 650; margin-bottom: 2px; }
.verdict .sub { font-size: 13px; opacity: .85; }
.verdict.ok   { background: var(--ok-soft);   border-color: color-mix(in srgb, var(--ok) 30%, transparent);   color: var(--ok); }
.verdict.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); color: var(--warn); }
.verdict.bad  { background: var(--bad-soft);  border-color: color-mix(in srgb, var(--bad) 30%, transparent);  color: var(--bad); }
.verdict svg { flex: 0 0 auto; margin-top: 1px; }

/* ── Metric grid: before / after ───────────────────────────────────────── */

.metrics {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0;
  font-size: 13px;
}

.metrics .head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-faint);
  font-weight: 600;
  padding: 0 0 8px;
  border-bottom: 1px solid var(--line);
}
.metrics .head.num { text-align: right; min-width: 84px; }

.metrics .k { padding: 7px 0; color: var(--text-dim); border-bottom: 1px solid var(--line); }
.metrics .v {
  padding: 7px 0 7px 16px;
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  border-bottom: 1px solid var(--line);
}
.metrics .row-last .k, .metrics .row-last .v { border-bottom: none; }

.v.good { color: var(--ok); }
.v.bad  { color: var(--bad); }
.v.dim  { color: var(--text-faint); }

/* ── Repair steps ──────────────────────────────────────────────────────── */

.steps { list-style: none; margin: 0; padding: 0; }

.steps li {
  display: flex;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  align-items: flex-start;
}
.steps li:last-child { border-bottom: none; }

.steps .mark {
  flex: 0 0 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin-top: 1px;
  font-size: 11px;
}
.steps .mark.did  { background: var(--ok);  color: #fff; }
.steps .mark.skip { background: var(--surface-2); color: var(--text-faint); border: 1px solid var(--line); }
.steps .mark.fail { background: var(--bad); color: #fff; }

.steps .label { font-weight: 550; }
.steps .detail { color: var(--text-dim); font-size: 12.5px; }
.steps li.inactive .label { color: var(--text-faint); font-weight: 450; }

/* ── Notes / warnings ──────────────────────────────────────────────────── */

.notes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.notes li {
  display: flex;
  gap: 8px;
  font-size: 13px;
  color: var(--warn);
  background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
}
.notes li svg { flex: 0 0 auto; margin-top: 2px; }

/* ── Buttons ───────────────────────────────────────────────────────────── */

button {
  font: inherit;
  font-weight: 550;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 7px 13px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
button:hover:not(:disabled) { background: var(--surface-2); }
button:disabled { opacity: .5; cursor: default; }

button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { filter: brightness(1.07); background: var(--accent); }
button.ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
button.ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
button.small { padding: 4px 9px; font-size: 12.5px; }

.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions .spacer { flex: 1; }

/* ── Progress ──────────────────────────────────────────────────────────── */

.progress {
  height: 4px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.progress > i {
  display: block;
  height: 100%;
  width: 30%;
  background: var(--accent);
  border-radius: 999px;
  animation: slide 1.2s ease-in-out infinite;
}
@keyframes slide {
  0%   { margin-left: -30%; }
  100% { margin-left: 100%; }
}

.working { display: flex; flex-direction: column; gap: 10px; }
.working .what { font-size: 13px; color: var(--text-dim); }

/* ── Saved banner ──────────────────────────────────────────────────────── */

.saved {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  background: var(--ok-soft);
  color: var(--ok);
  border: 1px solid color-mix(in srgb, var(--ok) 28%, transparent);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.saved .path { font-family: var(--mono); font-size: 12px; word-break: break-all; }

/* ── Settings ──────────────────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-dim); }
.field input {
  font: inherit;
  font-family: var(--mono);
  font-size: 13px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
}
.field input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.field .hint { font-size: 12px; color: var(--text-faint); }

.hidden { display: none !important; }

.error-text { color: var(--bad); font-size: 13px; }

footer {
  flex: 0 0 auto;
  padding: 9px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  font-size: 11.5px;
  color: var(--text-faint);
  display: flex;
  gap: 10px;
  align-items: center;
}
footer .spacer { flex: 1; }
