/* Brand Guard. Light and dark themes through custom properties.
   Spacing scale: 4 / 8 / 12 / 16 / 24 / 32. */

:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --inset: #f4f5f8;
  --text: #14161c;
  --text-2: #3d424d;
  --muted: #5d6472;
  --border: #e3e6ec;
  --border-strong: #ccd1da;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-on: #ffffff;
  --accent-fg: #4338ca;
  --accent-soft: #eef0ff;
  --accent-border: #c9ccf7;
  --ok-bg: #dcfce7;
  --ok-text: #166534;
  --warn-bg: #fef3c7;
  --warn-text: #8a4a05;
  --bad-bg: #fee2e2;
  --bad-text: #9b1c1c;
  --info-bg: #eef0ff;
  --info-text: #3730a3;
  --mark-bg: rgba(250, 204, 21, 0.45);
  --focus: #4f46e5;
  --bar-bg: #ffffff;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 4px 12px rgba(16, 24, 40, 0.04);
  --radius: 10px;
  --radius-sm: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --ease: 140ms ease;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d12;
    --surface: #11141b;
    --surface-2: #171b24;
    --inset: #0d1016;
    --text: #e9ebf1;
    --text-2: #c4c9d4;
    --muted: #9aa2b2;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    --accent: #5457d6;
    --accent-hover: #6366e8;
    --accent-on: #ffffff;
    --accent-fg: #a5a9ff;
    --accent-soft: rgba(124, 130, 255, 0.12);
    --accent-border: rgba(124, 130, 255, 0.35);
    --ok-bg: rgba(52, 211, 153, 0.13);
    --ok-text: #6ee7b7;
    --warn-bg: rgba(251, 191, 36, 0.13);
    --warn-text: #fcd34d;
    --bad-bg: rgba(248, 113, 113, 0.14);
    --bad-text: #fca5a5;
    --info-bg: rgba(124, 130, 255, 0.13);
    --info-text: #b9bcff;
    --mark-bg: rgba(250, 204, 21, 0.28);
    --focus: #8b8fff;
    --bar-bg: #0e1118;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.28);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { line-height: 1.3; margin: 0; letter-spacing: -0.015em; color: var(--text); }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 620; }
h3 { font-size: 15px; font-weight: 600; }
h4 { font-size: 13px; font-weight: 600; letter-spacing: 0; }
p { margin: 0; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.boot { padding: 32px 16px; color: var(--muted); text-align: center; }

/* ---------- buttons ---------- */
button { font: inherit; cursor: pointer; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-on);
  font-size: 14px;
  font-weight: 560;
  line-height: 1.2;
  transition: background-color var(--ease), border-color var(--ease), color var(--ease), box-shadow var(--ease);
}
.btn:hover { background: var(--accent-hover); }
.btn.secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn.secondary:hover { background: var(--surface-2); }
.btn.ghost {
  background: transparent;
  color: var(--muted);
}
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger {
  background: transparent;
  color: var(--bad-text);
  border-color: var(--border-strong);
}
.btn.danger:hover { background: var(--bad-bg); }
.btn.small { min-height: 30px; padding: 4px 10px; font-size: 13px; }
button:disabled, .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn:disabled:hover { background: var(--accent); }
.btn.secondary:disabled:hover, .btn.ghost:disabled:hover, .btn.danger:disabled:hover { background: transparent; }

.link-btn {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent-fg);
  text-decoration: underline;
  font: inherit;
  font-size: 13px;
}
a { color: var(--accent-fg); text-underline-offset: 2px; }

/* ---------- fields ---------- */
label { display: block; font-size: 13px; font-weight: 560; color: var(--text-2); margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.field .help, .help { font-weight: 400; color: var(--muted); font-size: 13px; margin-top: 6px; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--inset);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
  transition: border-color var(--ease), box-shadow var(--ease);
}
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--focus);
}
textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
textarea.big { min-height: 208px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.85; }
input[type="radio"] { accent-color: var(--accent); }

/* ---------- messages ---------- */
.msg { margin-top: 8px; font-size: 13.5px; }
.msg:empty { display: none; }
.msg.error, .msg.ok, .msg.info, .msg.warn {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}
.msg.error { background: var(--bad-bg); color: var(--bad-text); }
.msg.ok { background: var(--ok-bg); color: var(--ok-text); }
.msg.info { background: var(--info-bg); color: var(--info-text); }
.msg.warn { background: var(--warn-bg); color: var(--warn-text); }

.error-box, .warn-box {
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13.5px;
}
.error-box { background: var(--bad-bg); color: var(--bad-text); }
.warn-box { background: var(--warn-bg); color: var(--warn-text); }
.warn-box ul { margin: 4px 0 0; padding-left: 20px; }
.muted { color: var(--muted); }

/* ---------- logo ---------- */
.logo { display: block; flex: none; }

/* ---------- auth ---------- */
.auth-page { min-height: 100vh; display: flex; flex-direction: column; }
.auth-page .auth-wrap { flex: 1; min-height: 0; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 24px 24px;
  box-shadow: var(--shadow);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.auth-card .tagline { color: var(--muted); margin-bottom: 24px; }
.auth-card .warn-box { margin-bottom: 16px; }
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: var(--inset);
  border: 1px solid var(--border);
  padding: 3px;
  border-radius: var(--radius-sm);
  margin-bottom: 24px;
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 560;
  transition: background-color var(--ease), color var(--ease), box-shadow var(--ease);
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border-strong);
}
fieldset { border: 0; padding: 0; margin: 0 0 16px; }
legend { font-size: 13px; font-weight: 560; color: var(--text-2); padding: 0; margin-bottom: 6px; }
.radio { display: flex; gap: 8px; align-items: center; font-size: 14px; font-weight: 400; color: var(--text); margin: 0 0 4px; }
.radio input { width: auto; margin: 0; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; font-weight: 400; color: var(--text); margin: 0 0 16px; }
.check input { width: auto; margin: 0; accent-color: var(--accent); }
.auth-card .btn { width: 100%; min-height: 40px; }
.auth-title { margin: 16px 0 8px; }
.auth-title:focus, .auth-card [tabindex="-1"]:focus { outline: none; }
.auth-text { color: var(--text-2); margin-bottom: 16px; overflow-wrap: anywhere; }
.auth-text strong { color: var(--text); font-weight: 560; }
.auth-links { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px 16px; }
.forgot-row { margin: -8px 0 16px; }
.resend .msg { margin-top: 8px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bar-bg);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  min-height: 56px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand-name { font-size: 15px; font-weight: 650; letter-spacing: -0.015em; white-space: nowrap; }
a.nav-about {
  display: inline-flex;
  align-items: center;
  flex: none;
  margin-right: auto;
  margin-left: 4px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--accent-fg);
  font-size: 14px;
  font-weight: 560;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}
a.nav-about:hover { background: var(--accent-soft); text-decoration: none; }
.nav-about-short { display: none; }
.who { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.who strong { color: var(--text); font-weight: 560; }

.counter { display: flex; align-items: stretch; gap: 8px; flex: none; }
.stat {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  line-height: 1.2;
  white-space: nowrap;
}
.stat-label { font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: 0.01em; }
.stat-value { font-size: 14px; font-weight: 620; color: var(--text); font-variant-numeric: tabular-nums; }
.stat.low { background: var(--warn-bg); border-color: transparent; }
.stat.low .stat-label, .stat.low .stat-value { color: var(--warn-text); }

.notice-wrap { padding: 0 16px; }
.notice {
  max-width: 1088px;
  margin: 16px auto 0;
  padding: 8px 12px;
  background: var(--warn-bg);
  color: var(--warn-text);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}

/* ---------- tabs ---------- */
.tabs-bar { border-bottom: 1px solid var(--border); margin-top: 8px; }
.tabs {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 12px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 560;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color var(--ease), border-color var(--ease);
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--accent-fg); border-bottom-color: var(--accent); }
.tab:focus-visible { outline-offset: -2px; border-radius: 6px; }

main { max-width: 1120px; margin: 0 auto; padding: 24px 16px 48px; }
main:focus { outline: none; }
.stack > * + * { margin-top: 16px; }
/* Keep scrolled-to results clear of the sticky top bar (56px + 16px). */
.stack > div:not([class]), .results-grid { scroll-margin-top: 72px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.card > h2 + * { margin-top: 8px; }
.card .lead { color: var(--muted); font-size: 13px; }
.row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }

/* ---------- check ---------- */
.hint {
  background: var(--info-bg);
  color: var(--info-text);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13.5px;
}
.hint a { color: inherit; font-weight: 560; }
details.prompt-box { margin: 4px 0 16px; }
details.prompt-box summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 4px 0; }
details.prompt-box summary:hover { color: var(--text); }
details.prompt-box textarea { margin-top: 8px; }
.prompt-label { font-weight: 400; margin-top: 8px; }
.kbd-hint { color: var(--muted); font-size: 13px; }

.timer { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; margin-bottom: 12px; }
.results-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
@media (max-width: 860px) {
  .results-grid { grid-template-columns: minmax(0, 1fr); }
}

.verdict { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 12px 0; }
.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12.5px;
  line-height: 1.5;
}
.pill.on_brand { background: var(--ok-bg); color: var(--ok-text); }
.pill.some_drift { background: var(--warn-bg); color: var(--warn-text); }
.pill.off_brand { background: var(--bad-bg); color: var(--bad-text); }

.flag-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 12px; }
.flag {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface-2);
}
.flag-head { margin-bottom: 8px; }
.flag blockquote {
  margin: 0 0 8px;
  padding: 6px 12px;
  border-left: 2px solid var(--accent);
  background: var(--inset);
  border-radius: 0 6px 6px 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
}
.flag > p { font-size: 14px; }
.flag-row { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 8px; margin-top: 6px; font-size: 13.5px; }
.flag-row .lbl { color: var(--muted); font-size: 12px; font-weight: 560; padding-top: 1px; }
.tag {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.5;
  padding: 0 8px;
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border-strong);
}
.tag.rule { background: var(--warn-bg); color: var(--warn-text); border-color: transparent; }
.tag.voice { background: var(--accent-soft); color: var(--accent-fg); border-color: transparent; }

.orig { margin-top: 16px; }
.orig h4 { margin-bottom: 6px; color: var(--muted); }
.orig-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  max-height: 384px;
  overflow: auto;
  font-size: 14px;
}
mark { background: var(--mark-bg); color: inherit; border-radius: 3px; padding: 0 2px; }

.rewrite-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin: 12px 0;
  min-height: 64px;
}
.rewrite-note { color: var(--muted); font-size: 13px; margin-top: 12px; }
.free-note {
  display: inline-block;
  margin-top: 12px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--info-bg);
  color: var(--info-text);
  font-size: 12.5px;
  font-weight: 560;
}
.accept-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 12px; }
.accept-row .msg { margin-top: 0; }
.rewrite-warn { margin-top: 12px; }
.save-prompt { margin-top: 16px; }
.save-prompt .row { margin-top: 8px; align-items: flex-end; }
.save-prompt .row .field { flex: 1 1 224px; margin: 0; }

/* progress and skeletons */
.skel-stack { display: grid; gap: 8px; margin-top: 12px; }
.skel {
  display: block;
  height: 10px;
  border-radius: 5px;
  background: var(--border-strong);
  opacity: 0.55;
  animation: pulse 1.6s ease-in-out infinite;
}
.skel:nth-child(1) { width: 92%; }
.skel:nth-child(2) { width: 78%; }
.skel:nth-child(3) { width: 85%; }
.skel:nth-child(4) { width: 52%; }
@keyframes pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.65; }
}

/* ---------- paywall ---------- */
.paywall {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--surface-2);
}
.locked-lines { display: grid; gap: 8px; margin-bottom: 16px; filter: blur(1.5px); }
.locked-lines .skel { animation: none; opacity: 0.4; height: 9px; }
.paywall-title { font-size: 16px; font-weight: 620; }
.paywall-lead { color: var(--muted); font-size: 13.5px; margin: 4px 0 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); gap: 12px; }
.tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}
.tile.featured { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tile-head { min-height: 22px; }
.tile-tag {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-fg);
}
.tile-price { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tile-caption { color: var(--muted); font-size: 13px; flex: 1; margin-bottom: 12px; }
.tile .btn { width: 100%; }
.paywall-foot { margin-top: 12px; color: var(--muted); font-size: 13px; }
.paywall .msg { margin-top: 12px; }

/* ---------- setup and library ---------- */
.progress { font-size: 13px; font-weight: 560; color: var(--muted); margin: 4px 0 12px; font-variant-numeric: tabular-nums; }
.items { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 12px; }
.item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface-2);
}
.item .prewrap { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.item .meta { color: var(--muted); font-size: 12.5px; }
.item .actions { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-top: 12px; }
.item .reason { margin-top: 8px; font-size: 14px; }
.item h3 { margin-bottom: 4px; }
.item .prompt-body { margin-top: 8px; }
.item .prompt-body .prewrap { font-family: var(--mono); font-size: 13px; }
.empty {
  color: var(--muted);
  margin-top: 16px;
  padding: 24px 16px;
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  font-size: 14px;
}
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 600px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- team ---------- */
.invite {
  font-family: var(--mono);
  font-size: 28px;
  letter-spacing: 0.14em;
  background: var(--inset);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  overflow-wrap: anywhere;
  user-select: all;
}
.card .invite-help { margin-top: 12px; color: var(--text-2); }
.members { list-style: none; padding: 0; margin: 12px 0 0; }
.members li { padding: 8px 0; border-top: 1px solid var(--border); }
.members li:first-child { border-top: 0; }
.members .email { color: var(--muted); font-size: 13.5px; }

.plan-list { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.plan-price { font-variant-numeric: tabular-nums; }
.plan-foot { margin-top: 12px; color: var(--muted); font-size: 13px; }
.plan-stats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  .topbar-inner .who.user { display: none; }
}
@media (max-width: 720px) {
  .topbar-inner .who.team { display: none; }
}
@media (max-width: 640px) {
  .topbar .nav-about-long { display: none; }
  .topbar .nav-about-short { display: inline; }
}
@media (max-width: 520px) {
  .topbar-inner { gap: 8px; padding: 8px 12px; }
  .brand-name { display: none; }
  .counter { gap: 4px; }
  .stat { padding: 3px 8px; }
  .stat-label { font-size: 10.5px; }
  main { padding: 16px 12px 40px; }
  .card { padding: 16px; }
  .invite { font-size: 22px; }
  .auth-card { padding: 24px 16px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
