:root {
  --bg-main: #f3efe5;
  --bg-branch: #fbfaf5;
  --surface: #ffffff;
  --surface-soft: #f8f5ec;
  --ink: #1d1c18;
  --ink-2: #403e36;
  --ink-3: #716d60;
  --ink-4: #a19b8b;
  --rule: #e5dec9;
  --rule-strong: #d2c8ad;
  --accent: #347a52;
  --accent-deep: #23573a;
  --accent-soft: #e6f1e9;
  --blue: #3d6ea8;
  --blue-soft: #e8f0fa;
  --yellow: #9b6b16;
  --yellow-soft: #fbf0d8;
  --purple: #7756a8;
  --purple-soft: #f0e8fb;
  --shadow: 0 14px 36px rgba(29, 28, 24, 0.12);
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg-main);
  color: var(--ink);
  font-family: var(--sans);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 270px minmax(420px, 36%) minmax(0, 1fr);
  min-height: 100%;
}

.forest-rail,
.trunk,
.branch-area {
  height: 100vh;
  overflow: hidden;
}

.forest-rail {
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-right: 1px solid var(--rule-strong);
  background: #eee8dc;
  padding: 18px 14px;
}

.trunk {
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  border-right: 1px solid var(--rule-strong);
}

.branch-area {
  display: flex;
  flex-direction: column;
  background: var(--bg-branch);
}

.forest-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
}

.forest-brand div {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.forest-brand strong {
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1;
}

.forest-brand span:not(.brand-mark) {
  color: var(--ink-3);
  font-size: 12px;
}

.new-root-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 800;
}

.new-root-button:hover {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
}

.forest-search {
  display: flex;
  align-items: center;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.forest-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.forest-search input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  padding: 9px 0 9px 10px;
  font-size: 13px;
}

.forest-section-label {
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.forest-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.clear-forest-button {
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--surface);
}

.forest-list {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow: auto;
}

.forest-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  overflow: hidden;
}

.forest-item:hover,
.forest-item.active {
  border-color: var(--accent);
  background: var(--surface);
}

.forest-load {
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 10px 11px;
  text-align: left;
}

.forest-load:hover {
  background: var(--surface-soft);
}

.forest-topic,
.forest-stats {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.forest-topic {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.forest-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  color: var(--ink-3);
  font-size: 11px;
  line-height: 1.3;
}

.forest-stats span {
  flex: 0 0 auto;
}

.forest-actions {
  display: grid;
  grid-template-columns: 28px;
  border-left: 1px solid var(--rule);
}

.forest-empty {
  margin: 0;
  border: 1px dashed var(--rule-strong);
  border-radius: 8px;
  color: var(--ink-3);
  padding: 12px;
  font-size: 13px;
  line-height: 1.45;
}

.forest-insights {
  border-top: 1px solid var(--rule-strong);
  padding-top: 12px;
}

.insight-stats {
  display: grid;
  gap: 6px;
  margin-top: 6px;
}

.insight-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--ink-3);
  font-size: 12px;
}

.insight-row strong {
  color: var(--ink);
  font-size: 13px;
}

.insight-due {
  color: var(--yellow) !important;
}

.blind-spots {
  margin-top: 10px;
  border-top: 1px dashed var(--rule);
  padding-top: 8px;
}

.blind-label {
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 700;
}

.blind-item {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  color: var(--ink-2);
  font-size: 12px;
}

.blind-item small {
  color: #9a3a28;
  font-weight: 700;
}

.forest-review {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  border: 0;
  border-top: 1px solid var(--rule-strong);
  background: transparent;
  color: var(--ink-3);
  padding-top: 12px;
  font-size: 13px;
  text-align: left;
}

.forest-review:hover {
  color: var(--ink);
}

.forest-review strong {
  color: var(--ink);
}

.topbar {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--rule);
}

.root-label {
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand,
.topbar-actions,
.dock-label,
.branch-actions,
.icon-button,
.button,
.concept-chip,
.dock-card {
  display: inline-flex;
  align-items: center;
}

.brand {
  gap: 9px;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  min-width: 0;
}

.brand small {
  color: var(--ink-3);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 400;
}

.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: white;
  line-height: 1;
}

.topbar-actions {
  gap: 8px;
}

.session-pill {
  border: 1px solid var(--rule);
  border-radius: 8px;
  color: var(--ink-3);
  background: rgba(255, 255, 255, 0.55);
  padding: 7px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.shared-pill {
  color: var(--accent-deep);
  background: var(--accent-soft);
  border-color: var(--accent);
}

.history-strip {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--rule);
  background: rgba(255, 255, 255, 0.38);
  padding: 10px 20px;
}

.history-label {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 700;
}

.history-search {
  flex: 0 0 150px;
  display: flex;
  align-items: center;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.history-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.history-search input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  padding: 7px 0 7px 9px;
  font-size: 12px;
}

.history-search-button {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  padding: 0;
}

.history-search-button:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

.history-search-button .icon {
  width: 14px;
  height: 14px;
}

.history-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0;
}

.history-item {
  flex: 0 0 auto;
  width: 190px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-2);
  overflow: hidden;
}

.history-item:hover {
  border-color: var(--accent);
  background: var(--surface-soft);
}

.history-load {
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 8px 10px;
  text-align: left;
}

.history-load:hover {
  background: var(--surface-soft);
}

.history-actions {
  display: grid;
  grid-template-columns: 24px;
  border-left: 1px solid var(--rule);
}

.history-action {
  width: 24px;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-3);
  padding: 0;
}

.history-action:last-child {
  border-bottom: 0;
}

.history-action .icon {
  width: 13px;
  height: 13px;
}

.history-action:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

.history-action.danger:hover {
  background: #f8e3dc;
  color: #8c301e;
}

.history-topic,
.history-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-topic {
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.history-meta {
  margin-top: 3px;
  color: var(--ink-3);
  font-size: 11px;
}

.icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.icon-button,
.button {
  min-height: 34px;
  gap: 7px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  color: var(--ink-2);
  background: var(--surface);
  padding: 8px 12px;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.icon-button:hover,
.button:hover,
.dock-card:hover,
.concept-chip:hover {
  background: var(--surface-soft);
  border-color: var(--ink-4);
  color: var(--ink);
}

.icon-only {
  width: 34px;
  padding: 0;
  justify-content: center;
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.button.primary:hover {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
  color: white;
}

.trunk-content {
  flex: 1;
  overflow: auto;
  padding: 28px 32px 24px;
}

.welcome {
  display: grid;
  place-items: center;
  align-content: center;
}

.welcome-hero {
  text-align: center;
  max-width: 480px;
}

.welcome-mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 700;
  margin: 0 auto 16px;
}

.welcome-hero h1 {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 600;
  color: var(--ink);
}

.welcome-hero p {
  margin: 0;
  color: var(--ink-3);
  font-size: 15px;
  line-height: 1.7;
}

.pending-thread {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 34px;
  padding-top: 72px;
}

.pending-question-row {
  display: flex;
  justify-content: flex-end;
}

.user-question-bubble {
  max-width: min(520px, 72%);
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--rule);
  color: var(--ink);
  padding: 12px 16px;
  font-size: 16px;
  line-height: 1.5;
  box-shadow: 0 8px 20px rgba(45, 38, 28, 0.06);
}

.pending-response {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink-3);
  font-size: 14px;
  min-height: 32px;
}

.thinking-dot {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--ink);
  animation: thinking-pulse 1.1s ease-in-out infinite;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.trunk-title,
.branch-title,
.modal h2 {
  margin: 8px 0 8px;
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.18;
}

.trunk-title {
  font-size: 36px;
}

.trunk-subtitle {
  margin: 0 0 28px;
  color: var(--ink-2);
  font-size: 16px;
  line-height: 1.55;
}

.section {
  margin-bottom: 28px;
  padding-left: 12px;
  border-left: 3px solid var(--rule);
}

.reveal-section {
  opacity: 0;
  transform: translateY(8px);
  animation: reveal-section-in 360ms ease forwards;
  animation-delay: calc(var(--reveal-order, 1) * 70ms);
}

.section h2,
.section h3 {
  margin: 0 0 9px;
  color: var(--ink-3);
  font-size: 13px;
  font-weight: 800;
}

.section p,
.example-list,
.breakdown-list,
.distinction-list,
.misconceptions {
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.68;
}

.inline-concept {
  display: inline;
  border: 0;
  border-radius: 6px;
  padding: 1px 5px 2px;
  color: var(--blue);
  background: var(--blue-soft);
  font: inherit;
  font-weight: 800;
  line-height: inherit;
  cursor: pointer;
}

.inline-concept:hover {
  color: #1f6f9e;
  background: #d9edf8;
}

.lede {
  color: var(--ink);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.55;
}

.analogy,
.formal,
.example-card,
.code-example,
.check-card,
.source-note,
.quiz-card,
.reco-card {
  border-radius: 8px;
}

.analogy {
  margin: 0;
  padding: 14px 16px;
  border-left: 3px solid var(--accent);
  background: var(--surface-soft);
  color: var(--ink-2);
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.62;
}

.formal {
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--rule);
  background: var(--surface);
}

.example-card {
  padding: 14px 16px;
  border-left: 3px solid var(--accent);
  background: var(--surface-soft);
}

.example-card h3 {
  color: var(--ink);
  font-size: 14px;
}

.example-card p {
  margin: 0;
}

.example-note {
  color: var(--ink-3);
  font-size: 13px;
}

.code-example {
  overflow: auto;
  margin: 12px 0;
  padding: 12px;
  background: #23231f;
  color: #f8f5ec;
  font-size: 13px;
  line-height: 1.5;
}

.example-list {
  margin: 0;
  padding-left: 21px;
}

.breakdown-list,
.distinction-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.breakdown-list {
  list-style-position: inside;
}

.breakdown-list li,
.distinction-list p {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
}

.breakdown-list strong,
.distinction-list strong {
  margin-right: 8px;
  color: var(--accent-deep);
}

.misconceptions {
  display: grid;
  gap: 7px;
}

.misconceptions p {
  display: flex;
  gap: 10px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
}

.misconceptions span {
  color: #9a3a28;
  font-weight: 700;
}

.misconceptions strong {
  color: var(--ink-2);
  font-weight: 600;
}

.chip-hint {
  margin: 0 0 10px;
  color: var(--ink-4);
  font-size: 13px;
  line-height: 1.5;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.concept-chip {
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  padding: 8px 10px 8px 14px;
  color: var(--ink-2);
  font-size: 14px;
}

.concept-chip.is-active {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 7px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.s-unseen {
  color: var(--ink-3);
  background: #eee9dc;
}

.s-opened {
  color: var(--blue);
  background: var(--blue-soft);
}

.s-understood,
.s-verified {
  color: var(--accent-deep);
  background: var(--accent-soft);
}

.s-claimed {
  color: var(--blue);
  background: #e9f1f4;
}

.s-confused {
  color: var(--yellow);
  background: var(--yellow-soft);
}

.s-practice {
  color: var(--purple);
  background: var(--purple-soft);
}

.check-card {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #cfe2d3;
  background: var(--accent-soft);
  color: var(--ink-2);
  padding: 14px 16px;
  line-height: 1.5;
}

.check-dot {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-family: var(--serif);
  font-weight: 700;
}

.composer {
  border-top: 1px solid var(--rule);
  padding: 14px 20px 18px;
}


.composer-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  padding: 4px 4px 4px 14px;
}

.composer-inner:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.composer input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  padding: 10px 0;
}


.selection-prompt {
  position: fixed;
  z-index: 40;
  max-width: min(360px, calc(100vw - 24px));
  transform: translate(-50%, -4px);
  filter: drop-shadow(0 14px 28px rgba(23, 22, 20, 0.22));
}

.selection-prompt[hidden] {
  display: none;
}

.selection-prompt::after {
  content: "";
  position: absolute;
  left: var(--selection-arrow-x, 50%);
  bottom: -7px;
  width: 14px;
  height: 14px;
  background: var(--ink);
  transform: translateX(-50%) rotate(45deg);
  border-radius: 2px;
}

.selection-prompt .button {
  width: 100%;
  justify-content: center;
  position: relative;
  z-index: 1;
  border-color: var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: white;
  box-shadow: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.selection-prompt .button:hover {
  border-color: var(--ink);
  background: #2f3034;
}

.send-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
}

.branch-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--rule);
  background: var(--surface-soft);
  padding: 4px 8px;
}

.branch-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-3);
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 700;
}

.branch-tab:hover {
  color: var(--ink);
  background: var(--surface);
}

.branch-tab.active {
  color: var(--accent-deep);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(29, 28, 24, 0.06);
}

.branch-tab .icon {
  width: 14px;
  height: 14px;
}

.map-inline {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
}

.map-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--rule);
}

.map-header h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
}

.map-header p {
  margin: 4px 0 0;
  color: var(--ink-3);
  font-size: 13px;
}

.map-body {
  flex: 1;
  overflow: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
}

.map-body .map-tree {
  overflow: auto;
  padding: 16px 20px;
}

.map-body .map-aside {
  overflow: auto;
  background: var(--surface-soft);
  padding: 16px;
}

.dock {
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--rule);
  padding: 12px 20px;
}

.dock-empty {
  color: var(--ink-3);
  font-size: 14px;
}

.dock-label {
  flex: 0 0 auto;
  gap: 7px;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 700;
}

.dock-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0;
}

.dock-card {
  flex: 0 0 auto;
  gap: 8px;
  justify-content: space-between;
  min-width: 154px;
  max-width: 230px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-2);
  padding: 8px 10px;
}

.dock-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.branch-empty,
.branch-panel {
  flex: 1;
  overflow: auto;
}

.branch-empty {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 40px;
  color: var(--ink-3);
  text-align: center;
}

.branch-empty h2 {
  margin: 0;
  color: var(--ink-2);
  font-family: var(--serif);
  font-size: 24px;
}

.branch-empty p {
  max-width: 430px;
  margin: 0;
  line-height: 1.6;
}

.branch-illustration {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border: 1px solid var(--rule);
  border-radius: 8px;
  color: var(--accent);
  background: var(--surface);
}

.branch-illustration .icon {
  width: 32px;
  height: 32px;
}

.branch-panel {
  position: relative;
}

.branch-inner {
  max-width: 640px;
  margin: 0 auto;
  padding: 28px 32px 42px;
}

.branch-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  font-size: 32px;
}

.close-button {
  position: absolute;
  top: 16px;
  right: 18px;
}

.source-note {
  margin: 14px 0 28px;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  padding: 14px 18px;
  border-radius: 0 8px 8px 0;
}

.source-note strong {
  display: block;
  margin-bottom: 6px;
  color: var(--accent-deep);
  font-size: 13px;
  font-weight: 700;
}

.source-note p {
  margin: 0;
  color: var(--ink-2);
  line-height: 1.58;
  font-size: 14px;
}

.branch-actions {
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px solid var(--rule);
  margin-top: 10px;
  padding-top: 16px;
}

.alternative-block {
  margin-top: 20px;
  padding: 18px;
  border: 1px solid var(--yellow);
  border-radius: 8px;
  background: var(--yellow-soft);
}

.alternative-block .eyebrow {
  color: var(--yellow);
}

.quiz-card {
  margin-top: 20px;
  border: 1px solid var(--accent-soft);
  background: #f6faf7;
  padding: 18px;
  border-radius: 8px;
}

.quiz-card h3 {
  margin: 8px 0 12px;
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.35;
  color: var(--ink);
}

.quiz-options {
  display: grid;
  gap: 7px;
}

.quiz-option {
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink-2);
  padding: 10px 12px;
  text-align: left;
}

.quiz-option:hover {
  border-color: var(--accent);
  color: var(--accent-deep);
}

.quiz-option.correct {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-weight: 700;
}

.quiz-option.wrong {
  border-color: #b65a42;
  background: #f8e3dc;
  color: #8c301e;
  font-weight: 700;
}

.quiz-explanation {
  margin: 12px 0 0;
  color: var(--ink-2);
  line-height: 1.55;
}

.quiz-confirm {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.quiz-confirm-prompt {
  width: 100%;
  margin: 0;
  color: var(--ink-3);
  font-size: 13px;
  font-weight: 600;
}

.quiz-confirmed {
  margin: 12px 0 0;
  color: var(--ink-3);
  font-size: 13px;
  font-style: italic;
}

.quiz-option:disabled {
  cursor: default;
  opacity: 0.7;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(29, 28, 24, 0.35);
  backdrop-filter: blur(2px);
  z-index: 20;
  padding: 24px;
}

.modal {
  width: min(920px, 100%);
  max-height: min(720px, 90vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  border-bottom: 1px solid var(--rule);
  padding: 20px 24px 16px;
}

.modal-header h2,
.modal-header p {
  margin: 0;
}

.modal-header p {
  margin-top: 4px;
  color: var(--ink-3);
  font-size: 13px;
}

.modal-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  min-height: 0;
}

.review-modal {
  width: min(640px, 100%);
}

.review-body {
  display: grid;
  gap: 10px;
  overflow: auto;
  padding: 20px 24px 24px;
}

.review-card {
  display: grid;
  gap: 14px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
}

.review-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 700;
}

.review-card h3 {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1.05;
}

.review-prompt {
  margin: 0;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.55;
}

.review-reason {
  margin: 0;
  border-left: 3px solid var(--accent);
  color: var(--ink-2);
  padding-left: 12px;
  line-height: 1.5;
}

.review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px solid var(--rule);
  padding-top: 14px;
}

.review-row {
  width: 100%;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 12px;
  text-align: left;
}

.review-row:hover {
  border-color: var(--accent);
  background: var(--surface-soft);
}

.review-node {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
}

.review-row strong,
.review-row small {
  display: block;
}

.review-row small {
  margin-top: 3px;
  color: var(--ink-3);
  line-height: 1.35;
}

.review-empty {
  margin: 0;
  border: 1px dashed var(--rule-strong);
  border-radius: 8px;
  color: var(--ink-3);
  padding: 16px;
}

.map-tree,
.map-aside {
  overflow: auto;
  padding: 20px 24px;
}

.map-tree {
  border-right: 1px solid var(--rule);
}

.map-aside {
  background: var(--surface-soft);
}

.tree-row {
  width: 100%;
  min-height: 40px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  padding: 8px 10px;
  text-align: left;
}

.tree-row:hover {
  background: var(--surface-soft);
}

.tree-row.is-recommended {
  border: 1px solid #bdd9c4;
  background: var(--accent-soft);
}

.tree-row.is-recommended .tree-branch {
  border-color: var(--accent);
  background: var(--accent);
}

.tree-row.root {
  grid-template-columns: 18px minmax(0, 1fr);
  font-family: var(--serif);
  font-size: 17px;
}

.tree-node,
.tree-branch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.tree-node {
  background: var(--accent);
}

.tree-branch {
  border: 2px solid var(--rule-strong);
}

.reco-card {
  border: 1px solid #cfe2d3;
  background: var(--accent-soft);
  padding: 14px 16px;
}

.reco-card h3 {
  margin: 8px 0 6px;
  font-family: var(--serif);
  font-size: 17px;
}

.reco-card p {
  margin: 0;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.55;
}

.map-reco-action {
  width: 100%;
  justify-content: center;
  margin-top: 12px;
}

.stat-list {
  margin: 16px 0 0;
}

.stat-list div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px dashed var(--rule-strong);
  padding: 9px 0;
}

.stat-list dt {
  color: var(--ink-3);
}

.stat-list dd {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 700;
}

.toast,
.loading-bar {
  position: fixed;
  left: 50%;
  max-width: min(520px, calc(100vw - 32px));
  transform: translateX(-50%);
  border-radius: 8px;
  color: white;
  box-shadow: var(--shadow);
  padding: 12px 16px;
  font-size: 13px;
  text-align: center;
  z-index: 30;
}

.toast {
  bottom: 26px;
  background: var(--ink);
}

.loading-bar {
  top: 18px;
  background: var(--accent);
}

.branch-fade {
  animation: branch-in 220ms ease;
}

@keyframes thinking-pulse {
  0%,
  100% {
    transform: scale(0.86);
    opacity: 0.55;
  }
  50% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes reveal-section-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes branch-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .forest-rail,
  .trunk,
  .branch-area {
    height: auto;
    min-height: 52vh;
  }

  .branch-area {
    border-top: 1px solid var(--rule-strong);
  }

  .forest-rail {
    border-right: 0;
    border-bottom: 1px solid var(--rule-strong);
  }

  .trunk-content,
  .branch-inner {
    padding: 24px 20px;
  }

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

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .trunk-title {
    font-size: 30px;
  }

  .branch-title {
    font-size: 27px;
  }

  .modal-body {
    grid-template-columns: 1fr;
  }

  .map-body {
    grid-template-columns: 1fr;
  }

  .map-body .map-tree {
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }

  .map-tree {
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }
}

@media (max-width: 520px) {
  .brand {
    flex-wrap: wrap;
  }

  .session-pill {
    display: none;
  }

  .icon-button span {
    display: none;
  }

  .concept-chip,
  .button {
    width: 100%;
    justify-content: space-between;
  }

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

  .dock-scroll {
    width: 100%;
  }

  .close-button {
    top: 10px;
    right: 10px;
  }
}
