/*
 * Layout and components — specs/ux.md, on the K5 tokens. Bars run to the
 * physical edge and spend their own safe-area inset; nothing outside .scroll
 * scrolls; verbs are pills (the K5 flourish); state is never colour alone.
 */

/* ── Shell ─────────────────────────────────────────────────────────────── */

.shell { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.navbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-t) + 10px) calc(var(--gutter) + 4px) 8px;
}
.title { font-size: var(--t-title); font-weight: 700; margin: 0; letter-spacing: -0.02em; }
.back { background: none; border: 0; color: var(--ac); font-size: var(--t-body); padding: 4px 0; font-family: var(--ios); }
.state { font-size: var(--t-meta); color: var(--tx3); }

.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.up-to-date { background: var(--ok); }
.dot.pending { background: var(--warn); }
.dot.offline { background: var(--tx4); }

.scroll {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 0 var(--gutter) 96px; min-height: 0;
}
.scroll.pad { padding-top: 6px; }

/* ── Tab bar — active is filled, not tinted ─────────────────────────────── */

.tabbar {
  display: flex; flex: none;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 4px calc(var(--safe-b) + 4px);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: 0; color: var(--tx3); position: relative;
  font-family: var(--ios); padding: 2px 0;
}
.tab.on { color: var(--ac); }
.tabicon { width: 24px; height: 24px; display: block; }
.tabicon svg { width: 100%; height: 100%; display: block; }
.tablabel { font-size: 10px; letter-spacing: 0.01em; }
.tab.on .tablabel { font-weight: 600; }
.badge {
  position: absolute; top: -2px; right: calc(50% - 22px);
  background: var(--bad); color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 9px; padding: 1px 5px; min-width: 16px;
}

/* ── Sections, rows, cards ──────────────────────────────────────────────── */

.sect {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--tx3); font-weight: 500;
  margin: 18px 2px 6px;
}
.row, .card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 11px 14px; margin-bottom: 8px;
}
article.row { cursor: pointer; }
article.row:active { background: var(--hover); }
.rt { font-size: var(--t-row); font-weight: 590; line-height: 1.35; }
.rm { font-size: var(--t-meta); color: var(--tx3); margin-top: 3px; line-height: 1.4; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
.quote {
  margin: 8px 0; padding: 6px 10px; border-left: 3px solid var(--line-hard);
  color: var(--tx2); font-size: var(--t-row);
}
.empty { color: var(--tx3); text-align: center; padding: 48px 24px; font-size: var(--t-row); }
.fold summary { color: var(--tx3); font-size: var(--t-row); padding: 8px 2px; }

.card.take { display: block; width: 100%; text-align: left; font-family: var(--ios); font-size: var(--t-row); color: var(--tx); }
.card.take.chosen { border-color: var(--ac); background: var(--ac-bg); }
.card.take p { margin: 4px 0 0; white-space: pre-wrap; }
.lens { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ac); }
.card.src a { color: var(--ac); word-break: break-all; display: block; margin-top: 4px; text-decoration: none; }

/* ── Fields and verbs ───────────────────────────────────────────────────── */

.field {
  width: 100%; background: var(--inset); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 11px; color: var(--tx);
  font-family: var(--ios); font-size: var(--t-row); line-height: 1.45;
}
textarea.field { min-height: 74px; resize: vertical; }
textarea.field.big { min-height: 160px; }
select.field { appearance: none; }
.fieldrow { margin: 10px 0; }
.fieldrow label { display: block; font-size: var(--t-label); color: var(--tx2); margin-bottom: 4px; font-weight: 600; }
.hint { font-size: var(--t-meta); color: var(--tx3); margin: 4px 0 10px; line-height: 1.45; }
.hint.bad { color: var(--bad); }

.verbs { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.verbs.main { margin-top: 18px; }
.verb, .pill {
  font-family: var(--ios); font-size: var(--t-row); font-weight: 600;
  border-radius: 999px; padding: 8px 16px;
  background: var(--inset); color: var(--tx); border: 1px solid var(--line-hard);
}
.verb.primary, .pill.primary { background: var(--ac); color: var(--on-ac); border-color: var(--ac); }
.pill.outline { background: none; color: var(--ac); border: 1.5px solid var(--ac); }
.verb.quiet { background: none; border-color: transparent; color: var(--tx3); }
.verb.danger { background: none; border-color: var(--bad); color: var(--bad); }
.verb.big { font-size: var(--t-body); padding: 12px 26px; }
.verb:active, .pill:active { opacity: 0.75; }

.fab {
  position: absolute; right: 20px; bottom: calc(var(--safe-b) + 74px);
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--ac); color: var(--on-ac); border: 0;
  font-size: 30px; line-height: 1; font-weight: 400;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
}
.shell { position: relative; }

/* ── Progress, rejections ───────────────────────────────────────────────── */

.progress {
  font-family: var(--mono); font-size: var(--t-meta); color: var(--tx2);
  margin: 6px 2px; white-space: pre-wrap;
}
.progress.bad { color: var(--bad); }
.progresslist { margin: 4px 0; }
.reject {
  background: var(--warn-bg); border: 1px solid var(--warn);
  border-radius: var(--radius); padding: 10px 14px; margin: 0 var(--gutter) 8px;
  font-size: var(--t-meta); color: var(--tx2);
}
.reject strong { color: var(--warn); }

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

.group {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 10px; padding: 0 14px;
}
.group summary {
  font-size: var(--t-body); font-weight: 600; padding: 13px 0;
  cursor: pointer; list-style: none; display: flex; justify-content: space-between;
}
.group summary::after { content: "›"; color: var(--tx4); transform: rotate(90deg); }
.group[open] summary::after { transform: rotate(-90deg); }
.group .body { padding: 2px 0 14px; }
.group h3 { font-size: var(--t-row); margin: 18px 0 6px; }
.line { margin: 6px 0; font-size: var(--t-row); }

.segments { display: flex; background: var(--inset); border-radius: 9px; padding: 3px; }
.segment {
  flex: 1; border: 0; background: none; border-radius: 7px; padding: 7px 0;
  font-family: var(--ios); font-size: var(--t-row); color: var(--tx2);
}
.segment.on { background: var(--card); color: var(--tx); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

.relrail { display: flex; gap: 10px; overflow-x: auto; padding: 8px 0 4px; }
.relcard {
  flex: none; width: 230px; background: var(--inset);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px;
}
.row.idea p { margin: 0 0 4px; font-size: var(--t-row); }

/* ── The gate ───────────────────────────────────────────────────────────── */

.gate {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 14px; padding: 32px; text-align: center;
}
.gatetitle { font-size: var(--t-title); margin: 0; letter-spacing: -0.02em; }
.gatelede { color: var(--tx2); max-width: 34ch; margin: 0 0 10px; }
.gatefoot { position: absolute; bottom: calc(var(--safe-b) + 14px); color: var(--tx4); font-size: var(--t-meta); }

/* ── Mac ────────────────────────────────────────────────────────────────── */

[data-runtime="mac"] {
  --scale: 1.2;
  --safe-t: 0px; --safe-b: 0px; --safe-l: 0px; --safe-r: 0px;
}
[data-runtime="mac"] #app { height: 100%; }
