/* Workshop Toolkit: core look. Tools add their own CSS file; they reuse these tokens.
   Layout: one column, phone first, max 760px, big touch targets for gloved hands. */
:root {
  --bg:        #eef1f4;
  --surface:   #ffffff;
  --surface-2: #f5f7f9;
  --line:      #d5dbe2;
  --fg:        #17202b;
  --fg-2:      #4d5a69;
  --fg-3:      #6f7c8b;
  --accent:    #1d5fc4;
  --accent-fg: #ffffff;
  --accent-soft: #e3ecfa;
  --band:      #1b2633;
  --band-fg:   #e8eef5;
  --band-fg-2: #9fb0c2;
  --ok:        #1d7a45;  --ok-soft:   #e2f3e8;
  --warn:      #a45d00;  --warn-soft: #fdf0dc;
  --bad:       #b42318;  --bad-soft:  #fbe5e3;
  --info:      #4d5a69;  --info-soft: #e8ecf1;
  --focus:     #1d5fc4;
  --shadow:    0 1px 2px rgba(23, 32, 43, .08), 0 2px 8px rgba(23, 32, 43, .05);

  --font:      system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-num:  ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Consolas, monospace;

  --r:   10px;
  --r-s: 6px;
  --tap: 48px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f151c; --surface: #18212b; --surface-2: #1e2934; --line: #2c3a48;
    --fg: #e6ecf2; --fg-2: #aab7c5; --fg-3: #8495a7;
    --accent: #6ea3f5; --accent-fg: #0b1420; --accent-soft: #1b2c45;
    --band: #0a0f15; --band-fg: #e6ecf2; --band-fg-2: #8b9cb0;
    --ok: #4fc283; --ok-soft: #12301f; --warn: #f0a53a; --warn-soft: #3a2a10;
    --bad: #ff7a6e; --bad-soft: #3d1714; --info: #aab7c5; --info-soft: #233040;
    --focus: #8bb6f8; --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f151c; --surface: #18212b; --surface-2: #1e2934; --line: #2c3a48;
  --fg: #e6ecf2; --fg-2: #aab7c5; --fg-3: #8495a7;
  --accent: #6ea3f5; --accent-fg: #0b1420; --accent-soft: #1b2c45;
  --band: #0a0f15; --band-fg: #e6ecf2; --band-fg-2: #8b9cb0;
  --ok: #4fc283; --ok-soft: #12301f; --warn: #f0a53a; --warn-soft: #3a2a10;
  --bad: #ff7a6e; --bad-soft: #3d1714; --info: #aab7c5; --info-soft: #233040;
  --focus: #8bb6f8; --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.45 var(--font);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  min-height: 100vh;
}
body::before {
  content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px);
  background: var(--band); z-index: 30;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* ---- App bar ---- */
.appbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: var(--band); color: var(--band-fg);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.appbar-in { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 10px; min-height: 56px; }
.appbar a, .appbar button { color: var(--band-fg); }
.appbar .back {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px; margin-left: -10px; border-radius: var(--r-s);
  text-decoration: none; font-size: 22px; line-height: 1;
}
.appbar .titles { flex: 1; min-width: 0; }
.appbar .kicker { display: block; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--band-fg-2); font-weight: 600; }
.appbar h1 { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appbar .bar-actions { display: flex; gap: 6px; }
.appbar .iconbtn { background: transparent; border: 0; min-width: 44px; min-height: 44px; border-radius: var(--r-s); cursor: pointer; font-size: 15px; font-weight: 600; }
.offline-strip {
  background: var(--warn-soft); color: var(--warn); font-size: 14px; font-weight: 600;
  padding: 6px max(16px, env(safe-area-inset-right, 0px)) 6px max(16px, env(safe-area-inset-left, 0px));
  text-align: center;
}

/* ---- Page ---- */
.page {
  max-width: 760px; margin: 0 auto;
  padding-block: 16px 40px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: 16px;
}
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--fg-2); }
.small { font-size: 14px; }
.label {
  font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--fg-3);
}
h2 { margin: 0; font-size: 20px; line-height: 1.25; text-wrap: balance; }
h3 { margin: 0; font-size: 16px; }
p { margin: 0; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 12px; min-width: 0;
}
.card.flat { box-shadow: none; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px; border-radius: var(--r-s);
  border: 1px solid var(--line); background: var(--surface); color: var(--fg);
  font-weight: 650; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--fg-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); padding: 0 10px; }
.btn.block { width: 100%; }
.btn.small { min-height: 38px; padding: 0 12px; font-size: 14px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---- Forms ---- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 14px; font-weight: 650; color: var(--fg-2); }
.field .hint { font-size: 13px; color: var(--fg-3); }
.input, select.input, textarea.input {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--r-s);
  background: var(--surface-2); color: var(--fg);
}
textarea.input { min-height: 88px; resize: vertical; }
.input:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); }
.input.bad { border-color: var(--bad); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 420px) { .grid2.wrap { grid-template-columns: minmax(0, 1fr); } }
.form-error {
  background: var(--bad-soft); color: var(--bad); border-radius: var(--r-s);
  padding: 10px 12px; font-weight: 600; font-size: 15px;
}
.notice {
  background: var(--info-soft); color: var(--fg); border-radius: var(--r-s); padding: 10px 12px; font-size: 15px;
}
.notice.warn { background: var(--warn-soft); }

/* ---- Pills ---- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 700;
  background: var(--info-soft); color: var(--info);
}
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.ok   { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad  { background: var(--bad-soft); color: var(--bad); }

/* ---- Lists ---- */
.list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); overflow: hidden; }
.list > .item {
  display: flex; gap: 12px; align-items: center; padding: 14px 16px;
  border-top: 1px solid var(--line); color: var(--fg); text-decoration: none; min-width: 0;
}
.list > .item:first-child { border-top: 0; }
.list > button.item { background: none; border: 0; border-top: 1px solid var(--line); width: 100%; text-align: left; cursor: pointer; font: inherit; color: inherit; }
.list > button.item:first-child { border-top: 0; }
.list > a.item:hover, .list > button.item:hover { background: var(--surface-2); }
.item .main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item .title { font-weight: 700; overflow-wrap: anywhere; }
.item .sub { font-size: 14px; color: var(--fg-2); overflow-wrap: anywhere; }
.item .side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; flex-shrink: 0; max-width: 45%; }
.chev { color: var(--fg-3); font-size: 20px; }
.empty { padding: 28px 16px; text-align: center; color: var(--fg-2); }

/* ---- Home: tool cards ---- */
.tools { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.tool-card {
  display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 16px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line);
  color: var(--fg); text-decoration: none; box-shadow: var(--shadow);
}
.tool-card:hover { border-color: var(--fg-3); }
.tool-icon {
  width: 52px; height: 52px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.tool-icon svg { width: 30px; height: 30px; }
.tool-card .alerts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.tool-card.broken .tool-icon { background: var(--bad-soft); color: var(--bad); }

/* ---- Toast & panel ---- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 50;
  background: var(--band); color: var(--band-fg); padding: 12px 18px; border-radius: var(--r);
  font-weight: 600; max-width: min(92vw, 520px); box-shadow: 0 6px 24px rgba(0,0,0,.25);
}
.overlay {
  position: fixed; inset: 0; z-index: 40; background: rgba(10, 15, 21, .55);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 16px max(16px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.overlay .panel { width: 100%; max-width: 520px; max-height: 85vh; overflow: auto; }
@media (min-width: 640px) { .overlay { align-items: center; } }

.skeleton { color: var(--fg-3); padding: 16px 0; }
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: rise .18s ease-out; }
  @keyframes rise { from { transform: translate(-50%, 8px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
}
