/* SecDek — visual language inspired by PatDek.
 *
 * Principles:
 *   - White background, near-black text, one muted gray for metadata
 *   - Single sans-serif body; serif display for titles/section heads
 *   - Centered content column; no cards, borders, shadows, or chips
 *   - `* * *` asterisk dividers between sections
 *   - Minimal color; links are underlined in body text color
 */

:root {
  --bg:        #ffffff;
  --text:      #1a1a1a;
  --muted:     #6a6a6a;
  --subtle:    #a0a0a0;
  --border:    #e6e6e6;
  --link:      #1a1a1a;

  --accent:    #5f3d8a;   /* reserved — used sparingly */
  --warn:      #a33a2e;   /* reserved — scrub-signal accent */

  --font-sans: "Inter", "IBM Plex Sans", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  --font-serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --content:   820px;
  --wide:      1040px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--bg); color: var(--text); }
body {
  font: 17px/1.65 var(--font-sans);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--text);
  line-height: 1.25;
}
h1 { font-size: 2.4rem; margin: 0.4em 0 0.2em; }
h2 { font-size: 1.45rem; margin: 1.6em 0 0.6em; }
h3 { font-size: 1.15rem; margin: 1.2em 0 0.4em; font-weight: 600; }
p  { margin: 0 0 1em; }
strong { font-weight: 600; }
small { font-size: 0.9em; }

a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
a:hover { text-decoration-thickness: 2px; }

.muted  { color: var(--muted); }
.subtle { color: var(--subtle); }
.small  { font-size: 0.9em; }
.tiny   { font-size: 0.8em; }

.container       { max-width: var(--content); margin: 0 auto; padding: 0 24px; }
.container-wide  { max-width: var(--wide); margin: 0 auto; padding: 0 24px; }

/* --- Header / nav --- */
.site-header { padding: 48px 24px 16px; text-align: center; }
.brand {
  display: inline-block;
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.nav {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  gap: 32px;
  font-size: 0.95rem;
  color: var(--muted);
}
.nav a { color: var(--muted); text-decoration: none; }
.nav a:hover { color: var(--text); text-decoration: underline; }

main { padding-bottom: 120px; }

/* --- Asterisk divider --- */
.divider {
  text-align: center;
  color: var(--subtle);
  letter-spacing: 1em;
  font-size: 0.9rem;
  margin: 48px 0;
  user-select: none;
}
.divider::before { content: "\2217 \2217 \2217"; }

/* --- Landing hero / buckets --- */
.hero {
  text-align: center;
  max-width: 640px;
  margin: 48px auto 0;
}
.hero .tagline {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  line-height: 1.5;
  color: var(--muted);
  font-style: italic;
}
.lookup-form {
  display: flex;
  gap: 8px;
  margin: 28px auto 0;
  max-width: 520px;
}
.lookup-form input[type="search"] {
  flex: 1;
  padding: 10px 14px;
  font-size: 1rem;
  border: 1px solid var(--muted);
  border-radius: 4px;
  font-family: inherit;
}
.lookup-form input[type="search"]:focus {
  outline: none;
  border-color: currentColor;
}
.lookup-form button {
  padding: 10px 16px;
  font-size: 1rem;
  background: var(--muted);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
}
.lookup-form button:hover { opacity: 0.88; }

/* --- Watch control (grid header) + link-button (notifications) --- */
.watch-control {
  display: inline-block;
  margin-top: 12px;
}
.watch-control button {
  padding: 6px 14px;
  font-size: 0.9rem;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--muted);
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
}
.watch-control button:hover {
  color: var(--text);
  border-color: var(--text);
}
.watch-control.watching button {
  color: var(--text);
  border-color: var(--text);
  background: rgba(0, 0, 0, 0.04);
}
.grid-x-watch {
  margin-top: 4px;
  text-align: center;
}
.link-button {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
}
.link-button:hover { color: var(--text); }

.bucket { max-width: 640px; margin: 0 auto; text-align: center; }
.bucket h2 {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 500;
  margin-top: 0;
  color: var(--text);
}
.bucket p { color: var(--text); }
.bucket .bucket-detail {
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 0.75em;
}

/* --- Feed list (used on landing) --- */
.feed { max-width: 760px; margin: 0 auto; list-style: none; padding: 0; }
.feed li { padding: 20px 0; border-bottom: 1px solid var(--border); }
.feed li:last-child { border-bottom: none; }
.feed .feed-title { font-size: 1.05rem; font-weight: 500; color: var(--text); }
.feed .feed-title a { text-decoration: none; }
.feed .feed-title a:hover { text-decoration: underline; }
.feed .feed-meta { color: var(--muted); font-size: 0.9rem; margin-top: 4px; }
.feed .feed-pattern { color: var(--text); font-size: 0.95rem; margin-top: 6px; }

/* --- Letter detail page --- */
.letter-page { max-width: var(--content); margin: 0 auto; }
.letter-breadcrumb {
  text-align: center;
  color: var(--subtle);
  font-size: 0.85rem;
  margin-bottom: 12px;
}
.letter-breadcrumb a { color: var(--muted); text-decoration: none; }
.letter-title {
  text-align: center;
  font-family: var(--font-serif);
  font-size: 2.2rem;
  font-weight: 500;
  margin: 8px 0 6px;
  line-height: 1.25;
  color: var(--text);
}
.letter-subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 1rem;
  margin-bottom: 12px;
}
.letter-actions {
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 24px;
}
.letter-actions a { margin: 0 10px; }

/* Narrative section (under a divider) */
.section { max-width: 680px; margin: 0 auto; }
.section h2 {
  text-align: center;
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 500;
  margin-bottom: 1em;
  color: var(--text);
}
.section p { color: var(--text); }
.section .section-prose { font-size: 1.05rem; }

.signals { color: var(--text); }
.signals .signal { font-weight: 500; }

/* --- Raw-data disclosure --- */
details.raw { max-width: 760px; margin: 0 auto; font-size: 0.95rem; }
details.raw summary {
  cursor: pointer;
  color: var(--muted);
  text-align: center;
  padding: 8px 0;
  list-style: none;
  font-variant: small-caps;
  letter-spacing: 0.1em;
  font-size: 0.85rem;
}
details.raw summary::-webkit-details-marker { display: none; }
details.raw[open] summary { margin-bottom: 12px; }
details.raw dl {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 6px 24px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text);
  padding: 12px 0 0;
}
details.raw dt { color: var(--muted); }
details.raw dd { word-break: break-all; }
details.raw pre {
  white-space: pre-wrap;
  word-break: break-all;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text);
  padding: 12px;
  background: #f7f7f7;
  border: 1px solid var(--border);
  margin-top: 8px;
}

/* --- Markup bar --- */
.markup { max-width: 680px; margin: 0 auto; }
.markup fieldset { border: none; }
.markup legend {
  text-align: center;
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 500;
  margin-bottom: 1em;
  width: 100%;
}
.markup .markup-row {
  display: flex; justify-content: center; gap: 28px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.markup .markup-opt {
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer; font-size: 0.95rem; color: var(--text);
}
.markup .markup-note { display: block; margin: 12px 0; }
.markup .markup-note textarea {
  width: 100%; min-height: 72px; padding: 10px;
  font: inherit;
  border: 1px solid var(--border); background: #fafafa; color: var(--text);
  resize: vertical;
}
.markup button {
  font: inherit; padding: 8px 20px;
  background: var(--text); color: white; border: none; cursor: pointer;
  letter-spacing: 0.05em;
}
.markup button:hover { background: #333; }
.markup .markup-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 12px; font-size: 0.85rem; color: var(--muted);
}

/* --- Login --- */
.login { max-width: 360px; margin: 80px auto; text-align: center; }
.login input {
  font: inherit; padding: 10px 14px; margin: 16px 0; width: 100%;
  border: 1px solid var(--border); text-align: center; letter-spacing: 0.05em;
}
.login input:focus { outline: 1px solid var(--text); border-color: transparent; }
.login button {
  font: inherit; padding: 10px 32px;
  background: var(--text); color: white; border: none; cursor: pointer;
  letter-spacing: 0.05em;
}
.login button:hover { background: #333; }
.login .err { color: var(--warn); margin-top: 12px; }

/* --- Footer --- */
.site-footer {
  max-width: var(--content);
  margin: 120px auto 48px;
  padding: 32px 24px 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

/* --- Expert feedback bar --- */
.feedback-bar {
  max-width: 680px;
  margin: 96px auto 0;
  padding: 0 24px;
}
.feedback-bar details summary {
  cursor: pointer;
  color: var(--muted);
  text-align: center;
  padding: 8px 0;
  font-variant: small-caps;
  letter-spacing: 0.1em;
  font-size: 0.85rem;
  list-style: none;
}
.feedback-bar details summary::-webkit-details-marker { display: none; }
.feedback-bar details[open] summary { margin-bottom: 12px; }
.feedback-bar textarea {
  width: 100%;
  min-height: 90px;
  padding: 10px;
  font: inherit;
  border: 1px solid var(--border);
  background: #fafafa;
  color: var(--text);
  resize: vertical;
}
.feedback-bar button {
  display: block;
  margin: 12px auto 0;
  font: inherit;
  padding: 8px 24px;
  background: var(--text);
  color: white;
  border: none;
  cursor: pointer;
  letter-spacing: 0.05em;
}
.feedback-bar button:hover { background: #333; }

/* --- Docket related letters --- */
.docket-related {
  max-width: 680px;
  margin: 8px auto 0;
  list-style: none;
  padding: 0;
  border-top: 1px solid var(--border);
}
.docket-related li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}
.docket-related li a { text-decoration: none; }
.docket-related li a:hover { text-decoration: underline; }

/* --- Ingest log table --- */
.ingest-log h1 {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 500;
  text-align: center;
  margin: 8px 0 6px;
}
.ingest-log > p { text-align: center; margin-bottom: 32px; }
.ingest-scroll { overflow-x: auto; }
.ingest-runs {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}
.ingest-runs th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding: 8px 14px;
  white-space: nowrap;
}
.ingest-runs td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.ingest-runs tbody tr:last-child td { border-bottom: none; }
.ingest-runs tr.err td { color: var(--warn); }

/* Old generic utility classes kept for any stragglers */
.plain-list { list-style: none; padding: 0; margin: 0; }

/* --- Grid (2D spread) --- */
.grid-page { max-width: 1100px; margin: 0 auto; padding: 24px 20px 80px; }
.grid-x { border-bottom: 1px solid var(--border); padding-bottom: 18px; margin-bottom: 28px; }
.grid-x-eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.grid-x-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 1.9rem;
  margin: 0 0 6px;
  line-height: 1.2;
}
.grid-x-meta { color: var(--muted); font-size: 0.92rem; }
.grid-x-meta .sep { margin: 0 8px; }
.grid-x-title-sub {
  font-family: var(--font-serif);
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 6px;
}
.grid-x-actions { margin-top: 10px; font-size: 0.9rem; }
.grid-x-actions a { color: var(--muted); text-decoration: none; }
.grid-x-actions a:hover { text-decoration: underline; }

.grid-lenses {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 32px;
}
.grid-cell {
  padding: 14px 14px 18px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  min-height: 140px;
}
/* Cells in the final row have no bottom border (cleaner look when
   the row is full vs. partially filled). The repeat(4) layout means
   a 7-cell lens set fills row 1 fully (4) + row 2 partially (3). */
.grid-cell:nth-last-child(-n+4) { border-bottom: none; }
.grid-cell:nth-child(4n) { border-right: none; }
.grid-cell:last-child { border-right: none; }
.grid-cell-head {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.grid-cell-empty { color: var(--muted); font-size: 1.1rem; }
.grid-cell-lines { list-style: none; padding: 0; margin: 0; font-size: 0.9rem; line-height: 1.5; }
.grid-cell-lines li { margin-bottom: 4px; }
.grid-cell-label {
  display: inline-block;
  min-width: 0;
  color: var(--muted);
  font-size: 0.75rem;
  margin-right: 6px;
}
.grid-cell-value { }
.grid-cell a { color: inherit; text-decoration: none; border-bottom: 1px solid var(--border); }
.grid-cell a:hover { border-bottom-color: currentColor; }

.grid-analogs { border-top: 1px solid var(--border); padding-top: 18px; }
.grid-analogs-head {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 1.05rem;
  margin-bottom: 14px;
}
.grid-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 20px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
}
.grid-row:last-child { border-bottom: none; }
.grid-row-head {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.grid-row-empty { color: var(--muted); font-size: 1.1rem; }
.grid-row-analogs { list-style: none; padding: 0; margin: 0; }
.grid-row-analogs li { margin-bottom: 6px; }
.grid-analog {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 12px;
  padding: 4px 0;
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted transparent;
}
.grid-analog:hover { border-bottom-color: var(--border); }
.grid-analog-name { font-weight: 500; }
.grid-analog-date {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.88rem;
  text-align: right;
}
.grid-analog-title {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 1px;
}
.grid-footnote {
  margin-top: 36px;
  color: var(--muted);
  font-size: 0.85rem;
  font-style: italic;
}

@media (max-width: 900px) {
  .grid-lenses { grid-template-columns: repeat(2, 1fr); }
  .grid-cell { border-right: none; border-bottom: 1px solid var(--border); }
  .grid-row { grid-template-columns: 1fr; gap: 6px; }
}

/* --- Replay (trajectory timeline) --- */
.replay-page { max-width: 1200px; margin: 0 auto; padding: 24px 20px 80px; }
.replay-x { border-bottom: 1px solid var(--border); padding-bottom: 18px; margin-bottom: 20px; }
.replay-x-eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.replay-x-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 1.8rem;
  margin: 0 0 6px;
  line-height: 1.2;
}
.replay-x-meta { color: var(--muted); font-size: 0.92rem; }
.replay-x-meta .sep { margin: 0 8px; }
.replay-x-actions { margin-top: 10px; font-size: 0.9rem; }
.replay-x-actions a { color: var(--muted); text-decoration: none; margin-right: 14px; }
.replay-x-actions a:hover { text-decoration: underline; }

.replay-cohort-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.replay-cohort-label {
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-right: 4px;
}
.replay-cohort-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: 0.9rem;
  color: inherit;
  text-decoration: none;
  background: #fff;
}
.replay-cohort-pill:hover { background: #f4f4f4; }
.replay-cohort-pill.active { background: #111; color: #fff; border-color: #111; }
.replay-cohort-pill.active .replay-cohort-count { color: #ddd; }
.replay-cohort-count { color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }

.replay-frame {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 16px 20px;
  margin-bottom: 20px;
}
.replay-axis {
  position: relative;
  height: 24px;
  margin-left: 200px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.replay-axis-label {
  position: absolute;
  left: 0;
  bottom: 4px;
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.replay-axis-tick {
  position: absolute;
  bottom: 4px;
  transform: translateX(-50%);
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.replay-rows { }
.replay-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  align-items: center;
  min-height: 42px;
}
.replay-row:last-child { border-bottom: none; }
.replay-row.inbound {
  background: #f7f4ea;
  margin: -2px -8px 6px;
  padding: 10px 8px;
  border-radius: 4px;
  border-bottom: 1px solid var(--border);
}
.replay-row-eyebrow {
  display: inline-block;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--warn);
  margin-right: 6px;
}
.replay-row-label { font-size: 0.9rem; line-height: 1.2; }
.replay-row-name { color: inherit; text-decoration: none; font-weight: 500; }
.replay-row-name:hover { text-decoration: underline; }
.replay-row-date {
  color: var(--muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.replay-row-track {
  position: relative;
  height: 28px;
  border-left: 1px solid var(--border);
}
.replay-marker {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.replay-marker-form {
  font-size: 0.65rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  margin-bottom: 2px;
  line-height: 1;
}
.replay-marker-dot {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #111;
  text-decoration: none;
}
a.replay-marker-dot:hover { background: var(--warn); }
.replay-today {
  position: absolute;
  top: -2px;
  bottom: -2px;
  border-left: 2px dashed var(--warn);
  transform: translateX(-1px);
}
.replay-today-label {
  position: absolute;
  top: -16px;
  left: 6px;
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--warn);
  white-space: nowrap;
}

.replay-counts {
  margin-top: 20px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fafafa;
}
.replay-counts-head {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 8px;
}
.replay-counts ul { margin: 0; padding-left: 20px; font-size: 0.9rem; line-height: 1.6; }
.replay-counts-thin {
  margin-top: 20px;
  color: var(--muted);
  font-size: 0.88rem;
  font-style: italic;
}
.replay-footnote {
  margin-top: 30px;
  color: var(--muted);
  font-size: 0.85rem;
  font-style: italic;
  line-height: 1.5;
}

@media (max-width: 800px) {
  .replay-axis { margin-left: 140px; }
  .replay-row { grid-template-columns: 140px 1fr; }
}

.replay-frame-head {
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 10px;
  line-height: 1.4;
}
.replay-frame-head.muted { font-style: italic; }
