/* ==========================================================================
   ZHIYAO (PETER) XU — PERSONAL WEBSITE DESIGN SYSTEM
   Craft & Anti-Slop Principles (@charles.unemployed / Emil Kowalski / Rauno):
   - 60-30-10 Functional Color Allocation:
     60% Canvas (--bg), 30% Surface & Ink (--surface, --ink), 10% Action (--accent)
   - Nested border-radius math: r_inner = r_outer - padding (16px - 6px = 10px)
   - Proportional sans-serif for all prose; monospace strictly for code/metrics
   - Tabular numerals (tabular-nums) on all counters, dates, and telemetry
   - Balanced headlines (text-wrap: balance) & WCAG AAA text contrast
   - Tactile paper grain & blueprint square-dot background texture
   ========================================================================== */

:root,
[data-theme="light"] {
  --bg: #F4F1EA;
  --bg-elevated: #FAF8F3;
  --surface: #EDE8DF;
  --surface-hover: #E4DECFE0;
  --ink: #141413;
  --ink-secondary: #3F3E3A;
  --ink-muted: #6E6C65;
  --border: rgba(20, 20, 19, 0.11);
  --border-strong: rgba(20, 20, 19, 0.22);
  --accent: #FF4D1F;
  --accent-hover: #E03D12;
  --accent-soft: rgba(255, 77, 31, 0.12);
  --emerald: #17804D;
  --emerald-soft: rgba(23, 128, 77, 0.12);
  --amber: #B45309;
  --amber-soft: rgba(180, 83, 9, 0.12);
  --grid-dot: rgba(20, 20, 19, 0.08);
  --shadow-subtle: 0 1px 2px rgba(20, 20, 19, 0.04), 0 8px 24px rgba(20, 20, 19, 0.04);
}

[data-theme="dark"] {
  --bg: #0E0E10;
  --bg-elevated: #151518;
  --surface: #1C1C21;
  --surface-hover: #25252C;
  --ink: #F4F1EA;
  --ink-secondary: #C8C4BC;
  --ink-muted: #8E8B82;
  --border: rgba(244, 241, 234, 0.11);
  --border-strong: rgba(244, 241, 234, 0.24);
  --accent: #FF4D1F;
  --accent-hover: #FF663D;
  --accent-soft: rgba(255, 77, 31, 0.16);
  --emerald: #25D162;
  --emerald-soft: rgba(37, 209, 98, 0.15);
  --amber: #FFB020;
  --amber-soft: rgba(255, 176, 32, 0.15);
  --grid-dot: rgba(244, 241, 234, 0.07);
  --shadow-subtle: 0 2px 4px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  transition: background-color 220ms cubic-bezier(0.22, 1, 0.36, 1),
              color 220ms cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
  overflow-x: hidden;
}

/* Tactile Background Recipe: Square-dot blueprint grid + subtle paper grain */
.canvas-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: radial-gradient(var(--grid-dot) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: radial-gradient(ellipse 90% 80% at 50% 15%, #000 55%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 90% 80% at 50% 15%, #000 55%, transparent 100%);
}

.paper-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.028;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Typography & Utility Rules */
h1, h2, h3, h4 {
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.18;
  text-wrap: balance;
}

p {
  color: var(--ink-secondary);
}

.tabular {
  font-variant-numeric: tabular-nums;
}

.mono-meta,
.mono-label,
.mono-val {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  letter-spacing: -0.01em;
}

.mono-meta {
  color: var(--ink-muted);
}

.mono-val {
  color: var(--ink);
  font-weight: 500;
}

/* Consistent 1.75px Icon System (Rule #12) */
.icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Optical Centering for Play Triangle (Rule #17) */
.icon-play-tri {
  transform: translateX(1.5px);
}

/* Header & Navigation */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 700;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: -0.04em;
  position: relative;
}

.brand-mark::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name {
  font-weight: 600;
  font-size: 0.92rem;
}

.brand-meta {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.7rem;
  color: var(--ink-muted);
}

.nav-pill-track {
  position: relative;
  display: inline-flex;
  align-items: center;
  background: var(--surface);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.nav-pill-indicator {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: 88px;
  border-radius: 8px; /* r_inner (8) = r_outer (12) - padding (4) */
  background: var(--bg-elevated);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1),
              width 260ms cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.nav-link {
  position: relative;
  z-index: 1;
  text-decoration: none;
  color: var(--ink-secondary);
  font-size: 0.84rem;
  font-weight: 500;
  padding: 0.36rem 0.85rem;
  border-radius: 8px;
  transition: color 160ms ease;
}

.nav-link:hover,
.nav-link.active {
  color: var(--ink);
}

.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.control-btn,
.cmd-trigger {
  height: 34px;
  padding: 0 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 150ms ease, transform 150ms ease, background-color 150ms ease;
}

.control-btn:hover,
.cmd-trigger:hover {
  border-color: var(--border-strong);
  background: var(--surface);
}

.control-btn:active,
.cmd-trigger:active {
  transform: scale(0.97);
}

[data-theme="light"] .icon-moon {
  display: none;
}
[data-theme="dark"] .icon-sun {
  display: none;
}

/* Main Layout Container */
.main-container {
  position: relative;
  z-index: 1;
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 1.5rem 6rem;
}

/* Hero Section: Asymmetric 60 / 40 Split (Rule #7) */
.hero-section {
  padding: 4.5rem 0 4rem;
  border-bottom: 1px solid var(--border);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 3.5rem;
  align-items: center;
}

.meta-line {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 1.1rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.hero-headline {
  font-size: clamp(2.15rem, 3.8vw, 3.25rem);
  margin-bottom: 1.25rem;
  letter-spacing: -0.035em;
}

.hero-lead {
  font-size: 1.06rem;
  max-width: 62ch;
  margin-bottom: 1.85rem;
  color: var(--ink-secondary);
}

/* Buttons — Spend the 10% Action Color Once per Viewport (Rule #10 & #11) */
.hero-cta-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 2.5rem;
}

.btn-primary,
.btn-secondary {
  height: 42px;
  padding: 0 1.15rem;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  transition: transform 150ms cubic-bezier(0.22, 1, 0.36, 1),
              background-color 150ms ease,
              border-color 150ms ease;
}

.btn-primary {
  background: var(--accent);
  color: #FFFFFF;
  border: 1px solid var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-primary:active,
.btn-secondary:active {
  transform: scale(0.98);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--ink);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover {
  background: var(--surface);
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border);
}

.metric-item dt {
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  margin-bottom: 0.25rem;
}

.metric-item dd {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink);
}

/* Hero Right Console: Nested Radius Mathematics (Outer 16px - Padding 6px = Inner 10px, Rule #14) */
.console-outer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 6px;
  box-shadow: var(--shadow-subtle);
}

.console-inner {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
}

.console-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-bottom: 0.9rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.console-tabs {
  display: inline-flex;
  background: var(--surface);
  padding: 3px;
  border-radius: 8px;
}

.console-tab {
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-family: inherit;
  font-size: 0.74rem;
  font-weight: 500;
  padding: 0.28rem 0.6rem;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}

.console-tab.active {
  background: var(--bg-elevated);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.telemetry-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 0;
  font-size: 0.82rem;
  border-bottom: 1px dashed var(--border);
}

.telemetry-key {
  color: var(--ink-secondary);
}

.waveform-live {
  margin: 1rem 0;
  padding: 0.85rem;
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.wave-bars {
  height: 44px;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 0.6rem;
}

.wave-bar {
  flex: 1;
  background: var(--ink);
  border-radius: 2px;
  height: 25%;
  transition: height 240ms cubic-bezier(0.22, 1, 0.36, 1), background-color 200ms ease;
}

.wave-bar.highlight {
  background: var(--accent);
}

.wave-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mini-action-btn {
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--ink);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.7rem;
  padding: 0.2rem 0.55rem;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 140ms ease;
}

.mini-action-btn:hover {
  background: var(--accent);
  color: #FFF;
  border-color: var(--accent);
}

.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  padding-top: 0.5rem;
}

.tel-stat {
  display: flex;
  flex-direction: column;
}

.tel-label {
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.tel-num {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
}

.pipeline-steps {
  margin-top: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.pipe-node {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
  background: var(--surface);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.74rem;
}

.pipe-node.active-node {
  border-left: 3px solid var(--accent);
}

.console-note {
  font-size: 0.83rem;
  margin: 0.85rem 0;
  padding: 0.65rem;
  background: var(--surface);
  border-radius: 6px;
}

/* Section Layout */
.section-block {
  padding: 4.5rem 0;
  border-bottom: 1px solid var(--border);
}

.section-header-split {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 2.25rem;
  flex-wrap: wrap;
}

.section-title {
  font-size: clamp(1.55rem, 2.5vw, 2rem);
  margin-bottom: 0.5rem;
}

.section-subtitle {
  max-width: 65ch;
  font-size: 0.98rem;
}

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--ink);
  font-weight: 500;
  font-size: 0.9rem;
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--ink);
  transition: color 150ms ease, border-color 150ms ease;
}

.link-arrow:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* LangoLango Interactive Workbench (Outer 16px - Padding 6px = Inner 10px) */
.lango-workbench-outer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 6px;
  box-shadow: var(--shadow-subtle);
  margin-bottom: 3rem;
}

.lango-workbench-inner {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.workbench-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 1rem;
}

.workbench-tabs {
  display: inline-flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.wb-tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-secondary);
  font-family: inherit;
  font-size: 0.83rem;
  font-weight: 500;
  padding: 0.42rem 0.8rem;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  transition: all 150ms ease;
}

.wb-tab:hover {
  color: var(--ink);
  background: color-mix(in srgb, var(--bg-elevated) 60%, transparent);
}

.wb-tab.active {
  background: var(--bg-elevated);
  color: var(--ink);
  border-color: var(--border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.wb-badge {
  background: var(--accent-soft);
  color: var(--accent);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.05rem 0.42rem;
  border-radius: 99px;
}

.workbench-lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.passage-btn {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--ink-secondary);
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 500;
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
}

.passage-btn.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.wb-panel {
  padding: 1.75rem;
}

/* Reader Mode */
.reader-layout {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 2rem;
  align-items: start;
}

.article-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}

.reader-instruction {
  font-size: 0.84rem;
  color: var(--ink-muted);
  margin-bottom: 1.15rem;
}

.reading-passage {
  font-size: 1.08rem;
  line-height: 1.85;
  color: var(--ink);
  padding: 1.35rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.interactive-word {
  display: inline;
  padding: 0.08rem 0.3rem;
  margin: 0 1px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--ink);
  border-bottom: 1.5px solid var(--accent);
  cursor: pointer;
  font-weight: 500;
  transition: background-color 140ms ease, color 140ms ease;
}

.interactive-word:hover,
.interactive-word.selected {
  background: var(--accent);
  color: #FFFFFF;
}

/* Word Inspector */
.word-inspector {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.35rem;
}

.inspector-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.85rem;
}

.inspector-word {
  font-size: 1.45rem;
  margin: 0.15rem 0;
}

.mastery-pill {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  background: var(--amber-soft);
  color: var(--amber);
}

.mastery-pill.saved {
  background: var(--emerald-soft);
  color: var(--emerald);
}

.inspector-def {
  font-size: 0.94rem;
  margin-bottom: 1rem;
  color: var(--ink);
}

.inspector-context-box {
  padding: 0.75rem;
  background: var(--surface);
  border-radius: 6px;
  margin-bottom: 1.1rem;
}

.inspector-quote {
  font-size: 0.84rem;
  margin-top: 0.25rem;
  color: var(--ink-secondary);
}

.inspector-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-action-save {
  flex: 1;
  height: 38px;
  border-radius: 7px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--bg);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 140ms ease, background-color 140ms ease;
}

.btn-action-save.is-saved {
  background: var(--emerald);
  border-color: var(--emerald);
  color: #FFFFFF;
}

.btn-icon-speak {
  width: 38px;
  height: 38px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Mode 2: Spaced Repetition Flashcard Stage */
.srs-layout {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 2rem;
  align-items: center;
}

.flashcard-3d {
  position: relative;
  min-height: 215px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 1.35rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1), border-color 160ms ease;
  user-select: none;
}

.flashcard-3d:hover {
  border-color: var(--ink);
}

.flashcard-back {
  display: none;
}

.flashcard-3d.flipped .flashcard-front {
  display: none;
}

.flashcard-3d.flipped .flashcard-back {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 170px;
}

.fc-header,
.fc-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.fc-center {
  margin: 1.25rem 0;
}

.fc-term {
  font-size: 1.85rem;
  margin-bottom: 0.25rem;
}

.fc-meaning {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 0.5rem;
}

.fc-example {
  font-size: 0.86rem;
  color: var(--ink-muted);
}

.srs-grade-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  margin-top: 1rem;
}

.grade-btn {
  padding: 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  transition: transform 140ms ease, border-color 140ms ease, background-color 140ms ease;
}

.grade-btn:hover {
  border-color: var(--ink);
  background: var(--surface);
}

.grade-btn:active {
  transform: scale(0.96);
}

.grade-name {
  font-size: 0.82rem;
  font-weight: 600;
}

.grade-int {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.7rem;
  color: var(--ink-muted);
}

.srs-telemetry {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.35rem;
}

.srs-side-title {
  font-size: 1rem;
  margin-bottom: 0.35rem;
}

.srs-side-desc {
  font-size: 0.84rem;
  margin-bottom: 1rem;
}

.mastery-bar-stack {
  height: 10px;
  border-radius: 99px;
  background: var(--surface);
  overflow: hidden;
  display: flex;
  margin-bottom: 1rem;
}

.m-seg {
  height: 100%;
  transition: width 300ms ease;
}

.m-mastered {
  background: var(--emerald);
}
.m-known {
  background: var(--ink);
}
.m-learning {
  background: var(--accent);
}

.mastery-legend {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 1rem;
  font-size: 0.84rem;
}

.mastery-legend li {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dot-legend {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.5rem;
}

.dot-mastered { background: var(--emerald); }
.dot-known { background: var(--ink); }
.dot-learning { background: var(--accent); }

.srs-toast {
  padding: 0.55rem 0.75rem;
  background: var(--surface);
  border-radius: 6px;
}

/* Mode 3: Dictation */
.player-controls {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.9rem 1.1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1.25rem;
}

.play-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #FFFFFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.dict-waveform {
  flex: 1;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 3px;
}

.speed-pill,
.loop-pill {
  height: 30px;
  padding: 0 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--ink);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.74rem;
  cursor: pointer;
}

.loop-pill[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
}

.dict-input-row {
  display: flex;
  gap: 0.65rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.dict-input {
  flex: 1;
  min-width: 240px;
  height: 42px;
  padding: 0 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.92rem;
}

.dict-diff-output {
  margin-top: 0.85rem;
  font-size: 0.9rem;
  min-height: 1.5rem;
}

.diff-ok {
  color: var(--emerald);
  font-weight: 600;
}

.diff-miss {
  color: var(--accent);
  text-decoration: underline;
}

/* Study Notes Grid — Grouped by Generous Spacing, Not Heavy Boxes (Rule #8) */
.study-notes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2.75rem;
  padding-top: 1rem;
}

.study-note-title {
  font-size: 1.08rem;
  margin: 0.45rem 0 0.55rem;
}

.study-note-body {
  font-size: 0.92rem;
}

/* Experience Section */
.filter-pills {
  display: inline-flex;
  background: var(--surface);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
  gap: 4px;
}

.filter-btn {
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
}

.filter-btn.active {
  background: var(--bg-elevated);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.experience-list {
  display: flex;
  flex-direction: column;
}

.exp-item {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 2.5rem;
  padding: 2.25rem 0;
  border-top: 1px solid var(--border);
}

.exp-meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.exp-company {
  font-weight: 600;
  font-size: 1.02rem;
  color: var(--ink);
}

.exp-role {
  font-size: 1.2rem;
  margin-bottom: 0.45rem;
}

.exp-summary {
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

.exp-bullets {
  padding-left: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 1.25rem;
  color: var(--ink-secondary);
  font-size: 0.92rem;
}

.exp-bullets strong {
  color: var(--ink);
  font-weight: 600;
}

.tech-tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.tech-tag {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.73rem;
  padding: 0.22rem 0.6rem;
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink-secondary);
  border: 1px solid var(--border);
}

/* Research & Hawkes Simulator */
.research-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 2rem;
  align-items: start;
}

.hawkes-card-outer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 6px;
}

.hawkes-card-inner {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
}

.hawkes-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.hawkes-title {
  font-size: 1.22rem;
  margin-top: 0.2rem;
}

.hawkes-desc {
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

.hawkes-plot-wrap {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem;
  margin-bottom: 1.25rem;
}

.hawkes-svg {
  width: 100%;
  height: 175px;
  display: block;
}

.hawkes-plot-legend {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
}

.hawkes-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.slider-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.slider-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--ink-secondary);
}

input[type="range"] {
  accent-color: var(--accent);
  width: 100%;
  cursor: pointer;
}

.research-side-stack {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.research-item-card {
  padding: 1.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.research-card-title {
  font-size: 1.1rem;
  margin: 0.35rem 0 0.55rem;
}

.research-card-body {
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* Education & Stack */
.edu-honors-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3.5rem;
  margin-top: 2rem;
}

.sub-heading {
  font-size: 1.05rem;
  margin-bottom: 1.15rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.honors-heading {
  margin-top: 2.25rem;
}

.degree-list {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.degree-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.25rem;
}

.degree-name {
  font-size: 1rem;
}

.degree-detail {
  font-size: 0.88rem;
}

.honors-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.honors-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.92rem;
}

.stack-groups {
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

.stack-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Connect & Social Directory */
.connect-section {
  border-bottom: none;
}

.connect-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 3.5rem;
  align-items: start;
}

.connect-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.social-directory {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
}

.social-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--ink);
  transition: padding-left 160ms cubic-bezier(0.22, 1, 0.36, 1), color 160ms ease;
}

.social-row:hover {
  padding-left: 0.9rem;
  color: var(--accent);
}

.social-platform {
  display: block;
  font-weight: 600;
  font-size: 0.96rem;
}

.social-arrow {
  font-family: "JetBrains Mono", monospace;
  font-size: 1rem;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  position: relative;
  z-index: 1;
}

.footer-inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

kbd {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
}

/* Command Palette Modal */
.cmd-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(14, 14, 16, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 14vh;
}

.cmd-backdrop[hidden] {
  display: none;
}

.cmd-modal {
  width: 100%;
  max-width: 540px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

.cmd-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}

.cmd-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
}

.cmd-esc {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  cursor: pointer;
}

.cmd-list {
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cmd-item {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.88rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  text-align: left;
}

.cmd-item:hover,
.cmd-item:focus {
  background: var(--surface);
  outline: none;
}

/* Responsive Breakpoints */
@media (max-width: 960px) {
  .hero-grid,
  .reader-layout,
  .srs-layout,
  .research-grid,
  .edu-honors-grid,
  .connect-grid {
    grid-template-columns: 1fr;
  }

  .study-notes-grid {
    grid-template-columns: 1fr;
    gap: 1.75rem;
  }

  .exp-item {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .site-nav {
    display: none;
  }
}


/* Hospital research and application work share one project entry. */
.research-contribution-label {
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 600;
  margin: 1.1rem 0 0.4rem;
}
.hospital-system-contribution {
  border-top: 1px solid var(--border);
}
.hospital-system-contribution .research-card-body {
  font-size: 1rem;
}
.section-block { scroll-margin-top: 6rem; }

/* Short, bounded transitions preserve the page's editorial rhythm. */
@keyframes panel-enter {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: no-preference) {
  .wb-panel:not([hidden]), .console-body:not([hidden]),
  .cmd-backdrop:not([hidden]) .cmd-modal {
    animation: panel-enter 220ms cubic-bezier(0.22, 1, 0.36, 1);
  }
  .flashcard-3d.flipped .flashcard-back {
    animation: panel-enter 180ms ease-out;
  }
  .btn-primary, .btn-secondary, .control-btn, .cmd-trigger,
  .btn-action-save, .btn-icon-speak, .play-btn {
    transition: transform 180ms ease, background-color 180ms ease, border-color 180ms ease;
  }
  .nav-link::after {
    content: "";
    position: absolute;
    left: 0.8rem;
    right: 0.8rem;
    bottom: 0.25rem;
    height: 1px;
    background: currentColor;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 180ms ease;
  }
  .nav-link:hover::after, .nav-link:focus-visible::after { transform: scaleX(1); }
}
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .btn-primary:hover, .btn-secondary:hover, .control-btn:hover,
  .cmd-trigger:hover, .btn-action-save:hover, .btn-icon-speak:hover, .play-btn:hover {
    transform: translateY(-2px);
  }
  .btn-primary:active, .btn-secondary:active, .control-btn:active,
  .cmd-trigger:active, .btn-action-save:active, .btn-icon-speak:active, .play-btn:active {
    transform: translateY(0);
  }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  body, .nav-pill-indicator, .wave-bar, .m-seg, .flashcard-3d,
  .grade-btn, .social-row, .btn-primary, .btn-secondary, .btn-action-save {
    transition: none;
  }
  .grade-btn:active, .btn-primary:active, .btn-secondary:active { transform: none; }
  .social-row:hover { padding-left: 0.5rem; }
}
:where(a, button, input):focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
}

/* Let content wrap instead of forcing narrow screens wider than the viewport. */
.hero-grid > *, .reader-layout > *, .srs-layout > *, .research-grid > *,
.edu-honors-grid > *, .connect-grid > *, .research-side-stack { min-width: 0; }
@media (max-width: 600px) {
  .header-inner { height: auto; min-height: 64px; padding: 0.65rem 1rem; flex-wrap: wrap; gap: 0.65rem; }
  .brand { gap: 0.5rem; }
  .brand-mark, .header-actions { flex-shrink: 0; }
  .main-container { padding-inline: 1rem; }
  .hero-section { padding-top: 2.5rem; }
  .hero-metrics { grid-template-columns: 1fr; gap: 1rem; }
  .console-header, .wave-caption, .hawkes-header, .player-controls { flex-wrap: wrap; }
  .telemetry-row { align-items: flex-start; gap: 0.75rem; }
  .telemetry-val { text-align: right; overflow-wrap: anywhere; }
  .filter-pills { flex-wrap: wrap; }
  .wb-panel, .research-item-card, .hawkes-card-inner { padding: 1rem; }
  .hawkes-controls { grid-template-columns: 1fr; }
  .dict-input { min-width: 0; width: 100%; flex-basis: 100%; }
  .dict-waveform { flex-basis: calc(100% - 54px); }
  .btn-primary, .btn-secondary { height: auto; min-height: 42px; padding-block: 0.6rem; overflow-wrap: anywhere; }
  .degree-top { flex-wrap: wrap; gap: 0.25rem; }
  .research-card-body { font-size: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  .control-btn, .cmd-trigger { transition: none; }
  .control-btn:active, .cmd-trigger:active { transform: none; }
}
