/* ========================================================================
   Learn — Craft-style KOL knowledge base
   Apple cream/paper aesthetic · SF Pro · soft shadows · spring motion
   ======================================================================== */

:root {
  /* Palette — paper white + Apple blue accent */
  --bg:        #f5f1ea;
  --bg-2:      #ebe6dc;
  --paper:     #fdfcf9;
  --paper-2:   #f9f6ef;
  --ink:       #1c1917;
  --ink-2:     #3c3530;
  --muted:     #807469;
  --muted-2:   #a8a092;
  --hair:      rgba(28, 25, 23, 0.08);
  --hair-2:    rgba(28, 25, 23, 0.04);
  --rule:      rgba(28, 25, 23, 0.06);

  --accent:    #0066cc;   /* Apple blue */
  --accent-2:  #004fa3;
  --accent-soft: rgba(0, 102, 204, 0.08);

  --star:      #d4a017;
  --warn:      #c5400a;
  --good:      #1f8a5b;
  --quote:     rgba(212, 160, 23, 0.10);

  /* Type */
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
             "Helvetica Neue", "PingFang SC", "HarmonyOS Sans SC",
             "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;

  --fs-reading: 17px;
  --lh-reading: 1.7;

  /* Geometry */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;

  /* Shadow — soft Craft style */
  --shadow-1: 0 1px 0 rgba(28,25,23,.04), 0 1px 2px rgba(28,25,23,.04);
  --shadow-2: 0 1px 0 rgba(28,25,23,.04), 0 6px 18px -6px rgba(28,25,23,.08), 0 2px 6px -2px rgba(28,25,23,.04);
  --shadow-3: 0 8px 30px -8px rgba(28,25,23,.18), 0 4px 12px -4px rgba(28,25,23,.10);
  --shadow-lift: 0 24px 60px -20px rgba(28,25,23,.30), 0 12px 24px -12px rgba(28,25,23,.15);

  /* Motion — Apple spring-ish */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --t-quick: 160ms;
  --t-base:  240ms;
  --t-slow:  420ms;
}

[data-theme="dark"] {
  --bg:        #14110e;
  --bg-2:      #1c1916;
  --paper:     #1f1c19;
  --paper-2:   #25221e;
  --ink:       #f5f1ea;
  --ink-2:     #d9d2c4;
  --muted:     #a8a092;
  --muted-2:   #6f665b;
  --hair:      rgba(245, 241, 234, 0.08);
  --hair-2:    rgba(245, 241, 234, 0.04);
  --rule:      rgba(245, 241, 234, 0.06);
  --accent:    #4a9eff;
  --accent-2:  #6ab1ff;
  --accent-soft: rgba(74, 158, 255, 0.12);
  --quote:     rgba(212, 160, 23, 0.14);
  --shadow-1: 0 1px 0 rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.2);
  --shadow-2: 0 1px 0 rgba(0,0,0,.3), 0 6px 18px -6px rgba(0,0,0,.5), 0 2px 6px -2px rgba(0,0,0,.3);
  --shadow-3: 0 8px 30px -8px rgba(0,0,0,.6), 0 4px 12px -4px rgba(0,0,0,.4);
  --shadow-lift: 0 24px 60px -20px rgba(0,0,0,.7), 0 12px 24px -12px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv11";
  min-height: 100vh;
  overflow-x: hidden;
}

button { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
::selection { background: var(--accent-soft); }

/* ---------- Layout ---------- */

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 32px 120px;
}

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.brand .logo {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600;
  align-self: center;
  transform: rotate(-3deg);
}
.brand .title {
  font-size: 19px;
  letter-spacing: -0.02em;
}
.brand .sub {
  color: var(--muted);
  font-size: 12.5px;
  letter-spacing: 0.02em;
  font-weight: 400;
}
.topbar-actions {
  margin-left: auto;
  display: flex; gap: 8px;
}
.icon-btn {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--hair);
  border-radius: 10px;
  cursor: pointer;
  color: var(--muted);
  transition: all var(--t-quick) var(--ease-out);
}
.icon-btn:hover {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--rule);
}
.icon-btn svg { width: 16px; height: 16px; }

/* ---------- KOL segmented control (wrap + search) ---------- */

.kol-wrap {
  margin-bottom: 24px;
}
.kol-search-row {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 10px;
}
.kol-search-box {
  flex: 1;
  position: relative;
  display: flex; align-items: center;
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: 10px;
  padding: 0 14px;
  height: 38px;
  transition: border-color var(--t-quick) var(--ease-out), box-shadow var(--t-quick) var(--ease-out);
}
.kol-search-box:focus-within {
  border-color: var(--accent, #0066cc);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.08);
}
.kol-search-box svg {
  width: 14px; height: 14px; color: var(--muted);
  flex-shrink: 0; margin-right: 8px;
}
.kol-search-input {
  flex: 1; border: none; outline: none;
  background: transparent; font-family: inherit;
  font-size: 13.5px; color: var(--ink);
}
.kol-search-input::placeholder { color: var(--muted-2); }
.kol-search-clear {
  background: transparent; border: none; cursor: pointer;
  color: var(--muted); font-size: 18px; line-height: 1;
  padding: 0 4px; opacity: 0; transition: opacity var(--t-quick);
}
.kol-search-box.has-value .kol-search-clear { opacity: 1; }
.kol-search-clear:hover { color: var(--ink); }
.kol-stat {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px; color: var(--muted);
  white-space: nowrap;
  padding: 4px 10px;
  background: var(--paper); border: 1px solid var(--hair);
  border-radius: 999px;
}

.kol-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  background: var(--paper);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  border: 1px solid var(--hair);
  position: relative;
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.kol-bar::-webkit-scrollbar { width: 6px; height: 6px; }
.kol-bar::-webkit-scrollbar-thumb { background: var(--hair); border-radius: 3px; }
.kol-pill {
  position: relative;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  line-height: 1.25;
  transition: color var(--t-quick) var(--ease-out), background var(--t-quick), border-color var(--t-quick), transform var(--t-quick);
  color: var(--muted);
  min-width: 0;
  max-width: 260px;
  flex: 0 0 auto;
}
.kol-pill .pn { font-weight: 600; font-size: 13px; letter-spacing: -0.005em; color: var(--ink-2); }
.kol-pill .pt {
  font-size: 11px; opacity: 0.8; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 220px;
}
.kol-pill:hover {
  background: var(--bg);
  border-color: var(--hair);
  transform: translateY(-1px);
}
.kol-pill:hover .pn { color: var(--ink); }
.kol-pill.active {
  background: var(--bg);
  border-color: var(--rule);
  box-shadow: var(--shadow-1), inset 0 0 0 0.5px var(--accent, #0066cc);
}
.kol-pill.active .pn { color: var(--accent, #0066cc); }
.kol-pill.active .pt { opacity: 1; color: var(--ink-2); }
.kol-pill.hidden { display: none; }
.kol-pill.match-highlight {
  background: rgba(212, 160, 23, 0.10);
  border-color: rgba(212, 160, 23, 0.25);
}
.kol-pill .pn mark, .kol-pill .pt mark {
  background: rgba(212, 160, 23, 0.30);
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
}
@keyframes pop-in {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

@media (max-width: 720px) {
  .kol-search-row { flex-direction: column; align-items: stretch; }
  .kol-stat { align-self: flex-end; }
  .kol-bar { max-height: 280px; }
  .kol-pill { max-width: 100%; flex: 1 1 calc(50% - 6px); }
  .kol-pill .pt { max-width: 100%; }
}

/* ---------- Section tabs ---------- */

.section-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--rule);
  overflow-x: auto;
  scrollbar-width: none;
}
.section-tabs::-webkit-scrollbar { display: none; }
.sec-tab {
  position: relative;
  padding: 14px 18px 16px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  white-space: nowrap;
  transition: color var(--t-quick) var(--ease-out);
  display: flex; align-items: center; gap: 8px;
}
.sec-tab:hover { color: var(--ink); }
.sec-tab.active { color: var(--ink); }
.sec-tab.active::after {
  content: "";
  position: absolute; left: 14px; right: 14px; bottom: -1px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px 2px 0 0;
}
.sec-tab .count {
  font-size: 11px;
  padding: 1px 7px;
  background: var(--bg-2);
  color: var(--muted);
  border-radius: 99px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.sec-tab.active .count {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------- Pane container ---------- */

.pane {
  display: none;
  animation: fade-in var(--t-base) var(--ease-out);
}
.pane.active { display: block; }
@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Section title block (used in each pane) ---------- */

.pane-head {
  margin-bottom: 28px;
}
.pane-head .eyebrow {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
}
.pane-head h2 {
  margin: 0 0 8px;
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.15;
}
.pane-head .lede {
  color: var(--muted);
  font-size: 15.5px;
  line-height: 1.55;
  max-width: 60ch;
}

/* ========================================================================
   PANE: Summary (一页提纲)
   ======================================================================== */

.summary-pane .summary-content {
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: var(--r-lg);
  padding: 48px 56px;
  box-shadow: var(--shadow-2);
  font-size: 16px;
  line-height: 1.7;
  color: var(--ink-2);
  max-width: 760px;
}
.summary-content h1 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0 0 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--rule);
}
.summary-content h2 {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin: 36px 0 12px;
  position: relative;
}
.summary-content h2::before {
  content: "";
  position: absolute;
  left: -20px;
  top: 0.55em;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.summary-content h3 { font-size: 15.5px; font-weight: 600; margin-top: 20px; }
.summary-content strong { color: var(--ink); font-weight: 600; }
.summary-content p { margin: 10px 0; }
.summary-content blockquote {
  margin: 16px 0;
  padding: 14px 20px;
  background: var(--quote);
  border-left: 3px solid var(--star);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: 14.5px;
}
.summary-content blockquote p { margin: 4px 0; }
.summary-content code {
  background: var(--bg-2);
  padding: 1px 7px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 0.88em;
  color: var(--ink-2);
}
.summary-content hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 28px 0;
}
.summary-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 14px;
}
.summary-content th, .summary-content td {
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--rule);
}
.summary-content th {
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--bg-2);
}

/* ========================================================================
   PANE: Bestiary (敌方图鉴) — restyle pre-rendered HTML
   ======================================================================== */

.bestiary-section { margin-bottom: 36px; }
.bestiary-section h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 600;
  margin: 0 0 14px;
}
.bestiary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.bestiary-card {
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: var(--r-md);
  padding: 22px 24px;
  box-shadow: var(--shadow-1);
  transition: all var(--t-base) var(--ease-out);
  position: relative;
  overflow: hidden;
}
.bestiary-card::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--c, var(--accent));
}
.bestiary-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
}
.bestiary-card .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--c, var(--accent));
  font-weight: 600;
  margin-bottom: 8px;
}
.bestiary-card .name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 10px;
  line-height: 1.3;
}
.bestiary-card .behavior {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink-2);
  margin-bottom: 12px;
}
.bestiary-card .warning {
  font-size: 12.5px;
  line-height: 1.55;
  padding: 10px 12px;
  background: rgba(197, 64, 10, 0.06);
  border-radius: var(--r-sm);
  color: var(--ink-2);
  margin-bottom: 10px;
}
.bestiary-card .warning strong { color: var(--warn); font-weight: 600; }
.bestiary-card .quote {
  font-size: 12.5px;
  font-style: italic;
  color: var(--muted);
  padding: 8px 0 0;
  border-top: 1px dashed var(--rule);
  line-height: 1.5;
}

/* ========================================================================
   PANE: Tactics (战术手册) & Counter-examples (反例库)
   ======================================================================== */

.tactic-section, .ce-section-group { margin-bottom: 28px; }
.tactic-section > h3, .ce-section-group > h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 600;
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}

.tactic-card, .ce-card {
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: var(--r-md);
  margin-bottom: 10px;
  box-shadow: var(--shadow-1);
  overflow: hidden;
  transition: box-shadow var(--t-quick) var(--ease-out);
}
.tactic-card[open], .ce-card[open] {
  box-shadow: var(--shadow-2);
}
.tactic-card > summary, .ce-card > summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 22px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
  font-size: 14.5px;
  letter-spacing: -0.005em;
  user-select: none;
  transition: background var(--t-quick) var(--ease-out);
}
.tactic-card > summary::-webkit-details-marker,
.ce-card > summary::-webkit-details-marker { display: none; }
.tactic-card > summary:hover, .ce-card > summary:hover { background: var(--paper-2); }
.tactic-card[open] > summary, .ce-card[open] > summary {
  border-bottom: 1px solid var(--rule);
  background: var(--paper-2);
}
.tac-stars, .ce-stars {
  color: var(--star);
  font-size: 11px;
  letter-spacing: 1px;
  flex-shrink: 0;
}
.tac-name, .ce-name { flex: 1; color: var(--ink); }
.tac-id {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 7px;
  background: var(--bg-2);
  color: var(--muted);
  border-radius: 5px;
  letter-spacing: 0;
}
.ce-sev {
  font-size: 9px;
  padding: 2px 7px;
  border-radius: 4px;
  color: var(--paper);
  font-weight: 700;
  letter-spacing: 0.5px;
}
.ce-sev-high   { background: #c5400a; }
.ce-sev-medium { background: #b78700; }
.ce-sev-low    { background: #807469; }
.ce-card[data-ce-sev="high"]   { border-left: 3px solid #c5400a; }
.ce-card[data-ce-sev="medium"] { border-left: 3px solid #b78700; }
.ce-card[data-ce-sev="low"]    { border-left: 3px solid #807469; }

.tac-body, .ce-body {
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--ink-2);
  animation: slide-down var(--t-base) var(--ease-out);
}
@keyframes slide-down {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.tac-oneliner {
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink);
  background: var(--accent-soft);
  padding: 12px 16px;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.tac-section h5, .ce-section h5 {
  font-size: 11px;
  color: var(--muted);
  margin: 0 0 6px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
}
.tac-section ul, .ce-section ul { margin: 0; padding-left: 18px; }
.tac-section li, .ce-section li { margin-bottom: 5px; }
.tac-section code, .ce-section code {
  font-size: 12px;
  padding: 1px 6px;
  background: var(--bg-2);
  border-radius: 4px;
  font-family: var(--font-mono);
}
.tac-grid, .ce-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.tac-plug {
  border-top: 1px dashed var(--rule);
  padding-top: 12px;
  margin-top: 4px;
}
.tac-plug summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
}
.tac-plug pre {
  background: var(--bg-2);
  padding: 12px 14px;
  border-radius: var(--r-sm);
  font-size: 11.5px;
  overflow-x: auto;
  font-family: var(--font-mono);
  margin: 8px 0 0;
  max-height: 320px;
  overflow-y: auto;
  line-height: 1.5;
}
.ce-wrong {
  background: rgba(197, 64, 10, 0.05);
  border-left: 3px solid var(--warn);
  padding: 10px 14px;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.ce-right {
  background: rgba(31, 138, 91, 0.05);
  border-left: 3px solid var(--good);
  padding: 10px 14px;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.ce-quote blockquote {
  margin: 0;
  padding: 10px 14px;
  background: var(--bg-2);
  border-left: 3px solid var(--muted-2);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-style: italic;
  color: var(--ink-2);
  font-size: 12.5px;
}
.ce-inval {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 3px 8px;
  margin: 2px 4px 2px 0;
  background: var(--bg-2);
  border: 1px dashed var(--rule);
  border-radius: 4px;
  color: var(--ink-2);
}
.ce-invals { display: flex; flex-wrap: wrap; gap: 4px; }

/* ========================================================================
   PANE: Tweets (推文流)
   ======================================================================== */

.controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 24px;
  padding: 18px 20px;
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.search-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.search-box {
  flex: 1;
  position: relative;
}
.search-box svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--muted);
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 11px 16px 11px 40px;
  border: 1px solid var(--hair);
  background: var(--bg);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  transition: all var(--t-quick) var(--ease-out);
}
.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  background: var(--paper);
}
.search-input::placeholder { color: var(--muted-2); }

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.chip-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
  margin-right: 4px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: var(--bg);
  border: 1px solid var(--hair);
  border-radius: 99px;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
  transition: all var(--t-quick) var(--ease-out);
  user-select: none;
  letter-spacing: -0.005em;
}
.chip:hover { background: var(--paper-2); color: var(--ink); }
.chip.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.chip .emoji { font-size: 12px; }
.chip .count {
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  opacity: 0.6;
  margin-left: 2px;
}
.chip.theme-chip.active { background: var(--c, var(--ink)); border-color: var(--c, var(--ink)); }
.chip.star-chip { color: var(--star); }
.chip.star-chip.active { background: var(--star); color: var(--paper); border-color: var(--star); }

.toggle-row {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 12.5px;
  color: var(--muted);
  flex-wrap: wrap;
}
.toggle-row label {
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer;
}
.toggle-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border: 1.5px solid var(--muted-2);
  border-radius: 4px;
  cursor: pointer;
  position: relative;
  transition: all var(--t-quick) var(--ease-out);
}
.toggle-row input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.toggle-row input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 3px; top: 0px;
  width: 4px; height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.stat {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.stat .num { color: var(--ink); font-weight: 600; }

.btn-text {
  background: transparent; border: none;
  color: var(--muted); cursor: pointer; font-size: 12.5px;
  padding: 4px 8px; border-radius: 6px;
  transition: all var(--t-quick) var(--ease-out);
}
.btn-text:hover { background: var(--bg-2); color: var(--ink); }

.sort-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg);
  border: 1px solid var(--hair);
  border-radius: 8px;
  padding: 6px 28px 6px 10px;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path d='M3 4.5l3 3 3-3' fill='none' stroke='%23807469' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
}

/* Tweet cards */
.tweet-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.tweet-card {
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: var(--r-md);
  padding: 26px 32px;
  box-shadow: var(--shadow-1);
  cursor: pointer;
  transition: all var(--t-base) var(--ease-out);
  position: relative;
  animation: tweet-in var(--t-base) var(--ease-out) both;
}
@keyframes tweet-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.tweet-card:hover {
  box-shadow: var(--shadow-3);
  transform: translateY(-1px);
  border-color: var(--rule);
}
.tweet-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.tweet-meta .stars { color: var(--star); letter-spacing: 1px; font-size: 11px; }
.tweet-meta .dot { width: 2px; height: 2px; background: var(--muted-2); border-radius: 50%; }
.tweet-meta .date { font-variant-numeric: tabular-nums; }
.tweet-meta .type-pill {
  font-size: 10.5px;
  padding: 1px 7px;
  background: var(--bg-2);
  color: var(--muted);
  border-radius: 4px;
  letter-spacing: 0.02em;
}
.tweet-meta .contrarian {
  font-size: 10.5px;
  padding: 1px 7px;
  background: rgba(197, 64, 10, 0.08);
  color: var(--warn);
  border-radius: 4px;
}
.tweet-meta .bookmark {
  margin-left: auto;
  background: transparent; border: none; cursor: pointer;
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px;
  color: var(--muted-2);
  transition: all var(--t-quick) var(--ease-out);
}
.tweet-meta .bookmark:hover { background: var(--bg-2); color: var(--ink); }
.tweet-meta .bookmark.on { color: var(--star); }
.tweet-meta .bookmark svg { width: 14px; height: 14px; }

.tweet-text {
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink);
  white-space: pre-wrap;
  word-wrap: break-word;
  letter-spacing: -0.005em;
}
.tweet-text mark {
  background: var(--quote);
  color: var(--ink);
  padding: 1px 2px;
  border-radius: 2px;
}
.tweet-card.long .tweet-text {
  max-height: 6.5em;
  overflow: hidden;
  position: relative;
  -webkit-mask-image: linear-gradient(to bottom, #000 60%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 60%, transparent 100%);
}

.tweet-insight {
  margin-top: 18px;
  padding: 14px 18px;
  background: var(--accent-soft);
  border-radius: var(--r-sm);
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink-2);
}
.tweet-insight .label {
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 5px;
  display: block;
}

.tweet-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}
.tag-mini {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--bg-2);
  color: var(--muted);
  border-radius: 99px;
  letter-spacing: -0.005em;
}
.tag-mini.theme {
  background: color-mix(in oklab, var(--c) 12%, transparent);
  color: var(--c);
}

.tweet-footer {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.tweet-footer .read-more {
  margin-left: auto;
  color: var(--accent);
  display: inline-flex; align-items: center; gap: 4px;
  font-weight: 500;
  font-size: 12px;
}

.context-quote {
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--bg-2);
  border-left: 2px solid var(--muted-2);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}
.context-quote .ctx-author {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 500;
}

.load-more {
  display: flex; justify-content: center;
  margin: 24px 0;
}
.load-more button {
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: 99px;
  padding: 10px 24px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  box-shadow: var(--shadow-1);
  transition: all var(--t-quick) var(--ease-out);
}
.load-more button:hover {
  box-shadow: var(--shadow-2);
  transform: translateY(-1px);
}
.empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--muted);
}
.empty .em {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.4;
}

/* ========================================================================
   Reading mode (immersive fullscreen)
   ======================================================================== */

.reader {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 100;
  overflow-y: auto;
  display: none;
}
.reader.open {
  display: block;
  animation: reader-in var(--t-slow) var(--ease-out);
}
@keyframes reader-in {
  from { opacity: 0; transform: scale(1.02); }
  to { opacity: 1; transform: scale(1); }
}
.reader.closing {
  animation: reader-out var(--t-base) var(--ease-out) forwards;
}
@keyframes reader-out {
  to { opacity: 0; transform: scale(0.98); }
}
.reader-head {
  position: sticky; top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--rule);
  z-index: 10;
}
.reader-head .crumbs {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--muted);
}
.reader-head .crumbs .author { color: var(--ink); font-weight: 500; }
.reader-head .actions { display: flex; gap: 8px; }

.reader-body {
  max-width: 720px;
  margin: 0 auto;
  padding: 60px 32px 160px;
  font-size: var(--fs-reading);
  line-height: var(--lh-reading);
  color: var(--ink-2);
  animation: reader-body-in var(--t-slow) var(--ease-out) 80ms both;
}
@keyframes reader-body-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.reader-meta {
  display: flex; gap: 12px; align-items: center;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 28px;
}
.reader-meta .stars { color: var(--star); letter-spacing: 1px; }
.reader-quote {
  font-size: calc(var(--fs-reading) + 9px);
  line-height: 1.5;
  letter-spacing: -0.018em;
  color: var(--ink);
  font-weight: 400;
  margin: 0 0 40px;
  white-space: pre-wrap;
  position: relative;
}
.reader-quote::before {
  content: "“";
  position: absolute;
  left: -0.55em;
  top: -0.35em;
  font-size: 2.6em;
  line-height: 1;
  color: var(--star);
  font-family: Georgia, serif;
  opacity: 0.7;
}

.reader-insight {
  background: var(--paper);
  border: 1px solid var(--hair);
  border-left: 4px solid var(--accent);
  border-radius: var(--r-md);
  padding: 28px 32px;
  margin: 32px 0;
  box-shadow: var(--shadow-2);
}
.reader-insight .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px;
}
.reader-insight .body {
  font-size: calc(var(--fs-reading) + 1px);
  line-height: 1.65;
  color: var(--ink);
}
.reader-takeaway {
  background: rgba(31, 138, 91, 0.05);
  border-left: 4px solid var(--good);
  border-radius: var(--r-md);
  padding: 24px 28px;
  margin: 24px 0;
}
.reader-takeaway .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--good);
  font-weight: 700;
  margin-bottom: 10px;
}

.reader-section {
  margin: 32px 0;
}
.reader-section h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 600;
  margin: 0 0 14px;
}
.reader-section .content {
  font-size: var(--fs-reading);
  line-height: var(--lh-reading);
  color: var(--ink-2);
}
.reader-tags {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 12px 0;
}
.reader-tags .tag-mini {
  background: var(--paper);
  border: 1px solid var(--hair);
  font-size: 12px;
  padding: 4px 10px;
}
.reader-foot {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 60px; padding-top: 24px;
  border-top: 1px solid var(--rule);
  font-size: 12.5px; color: var(--muted);
  flex-wrap: wrap; gap: 12px;
}
.reader-nav {
  display: flex; gap: 10px;
}
.reader-nav button {
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: 99px;
  padding: 8px 18px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all var(--t-quick) var(--ease-out);
}
.reader-nav button:hover {
  box-shadow: var(--shadow-1);
  transform: translateY(-1px);
}
.reader-nav button:disabled { opacity: 0.35; cursor: not-allowed; }

.kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 5px;
  background: var(--bg-2);
  border: 1px solid var(--rule);
  border-radius: 4px;
  color: var(--muted);
}

/* ========================================================================
   Tweaks panel
   ======================================================================== */

.tweaks-panel {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 320px;
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lift);
  padding: 18px 20px;
  z-index: 200;
  display: none;
  animation: tweaks-in var(--t-base) var(--ease-spring);
}
.tweaks-panel.open { display: block; }
@keyframes tweaks-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.tweaks-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
}
.tweaks-head h3 {
  margin: 0; font-size: 14px; font-weight: 600;
}
.tweaks-head .close {
  background: transparent; border: none; cursor: pointer;
  width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted); border-radius: 6px;
}
.tweaks-head .close:hover { background: var(--bg-2); color: var(--ink); }
.tweak-group { margin-bottom: 16px; }
.tweak-group:last-child { margin-bottom: 0; }
.tweak-group .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
}
.tweak-seg {
  display: flex;
  background: var(--bg);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.tweak-seg button {
  flex: 1;
  padding: 6px 8px;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  transition: all var(--t-quick) var(--ease-out);
}
.tweak-seg button:hover { color: var(--ink); }
.tweak-seg button.active {
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow-1);
}
.tweak-swatches {
  display: flex; gap: 8px;
}
.tweak-swatch {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid var(--paper);
  box-shadow: 0 0 0 1px var(--hair);
  cursor: pointer;
  transition: all var(--t-quick) var(--ease-out);
}
.tweak-swatch.active {
  transform: scale(1.1);
  box-shadow: 0 0 0 2px var(--accent);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--paper);
  padding: 10px 18px;
  border-radius: 99px;
  font-size: 13px;
  box-shadow: var(--shadow-3);
  opacity: 0;
  transition: all var(--t-base) var(--ease-spring);
  pointer-events: none;
  z-index: 300;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Loading ---------- */
.loader {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
  transition: opacity var(--t-slow) var(--ease-out);
}
.loader.hide { opacity: 0; pointer-events: none; }
.loader .dot {
  width: 10px; height: 10px;
  background: var(--ink);
  border-radius: 50%;
  margin: 0 4px;
  animation: bounce 1.2s var(--ease-in-out) infinite;
}
.loader .dot:nth-child(2) { animation-delay: 0.15s; }
.loader .dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.3; }
  40% { transform: translateY(-12px); opacity: 1; }
}

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .app { padding: 20px 16px 100px; }
  .pane-head h2 { font-size: 26px; }
  .summary-pane .summary-content { padding: 28px 22px; }
  .summary-content h2::before { display: none; }
  .reader-body { padding: 40px 20px 100px; }
  .reader-quote { font-size: 22px; }
  .reader-quote::before { display: none; }
  .reader-head { padding: 14px 18px; }
  .tac-grid, .ce-grid { grid-template-columns: 1fr; }
  .bestiary-grid { grid-template-columns: 1fr; }
  .tweet-card { padding: 22px; }
  .tweaks-panel {
    left: 16px; right: 16px; width: auto;
  }
  .brand .sub { display: none; }
}
