:root {
  color-scheme: light;
  --bg: #f4efe5;
  --panel: rgba(255, 251, 245, 0.88);
  --panel-strong: #fffaf1;
  --panel-border: rgba(66, 49, 31, 0.12);
  --ink: #201a16;
  --muted: #68594c;
  --accent: #b55c33;
  --accent-strong: #8d3f1d;
  --accent-soft: rgba(181, 92, 51, 0.12);
  --success: #2d6a4f;
  --shadow: 0 18px 50px rgba(67, 45, 24, 0.12);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --page-width: 1440px;
  --ui-font: "Avenir Next", "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  --mono-font: "SFMono-Regular", "Menlo", "Monaco", "Cascadia Mono",
    "Liberation Mono", monospace;
}

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

html {
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(181, 92, 51, 0.12), transparent 28rem),
    linear-gradient(180deg, #f6f1e8 0%, #efe7da 100%);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--ui-font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: rgba(181, 92, 51, 0.15);
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  text-decoration: none;
  z-index: 20;
}

.skip-link:focus-visible {
  top: 1rem;
}

.hero,
.layout {
  width: min(calc(100% - 2rem), var(--page-width));
  margin-inline: auto;
}

.hero {
  padding: calc(2rem + env(safe-area-inset-top)) 0 1.5rem;
}

.hero__eyebrow,
.panel__kicker,
.section__eyebrow {
  margin: 0 0 0.55rem;
  color: var(--accent-strong);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
  font-weight: 700;
}

.hero h1,
.detail__header h2 {
  margin: 0;
  max-width: 14ch;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  line-height: 0.98;
  text-wrap: balance;
}

.hero h1 {
  font-size: clamp(3.1rem, 6vw, 5.7rem);
}

.hero__summary {
  margin: 1rem 0 0;
  max-width: 64ch;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.7;
}

.hero__meta,
.badge-row,
.stats,
.detail__actions,
.card-grid,
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.hero__meta {
  margin-top: 1.5rem;
}

.stat-pill,
.badge,
.mini-chip {
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.72);
  padding: 0.45rem 0.8rem;
  color: var(--ink);
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}

.mini-chip {
  padding: 0.28rem 0.55rem;
  font-size: 0.8rem;
}

.badge[data-tone="accent"] {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.badge[data-tone="success"] {
  background: rgba(45, 106, 79, 0.1);
  color: var(--success);
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 1.25rem;
  padding-bottom: calc(2rem + env(safe-area-inset-bottom));
}

.panel {
  min-width: 0;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel--tree {
  position: sticky;
  top: 1rem;
  align-self: start;
  max-height: calc(100vh - 2rem);
  overflow: hidden;
}

.panel__header {
  display: grid;
  gap: 1rem;
  padding: 1.4rem 1.4rem 0;
}

.panel__header h2,
.section-title {
  margin: 0;
  font-size: 1.55rem;
}

.search {
  display: grid;
  gap: 0.45rem;
}

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

.search input {
  width: 100%;
  border: 1px solid rgba(66, 49, 31, 0.18);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.95);
  padding: 0.88rem 1rem;
  color: var(--ink);
}

.search input::placeholder {
  color: #907d6c;
}

.search__result {
  min-height: 1.5rem;
  margin: 0;
  padding: 0.75rem 1.4rem 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.search input:focus-visible,
.tree__button:focus-visible,
.action-button:focus-visible,
.child-card__select:focus-visible,
.child-card__copy:focus-visible,
.breadcrumb__button:focus-visible {
  outline: 3px solid rgba(181, 92, 51, 0.34);
  outline-offset: 2px;
}

.tree {
  overflow: auto;
  max-height: calc(100vh - 14rem);
  padding: 0.8rem 0.8rem 1.3rem;
  content-visibility: auto;
}

.tree__group {
  display: grid;
  gap: 0.18rem;
}

.tree__node {
  display: grid;
  gap: 0.18rem;
}

.tree__button {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.7rem;
  border: 0;
  border-radius: 16px;
  background: transparent;
  padding: 0.75rem 0.85rem;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.tree__button:hover,
.tree__button[data-active="true"] {
  background: rgba(255, 255, 255, 0.82);
}

.tree__button[data-active="true"] {
  box-shadow: inset 0 0 0 1px rgba(181, 92, 51, 0.22);
}

.tree__title {
  min-width: 0;
  font-size: 0.98rem;
  font-weight: 700;
}

.tree__summary {
  min-width: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.tree__node[data-depth="1"] > .tree__button {
  background: rgba(181, 92, 51, 0.07);
}

.tree__children {
  margin-left: 1rem;
  padding-left: 0.7rem;
  border-left: 1px solid rgba(181, 92, 51, 0.18);
}

.panel--detail {
  padding: 1.45rem;
}

.detail__header {
  display: grid;
  gap: 1rem;
}

.detail__summary,
.detail__note,
.empty-state p,
.section-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.detail__summary {
  font-size: 1.06rem;
}

.detail__command {
  margin: 0;
  overflow: auto;
  border-radius: var(--radius-md);
  background: #211c18;
  padding: 1rem 1.1rem;
  color: #fef8ef;
  font-family: var(--mono-font);
  font-size: 0.95rem;
  line-height: 1.6;
}

.action-button,
.breadcrumb__button,
.child-card,
.child-card__select {
  border: 1px solid transparent;
  border-radius: 16px;
  background: #fff9ef;
  color: var(--ink);
}

.action-button,
.breadcrumb__button {
  padding: 0.78rem 1rem;
  cursor: pointer;
}

.action-button:hover,
.breadcrumb__button:hover {
  border-color: rgba(181, 92, 51, 0.28);
  background: #fffef8;
}

.action-button--accent {
  background: var(--accent);
  color: #fff9f2;
}

.action-button--accent:hover {
  background: var(--accent-strong);
}

.detail__section {
  margin-top: 1.5rem;
  display: grid;
  gap: 0.9rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.child-card {
  display: grid;
  gap: 0.8rem;
  padding: 1rem;
}

.child-card:hover,
.child-card__select:hover {
  border-color: rgba(181, 92, 51, 0.28);
}

.child-card__select {
  display: grid;
  gap: 0.8rem;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.child-card__select:hover {
  transform: translateY(-1px);
}

.child-card__title {
  margin: 0;
  font-size: 1rem;
}

.child-card__summary {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.child-card__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.child-card__copy {
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--accent-strong);
  cursor: pointer;
  font-weight: 700;
}

.breadcrumb {
  margin: 0;
  padding: 0;
  list-style: none;
  align-items: center;
}

.breadcrumb__button {
  padding: 0.4rem 0.7rem;
  font-size: 0.9rem;
}

.breadcrumb__sep {
  color: var(--muted);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 22rem;
  text-align: center;
  padding: 2rem;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  min-width: 12rem;
  max-width: min(24rem, calc(100vw - 2rem));
  border-radius: 16px;
  background: rgba(32, 26, 22, 0.94);
  padding: 0.9rem 1rem;
  color: #fffdf8;
  opacity: 0;
  transform: translateY(0.75rem);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast[data-visible="true"] {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .panel--tree {
    position: static;
    max-height: none;
  }

  .tree {
    max-height: 32rem;
  }

  .hero h1 {
    max-width: 11ch;
  }
}

@media (max-width: 640px) {
  .hero,
  .layout {
    width: min(calc(100% - 1rem), var(--page-width));
  }

  .hero {
    padding-top: calc(1.25rem + env(safe-area-inset-top));
  }

  .panel__header,
  .panel--detail {
    padding-inline: 1rem;
  }

  .tree {
    padding-inline: 0.6rem;
  }

  .detail__actions {
    display: grid;
  }
}
