/* Topward Work. Colours and type are Topward's tokens (copied from ~/topward, not imported). */
@font-face {
  font-family: 'Archivo Variable';
  src: url('/assets/archivo.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}

:root {
  --accent-h: 250;
  --bg: oklch(0.975 0.004 250);
  --surface: oklch(1 0 0);
  --surface-2: oklch(0.955 0.006 250);
  --line: oklch(0.885 0.009 250);
  --line-strong: oklch(0.78 0.012 250);
  --fg: oklch(0.21 0.016 250);
  --muted: oklch(0.47 0.016 250);
  --header: oklch(0.2 0.016 250);
  --on-header: oklch(0.96 0.005 250);
  --accent: oklch(0.5 0.17 var(--accent-h));
  --accent-hover: oklch(0.46 0.16 var(--accent-h));
  --accent-wash: oklch(0.55 0.17 var(--accent-h) / 0.11);
  --on-accent: oklch(1 0 0);
  --ok: oklch(0.5 0.13 155);
  --ok-wash: oklch(0.5 0.13 155 / 0.12);
  --warn: oklch(0.52 0.12 75);
  --warn-wash: oklch(0.7 0.15 80 / 0.18);
  --bad: oklch(0.52 0.19 28);
  --bad-wash: oklch(0.52 0.19 28 / 0.11);
  --focus: oklch(0.55 0.17 250);
  --shadow-1: 0 1px 2px oklch(0.2 0.02 250 / 0.06), 0 2px 8px oklch(0.2 0.02 250 / 0.04);
  --shadow-2: 0 2px 6px oklch(0.2 0.02 250 / 0.08), 0 16px 40px oklch(0.2 0.02 250 / 0.12);
  --font: 'Archivo Variable', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --r-sm: 6px; --r-md: 10px; --r-lg: 16px;
  --target: 44px;
  color-scheme: light;
}
@media (pointer: fine) and (min-width: 1100px) { :root { --target: 36px; } }
@media (prefers-color-scheme: dark) {
  :root {
    --bg: oklch(0.165 0.012 250);
    --surface: oklch(0.205 0.014 250);
    --surface-2: oklch(0.245 0.015 250);
    --line: oklch(0.3 0.015 250);
    --line-strong: oklch(0.4 0.017 250);
    --fg: oklch(0.95 0.006 250);
    --muted: oklch(0.73 0.014 250);
    --header: oklch(0.13 0.011 250);
    --on-header: oklch(0.95 0.006 250);
    --accent: oklch(0.7 0.14 var(--accent-h));
    --accent-hover: oklch(0.76 0.12 var(--accent-h));
    --accent-wash: oklch(0.7 0.14 var(--accent-h) / 0.17);
    --on-accent: oklch(0.15 0.03 var(--accent-h));
    --ok: oklch(0.78 0.15 155);
    --ok-wash: oklch(0.78 0.15 155 / 0.14);
    --warn: oklch(0.83 0.14 85);
    --warn-wash: oklch(0.83 0.14 85 / 0.14);
    --bad: oklch(0.74 0.16 25);
    --bad-wash: oklch(0.74 0.16 25 / 0.15);
    --focus: oklch(0.79 0.12 240);
    --shadow-1: none;
    --shadow-2: 0 16px 48px oklch(0 0 0 / 0.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 400 0.9375rem/1.5 var(--font); }
h1, h2, h3 { font-stretch: 118%; line-height: 1.2; margin: 0; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Header */
.bar { background: var(--header); color: var(--on-header); }
.bar-in { max-width: 1120px; margin: 0 auto; padding: 0 16px; min-height: 56px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; color: inherit; text-decoration: none; font-weight: 700; font-stretch: 125%; letter-spacing: 0.01em; }
.brand svg { width: 22px; height: 22px; }
.bar .spacer { flex: 1; }
.who { font-size: 0.8125rem; opacity: 0.8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.bar .btn-ghost { color: var(--on-header); border-color: oklch(1 0 0 / 0.25); }
.bar .btn-ghost:hover { background: oklch(1 0 0 / 0.08); }

main { max-width: 1120px; margin: 0 auto; padding: 32px 16px 64px; }
.page-head { margin-bottom: 24px; }
.page-head h1 { font-size: 1.375rem; }
.page-head p { color: var(--muted); margin: 4px 0 0; }

/* Buttons and fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--target); padding: 0 16px;
  border: 1px solid transparent; border-radius: var(--r-sm); background: var(--accent); color: var(--on-accent);
  font: 600 0.875rem var(--font); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-ghost { background: transparent; color: var(--fg); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: transparent; color: var(--bad); border-color: currentColor; }
.btn-danger:hover { background: var(--bad-wash); }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 0.8125rem; }
label { display: block; font-size: 0.8125rem; font-weight: 600; margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], select {
  width: 100%; min-height: var(--target); padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--fg); font: 400 0.9375rem var(--font); }
input:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px oklch(0.55 0.17 250 / 0.2); }
.field { margin-bottom: 16px; }
.hint { color: var(--muted); font-size: 0.8125rem; margin-top: 4px; }
.msg { border-radius: var(--r-sm); padding: 10px 12px; font-size: 0.875rem; margin-bottom: 16px; }
.msg.bad { background: var(--bad-wash); color: var(--bad); }
.msg.ok { background: var(--ok-wash); color: var(--ok); }

/* Library */
.apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.app { display: flex; flex-direction: column; gap: 12px; padding: 20px; min-height: 150px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); color: var(--fg); text-decoration: none;
  transition: border-color 0.15s, transform 0.15s; }
.app:hover { border-color: var(--accent); transform: translateY(-2px); }
.app-icon { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-wash);
  color: var(--accent); font-size: 26px; font-weight: 700; font-stretch: 125%; overflow: hidden; }
.app-icon img { width: 100%; height: 100%; object-fit: cover; }
.app h2 { font-size: 1.0625rem; }
.app p { margin: 0; color: var(--muted); font-size: 0.875rem; }
.empty { text-align: center; padding: 64px 16px; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--r-lg); }
.empty h2 { color: var(--fg); font-size: 1.0625rem; margin-bottom: 6px; }
.empty code { font-family: var(--mono); font-size: 0.8125rem; }

/* Sign-in */
.signin-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-2); }
.signin { width: 100%; max-width: 400px; padding: 28px; }
.signin .brand { color: var(--fg); margin-bottom: 20px; }
.signin h1 { font-size: 1.375rem; margin-bottom: 4px; }
.signin .lead { color: var(--muted); margin: 0 0 20px; font-size: 0.875rem; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: var(--r-md); margin-bottom: 20px; }
.tabs button { min-height: 36px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted); font: 600 0.875rem var(--font); cursor: pointer; }
.tabs button[aria-selected=true] { background: var(--surface); color: var(--fg); box-shadow: var(--shadow-1); }
.signin .btn { width: 100%; }
#code { font-family: var(--mono); letter-spacing: 0.08em; text-transform: uppercase; }

/* Admin */
.section { margin-bottom: 32px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.section-head h2 { font-size: 1.0625rem; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; text-align: right; }
td.actions .btn + .btn { margin-left: 6px; }
td .sub { color: var(--muted); font-size: 0.8125rem; }
.mono { font-family: var(--mono); font-size: 0.8125rem; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.pill.ok { background: var(--ok-wash); color: var(--ok); }
.pill.warn { background: var(--warn-wash); color: var(--warn); }
.pill.bad { background: var(--bad-wash); color: var(--bad); }
.pill.accent { background: var(--accent-wash); color: var(--accent); }

dialog { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); color: var(--fg); padding: 24px;
  width: min(460px, calc(100vw - 32px)); box-shadow: var(--shadow-2); }
dialog::backdrop { background: oklch(0.15 0.02 250 / 0.5); }
dialog h2 { font-size: 1.0625rem; margin-bottom: 16px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checks { display: grid; gap: 6px; max-height: 180px; overflow: auto; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); }
.checks label { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 0; font-size: 0.875rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.secret { font-family: var(--mono); font-size: 1.25rem; letter-spacing: 0.06em; padding: 14px; text-align: center; background: var(--surface-2);
  border-radius: var(--r-md); user-select: all; word-break: break-all; margin: 8px 0 12px; }

.center-page { min-height: 100vh; display: grid; place-items: center; text-align: center; padding: 24px 16px; }
.center-page h1 { font-size: 1.375rem; margin-bottom: 8px; }
.center-page p { color: var(--muted); margin: 0 0 20px; }

@media (max-width: 600px) {
  main { padding-top: 24px; }
  .row { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
}
.pw-card { padding: 20px; max-width: 460px; box-shadow: none; }
