/* =====================================================================
   flashlit — minimalist editorial design
   - Pure white background, near-black ink
   - Literary serif for editorial moments, clean sans for UI/data
   - Generous whitespace, restrained chrome, refined typography
   - Designed for long reading sessions; high contrast without harshness
   ===================================================================== */

:root {
  /* Ink palette — black-on-white, with two soft greys for hierarchy */
  --ink:        #111111;   /* primary text — softer than pure #000 */
  --ink-soft:   #2a2a2a;   /* secondary text */
  --muted:      #757575;   /* meta / labels */
  --muted-2:    #a8a8a8;   /* the quietest text */
  --bg:         #ffffff;
  --bg-soft:    #fafafa;   /* alt rows, code blocks, very subtle panels */
  --bg-warm:    #f7f4ee;   /* still subtle, slightly warm — for piece bodies */
  --line:       #ececec;   /* hairline dividers */
  --line-soft:  #f3f3f3;
  --rule:       #1a1a1a;   /* strong rule (under section headings) */

  /* Status palette — quiet, never shouty */
  --ok-fg:    #1f5b32;
  --ok-bg:    #ecf6ee;
  --warn-fg:  #6b5414;
  --warn-bg:  #fbf3d9;
  --error-fg: #93251a;
  --error-bg: #fbe9e6;

  /* Type — serif for editorial, sans for UI, mono for data */
  --serif: "Iowan Old Style", "Charter", "Apple Garamond", "Source Serif Pro",
           Georgia, "Times New Roman", serif;
  --sans:  -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI",
           "Helvetica Neue", Arial, sans-serif;
  --mono:  "SF Mono", "Menlo", "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  font-feature-settings: "kern", "liga", "calt";
}

::selection { background: #1a1a1a; color: #fff; }

a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 120ms ease, color 120ms ease;
}
a:hover { border-bottom-color: var(--ink); }
a:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-bottom-color: transparent;
}

/* ===== Typography ===== */
h1, h2, h3, h4, h5 {
  font-family: var(--serif);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1.25;
}
h1 { font-size: 38px; margin: 0 0 24px; font-weight: 700; }
h2 {
  font-size: 22px;
  margin: 48px 0 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
h3 { font-size: 17px; margin: 28px 0 8px; }
h4 { font-size: 15px; margin: 20px 0 6px; }

p { margin: 0 0 16px; }

small, .meta { font-size: 13px; color: var(--muted); }
.muted { color: var(--muted); }

code, pre {
  font-family: var(--mono);
  font-size: 13px;
}
code {
  padding: 1px 6px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 3px;
}
pre {
  padding: 14px 18px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow-x: auto;
  line-height: 1.55;
}
pre code { padding: 0; background: transparent; border: none; }

hr { border: 0; border-top: 1px solid var(--line); margin: 32px 0; }

/* ===== Header / nav ===== */
header {
  display: flex;
  align-items: baseline;
  gap: 32px;
  padding: 22px 40px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  background: rgba(255,255,255,0.92);
}
.brand a {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
  border-bottom: none;
}
.brand a:hover { border-bottom: none; }

nav {
  display: flex;
  gap: 28px;
  flex: 1;
  font-size: 14px;
}
nav a {
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.005em;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
}
nav a:hover { color: var(--ink); border-bottom-color: transparent; }
nav a.active { color: var(--ink); border-bottom: 1px solid var(--ink); }

.user { color: var(--muted); font-size: 13px; }
.user a { color: var(--muted); }

/* ===== Layout ===== */
main {
  max-width: 1080px;
  margin: 56px auto;
  padding: 0 40px 96px;
}

/* Editorial reading width — for /brief, /news, reports */
.prose {
  max-width: 680px;
}

/* ===== Tables — quiet, readable ===== */
table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0 28px;
  font-size: 14px;
}
th, td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  border-bottom: 1px solid var(--ink);
}
tr:hover td { background: var(--bg-soft); }
tr.inactive td { color: var(--muted-2); }
tr.inactive:hover td { background: transparent; }
td.notes { color: var(--muted); font-size: 13px; max-width: 380px; }
.scroll { overflow-x: auto; }

/* ===== Stat cards ===== */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0;
  margin: 24px 0 40px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.card {
  padding: 18px 20px;
  border-right: 1px solid var(--line);
}
.card:last-child { border-right: none; }
.card .num {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.card .lbl {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  margin-top: 4px;
}

/* ===== Forms ===== */
input[type=text], input[type=number], input[type=email],
input[type=search], select, textarea {
  font: inherit;
  font-size: 14px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--bg);
  color: var(--ink);
  transition: border-color 120ms ease;
}
textarea {
  width: 100%;
  font-family: var(--mono);
  font-size: 13px;
  padding: 14px 16px;
  resize: vertical;
  line-height: 1.55;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--ink);
}

button, .btn {
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  background: var(--ink);
  color: #fff;
  border: 1px solid var(--ink);
  padding: 9px 22px;
  border-radius: 3px;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
  letter-spacing: 0.005em;
}
button:hover, .btn:hover { background: #000; }
button.secondary {
  background: var(--bg);
  color: var(--ink);
}
button.secondary:hover { background: var(--bg-soft); }

.row {
  display: flex;
  gap: 16px;
  align-items: center;
  margin: 16px 0 28px;
}
.row label { font-size: 13px; color: var(--muted); }

/* ===== Status messages ===== */
.error { background: var(--error-bg); color: var(--error-fg); padding: 12px 16px; border-radius: 3px; margin: 14px 0; border-left: 3px solid var(--error-fg); }
.ok    { background: var(--ok-bg);    color: var(--ok-fg);    padding: 12px 16px; border-radius: 3px; margin: 14px 0; border-left: 3px solid var(--ok-fg); }
.warn  { background: var(--warn-bg);  color: var(--warn-fg);  padding: 14px 18px; border-radius: 3px; margin: 16px 0; border-left: 3px solid var(--warn-fg); }
.warn ol { margin: 8px 0; padding-left: 22px; }
.warn pre { font-size: 12px; }

.examples li { margin: 8px 0; }
.examples code { display: block; padding: 10px 12px; background: var(--bg-soft); }

/* ===== Markdown article ===== */
.markdown {
  max-width: 720px;
  font-size: 16px;
  line-height: 1.72;
}
.markdown h1:first-child { margin-top: 0; }
.markdown h2 { margin-top: 40px; }
.markdown table { font-size: 14px; }
.markdown blockquote {
  border-left: 2px solid var(--ink);
  margin: 18px 0;
  padding: 4px 0 4px 20px;
  color: var(--ink-soft);
  font-style: italic;
  font-family: var(--serif);
  font-size: 17px;
}
.markdown ul, .markdown ol { padding-left: 24px; }
.markdown li { margin: 6px 0; }

/* ===== Schema ===== */
.schema-table { margin-bottom: 40px; }
table.schema { font-size: 13px; }
.schema-overview ul li { margin: 8px 0; }

/* ===== Next steps ===== */
.next { margin: 28px 0 40px; }
.next h2 { margin-top: 0; }

/* ===== Login ===== */
body.login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}
.login-card {
  background: var(--bg);
  padding: 56px 56px;
  max-width: 480px;
  width: 100%;
  text-align: center;
}
.login-card h1 {
  font-family: var(--serif);
  font-size: 40px;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}
.login-card p { color: var(--muted); }
.btn-google {
  display: inline-block;
  background: var(--ink);
  color: #fff;
  padding: 12px 28px;
  border-radius: 3px;
  font-weight: 500;
  margin-top: 24px;
  border-bottom: none;
}
.btn-google:hover { background: #000; color: #fff; border-bottom: none; }

/* ===== Filter bar (analysis page) ===== */
.filter-bar {
  padding: 20px 0;
  margin: 8px 0 24px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px 18px;
}
.filter-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.filter-grid label.span-2 { grid-column: span 2; }
.filter-grid select,
.filter-grid input[type=text],
.filter-grid input[type=number] {
  padding: 6px 10px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: normal;
  font-size: 14px;
}

/* ===== Analysis table ===== */
table.analysis { font-size: 13.5px; }
table.analysis th { font-size: 10.5px; padding: 8px 8px; }
table.analysis td { padding: 8px 8px; }
table.analysis td.theme { color: var(--muted); max-width: 280px; font-size: 13px; }
table.analysis a.sortlink { color: var(--muted); text-transform: uppercase; }
table.analysis a.sortlink:hover { color: var(--ink); border-bottom-color: transparent; }
table.analysis tr:hover td { background: var(--bg-soft); }

.pagination { margin: 20px 0; color: var(--muted); font-size: 14px; }
.pagination a { margin-left: 14px; }

/* ===== Tags / chips ===== */
.tag {
  display: inline-block;
  padding: 3px 11px;
  border: 1px solid var(--line);
  border-radius: 14px;
  margin: 0 4px 4px 0;
  font-size: 12px;
  color: var(--ink-soft);
  background: var(--bg);
}

/* ===== Piece body — the reading experience ===== */
.piece-body {
  background: var(--bg);
  padding: 0;
  white-space: pre-wrap;
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.78;
  max-width: 640px;
  color: var(--ink);
  letter-spacing: 0.005em;
}

/* ===== Next-steps cards ===== */
.step {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}
.step:last-child { border-bottom: none; }
.step.completed { opacity: 0.45; }
.step.completed .step-title { text-decoration: line-through; }
.step input[type=checkbox] {
  margin-top: 6px;
  width: 18px; height: 18px;
  cursor: pointer;
  accent-color: var(--ink);
}
.step-body { flex: 1; }
.step-title { font-weight: 600; font-size: 15.5px; margin-bottom: 4px; font-family: var(--sans); }
.step-meta { color: var(--muted); font-size: 12px; margin-top: 8px; }
.step-body p { margin: 6px 0; font-size: 14.5px; }
.step-body pre { font-size: 12.5px; }

/* ===== Q&A chat ===== */
.qa-chat {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.qa-message {
  padding: 12px 16px;
  border-radius: 4px;
  max-width: 86%;
  white-space: pre-wrap;
  font-size: 14.5px;
  line-height: 1.6;
}
.qa-message.user {
  background: var(--ink);
  color: #fff;
  align-self: flex-end;
  border-radius: 12px 12px 2px 12px;
}
.qa-message.assistant {
  background: var(--bg-soft);
  align-self: flex-start;
  border: 1px solid var(--line);
  border-radius: 12px 12px 12px 2px;
}
.qa-form { display: flex; gap: 10px; margin-top: 16px; }
.qa-form input {
  flex: 1;
  padding: 11px 14px;
  font-size: 14.5px;
}

/* ===== Reports ===== */
.report-card {
  padding: 28px 0 36px;
  margin: 24px 0;
  border-bottom: 1px solid var(--line);
}
.report-card:last-child { border-bottom: none; }
.report-card header {
  border-bottom: none;
  padding-bottom: 8px;
  margin-bottom: 18px;
  background: transparent;
  position: static;
  backdrop-filter: none;
}
.report-card h2 {
  font-size: 28px;
  margin: 0;
  border-bottom: none;
  padding-bottom: 0;
}
.report-card h2 a { color: var(--ink); border-bottom: none; }
.report-card h2 a:hover { border-bottom: 1px solid var(--ink); }
.report-preview {
  max-height: 700px;
  overflow: hidden;
  position: relative;
  font-size: 16px;
  line-height: 1.72;
}
.report-preview::after {
  content: "";
  position: absolute; bottom: 0; left: 0; right: 0; height: 110px;
  background: linear-gradient(transparent, var(--bg));
  pointer-events: none;
}
.report-card { position: relative; }
.report-card::after {
  content: "Read full report →";
  display: block;
  text-align: center;
  padding: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

/* ===== Reading-status badges ===== */
.rs-badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 12px;
  white-space: nowrap;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.rs-not_read   { background: var(--bg-soft); color: var(--muted); border: 1px solid var(--line); }
.rs-visited    { background: #eef3ff; color: #2745a3; }
.rs-read       { background: var(--ok-bg);   color: var(--ok-fg); }
.rs-read_again { background: var(--warn-bg); color: var(--warn-fg); }

/* ============================================================
   News / blog — editorial layout
   ============================================================ */
.news-day { margin-top: 56px; }
.news-day:first-of-type { margin-top: 32px; }

.news-date {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin: 0 0 24px;
  padding: 0 0 14px;
  border-bottom: 1px solid var(--ink);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.news-date a { color: var(--ink); border-bottom: none; }
.news-date a:hover { color: var(--muted); }
.news-count {
  font-size: 11px;
  color: var(--muted-2);
  font-weight: 500;
  letter-spacing: 0.06em;
}

.news-entry {
  padding: 0 0 36px;
  margin-bottom: 36px;
  border-bottom: 1px solid var(--line-soft);
}
.news-entry:last-child { border-bottom: none; margin-bottom: 0; }

.news-entry h3 {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin: 0 0 10px;
}
.news-entry h3 a { color: var(--ink); border-bottom: none; }
.news-entry h3 a:hover { border-bottom: 1px solid var(--ink); }

.news-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 14px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.news-cat-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 2px 9px;
  border-radius: 12px;
  background: var(--bg-soft);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}

.news-summary {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.62;
  color: var(--ink-soft);
  margin: 0;
  max-width: 640px;
}

/* Subtle visual cues by category, no shouting */
.news-cat-db_update    .news-cat-badge { background: var(--ok-bg);    color: var(--ok-fg);    border-color: transparent; }
.news-cat-announcement .news-cat-badge { background: #eef3ff;          color: #2745a3;         border-color: transparent; }
.news-cat-awards       .news-cat-badge { background: var(--warn-bg);  color: var(--warn-fg);  border-color: transparent; }
.news-cat-craft        .news-cat-badge { background: #faf0ff;          color: #5a2a85;         border-color: transparent; }
.news-cat-submissions  .news-cat-badge { background: #f0fbfa;          color: #1f5f59;         border-color: transparent; }

/* Empty state */
.empty {
  padding: 56px 32px;
  border: 1px dashed var(--line);
  border-radius: 4px;
  color: var(--muted);
  text-align: center;
  margin-top: 32px;
  font-size: 15px;
}
.empty code { font-size: 13px; }

/* ===== Responsive ===== */
@media (max-width: 720px) {
  header { padding: 16px 22px; gap: 18px; flex-wrap: wrap; }
  nav { gap: 16px; font-size: 13.5px; flex-wrap: wrap; }
  main { margin: 32px auto; padding: 0 22px 64px; }
  h1 { font-size: 30px; }
  h2 { font-size: 19px; }
  .news-entry h3 { font-size: 19px; }
  .news-summary { font-size: 16px; }
  .filter-grid { grid-template-columns: 1fr 1fr; }
  .cards { grid-template-columns: 1fr 1fr; }
  .card { border-bottom: 1px solid var(--line); }
  .card:nth-child(2n) { border-right: none; }
}

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