/* NormForms — editorial style: cream canvas, warm hairlines, near-black,
   ~8px-radius buttons, white cards with a whisper of shadow, crosshair-marked rules. */
:root {
  color-scheme: light;
  --bg: #faf9f5; --card: #ffffff; --field: #ffffff; --pre-bg: #fdfdfd; --text: #171716; --muted: #8a8880;
  --border: #e0ddd3; --btn: #171716; --btn-text: #ffffff;
  --ok: #1a9e57; --warn: #c97b16; --bad: #cf4437; --tag: #5560d4;
  --card-shadow: 0 1px 2px rgba(23, 23, 22, 0.04), 0 2px 8px rgba(23, 23, 22, 0.03);
}
/* Dark palette — warm near-blacks with a coral accent. Applied two ways:
   explicit user choice (html[data-theme], set by the theme controller) or
   OS preference when no choice is stored. Keep both blocks identical. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #262624; --card: #30302e; --field: #2c2c2a; --pre-bg: #2b2a27; --text: #f0eee6; --muted: #b0aba0;
  --border: #3e3d39; --btn: #f0eee6; --btn-text: #262624;
  --ok: #4cc98a; --warn: #e2a04a; --bad: #e2685c; --tag: #d97757;
  --card-shadow: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #262624; --card: #30302e; --field: #2c2c2a; --pre-bg: #2b2a27; --text: #f0eee6; --muted: #b0aba0;
    --border: #3e3d39; --btn: #f0eee6; --btn-text: #262624;
    --ok: #4cc98a; --warn: #e2a04a; --bad: #e2685c; --tag: #d97757;
    --card-shadow: none;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.55; font-size: 0.9375rem;
}

/* Chrome: header on the canvas, hairline rule with crosshairs beneath */
.topbar {
  display: flex; align-items: center; gap: 1rem;
  max-width: 76rem; margin: 0 auto; padding: 1rem 2.75rem;
}
.wordmark { display: flex; align-items: center; text-decoration: none; }
.logo { height: 1.5rem; width: auto; display: block; }
:root[data-theme="dark"] .logo { filter: invert(1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo { filter: invert(1); } }
.topbar nav { display: flex; align-items: center; gap: 1.25rem; }
.topbar nav.primary { margin-left: 1.75rem; }
.topbar nav.account { margin-left: auto; }
.topbar nav a { color: var(--text); text-decoration: none; font-weight: 500; font-size: 0.9rem; }
.topbar nav a:hover { text-decoration: underline; }
.topbar nav .btn { margin-top: 0; text-decoration: none; }
.topbar nav .btn:hover { text-decoration: none; }
.topbar nav a.btn { color: var(--btn-text); } /* beat `.topbar nav a` color */
.topbar nav a.btn.subtle { color: var(--text); }
/* button_to wraps its button in a form — flatten it so the button is a flex
   item, and kill the global button top margin inside the nav. */
.topbar nav form { display: contents; }
.topbar nav button, .topbar nav input[type="submit"] { margin-top: 0; }

/* Theme switcher: bare icon button; shows a moon in light mode, a sun in
   dark. The pairs of selectors mirror the two ways dark mode activates. */
.theme-toggle {
  display: inline-flex; background: none; border: none; border-radius: 0.5rem;
  padding: 0.3rem; margin: 0; color: var(--text); cursor: pointer;
}
.theme-toggle:hover { opacity: 1; background: color-mix(in srgb, var(--text) 8%, transparent); }
.theme-toggle svg { display: block; }
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .moon { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .sun { display: block; }
}

.rule { position: relative; height: 1px; background: var(--border); }
.rule .cross {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  font-size: 1.05rem; line-height: 1; font-weight: 400; color: var(--text);
  background: var(--bg); padding: 0 0.2rem; user-select: none;
}
.rule .cross.l { left: max(1rem, calc(50% - 37rem)); }
.rule .cross.r { left: min(calc(100% - 1rem), calc(50% + 37rem)); }

.container { max-width: 72rem; margin: 0 auto; padding: 2rem 1.5rem 5rem; }

/* Cards & text — hairline borders, softly shadowed on the canvas */
.card {
  background: transparent; border: 1px solid var(--border); border-radius: 0;
  padding: 1.375rem; margin-bottom: 1.25rem; margin-top: 1.25rem;
  box-shadow: var(--card-shadow);
}
/* Framed variant: icon + title header, hairline divider, padded body */
.card:has(> .card-head) { padding: 0; }
.card-head {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.95rem 1.375rem; border-bottom: 1px solid var(--border);
  background: var(--card);
}
.card-head h2 { margin: 0; font-size: 0.95rem; }
.card-head svg { color: var(--text); flex: 0 0 auto; }
.card-head .btn, .card-head button { margin: 0 0 0 auto; padding: 0.4rem 0.9rem; font-size: 0.8125rem; }
.card-head > .muted { margin-left: auto; font-size: 0.8125rem; }
.card-head > .muted + .btn { margin-left: 0; }
.pagination { display: flex; gap: 1rem; justify-content: center; align-items: baseline; margin-top: 1.25rem; font-size: 0.875rem; }
.card-body { padding: 1.25rem 1.375rem 1.375rem; background: var(--card); }
.card-body > .muted:first-child { margin-top: 0; }
h1 { font-size: 1.75rem; letter-spacing: -0.03em; margin: 0 0 1.25rem; font-weight: 800; }
h2 { font-size: 1.0625rem; letter-spacing: -0.01em; margin: 0 0 0.625rem; font-weight: 700; }
.muted { color: var(--muted); font-size: 0.8125rem; }
a { color: var(--text); text-underline-offset: 2px; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8125rem; }
pre { background: var(--pre-bg); border: 1px solid var(--border); border-radius: 0.75rem; padding: 0.875rem 1rem; overflow-x: auto; white-space: pre-wrap; word-break: break-word; }

/* Forms & inputs */
label { display: block; font-size: 0.8125rem; font-weight: 600; margin: 0.875rem 0 0.3rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="number"], select, textarea {
  width: 100%; max-width: 26rem; padding: 0.55rem 0.8rem; font: inherit; color: var(--text);
  background: var(--field); border: 1px solid var(--border); border-radius: 0.5rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--text); outline-offset: 1px; }
.check { display: flex; gap: 0.5rem; align-items: center; font-weight: 400; margin: 0.875rem 0 0.3rem; font-size: 0.875rem; }
.check input { width: auto; }

/* Buttons: rectangular, 8px radius. Primary = solid near-black.
   input[type=submit] included — Rails f.submit renders an input, not a button. */
button, .btn, input[type="submit"] {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  width: auto; max-width: none;
  padding: 0.55rem 1.1rem; margin-top: 0.875rem; font: inherit; font-size: 0.875rem; font-weight: 600;
  color: var(--btn-text); background: var(--btn); border: 1px solid var(--btn);
  border-radius: 0.5rem; cursor: pointer; text-decoration: none;
}
button:hover, .btn:hover, input[type="submit"]:hover { opacity: 0.85; }
button.subtle, .btn.subtle, input[type="submit"].subtle { background: var(--card); color: var(--text); border-color: var(--border); }
button.subtle:hover, .btn.subtle:hover, input[type="submit"].subtle:hover { opacity: 1; border-color: var(--muted); }
button.danger, input[type="submit"].danger { background: var(--card); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); }
form.inline, .inline form { display: inline; }

/* Settings blocklist */
.blocklist { list-style: none; margin: 1.25rem 0 0; padding: 0; }
.blocklist li { display: flex; align-items: center; gap: 0.75rem; padding: 0.45rem 0; border-top: 1px solid var(--border); }
.blocklist li:first-child { border-top: 0; }
.blocklist code { overflow-wrap: anywhere; }
.blocklist li button { margin: 0 0 0 auto; padding: 0.3rem 0.75rem; font-size: 0.8125rem; }

/* Confirmation modal — replaces the browser confirm() for data-turbo-confirm.
   Padding lives on .confirm-box so clicks on the dialog element itself can
   only mean the backdrop (used to dismiss). */
dialog.confirm {
  border: 1px solid var(--border); border-radius: 0.75rem; padding: 0;
  max-width: 26rem; background: var(--card); color: var(--text);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}
dialog.confirm::backdrop { background: rgba(23, 23, 22, 0.45); }
.confirm-box { padding: 1.375rem; }
.confirm-box p { margin: 0; line-height: 1.55; }
.confirm-actions { display: flex; gap: 0.625rem; justify-content: flex-end; margin-top: 1.25rem; }
.confirm-actions button { margin: 0; }

/* Pills (statuses & counts) */
.pill, .badge {
  display: inline-flex; align-items: center; padding: 0.14rem 0.65rem; border-radius: 999px;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.01em;
  background: var(--card); color: var(--muted); border: 1px solid var(--border);
}
.pill.red, .pill.trouble, .badge.trouble { background: color-mix(in srgb, var(--bad) 10%, var(--card)); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, var(--border)); }
.pill.amber { background: color-mix(in srgb, var(--warn) 12%, var(--card)); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, var(--border)); }
.pill.green, .badge.party { background: color-mix(in srgb, var(--ok) 11%, var(--card)); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, var(--border)); }
.pill.purple { background: color-mix(in srgb, var(--tag) 11%, var(--card)); color: var(--tag); border-color: color-mix(in srgb, var(--tag) 30%, var(--border)); }

/* Admin panel */
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.admin-table th { text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); }
.admin-table td { padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: baseline; }
.admin-table tr:last-child td { border-bottom: none; }
.over-quota { color: var(--bad); font-weight: 600; }

/* Toasts (bottom right) */
.toasts { position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 50; display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-end; }
.toast {
  display: flex; align-items: center; gap: 0.6rem; min-width: 15rem; max-width: 24rem;
  padding: 0.7rem 1rem; background: var(--card); border: 1px solid var(--border);
  border-radius: 0.75rem; box-shadow: 0 4px 16px rgb(20 20 22 / 0.12);
  font-size: 0.875rem; cursor: pointer;
  opacity: 0; transform: translateY(0.5rem); transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; transform: none; }
.toast::before { content: ""; flex: 0 0 auto; width: 0.55rem; height: 0.55rem; border-radius: 999px; }
.toast.notice::before { background: var(--ok); }
.toast.alert::before { background: var(--bad); }

/* Banners (persistent, contextual) */
.flash { max-width: 72rem; margin: 1.25rem auto 0; padding: 0 1.5rem; }
.banner { padding: 0.7rem 1.1rem; border-radius: 0.75rem; font-size: 0.875rem; margin-bottom: 0.625rem; }
.banner.trouble { background: color-mix(in srgb, var(--bad) 8%, var(--card)); color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 25%, var(--border)); }
.banner.verify { background: color-mix(in srgb, var(--warn) 9%, var(--card)); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 25%, var(--border)); display: flex; align-items: center; gap: 0.875rem; flex-wrap: wrap; }
.banner.verify button, .banner.verify .btn { margin: 0; padding: 0.3rem 0.85rem; font-size: 0.8125rem; }
.banner.party { background: color-mix(in srgb, var(--ok) 9%, var(--card)); color: var(--ok); border: 1px solid color-mix(in srgb, var(--ok) 25%, var(--border)); }

/* Page head */
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.panel-head h1, .panel-head h2 { margin-bottom: 0; }
.panel-head + .form-grid, .panel-head + .card { margin-top: 1.25rem; }
.panel-head button, .panel-head .btn { margin-top: 0; }
.head-actions { display: flex; gap: 0.5rem; }
.head-actions .btn { margin-top: 0; }
.panel-head p { margin: 0; }

/* Forms index: card grid, 3 across */
.form-grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 1.25rem; }
@media (max-width: 64rem) { .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 42rem) { .form-grid { grid-template-columns: 1fr; } }
.form-card { display: flex; flex-direction: column; gap: 0.7rem; margin-bottom: 0; }
.form-card h2 { margin: 0; }
.form-card h2 a { text-decoration: none; }
.form-card h2 a:hover { text-decoration: underline; }
.pill-row { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.form-card .meta { display: flex; flex-direction: column; gap: 0.1rem; font-size: 0.8125rem; color: var(--muted); overflow-wrap: anywhere; }
.card-foot {
  margin-top: auto; padding-top: 0.875rem; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
}
.card-foot .btn { margin-top: 0; padding: 0.4rem 0.9rem; font-size: 0.8125rem; }

/* Tabs */
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.125rem; }
.tabs button {
  margin: 0; padding: 0.5rem 0.9rem; background: transparent; color: var(--muted);
  border: 0; border-bottom: 2px solid transparent; border-radius: 0; font-weight: 600; font-size: 0.875rem;
}
.tabs button:hover { background: transparent; color: var(--text); opacity: 1; }
.tabs button.active { color: var(--text); border-bottom-color: var(--text); }
.tabs.page-tabs { margin: 1.5rem 0 1.25rem; }
.tabs button .pill { margin-left: 0.3rem; }
.qr { margin-top: 0.875rem; }
.qr svg { width: 10rem; height: 10rem; background: #fff; padding: 0.5rem; border-radius: 0.75rem; border: 1px solid var(--border); }

/* Submissions log */
.submission { display: flex; gap: 0.875rem; padding: 0.8rem 0; border-top: 1px solid var(--border); align-items: baseline; }
.submission:first-of-type { border-top: 0; }
.submission .when { flex: 0 0 9.5rem; }
.submission .data { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.submission .data dt { font-weight: 600; font-size: 0.8125rem; display: inline; }
.submission .data dd { display: inline; margin: 0 0.75rem 0 0.25rem; }
.submission .actions { flex: 0 0 auto; }
.submission .full-message { margin-top: 0.35rem; }
.submission .full-message summary { cursor: pointer; font-size: 0.8125rem; color: var(--muted); }
.submission .full-message dd { white-space: pre-wrap; display: block; margin: 0.15rem 0 0.6rem; }
.submission .full-message dt { display: block; }
.submission .actions button { margin: 0; padding: 0.2rem 0.7rem; font-size: 0.72rem; }
.dot { display: inline-block; width: 0.55rem; height: 0.55rem; border-radius: 999px; margin-right: 0.35rem; }
.dot.delivered { background: var(--ok); }
.dot.pending { background: var(--warn); }
.dot.failed { background: var(--bad); }
.dot.held { background: var(--muted); }

/* Field editor rows */
.field-row { display: flex; gap: 0.5rem; align-items: flex-end; flex-wrap: wrap; padding: 0.7rem 0; border-top: 1px solid var(--border); }
.field-row:first-of-type { border-top: 0; }
.field-row form { display: flex; gap: 0.5rem; align-items: flex-end; flex-wrap: wrap; }
.field-row label { margin: 0 0 0.25rem; font-size: 0.72rem; }
.field-row input[type="text"], .field-row select { max-width: 11rem; padding: 0.4rem 0.6rem; }
.field-row input[type="number"] { max-width: 4.5rem; padding: 0.4rem 0.6rem; }
.field-row button, .field-row input[type="submit"] { margin: 0; padding: 0.4rem 0.85rem; font-size: 0.8125rem; }
.field-row .check { margin: 0 0 0.45rem; font-size: 0.8125rem; }
.field-row .move-btns { display: flex; flex-direction: column; gap: 0.15rem; align-self: center; }
.field-row .move-btns button { padding: 0.1rem 0.5rem; line-height: 1.2; }
.field-row .move-btns button:disabled { opacity: 0.35; cursor: default; }

/* Usage meter */
.meter { height: 0.55rem; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); overflow: hidden; max-width: 26rem; }
.meter span { display: block; height: 100%; background: var(--btn); border-radius: 999px; }

/* Auth screens */
.auth { max-width: 24rem; margin: 7vh auto 0; }

/* Articles */
.prose, .prose-head { max-width: 42rem; margin: 0 auto; }
.prose h1 { font-size: clamp(1.875rem, 4.5vw, 2.75rem); line-height: 1.1; margin-bottom: 0.25rem; }
.prose h2 { font-size: 1.25rem; margin: 2rem 0 0.5rem; }
.prose p, .prose ul { margin: 0.75rem 0; font-size: 1rem; line-height: 1.65; }
.prose li { margin: 0.35rem 0; }
.prose pre { margin: 1rem 0; }
.article-list { max-width: 42rem; margin: 1.5rem auto 0; }
.prose-head { margin-bottom: 1.5rem; }
.prose-head h1 { margin-bottom: 0.25rem; }

/* Landing page — full-height vertical frame lines. */
.landing pre { background: transparent; }
.vlines { position: fixed; inset: 0; pointer-events: none; }
.vlines::before, .vlines::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 1px; background: var(--border);
}
.vlines::before { left: max(1rem, calc(50% - 37rem)); }
.vlines::after { left: min(calc(100% - 1rem), calc(50% + 37rem)); }

.hero { text-align: center; padding: 3.5rem 0 2.5rem; }
.hero h1 {
  margin: 0 auto; max-width: 22ch;
  font-size: clamp(2.5rem, 7vw, 4.25rem); line-height: 1.05; letter-spacing: -0.04em;
}
.hero .sub { max-width: 34rem; margin: 1.5rem auto 0; color: var(--muted); font-size: 1.125rem; line-height: 1.5; }
.cta-row { display: flex; justify-content: center; gap: 0.75rem; margin-top: 2rem; }
.cta-row .btn { margin-top: 0; padding: 0.7rem 1.4rem; font-size: 0.9375rem; }

.mock { max-width: 46rem; margin: 2.5rem auto 0; }
.mock .card { margin-bottom: 0; padding: 0; overflow: hidden; }
.mock .mock-head { display: flex; align-items: center; gap: 0.55rem; padding: 0.9rem 1.25rem; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 0.875rem; }
.mock .mock-head .logo { height: 1.1rem; }
.mock pre { border: 0; border-radius: 0; margin: 0; padding: 1.25rem; background: var(--card); }

.section { padding: 3.5rem 0 0; }
.section > h2 { text-align: center; font-size: clamp(1.5rem, 3.5vw, 2.25rem); letter-spacing: -0.03em; margin-bottom: 2rem; }
.steps, .features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; }
.features { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 64rem) { .features { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 42rem) { .steps, .features { grid-template-columns: 1fr; } }
.steps .card, .features .card { margin-bottom: 0; }
.step-num { font-size: 0.8125rem; font-weight: 700; color: var(--muted); letter-spacing: 0.06em; }

.pricing { display: grid; grid-template-columns: repeat(4, minmax(0, 18rem)); justify-content: center; gap: 1.25rem; }
.pricing-contact { text-align: center; margin-top: 1.25rem; }
.actions-row { display: flex; gap: 0.75rem; flex-wrap: wrap; }
@media (max-width: 64rem) { .pricing { grid-template-columns: repeat(2, minmax(0, 20rem)); } }
@media (max-width: 42rem) { .pricing { grid-template-columns: 1fr; } }
.pricing .card { margin-bottom: 0; display: flex; flex-direction: column; }
.price { font-size: 2.25rem; font-weight: 800; letter-spacing: -0.03em; margin: 0.25rem 0; }
.price small { font-size: 0.9375rem; font-weight: 500; color: var(--muted); }
.plan-list { list-style: none; margin: 0.75rem 0 1rem; padding: 0; display: flex; flex-direction: column; gap: 0.45rem; font-size: 0.9rem; }
.plan-list li::before { content: "✓"; color: var(--ok); font-weight: 700; margin-right: 0.5rem; }
.pricing .btn { margin-top: auto; }

.landing-foot {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  margin-top: 4rem; padding-top: 1.5rem; border-top: 1px solid var(--border);
  color: var(--muted); font-size: 0.8125rem;
}
.landing-foot img { height: 1rem; opacity: 0.7; }
:root[data-theme="dark"] .landing-foot img { filter: invert(1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .landing-foot img { filter: invert(1); } }
