/* The Command Center: phone first, light and dark following the phone. */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --text: #16181d;
  --muted: #5d6573;
  --line: #dde1e7;
  --accent: #2f5bd3;
  --accent-text: #ffffff;
  --accent-soft: #e5ecfc;
  --advice: #1f7a4d;
  --advice-soft: #e2f4ea;
  --danger: #c23b33;
  --danger-soft: #fbe7e5;
  --warn: #9a6200;
  --warn-soft: #fff3d6;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #181b21;
    --surface-2: #22262e;
    --text: #e8eaee;
    --muted: #9aa2af;
    --line: #2c313a;
    --accent: #7c9cf5;
    --accent-text: #0f1115;
    --accent-soft: #1f2a45;
    --advice: #5cc98e;
    --advice-soft: #16301f;
    --danger: #f07b72;
    --danger-soft: #3a1b19;
    --warn: #f0b64a;
    --warn-soft: #34290f;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-wrap: anywhere;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0; }
.hidden { display: none !important; }
/* A file input the label opens: invisible but not display:none (older iOS ignores those). */
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }
label.btn { position: relative; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.error { color: var(--danger); }
.warn-text { color: var(--warn); }

/* ---------- shell ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top h1 { font-size: 1.15rem; flex: 1; }
.sync { font-size: 0.8rem; text-align: right; }
.icon-btn {
  width: 40px; height: 40px;
  border: 0; border-radius: 50%;
  background: var(--surface-2); color: var(--text);
  display: grid; place-items: center;
}
.icon-btn svg { width: 22px; height: 22px; }

.view {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 16px calc(env(safe-area-inset-bottom) + 96px);
}

.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  position: relative;
  border: 0; background: none; color: var(--muted);
  padding: 8px 2px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 0.7rem;
}
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--accent); font-weight: 600; }
.badge {
  position: absolute; top: 3px; left: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px;
  background: var(--danger); color: #fff;
  font-size: 0.7rem; line-height: 18px; text-align: center;
}
svg path { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.toast {
  position: fixed;
  left: 16px; right: 16px;
  bottom: calc(env(safe-area-inset-bottom) + 76px);
  z-index: 10;
  max-width: 560px; margin: 0 auto;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--text); color: var(--bg);
  opacity: 0; transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--danger); color: #fff; }

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin: 0 0 12px;
}
.card h2 { font-size: 1.05rem; margin-bottom: 8px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.card-id { font-weight: 700; text-decoration: none; }
.asker { color: var(--muted); margin-top: 2px; }
.context { white-space: pre-wrap; margin: 10px 0 4px; }
.waiting {
  margin: 10px 0 0; padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 0.9rem;
}
.tag {
  display: inline-block;
  margin-left: 6px; padding: 1px 7px;
  border-radius: 8px;
  background: var(--surface-2); color: var(--muted);
  font-size: 0.72rem;
}
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.intro { margin: 4px 0 12px; }

.group { margin-bottom: 18px; }
.group-title { font-size: 1rem; margin: 8px 2px; display: flex; align-items: center; gap: 8px; }
.project-title { font-size: 0.9rem; color: var(--muted); margin: 10px 2px 6px; display: flex; align-items: center; gap: 8px; font-weight: 600; }
.count {
  min-width: 22px; padding: 0 7px;
  border-radius: 11px;
  background: var(--surface-2); color: var(--muted);
  font-size: 0.75rem; line-height: 22px; text-align: center;
}

/* ---------- questions ---------- */

.question { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 12px; }
.question h3 { font-size: 1.02rem; margin: 4px 0 10px; }
.chip {
  display: inline-block;
  padding: 1px 8px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 0.75rem; font-weight: 600;
}
.options { display: grid; gap: 8px; }
.option {
  text-align: left;
  width: 100%;
  padding: 11px 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  display: grid; gap: 3px;
}
.option.advised { border-color: color-mix(in srgb, var(--advice) 55%, var(--line)); }
.option.picked { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.option-label { font-weight: 650; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.option-desc { color: var(--muted); font-size: 0.9rem; }
.advice {
  padding: 0 7px; border-radius: 8px;
  background: var(--advice-soft); color: var(--advice);
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .02em;
}
.why { color: var(--muted); margin: 8px 0 0; }

.input {
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.input:focus { outline: none; border-color: var(--accent); }
textarea.input { resize: vertical; min-height: 48px; }
select.input { appearance: auto; }

.gallery { display: flex; gap: 8px; overflow-x: auto; margin: 10px 0 2px; }
.gallery img { height: 120px; max-width: 220px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); display: block; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.thumb { position: relative; width: 72px; height: 72px; border-radius: 10px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; font-size: 0.7rem; color: var(--muted); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-x {
  position: absolute; top: 3px; right: 3px;
  width: 24px; height: 24px; border: 0; border-radius: 50%;
  background: rgb(0 0 0 / 60%); color: #fff; font-size: 16px; line-height: 24px; padding: 0;
}

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

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; justify-content: flex-end; }
.actions.tight { margin-top: 0; flex-wrap: nowrap; }
.btn {
  min-height: 44px;
  padding: 0 16px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.big { width: 100%; min-height: 52px; font-size: 1.05rem; margin-top: 12px; }
.btn:disabled { opacity: .45; cursor: default; }
.small-btn { min-height: 38px; padding: 0 12px; font-size: 0.88rem; }
.link { border: 0; background: none; color: var(--accent); padding: 4px 0; font: inherit; cursor: pointer; }

/* ---------- folds ---------- */

.fold { margin: 16px 0; }
.fold summary { cursor: pointer; color: var(--muted); font-weight: 600; padding: 8px 2px; }
.answered { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 8px 0; }
.answered .q { margin: 4px 0; }
.answered .a { margin: 4px 0; font-weight: 650; white-space: pre-wrap; }
.todo-text { white-space: pre-wrap; margin: 8px 0; font-size: 1.02rem; }

/* ---------- who does what ---------- */

.pc.stale { opacity: .7; }
.usage { display: grid; grid-template-columns: 56px 1fr 44px; align-items: center; gap: 8px; margin-top: 10px; }
.usage-reset { grid-column: 2 / 4; margin-top: -4px; }
.usage-label { font-size: 0.85rem; color: var(--muted); }
.usage-num { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.bar { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.fill { height: 100%; border-radius: 5px; }
.fill.low { background: var(--advice); }
.fill.mid { background: var(--warn); }
.fill.high { background: var(--danger); }
.warn { background: var(--warn-soft); color: var(--warn); padding: 8px 10px; border-radius: 10px; margin: 10px 0 0; font-size: 0.9rem; }
.roster { list-style: none; margin: 10px 0 0; padding: 0; }
.roster li { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.dot { flex: none; width: 10px; height: 10px; border-radius: 50%; margin-top: 7px; }
.dot.on { background: var(--advice); }
.dot.off { background: var(--line); }

/* ---------- controls ---------- */

.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.row:first-of-type { border-top: 0; }
.field { display: block; margin-top: 10px; font-size: 0.9rem; color: var(--muted); }
.radios, .checks { display: grid; gap: 6px; margin-top: 10px; }
.check { display: flex; align-items: center; gap: 8px; min-height: 36px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.commands { list-style: none; margin: 0; padding: 0; }
.commands li { padding: 8px 0; border-top: 1px solid var(--line); }

/* ---------- login ---------- */

.login { max-width: 420px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 48px) 16px 48px; }
.login h1 { font-size: 1.6rem; margin-bottom: 6px; }
.login h2 { font-size: 1.05rem; margin: 28px 0 4px; }
.first-time { border-top: 1px solid var(--line); margin-top: 24px; }
.code { text-transform: uppercase; letter-spacing: .12em; font-family: ui-monospace, "SF Mono", Menlo, monospace; text-align: center; font-size: 1.1rem; }
.login .error { margin-top: 14px; }
