:root {
  --bg: #f3eee1;
  --surface: #fbf9f3;
  --surface-2: #efe9d8;
  --ink: #23272a;
  --muted: #5a625e;
  --primary: #1d4d2b;
  --primary-dark: #143722;
  --mint: #d9ecdf;
  --mint-ink: #173d24;
  --line: #ddd5c0;
  --danger: #9c2b2e;
  --danger-bg: #f7e4e1;
  --warn-bg: #f7efda;
  --radius-card: 10px;
  --radius-input: 7px;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--primary);
  color: #fff;
  padding: 0.6rem 1rem;
  z-index: 100;
  border-radius: 0 0 6px 0;
}
.skip:focus { left: 0; }

.wrap { max-width: 1060px; margin: 0 auto; padding: 0 1.25rem; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.25; margin: 0 0 0.6rem; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.35rem; margin-top: 2rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 0.8rem; }
a { color: var(--primary); }
a:hover { color: var(--primary-dark); }

:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 3px; }

/* Top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-inner { display: flex; align-items: center; gap: 1.5rem; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 0.55rem; text-decoration: none; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--primary); color: #fff;
  font-family: var(--serif); font-size: 1.2rem; font-weight: 700;
}
.brand-name { font-family: var(--serif); font-size: 1.35rem; color: var(--ink); }
.nav { display: flex; gap: 0.25rem; margin-left: 0.5rem; }
.nav a {
  text-decoration: none; color: var(--muted); font-weight: 600;
  padding: 0.45rem 0.8rem; border-radius: 8px;
}
.nav a:hover { color: var(--ink); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--primary); background: var(--mint); }
.connect-slot { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; }
.connect-state { font-size: 0.85rem; color: var(--muted); }

/* Notices */
.notice {
  max-width: 1060px; margin: 0.9rem auto 0; padding: 0 1.25rem;
}
.notice-inner {
  border-radius: var(--radius-card);
  padding: 0.7rem 1rem;
  font-size: 0.92rem;
  border: 1px solid var(--line);
  background: var(--warn-bg);
}
.notice-inner.mock { background: var(--warn-bg); }
.notice-inner.info { background: var(--mint); color: var(--mint-ink); border-color: #bcd8c4; }

/* Layout */
#view { padding-top: 1.75rem; padding-bottom: 3rem; min-height: 60vh; }
.lede { color: var(--muted); font-size: 1.05rem; max-width: 62ch; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } .nav { gap: 0; } .nav a { padding: 0.45rem 0.5rem; } }
/* Narrow sidebar / widget / phone widths: stack everything, keep tap targets full-width. */
@media (max-width: 480px) {
  .wrap { padding: 0 0.85rem; }
  #view { padding-top: 1.1rem; }
  h1 { font-size: 1.45rem; }
  .card { padding: 1rem; }
  .nav { overflow-x: auto; white-space: nowrap; }
  .btn-row { flex-direction: column; align-items: stretch; }
  .draft-controls { flex-direction: column; align-items: stretch; }
  .draft-controls select { width: 100%; min-width: 0; }
  .chip-row { gap: 0.35rem; }
  .modal { padding: 1.1rem; }
  .modal-foot { margin-top: 1rem; padding-top: 0.8rem; flex-direction: column; align-items: stretch; }
  .modal-foot .btn { width: 100%; }
  .toast-root { left: 0.85rem; right: 0.85rem; max-width: none; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1rem;
}
.card.tight { padding: 0.9rem 1.1rem; }

/* Story cards */
.story-title { font-size: 1.2rem; margin-bottom: 0.3rem; }
.story-title a { color: var(--ink); text-decoration: none; }
.story-title a:hover { color: var(--primary); text-decoration: underline; }
.byline { font-size: 0.85rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 0.35rem 0.7rem; margin-bottom: 0.6rem; }
.byline a { color: var(--primary); }
.why { border-left: 3px solid var(--primary); padding: 0.35rem 0 0.35rem 0.8rem; margin: 0.7rem 0; color: var(--mint-ink); font-size: 0.95rem; }
.summary { color: var(--ink); }
.missing { color: var(--muted); font-style: italic; }

/* Badges and pills */
.badge {
  display: inline-block; font-size: 0.75rem; font-weight: 700;
  padding: 0.12rem 0.55rem; border-radius: 999px;
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--line);
  vertical-align: middle;
}
.badge.provider { background: var(--mint); color: var(--mint-ink); border-color: #bcd8c4; }
.badge.mock { background: var(--warn-bg); color: #6d4c12; border-color: #d9c48f; }
.badge.real { background: var(--primary); color: #fff; border-color: var(--primary); }
.badge.status-scheduled { background: var(--primary); color: #fff; border-color: var(--primary); }
.badge.status-approved { background: var(--mint); color: var(--mint-ink); border-color: #bcd8c4; }
.badge.status-skipped { background: var(--surface-2); color: var(--muted); }

/* Forms */
label.field { display: block; margin-bottom: 1rem; }
/* Class display rules beat the UA style for [hidden] — restore it globally. */
[hidden] { display: none !important; }
.field > span.label { display: block; font-weight: 650; margin-bottom: 0.35rem; }
.field .hint { font-size: 0.85rem; color: var(--muted); margin-top: 0.3rem; }
input[type="text"], input[type="datetime-local"], select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: #fff; border: 1px solid #c9c2ab;
  border-radius: var(--radius-input); padding: 0.6rem 0.7rem;
}
textarea { min-height: 110px; resize: vertical; }
input[type="checkbox"] { width: 1.1rem; height: 1.1rem; accent-color: var(--primary); }

.chip-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0 1rem; }
.chip {
  display: inline-flex; align-items: center; gap: 0.45rem;
  border: 1px solid #c9c2ab; background: #fff;
  border-radius: 999px; padding: 0.35rem 0.4rem 0.35rem 0.8rem;
  font-size: 0.92rem; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip button {
  border: 0; background: transparent; cursor: pointer;
  font-size: 1rem; line-height: 1; padding: 0 0.4rem; color: inherit; opacity: 0.7;
}
.chip button:hover { opacity: 1; }

/* Grounded take-questions: left-aligned numbered cards, not pills. */
.take-prompts { list-style: none; margin: 0 0 0.6rem; padding: 0; display: grid; gap: 0.5rem; counter-reset: prompt; }
.prompt-q { display: block; width: 100%; text-align: left; font: inherit; line-height: 1.45; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 0.6rem 0.8rem 0.6rem 2.6rem; cursor: pointer; position: relative; }
.prompt-q::before { counter-increment: prompt; content: counter(prompt); position: absolute; left: 0.8rem; top: 0.6rem; min-width: 1.2rem; height: 1.2rem; line-height: 1.2rem; text-align: center; font-size: 0.75rem; font-weight: 700; color: var(--primary); background: var(--mint); border-radius: 999px; }
.prompt-q:hover { border-color: var(--primary); }
.prompt-q:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  font: inherit; font-weight: 650; cursor: pointer;
  border-radius: 8px; padding: 0.6rem 1.15rem;
  border: 1px solid var(--primary);
  background: var(--primary); color: #fff;
  text-decoration: none;
}
.btn:hover { background: var(--primary-dark); color: #fff; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.secondary { background: transparent; color: var(--primary); }
.btn.secondary:hover { background: var(--mint); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--primary); padding: 0.4rem 0.6rem; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.small { padding: 0.35rem 0.7rem; font-size: 0.88rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem; align-items: center; }

/* Tabs */
.tabs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 1rem 0; border-bottom: 1px solid var(--line); padding-bottom: 0.6rem; }
.tabs button {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; background: transparent; color: var(--muted);
  border-radius: 8px; padding: 0.45rem 0.9rem;
}
.tabs button[aria-selected="true"] { background: var(--primary); color: #fff; }
.tabs button:hover:not([aria-selected="true"]) { background: var(--surface-2); color: var(--ink); }

/* Draft cards */
.draft-card { border: 1px solid var(--line); border-radius: var(--radius-card); background: #fff; padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.draft-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; flex-wrap: wrap; }
.draft-head h3 { margin: 0; }
.draft-text { white-space: pre-wrap; margin: 0.6rem 0; }
.draft-meta { font-size: 0.83rem; color: var(--muted); }
.draft-controls { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.8rem; align-items: end; }
.draft-controls label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; font-weight: 600; }
.draft-controls select { width: auto; min-width: 9rem; }

/* States */
.empty { text-align: left; padding: 2rem 1rem; color: var(--muted); }
.error-box { background: var(--danger-bg); border: 1px solid #d8a9a6; border-radius: var(--radius-card); padding: 1rem 1.2rem; margin: 1rem 0; }
.error-box h3 { color: var(--danger); margin-bottom: 0.3rem; }
.loading { color: var(--muted); padding: 1.5rem 0; }
.spinner { display: inline-block; width: 1rem; height: 1rem; border: 2px solid var(--line); border-top-color: var(--primary); border-radius: 50%; margin-right: 0.5rem; vertical-align: -2px; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(35, 39, 42, 0.5); display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 50; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 12px; max-width: 560px; width: 100%; padding: 1.5rem; border: 1px solid var(--line); max-height: calc(100vh - 2rem); overflow-y: auto; }
.modal-foot { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1.2rem 0 0; padding: 0.9rem 0 0.1rem; background: var(--surface); border-top: 1px solid var(--line); }
.modal pre.confirm-text { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-input); padding: 0.9rem; white-space: pre-wrap; max-height: min(220px, 26vh); overflow-y: auto; }

/* Toasts */
.toast-root { position: fixed; bottom: 1rem; right: 1rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 60; max-width: min(92vw, 380px); }
.toast { background: var(--ink); color: #fff; border-radius: 8px; padding: 0.7rem 1rem; font-size: 0.92rem; }
.toast.error { background: var(--danger); }
.toast.success { background: var(--primary); }

.footer { color: var(--muted); font-size: 0.85rem; padding-bottom: 2rem; border-top: 1px solid var(--line); padding-top: 1rem; }

/* Ask Posty */
.ask-block { margin: 0 0 2rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.ask-block:last-child { border-bottom: 0; }
.ask-q { font-size: 1.05rem; font-weight: 650; margin: 0 0 1rem; }
.ask-who { display: block; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--primary); margin-bottom: 0.15rem; }
.ask-composer { position: sticky; bottom: 0; background: var(--bg); border-top: 1px solid var(--line); padding: 0.8rem 0 1.2rem; margin-top: 1rem; }
.ask-suggest { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin-bottom: 0.6rem; }
.ask-row { display: flex; gap: 0.5rem; }
.ask-row input { flex: 1; border: 1px solid var(--line); border-radius: var(--radius-input); padding: 0.6rem 0.8rem; font: inherit; background: var(--surface); }
.ask-row .btn { flex: 0 0 auto; }

/* Shortcut list */
.keys { margin: 0.5rem 0 1rem; }
.keys > div { display: flex; gap: 0.7rem; align-items: baseline; margin-bottom: 0.35rem; }
.keys dt { white-space: nowrap; }
.keys dd { margin: 0; color: var(--muted); }
kbd { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; font-size: 0.8rem; font-weight: 600; }

/* Structured article briefs */
.brief-points { margin: 0.6rem 0; }
.brief-points summary { cursor: pointer; font-weight: 650; color: var(--primary); font-size: 0.92rem; }
.brief-points ul { margin: 0.5rem 0 0.2rem; padding-left: 1.3rem; }
.brief-points li { margin-bottom: 0.35rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
