@font-face {
  font-family: "Loretta";
  src: url("/fonts/loretta-medium.otf") format("opentype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Schibsted Grotesk";
  src: url("/fonts/schibsted-grotesk-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --border: #e5ebf3;
  --border-strong: #cdddf7;
  --ink: #0e1726;
  --slate: #364253;
  --muted: #64748b;
  --faint: #93a1b5;
  --accent: #0047aa;
  --accent-deep: #063fb8;
  --accent-tint: #eef4ff;
  --grad: linear-gradient(90deg, #2ec1ec 0%, #1a87dc 45%, #0b61c7 76%, #063fb8 100%);
  --shadow: 0 1px 2px rgba(14, 23, 38, .04), 0 8px 24px rgba(14, 23, 38, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Schibsted Grotesk", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: 3px; background: var(--grad); z-index: 5; }
a { color: var(--accent); }
button, input, select { font: inherit; }

.page { display: flex; flex-direction: column; width: 100%; max-width: 1060px; min-height: 100svh; margin: 0 auto; padding: 18px 20px 44px; }
.topline { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 38px; }
.brand { font-family: "Loretta", Georgia, serif; font-size: 25px; color: var(--accent); text-decoration: none; }
.stamp { color: var(--muted); font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }

.setup-grid {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(400px, 1.1fr);
  gap: clamp(22px, 4vw, 56px);
  align-items: start;
  margin-bottom: 18px;
}
.hero { margin: 6px 0 0; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 11.5px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
h1 { margin: 0; font-family: "Loretta", Georgia, serif; font-size: clamp(38px, 7vw, 64px); line-height: .98; font-weight: 500; }
.subline { max-width: 600px; margin: 14px 0 0; color: var(--slate); font-size: 17px; line-height: 1.5; }

.panel {
  margin: 0 0 18px;
  padding: clamp(20px, 3vw, 28px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 6px; font-family: "Loretta", Georgia, serif; font-size: clamp(22px, 3vw, 28px); font-weight: 500; }

.field { display: grid; gap: 7px; margin-bottom: 18px; }
.field:last-of-type { margin-bottom: 0; }
.field label { color: var(--ink); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.field-hint { margin: -2px 0 2px; color: var(--muted); font-size: 13px; line-height: 1.4; }

input[type="email"], input[type="text"], input[type="time"], select {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  outline: none;
}
select { cursor: pointer; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 71, 170, .12); }

button {
  min-height: 46px;
  margin-top: 18px;
  padding: 0 20px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 140ms ease;
}
button:hover, button:focus-visible { background: var(--accent-deep); outline: none; }
button:disabled { cursor: not-allowed; opacity: .62; }

.form-status { min-height: 20px; margin-top: 11px; color: var(--muted); font-size: 13.5px; line-height: 1.45; }
.form-status.ok { color: #047857; }
.form-status.err { color: #b3261e; }

.muted { margin: 0 0 14px; color: var(--slate); font-size: 14.5px; line-height: 1.5; }

/* ---- Chips ---- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 9px; }
.chips:empty { margin-bottom: 0; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 7px 12px;
  background: var(--accent-tint);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.2;
}
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border-radius: 999px;
  border: none;
  background: rgba(0, 71, 170, .14);
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.chip button:hover, .chip button:focus-visible {
  background: var(--accent);
  color: #fff;
  outline: none;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(140px, 180px) minmax(240px, 1fr) minmax(150px, 180px);
  gap: 16px;
  align-items: start;
  margin-top: 24px;
}
.settings-grid .field { margin-bottom: 0; }
.settings-note { margin: 10px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }

.legal { margin: auto 4px 0; padding-top: 22px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.legal a { font-weight: 700; text-decoration: none; }

@media (max-width: 860px) {
  .setup-grid { grid-template-columns: 1fr; }
  .hero { margin: 0; }
}

@media (max-width: 600px) {
  .page { padding: 18px 16px 40px; }
  .topline { margin-bottom: 28px; }
  .settings-grid { grid-template-columns: 1fr; gap: 14px; }
}

.turnstile-slot { margin: 4px 0 14px; }
.turnstile-slot[hidden] { display: none; }

/* ---- Subscription editor (/api/daily_inbox_edit) ------------------------ */
/* An account page, not a signup form: what we watch for you, stated as data,
   with the one editable thing given the weight on the page. */

.edit-head { margin-bottom: 24px; }
.edit-head h1 { font-size: clamp(30px, 5vw, 46px); }
.edit-head .subline { margin-top: 12px; font-size: 16px; }

.sub-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 1px;
  margin: 0 0 18px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.sub-summary > div { padding: 13px 16px; background: var(--surface); }
.sub-summary dt {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.sub-summary dd {
  margin: 0;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 6px;
}
.panel-head h2 { margin: 0; }
.term-count { color: var(--muted); font-size: 13px; white-space: nowrap; }
.term-count.at-limit { color: #b3261e; font-weight: 700; }

.chips-empty { margin: 2px 0 12px; color: var(--muted); font-size: 14px; }

/* Removing a term is one click, so it needs a way back. */
.undo-line { min-height: 21px; margin-top: 10px; color: var(--muted); font-size: 13.5px; }

.linkish {
  min-height: 0;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  font-size: 13.5px;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}
.linkish:hover, .linkish:focus-visible { background: none; color: var(--accent-deep); }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 22px; }
.actions button { margin-top: 0; }
.btn-quiet { background: transparent; color: var(--accent); border-color: var(--border-strong); }
.btn-quiet:hover, .btn-quiet:focus-visible { background: var(--accent-tint); color: var(--accent-deep); }
.dirty-flag { color: #92400e; font-size: 13px; font-weight: 700; }
.dirty-flag[hidden] { display: none; }

@media (max-width: 560px) {
  .actions { flex-direction: column; align-items: stretch; }
  .actions button { width: 100%; }
  .dirty-flag { text-align: center; }
}

/* ---------------------------------------------------------------------------
   Setup mode: follow one category, or track your own keywords - never both.

   Two inherited rules have to be undone explicitly here:
   - the global `button` rule sets min-height:46px and margin-top:18px for the
     full-width submit button, which turned these pills into tall, oddly
     spaced blocks;
   - `.field { display: grid }` outranks the browser's [hidden] rule, so a
     hidden fieldset kept rendering. Same fix the file already uses for
     .turnstile-slot and .dirty-flag.
--------------------------------------------------------------------------- */
.mode-field,
.cat-field { margin: 0 0 18px; padding: 0; border: 0; }
.mode-field legend,
.cat-field legend {
  padding: 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.field[hidden],
.cat-field[hidden],
.mode-field[hidden] { display: none; }

.mode-switch {
  /* A grid item stretches to fill its column, which made the capsule run past
     the two pills inside it. Shrink it back onto its contents. */
  display: inline-flex;
  justify-self: start;
  width: fit-content;
  max-width: 100%;
  gap: 3px;
  margin-top: 8px;
  padding: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.mode {
  min-height: 0;
  margin-top: 0;
  padding: 8px 15px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--slate);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}
.mode:hover { background: transparent; color: var(--ink); }
.mode:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mode--on,
.mode--on:hover { background: var(--accent); color: #fff; font-weight: 700; }

.cat-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.cat {
  min-height: 0;
  margin-top: 0;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--slate);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}
.cat:hover { background: #fff; border-color: var(--border-strong); color: var(--ink); }
.cat:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cat--on,
.cat--on:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
  .cat, .mode { transition: none; }
}
