:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --panel-soft: #f9fbfc;
  --ink: #17202c;
  --muted: #667085;
  --line: #d9e0e8;
  --soft-line: #edf1f5;
  --green: #136f63;
  --green-soft: #e4f2ef;
  --blue: #275f9f;
  --blue-soft: #e7f0fb;
  --gold: #8a5a00;
  --gold-soft: #fff3d8;
  --red: #a33a3a;
  --red-soft: #fde9e8;
  --shadow: 0 16px 44px rgba(23, 32, 44, .08);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, #e9f1ee 0, #f5f7f8 260px),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 11px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
}

button:hover {
  border-color: #98a8ba;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

.app-shell {
  width: min(1560px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 42px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: start;
  margin-bottom: 16px;
}

.eyebrow,
.section-kicker {
  display: block;
  margin: 0 0 7px;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  max-width: 920px;
  margin-bottom: 0;
  font-size: clamp(34px, 4.8vw, 58px);
  line-height: 1;
  letter-spacing: 0;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 650px;
}

.site-nav a {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, .84);
  text-decoration: none;
  font-size: 13px;
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 12px;
  margin-bottom: 12px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
}

.stat,
.quick-panel,
.control-surface,
.mode-tabs,
.left-panel,
.map-card,
.cards-card,
.practice-view,
.right-panel,
.lookup-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.stat {
  min-height: 74px;
  padding: 12px;
}

.stat strong {
  display: block;
  font-size: 23px;
  line-height: 1.05;
}

.stat span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.quick-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.quick-panel strong {
  display: block;
  font-size: 18px;
}

.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.control-surface {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 180px 130px 160px 132px auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  box-shadow: var(--shadow);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
}

.toggle-row input {
  width: 16px;
  min-height: 16px;
}

.reset-button {
  min-width: 74px;
}

.mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
  padding: 10px;
}

.mode-tabs button.active {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-soft);
  font-weight: 900;
}

.match-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
}

.learning-layout {
  display: grid;
  grid-template-columns: 285px minmax(0, 1fr) 400px;
  gap: 14px;
  align-items: start;
  margin-top: 14px;
}

.left-panel,
.right-panel {
  position: sticky;
  top: 14px;
  max-height: calc(100vh - 28px);
  overflow: hidden;
}

.center-panel {
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
  padding: 13px 15px;
  background: var(--panel-soft);
}

.panel-head h2 {
  margin: 0;
  font-size: 17px;
}

.panel-note {
  color: var(--muted);
  font-size: 12px;
}

.module-nav {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 88px);
  overflow: auto;
  padding: 12px;
}

.module-group {
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.module-group.active {
  border-color: rgba(19, 111, 99, .45);
  box-shadow: 0 0 0 2px rgba(19, 111, 99, .1);
}

.module-button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 54px;
  border: 0;
  border-radius: 0;
  text-align: left;
}

.module-button span:first-child {
  display: grid;
  gap: 3px;
}

.module-button small {
  color: var(--muted);
  font-size: 12px;
}

.module-picks {
  display: grid;
  gap: 6px;
  padding: 0 10px 10px;
}

.module-picks button {
  min-height: 30px;
  border-radius: 999px;
  padding: 5px 9px;
  overflow-wrap: anywhere;
  text-align: left;
  font-size: 13px;
}

.count-pill,
.category-badge,
.level-badge,
.master-badge {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.count-pill,
.category-badge {
  color: var(--green);
  background: var(--green-soft);
}

.level-badge {
  color: var(--blue);
  background: var(--blue-soft);
}

.master-badge {
  color: var(--gold);
  background: var(--gold-soft);
}

.map-card,
.cards-card,
.practice-view {
  overflow: hidden;
  margin-bottom: 14px;
}

.zoom-controls {
  display: flex;
  gap: 8px;
}

.zoom-controls button {
  min-width: 42px;
}

.graph-viewport {
  height: 355px;
  overflow: hidden;
  background:
    linear-gradient(#edf1f5 1px, transparent 1px),
    linear-gradient(90deg, #edf1f5 1px, transparent 1px),
    #fbfcfe;
  background-size: 28px 28px;
}

.graph-stage {
  position: relative;
  width: 100%;
  height: 100%;
  transform-origin: center;
}

.relation-svg,
.graph-nodes {
  position: absolute;
  inset: 0;
}

.relation-svg line {
  stroke: #9eafc2;
  stroke-width: 1.5;
}

.relation-svg text {
  fill: #667085;
  font-size: 11px;
}

.graph-node {
  position: absolute;
  display: grid;
  gap: 4px;
  width: min(170px, 26vw);
  min-height: 60px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(23, 32, 44, .08);
  text-align: left;
  transform: translate(-50%, -50%);
}

.graph-node.center {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(19, 111, 99, .13), 0 10px 24px rgba(23, 32, 44, .1);
}

.graph-node strong {
  overflow-wrap: anywhere;
  font-size: 15px;
}

.graph-node span {
  color: var(--muted);
  font-size: 12px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
}

.node-card {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 9px;
  min-height: 168px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  text-align: left;
}

.node-card.active {
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(19, 111, 99, .12);
}

.node-card h3 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 18px;
  line-height: 1.14;
}

.node-card p {
  margin: 0;
  color: #475467;
  font-size: 13px;
  line-height: 1.42;
}

.meta-row,
.card-foot,
.related-chips,
.practice-actions,
.step-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.card-foot {
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.card-foot strong {
  color: var(--green);
}

.detail-content {
  max-height: calc(100vh - 88px);
  overflow: auto;
  padding: 14px;
}

.detail-title {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.detail-title h3 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 28px;
  line-height: 1.05;
}

.detail-block {
  border-top: 1px solid var(--soft-line);
  padding: 12px 0;
}

.detail-block h4 {
  margin: 0 0 8px;
  color: #344054;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.detail-block p,
.detail-block li {
  color: #475467;
  line-height: 1.55;
}

.detail-block p {
  margin-bottom: 0;
}

.detail-block ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 20px;
}

.example-list {
  display: grid;
  gap: 9px;
}

.example-list p {
  display: grid;
  gap: 3px;
  border-left: 3px solid var(--green-soft);
  padding-left: 10px;
}

.example-list strong {
  color: var(--ink);
}

.example-list span,
.muted {
  color: var(--muted);
}

.related-chips button {
  min-height: 30px;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 13px;
}

.primary-action {
  width: 100%;
  border-color: var(--green);
  color: #fff;
  background: var(--green);
  font-weight: 900;
}

.learning-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.practice-title {
  display: grid;
  gap: 9px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel-soft);
}

.practice-title h3 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: clamp(30px, 4vw, 50px);
  line-height: 1;
}

.practice-title p {
  margin: 0;
  color: var(--muted);
}

.step-strip span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--muted);
  background: #fff;
  font-size: 12px;
  font-weight: 800;
}

.step-strip span.active {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-soft);
}

.prompt-block {
  border: 1px dashed #a7b6c7;
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfe;
}

.practice-actions {
  padding-top: 2px;
}

.flashcard {
  display: grid;
  gap: 12px;
  min-height: 340px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  padding: 22px;
  background: var(--panel-soft);
}

.flashcard > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.flashcard h3 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: clamp(38px, 6vw, 72px);
  line-height: 1;
}

.flashcard p {
  margin: 0;
  color: #475467;
  font-size: 17px;
  line-height: 1.55;
}

.flashcard.revealed {
  background: #fff;
}

.context-sentence {
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  padding: 20px;
  background: #fff;
  font-size: clamp(24px, 3.5vw, 38px);
  line-height: 1.25;
}

.context-translation {
  margin: 0;
  color: #475467;
  font-size: 17px;
}

.lookup-results {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.lookup-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.lookup-card h3 {
  margin: 8px 0 5px;
  overflow-wrap: anywhere;
  font-size: 20px;
}

.lookup-card p {
  margin: 0 0 5px;
  color: #475467;
}

.lookup-card small {
  color: var(--muted);
  line-height: 1.45;
}

.empty-state {
  border: 1px dashed #b7c4d1;
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  background: #fbfcfe;
  line-height: 1.6;
}

mark {
  border-radius: 3px;
  padding: 0 2px;
  color: inherit;
  background: #fff0ad;
}

@media (max-width: 1320px) {
  .stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .dashboard,
  .learning-layout,
  .topbar {
    grid-template-columns: 1fr;
  }

  .site-nav {
    justify-content: flex-start;
    max-width: none;
  }

  .left-panel,
  .right-panel {
    position: static;
    max-height: none;
  }

  .module-nav,
  .detail-content {
    max-height: none;
  }

  .module-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .app-shell {
    width: min(100% - 24px, 780px);
    padding-top: 16px;
  }

  .control-surface {
    grid-template-columns: 1fr 1fr;
  }

  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  h1 {
    font-size: 34px;
  }

  .dashboard,
  .stats,
  .control-surface,
  .card-grid,
  .module-nav,
  .lookup-card {
    grid-template-columns: 1fr;
  }

  .quick-actions {
    grid-template-columns: 1fr 1fr;
  }

  .match-count {
    width: 100%;
    margin-left: 0;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .graph-viewport {
    height: 310px;
  }

  .graph-node {
    width: 132px;
  }

  .context-sentence {
    font-size: 24px;
  }
}
