@font-face {
  font-family: 'Public Sans';
  src: url('/fonts/PublicSans-Variable.ttf') format('truetype-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Geist Mono';
  src: url('/fonts/GeistMono-Variable.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}


:root {
  --bg-deep: #0A0B12;
  --bg-panel: #111220;
  --bg-card: #191A2C;
  --bg-hover: #21223A;
  --bg-input: #161728;
  --border: rgba(255,255,255,0.07);
  --border-strong: rgba(255,255,255,0.13);
  --border-focus: rgba(168,123,217,0.5);
  --ink: #F2EEE6;
  --ink-soft: rgba(242,238,230,0.82);
  --ink-muted: rgba(242,238,230,0.56);
  --ink-faint: rgba(242,238,230,0.32);
  --ink-trace: rgba(242,238,230,0.16);
  --eosin: #FF6E89;
  --eosin-soft: rgba(255,110,137,0.14);
  --amethyst: #A87BD9;
  --amethyst-soft: rgba(168,123,217,0.14);
  --gold: #E8C880;
  --gold-soft: rgba(232,200,128,0.12);
  --teal: #8BD3D0;
  --teal-soft: rgba(139,211,208,0.12);
  --green: #7BC88B;
  --green-soft: rgba(123,200,139,0.12);
  --red: #FF6B6B;
  --red-soft: rgba(255,107,107,0.12);
  --bronze: #CD7F32;
  --silver: #C0C0C0;
  --platinum: #E5E4E2;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 23.8px; }
html, body {
  background: var(--bg-deep); color: var(--ink);
  font-family: 'Public Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  height: 100%; overflow: hidden;
}
.mono { font-family: 'Geist Mono', monospace; }

.view { display: none; height: 100%; }
.view.active { display: flex; flex-direction: column; }

/* HOME */
#home { align-items: center; justify-content: center; position: relative; overflow: hidden; }
.orb { position: absolute; border-radius: 50%; pointer-events: none; filter: blur(1px); }
.orb-1 { width: 500px; height: 500px; background: radial-gradient(circle, rgba(168,123,217,0.08) 0%, transparent 70%); top: -100px; right: -100px; }
.orb-2 { width: 600px; height: 600px; background: radial-gradient(circle, rgba(255,110,137,0.06) 0%, transparent 70%); bottom: -150px; left: -100px; }
.orb-3 { width: 400px; height: 400px; background: radial-gradient(circle, rgba(232,200,128,0.04) 0%, transparent 70%); top: 40%; left: 50%; }

.home-content { position: relative; z-index: 1; width: 100%; max-width: 680px; padding: 2rem; text-align: center; }
.home-logo svg { width: 48px; height: 48px; }
.home-title {
  font-size: 2.2rem; font-weight: 800; letter-spacing: -0.03em; margin: 0.5rem 0 0.25rem;
  background: linear-gradient(135deg, var(--ink) 0%, var(--amethyst) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.home-subtitle { font-size: 0.9rem; color: var(--ink-muted); margin-bottom: 2.5rem; }

.search-container { position: relative; width: 100%; }
.search-bar {
  width: 100%; padding: 1rem 1.25rem 1rem 3rem; font-size: 1rem;
  font-family: 'Public Sans', sans-serif; background: var(--bg-panel);
  border: 1.5px solid var(--border-strong); border-radius: 16px;
  color: var(--ink); outline: none; transition: all 0.2s;
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
}
.search-bar::placeholder { color: var(--ink-faint); }
.search-bar:focus { border-color: var(--border-focus); box-shadow: 0 4px 24px rgba(0,0,0,0.3), 0 0 0 3px rgba(168,123,217,0.1); }
.search-icon { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--ink-faint); font-size: 1.1rem; pointer-events: none; }

.search-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--bg-panel); border: 1px solid var(--border-strong);
  border-radius: 12px; overflow: hidden; box-shadow: var(--shadow);
  display: none; z-index: 10; max-height: 400px; overflow-y: auto;
}
.search-dropdown.visible { display: block; }
.search-result {
  display: flex; align-items: center; gap: 0.85rem;
  padding: 0.75rem 1.1rem; cursor: pointer; transition: background 0.1s;
  border-bottom: 1px solid var(--border);
}
.search-result:last-child { border-bottom: none; }
.search-result:hover { background: var(--bg-hover); }
.sr-thumb { width: 38px; height: 38px; border-radius: 6px; flex-shrink: 0; border: 1px solid var(--border); overflow: hidden; }
.sr-info { flex: 1; min-width: 0; }
.sr-name { font-size: 0.85rem; font-weight: 500; }
.sr-meta { font-size: 0.7rem; color: var(--ink-muted); margin-top: 0.1rem; }

.upload-cta {
  margin-top: 2rem; display: inline-flex; align-items: center; gap: 0.6rem;
  padding: 0.65rem 1.4rem; border-radius: 12px;
  background: linear-gradient(135deg, rgba(168,123,217,0.15) 0%, rgba(255,110,137,0.1) 100%);
  border: 1px solid rgba(168,123,217,0.25); color: var(--amethyst);
  font-size: 0.8rem; font-weight: 500; cursor: pointer; transition: all 0.2s;
}
.upload-cta:hover { background: linear-gradient(135deg, rgba(168,123,217,0.22) 0%, rgba(255,110,137,0.15) 100%); transform: translateY(-1px); }

.home-stats { display: flex; gap: 2rem; justify-content: center; margin-top: 2.5rem; }
.stat-value { font-family: 'Geist Mono', monospace; font-size: 1.6rem; font-weight: 600; }
.stat-value.eosin { color: var(--eosin); }
.stat-value.amethyst { color: var(--amethyst); }
.stat-value.gold { color: var(--gold); }
.stat-label { font-size: 0.65rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); margin-top: 0.2rem; }

.organ-grid { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; margin-top: 2rem; }
.organ-pill {
  font-size: 0.7rem; padding: 0.4rem 0.85rem; border-radius: 20px;
  border: 1px solid var(--border); background: var(--bg-panel);
  color: var(--ink-muted); cursor: pointer; transition: all 0.15s;
  display: flex; align-items: center; gap: 0.4rem;
}
.organ-pill:hover { border-color: var(--border-strong); color: var(--ink-soft); background: var(--bg-hover); }
.organ-count { font-family: 'Geist Mono', monospace; font-size: 0.6rem; color: var(--ink-faint); }

/* BROWSER */
#browser { flex-direction: row; }

.top-bar {
  position: absolute; top: 0; left: 0; right: 0; height: 52px;
  background: var(--bg-panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 1.25rem; gap: 1rem; z-index: 5;
}
.back-btn {
  background: none; border: none; color: var(--ink-muted); font-size: 1.1rem;
  cursor: pointer; padding: 0.3rem; border-radius: 6px; transition: all 0.15s;
}
.back-btn:hover { color: var(--ink); background: rgba(255,255,255,0.05); }
.top-bar-title { font-size: 0.8rem; font-weight: 600; flex: 1; }
.top-search-wrap { position: relative; }
.top-search-wrap .si { position: absolute; left: 0.6rem; top: 50%; transform: translateY(-50%); color: var(--ink-faint); font-size: 0.8rem; pointer-events: none; }
.top-search {
  width: 220px; padding: 0.4rem 0.7rem 0.4rem 2rem; font-size: 0.78rem;
  font-family: 'Public Sans', sans-serif; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: 8px; color: var(--ink); outline: none;
}
.top-search::placeholder { color: var(--ink-faint); }
.top-search:focus { border-color: var(--border-focus); }

.list-panel {
  width: 340px; flex-shrink: 0; display: flex; flex-direction: column;
  border-right: 1px solid var(--border); padding-top: 52px; background: var(--bg-panel);
}
.list-header { padding: 0.85rem 1rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.list-organ-label { font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-muted); font-weight: 600; }
.list-count { font-family: 'Geist Mono', monospace; font-size: 0.75rem; color: var(--gold); }

.filter-row { display: flex; gap: 0.35rem; padding: 0.6rem 1rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.filter-pill {
  font-size: 0.6rem; padding: 0.25rem 0.6rem; border-radius: 16px;
  border: 1px solid var(--border); background: transparent;
  color: var(--ink-faint); cursor: pointer; transition: all 0.15s;
}
.filter-pill:hover { color: var(--ink-muted); border-color: var(--border-strong); }
.filter-pill.active { background: var(--amethyst-soft); border-color: var(--amethyst); color: var(--amethyst); }

.entry-list { flex: 1; overflow-y: auto; padding: 0.4rem; }
.entry-list::-webkit-scrollbar { width: 3px; }
.entry-list::-webkit-scrollbar-track { background: transparent; }
.entry-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }

.entry-row {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.55rem 0.65rem; border-radius: 8px;
  cursor: pointer; transition: all 0.12s; margin-bottom: 2px;
}
.entry-row:hover { background: var(--bg-hover); }
.entry-row.active { background: var(--bg-hover); box-shadow: inset 3px 0 0 var(--amethyst); }
.entry-row.unenc { opacity: 0.75; }

.e-thumb {
  width: 36px; height: 36px; border-radius: 5px; background: var(--bg-card);
  border: 1px solid var(--border); display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; overflow: hidden;
}
.e-thumb.caught { border-color: rgba(168,123,217,0.25); }
.e-info { flex: 1; min-width: 0; }
.e-num { font-family: 'Geist Mono', monospace; font-size: 0.55rem; color: var(--ink-faint); }
.e-name { font-size: 0.60rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-row.unenc .e-name { color: var(--ink-muted); }

.e-tier {
  font-size: 0.5rem; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 0.12rem 0.4rem; border-radius: 3px; font-weight: 600; flex-shrink: 0;
}
.t-disc { background: var(--green-soft); color: var(--green); }
.t-appr { background: rgba(205,127,50,0.15); color: var(--bronze); }
.t-adep { background: rgba(192,192,192,0.12); color: var(--silver); }
.t-expr { background: var(--gold-soft); color: var(--gold); }
.t-mast { background: rgba(229,228,226,0.12); color: var(--platinum); }
.t-none { background: rgba(255,255,255,0.04); color: var(--ink-faint); }

.e-dots { display: flex; gap: 2px; flex-shrink: 0; }
.e-dots span { width: 4px; height: 4px; border-radius: 50%; background: rgba(255,255,255,0.08); }
.e-dots span.f { background: var(--amethyst); }

/* DETAIL PANEL */
.detail-panel { flex: 1; padding-top: 52px; overflow-y: auto; display: flex; flex-direction: column; will-change: scroll-position; contain: layout style paint; }
.detail-panel::-webkit-scrollbar { width: 5px; }
.detail-panel::-webkit-scrollbar-track { background: transparent; }
.detail-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 3px; }

.hero {
  display: flex; gap: 1.75rem; padding: 1.75rem 2rem;
  background: linear-gradient(135deg, rgba(20,18,40,0.9) 0%, rgba(30,20,45,0.8) 50%, rgba(20,30,45,0.7) 100%);
  border-bottom: 1px solid var(--border);
}
.hero-img {
  width: 190px; height: 150px; border-radius: 10px; background: var(--bg-card);
  border: 2px solid rgba(168,123,217,0.2); overflow: hidden; flex-shrink: 0; position: relative; cursor: pointer;
}
.hero-img .photo-tag {
  position: absolute; bottom: 5px; right: 5px; font-size: 0.5rem;
  background: rgba(0,0,0,0.75); color: var(--ink-muted); padding: 0.12rem 0.35rem; border-radius: 3px;
}

.hero-right { flex: 1; display: flex; flex-direction: column; }
.hero-num { font-family: 'Geist Mono', monospace; font-size: 0.65rem; color: var(--ink-faint); margin-bottom: 0.2rem; }
.hero-name { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 0.15rem; }
.hero-desc { font-size: 0.82rem; color: var(--ink-muted); line-height: 1.45; margin-bottom: 0.85rem; }

.hero-bottom { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.5rem; }
.type-chips { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.tc { font-size: 0.55rem; letter-spacing: 0.07em; text-transform: uppercase; padding: 0.2rem 0.5rem; border-radius: 4px; font-weight: 600; }
.tc-neo { background: var(--eosin-soft); color: var(--eosin); }
.tc-epi { background: var(--amethyst-soft); color: var(--amethyst); }
.tc-mal { background: rgba(255,80,80,0.12); color: #FF6B6B; }
.tc-hy { background: var(--gold-soft); color: var(--gold); }
.tc-inf { background: var(--teal-soft); color: var(--teal); }
.tc-nor { background: var(--green-soft); color: var(--green); }

.hero-stains { display: flex; gap: 0.3rem; flex-wrap: wrap; justify-content: flex-end; flex-shrink: 0; }
.hs-label { font-size: 0.48rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-faint); width: 100%; text-align: right; margin-bottom: 0.1rem; }
.hs-chip {
  display: flex; align-items: center; gap: 0.35rem;
  padding: 0.18rem 0.5rem; background: rgba(255,255,255,0.04);
  border: 1px solid var(--border); border-radius: 4px;
  font-size: 0.62rem; color: var(--ink-soft); white-space: nowrap;
}
.hs-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.hs-primary { font-size: 0.42rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); margin-left: 0.15rem; }

/* Tabs */
.tabs {
  display: flex; border-bottom: 1px solid var(--border); padding: 0 2rem;
  background: var(--bg-panel); position: sticky; top: 0; z-index: 2;
}
.tab {
  padding: 0.7rem 0.9rem; font-size: 0.68rem; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--ink-faint); cursor: pointer;
  border-bottom: 2px solid transparent; transition: all 0.12s; white-space: nowrap;
}
.tab:hover { color: var(--ink-muted); }
.tab.active { color: var(--amethyst); border-bottom-color: var(--amethyst); }

.tab-content { display: none; padding: 1.5rem 2rem; }
.tab-content.active { display: block; }

/* FEATURES TAB */
.sec-title { font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-muted); margin-bottom: 0.65rem; font-weight: 600; }
.feat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; margin-bottom: 1.25rem; }

.feat-chip {
  display: flex; align-items: center; gap: 0.45rem;
  padding: 0.5rem 0.6rem; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer; transition: all 0.15s; position: relative;
}
.feat-chip:hover { border-color: var(--amethyst); background: var(--bg-hover); transform: translateY(-1px); }
.feat-chip.locked { opacity: 0.55; }
.feat-chip .f-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.feat-chip .f-dot.on { background: var(--green); }
.feat-chip .f-dot.off { background: var(--ink-trace); }
.feat-chip .f-name { font-size: 0.68rem; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feat-chip.locked .f-name { color: var(--ink-faint); font-style: italic; }
.feat-chip .f-arrow { font-size: 0.55rem; color: var(--ink-faint); margin-left: auto; flex-shrink: 0; }

.facts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem; }
.fact {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 7px; padding: 0.7rem 0.85rem;
}
.fact-label { font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--amethyst); font-weight: 600; margin-bottom: 0.2rem; }
.fact-val { font-size: 0.8rem; color: var(--ink-soft); line-height: 1.45; }
.fact { border-left: 3px solid var(--amethyst-soft); padding-left: 0.75rem; }

/* PATHOPHYSIOLOGY */
.patho-box {
  background: linear-gradient(135deg, rgba(168,123,217,0.06) 0%, rgba(139,211,208,0.04) 100%);
  border: 1px solid rgba(168,123,217,0.12); border-radius: 10px;
  padding: 1rem 1.2rem; margin: 0.8rem 0 1.2rem 0;
}
.patho-label {
  font-size: 0.6rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--amethyst); font-weight: 600; margin-bottom: 0.45rem;
  display: flex; align-items: center; gap: 0.4rem;
}
.patho-label svg { width: 14px; height: 14px; }
.patho-text { font-size: 0.82rem; color: var(--ink-soft); line-height: 1.65; }
.patho-text strong { color: var(--ink); font-weight: 600; }
.patho-analogy {
  margin-top: 0.6rem; padding: 0.6rem 0.8rem;
  background: rgba(232,200,128,0.06); border-left: 3px solid var(--gold);
  border-radius: 0 6px 6px 0; font-size: 0.78rem; color: var(--ink-muted); line-height: 1.55;
}
.patho-analogy::before { content: 'Think of it like: '; font-weight: 600; color: var(--gold); }

/* SAMPLE REPORT */
.report-box {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden;
}
.report-header {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.75rem 1rem; background: rgba(168,123,217,0.05);
  border-bottom: 1px solid var(--border);
}
.report-header-icon { font-size: 1rem; }
.report-header-title { font-size: 0.8rem; font-weight: 600; color: var(--ink); }
.report-header-type { font-size: 0.5rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--amethyst); background: var(--amethyst-soft); padding: 0.1rem 0.4rem; border-radius: 3px; margin-left: auto; }
.report-body { padding: 1rem 1.2rem; }
.report-section { margin-bottom: 0.8rem; }
.report-section:last-child { margin-bottom: 0; }
.report-field-label {
  font-size: 0.58rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--amethyst); font-weight: 600; margin-bottom: 0.15rem;
}
.report-field-val {
  font-size: 0.8rem; color: var(--ink-soft); line-height: 1.5;
  font-family: 'Geist Mono', monospace;
}
.report-field-val .clickable {
  color: var(--amethyst); cursor: pointer; text-decoration: underline;
  text-decoration-style: dotted; text-underline-offset: 2px;
}
.report-field-val .clickable:hover { color: var(--eosin); }
.report-divider { height: 1px; background: var(--border); margin: 0.6rem 0; }
.report-note {
  font-size: 0.68rem; color: var(--ink-faint); font-style: italic;
  margin-top: 0.5rem; line-height: 1.4;
}

/* QUESTS */
.quest-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.85rem; }
.quest-title {
  font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-muted); font-weight: 600; display: flex; align-items: center; gap: 0.5rem;
}
.quest-level {
  font-family: 'Geist Mono', monospace; font-size: 0.65rem; color: var(--gold);
  background: var(--gold-soft); padding: 0.2rem 0.5rem; border-radius: 4px;
}
.quest-xp-bar { height: 4px; background: rgba(255,255,255,0.06); border-radius: 2px; margin-bottom: 1rem; overflow: hidden; }
.quest-xp-fill { height: 100%; border-radius: 2px; background: linear-gradient(90deg, var(--amethyst), var(--gold)); transition: width 0.6s ease; }

.quest-list { display: flex; flex-direction: column; gap: 0.35rem; }
.quest-row {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.6rem 0.75rem; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer; transition: all 0.12s;
}
.quest-row:hover { border-color: var(--border-strong); }
.quest-row.done { opacity: 0.65; }
.q-check {
  width: 18px; height: 18px; border-radius: 4px;
  border: 1.5px solid var(--border-strong); display: flex;
  align-items: center; justify-content: center; flex-shrink: 0; font-size: 0.6rem;
}
.q-check.done { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.q-text { flex: 1; font-size: 0.78rem; color: var(--ink-soft); }
.quest-row.done .q-text { text-decoration: line-through; color: var(--ink-faint); }
.q-prog { font-family: 'Geist Mono', monospace; font-size: 0.65rem; color: var(--ink-faint); }
.q-prog.done { color: var(--green); }
.q-xp { font-family: 'Geist Mono', monospace; font-size: 0.55rem; color: var(--gold); background: var(--gold-soft); padding: 0.1rem 0.35rem; border-radius: 3px; }

/* DIFFERENTIALS TAB */
.diff-list { display: flex; flex-direction: column; gap: 0.75rem; }
.diff-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; transition: border-color 0.15s;
}
.diff-card:hover { border-color: var(--border-strong); }

.diff-header {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.85rem 1rem; border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.diff-header:hover { background: rgba(255,255,255,0.02); }
.diff-icon {
  width: 32px; height: 32px; border-radius: 6px;
  background: var(--eosin-soft); display: flex; align-items: center;
  justify-content: center; font-size: 0.8rem; flex-shrink: 0;
  color: var(--eosin);
}
.diff-title-area { flex: 1; }
.diff-name { font-size: 0.88rem; font-weight: 600; }
.diff-oneliner { font-size: 0.72rem; color: var(--ink-muted); margin-top: 0.1rem; }

.diff-body {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
}

.diff-col {
  padding: 0.85rem 1rem;
}
.diff-col-shared { border-right: 1px solid var(--border); }

.diff-col-label {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.55rem; letter-spacing: 0.1em; text-transform: uppercase;
  font-weight: 600; margin-bottom: 0.55rem;
}
.diff-col-label .dot-shared {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); flex-shrink: 0;
}
.diff-col-label .dot-tell {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--gold); flex-shrink: 0;
}
.diff-col-label.shared-label { color: var(--green); }
.diff-col-label.tell-label { color: var(--gold); }

.diff-items { display: flex; flex-direction: column; gap: 0.3rem; }
.diff-item {
  display: flex; align-items: flex-start; gap: 0.4rem;
  font-size: 0.76rem; color: var(--ink-soft); line-height: 1.4;
}
.diff-item .di-dot {
  width: 5px; height: 5px; border-radius: 50%;
  flex-shrink: 0; margin-top: 0.4rem;
}
.diff-item .di-dot.green { background: var(--green); }
.diff-item .di-dot.gold { background: var(--gold); }

/* IHC Panel in Differentials */
.diff-ihc {
  padding: 0.75rem 1rem; border-top: 1px solid var(--border);
  background: rgba(168,123,217,0.03);
}
.diff-ihc-title {
  font-size: 0.55rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--amethyst); font-weight: 600; margin-bottom: 0.5rem;
  display: flex; align-items: center; gap: 0.4rem;
}
.diff-ihc-title svg { width: 12px; height: 12px; }

.ihc-table { width: 100%; border-collapse: collapse; }
.ihc-table th {
  font-size: 0.52rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 600; padding: 0.3rem 0.5rem;
  text-align: left; border-bottom: 1px solid var(--border);
}
.ihc-table th.col-result { text-align: center; }
.ihc-table td {
  font-size: 0.72rem; padding: 0.35rem 0.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.ihc-table tr:last-child td { border-bottom: none; }
.ihc-table .stain-cell {
  font-weight: 500; color: var(--ink-soft); cursor: pointer;
  transition: color 0.12s;
}
.ihc-table .stain-cell:hover { color: var(--amethyst); text-decoration: underline; }
.ihc-table .result-cell { text-align: center; font-family: 'Geist Mono', monospace; font-size: 0.7rem; font-weight: 600; }
.ihc-table .r-pos { color: var(--green); }
.ihc-table .r-neg { color: var(--red); }
.ihc-table .r-var { color: var(--gold); }
.ihc-table .key-row td { background: rgba(168,123,217,0.06); }
.ihc-table .key-badge {
  font-size: 0.42rem; letter-spacing: 0.06em; text-transform: uppercase;
  background: var(--amethyst-soft); color: var(--amethyst);
  padding: 0.08rem 0.3rem; border-radius: 2px; margin-left: 0.3rem;
}

/* MODALS (shared) */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: none; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-overlay.visible { display: flex; }

/* FEATURE DETAIL MODAL */
.feat-modal {
  background: var(--bg-panel); border: 1px solid var(--border-strong);
  border-radius: 14px; width: 1040px; max-width: 95vw; max-height: 85vh;
  overflow-y: auto; box-shadow: 0 24px 80px rgba(0,0,0,0.5);
  will-change: scroll-position; contain: layout style paint;
}
.feat-modal::-webkit-scrollbar { width: 4px; }
.feat-modal::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }

.fm-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border);
}
.fm-title { font-size: 1.1rem; font-weight: 700; }
.fm-close {
  background: none; border: none; color: var(--ink-faint);
  font-size: 1.3rem; cursor: pointer; padding: 0.2rem 0.4rem;
  border-radius: 6px; transition: all 0.12s; line-height: 1;
}
.fm-close:hover { color: var(--ink); background: rgba(255,255,255,0.06); }

.fm-body { padding: 1.25rem 1.5rem; }
.fm-desc { font-size: 0.85rem; color: var(--ink-soft); line-height: 1.55; margin-bottom: 1.2rem; }

.fm-props { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-bottom: 1.2rem; }
.fm-prop {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 6px; padding: 0.6rem 0.75rem; border-left: 3px solid transparent;
}
.fm-prop[data-prop="shape"] { border-left-color: #E8C880; }
.fm-prop[data-prop="size"] { border-left-color: #8BD3D0; }
.fm-prop[data-prop="nucleus"] { border-left-color: #8B7CC8; }
.fm-prop[data-prop="cytoplasm"] { border-left-color: #FF6E89; }
.fm-prop[data-prop="membrane"] { border-left-color: #7EB8E0; }
.fm-prop[data-prop="chromatin"] { border-left-color: #6B5E9E; }
.fm-prop[data-prop="location"] { border-left-color: #9DD6A0; }
.fm-prop-label { font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 700; margin-bottom: 0.2rem; }
.fm-prop[data-prop="shape"] .fm-prop-label { color: #E8C880; }
.fm-prop[data-prop="size"] .fm-prop-label { color: #8BD3D0; }
.fm-prop[data-prop="nucleus"] .fm-prop-label { color: #8B7CC8; }
.fm-prop[data-prop="cytoplasm"] .fm-prop-label { color: #FF6E89; }
.fm-prop[data-prop="membrane"] .fm-prop-label { color: #7EB8E0; }
.fm-prop[data-prop="chromatin"] .fm-prop-label { color: #6B5E9E; }
.fm-prop[data-prop="location"] .fm-prop-label { color: #9DD6A0; }
.fm-prop-val { font-size: 0.78rem; color: var(--ink-soft); line-height: 1.4; }
.fm-prop-details { margin-top: 0.35rem; display: flex; flex-direction: column; gap: 0.25rem; }
.fm-detail {
  padding: 0.35rem 0.55rem; background: rgba(168,123,217,0.04);
  border-left: 2px solid var(--amethyst-soft); border-radius: 0 4px 4px 0;
}
.fm-detail-term { font-size: 0.72rem; font-weight: 600; color: var(--ink); margin-bottom: 0.1rem; }
.fm-detail-why { font-size: 0.7rem; color: var(--ink-muted); line-height: 1.45; }

.fm-section-title {
  font-size: 0.6rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-muted); margin: 1rem 0 0.5rem; font-weight: 600;
}

.fm-stain-row {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.4rem 0.65rem; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 5px; margin-bottom: 0.3rem;
}
.fm-stain-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.fm-stain-name { font-size: 0.75rem; font-weight: 500; width: 50px; }
.fm-stain-pat { font-size: 0.72rem; color: var(--ink-muted); flex: 1; }

.fm-photo-section { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.fm-photo-row { display: flex; gap: 0.5rem; align-items: center; }
.fm-photo-thumb {
  width: 60px; height: 48px; border-radius: 6px; background: var(--bg-card);
  border: 1px solid var(--border); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.fm-photo-thumb .empty { font-size: 0.6rem; color: var(--ink-faint); }
.fm-photo-status { font-size: 0.75rem; color: var(--ink-muted); }

.fm-capture-btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 1rem; border-radius: 8px;
  background: linear-gradient(135deg, rgba(168,123,217,0.2) 0%, rgba(255,110,137,0.12) 100%);
  border: 1px solid rgba(168,123,217,0.3); color: var(--amethyst);
  font-size: 0.78rem; font-weight: 500; cursor: pointer; transition: all 0.15s;
  font-family: 'Public Sans', sans-serif; margin-top: 0.6rem;
}
.fm-capture-btn:hover {
  background: linear-gradient(135deg, rgba(168,123,217,0.3) 0%, rgba(255,110,137,0.18) 100%);
  transform: translateY(-1px);
}

/* STAIN DETAIL MODAL */
.stain-modal {
  background: var(--bg-panel); border: 1px solid var(--border-strong);
  border-radius: 14px; width: 560px; max-height: 85vh;
  overflow-y: auto; box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}
.stain-modal::-webkit-scrollbar { width: 4px; }
.stain-modal::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }

.sm-header {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border);
}
.sm-header-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.sm-title { font-size: 1.1rem; font-weight: 700; flex: 1; }
.sm-type-badge {
  font-size: 0.5rem; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 0.15rem 0.5rem; border-radius: 3px; font-weight: 600;
}
.sm-type-ihc { background: var(--amethyst-soft); color: var(--amethyst); }
.sm-type-histo { background: var(--teal-soft); color: var(--teal); }
.sm-type-special { background: var(--gold-soft); color: var(--gold); }
.sm-type-if { background: var(--eosin-soft); color: var(--eosin); }

.sm-body { padding: 1.25rem 1.5rem; }

.sm-why {
  background: linear-gradient(135deg, rgba(168,123,217,0.08) 0%, rgba(139,211,208,0.06) 100%);
  border: 1px solid rgba(168,123,217,0.15); border-radius: 8px;
  padding: 0.85rem 1rem; margin-bottom: 1.2rem;
}
.sm-why-label {
  font-size: 0.52rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--amethyst); font-weight: 600; margin-bottom: 0.3rem;
}
.sm-why-text { font-size: 0.82rem; color: var(--ink-soft); line-height: 1.55; }

.sm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-bottom: 1rem; }
.sm-field {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 6px; padding: 0.6rem 0.75rem;
}
.sm-field.wide { grid-column: 1 / -1; }
.sm-field-label { font-size: 0.5rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 0.15rem; }
.sm-field-val { font-size: 0.78rem; color: var(--ink-soft); line-height: 1.4; }

.sm-perf {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem;
  margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border);
}
.sm-perf-item {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.7rem 0.85rem; text-align: center;
}
.sm-perf-value {
  font-family: 'Geist Mono', monospace; font-size: 1.2rem; font-weight: 700;
}
.sm-perf-value.high { color: var(--green); }
.sm-perf-value.med { color: var(--gold); }
.sm-perf-value.low { color: var(--eosin); }
.sm-perf-label { font-size: 0.5rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); margin-top: 0.15rem; }
.sm-perf-note { font-size: 0.65rem; color: var(--ink-muted); margin-top: 0.2rem; }

.sm-pitfalls {
  margin-top: 1rem; padding: 0.75rem 0.9rem;
  background: rgba(255,107,107,0.06); border: 1px solid rgba(255,107,107,0.12);
  border-radius: 7px;
}
.sm-pitfalls-label {
  font-size: 0.52rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--red); font-weight: 600; margin-bottom: 0.3rem;
}
.sm-pitfall-item { font-size: 0.75rem; color: var(--ink-soft); line-height: 1.45; margin-bottom: 0.25rem; }
.sm-pitfall-item:last-child { margin-bottom: 0; }

/* STAINS TAB (enhanced) */
.stain-list { display: flex; flex-direction: column; gap: 0.35rem; }
.stain-row {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.55rem 0.75rem; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer; transition: all 0.12s;
}
.stain-row:hover { border-color: var(--amethyst); background: var(--bg-hover); transform: translateY(-1px); }
.s-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.s-name { font-size: 0.78rem; font-weight: 500; min-width: 55px; }
.s-pat { font-size: 0.73rem; color: var(--ink-muted); flex: 1; }
.s-pri { font-size: 0.5rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); background: var(--gold-soft); padding: 0.1rem 0.35rem; border-radius: 3px; }
.s-arrow { font-size: 0.65rem; color: var(--ink-faint); flex-shrink: 0; }

.stain-why {
  font-size: 0.7rem; color: var(--ink-muted); line-height: 1.4;
  padding: 0.35rem 0.75rem 0.35rem 2.2rem;
  margin-top: -0.15rem; margin-bottom: 0.2rem;
}

/* Photos tab */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
.photo-card {
  border-radius: 8px; overflow: hidden; background: var(--bg-card);
  border: 1px solid var(--border); cursor: pointer; transition: all 0.15s;
}
.photo-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.pc-img { width: 100%; aspect-ratio: 4/3; }
.pc-meta { padding: 0.45rem 0.55rem; }
.pc-date { font-size: 0.6rem; color: var(--ink-faint); font-family: 'Geist Mono', monospace; }
.pc-variant { font-size: 0.68rem; color: var(--ink-muted); margin-top: 0.1rem; }
.photo-upload-btn {
  border: 2px dashed var(--border-strong); border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.3rem; cursor: pointer; aspect-ratio: 4/3; transition: all 0.15s; color: var(--ink-faint);
}
.photo-upload-btn:hover { border-color: var(--amethyst); color: var(--amethyst); background: rgba(168,123,217,0.05); }

.cx-toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%) translateY(1rem);
  padding: 0.6rem 1.2rem; border-radius: 8px; font-size: 0.8rem; font-weight: 500;
  color: var(--ink); background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(0,0,0,0.4); opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s; z-index: 9999;
}
.cx-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.cx-toast[data-tone="success"] { border-color: var(--teal); }
.cx-toast[data-tone="warn"] { border-color: var(--gold); }

/* INLINE EDIT SYSTEM */
[data-field] { position: relative; }
.edit-tools {
  position: absolute; top: 4px; right: 4px;
  display: flex; gap: 3px; z-index: 3;
}
.edit-btn {
  width: 28px; height: 28px; border-radius: 6px;
  border: 1px solid var(--border-strong); background: var(--bg-panel);
  color: var(--ink-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center; padding: 0;
  transition: all 0.12s;
}
.edit-btn:hover {
  color: var(--ink); background: var(--amethyst-soft);
  border-color: var(--amethyst);
}
.edit-btn:focus-visible { outline: 2px solid var(--amethyst); outline-offset: 1px; }
.edit-textarea {
  width: 100%; min-height: 60px; padding: 0.5rem;
  background: var(--bg-input); border: 1px solid var(--amethyst-soft);
  border-radius: 6px; color: var(--ink);
  font-family: 'Public Sans', sans-serif; font-size: 0.78rem;
  line-height: 1.55; resize: vertical;
}
.edit-textarea:focus { outline: none; border-color: var(--amethyst); }
.edit-actions { display: flex; gap: 6px; margin-top: 6px; align-items: center; }
.edit-save, .edit-cancel {
  padding: 4px 14px; border-radius: 5px;
  border: 1px solid var(--border); font-size: 0.65rem;
  cursor: pointer; font-family: inherit; transition: all 0.12s;
}
.edit-save {
  background: var(--amethyst); color: #fff; border-color: var(--amethyst);
}
.edit-save:hover { filter: brightness(1.15); }
.edit-cancel {
  background: transparent; color: var(--ink-muted);
}
.edit-cancel:hover { color: var(--ink); background: var(--bg-hover); }
.edit-badge {
  display: inline-block; font-size: 0.5rem; color: var(--amethyst);
  margin-left: 6px; text-transform: uppercase; letter-spacing: 0.08em;
  vertical-align: middle; font-weight: 600;
}
.edit-images {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px;
}
.edit-img-wrap {
  position: relative; border-radius: 6px; overflow: hidden;
  border: 1px solid var(--border);
}
.user-img {
  display: block; max-width: 220px; max-height: 160px;
  object-fit: cover; border-radius: 5px;
}
.edit-img-del {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0,0,0,0.7); border: none;
  color: #fff; font-size: 14px; line-height: 1;
  cursor: pointer; display: none;
  align-items: center; justify-content: center;
}
.edit-img-wrap:hover .edit-img-del { display: flex; }
.edit-img-del:hover { background: var(--red); }
