/* ============================================================
   ANRAY 系统框架 · 桌面级查看器
   设计语言：温暖中性纸感 + 酒红主调 + 黄铜点缀
   ============================================================ */

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

:root {
  /* — Brand palette — */
  --oxblood:   #6E2A1E;
  --oxblood-2: #8A3B2C;
  --oxblood-3: #4F1D14;
  --brass:     #B98A4E;
  --brass-2:   #9A7036;
  --cream:     #F4ECDF;
  --cream-2:   #ECE2D0;
  --paper:     #FBF8F1;
  --paper-2:   #F6F1E6;
  --ink:       #1F1B17;
  --ink-2:     #3A332C;
  --ink-3:     #6B6358;
  --ink-4:     #9A9286;
  --line:      #E4DCC9;
  --line-2:    #D6CCB5;
  --hi:        #FFF3C4;

  /* — Status colors — */
  --new-bg:    #FBE7DC;
  --new-fg:    #6E2A1E;
  --new-mark:  #6E2A1E;
  --fix-bg:    #FFF1D5;
  --fix-fg:    #8A5A0C;
  --fix-mark:  #B98A4E;

  /* — Category accents (10 modules) — */
  --c-plum:    #6E3A8E;
  --c-oxblood: #6E2A1E;
  --c-brass:   #B98A4E;
  --c-forest:  #406A4E;
  --c-ember:   #B3541C;
  --c-magenta: #A93766;
  --c-earth:   #7A5530;
  --c-indigo:  #2D4A7A;
  --c-steel:   #4A5C72;
  --c-moss:    #3A6240;
  --c-neutral: #9A9286;

  /* — Layout — */
  --top-h:    56px;
  --bar-h:    44px;
  --rail-w:   268px;
  --tree-w:   400px;
  --status-h: 30px;
  --radius:   6px;
  --radius-l: 10px;

  /* — Type — */
  --font-sans: 'Inter', -apple-system, 'PingFang SC', 'Noto Sans SC', 'Helvetica Neue', Arial, sans-serif;
  --font-serif: 'Noto Serif SC', 'Source Han Serif SC', 'Songti SC', Georgia, serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Menlo', 'Consolas', monospace;

  /* — Shadow — */
  --sh-1: 0 1px 0 rgba(31, 27, 23, 0.04), 0 1px 2px rgba(31, 27, 23, 0.04);
  --sh-2: 0 1px 0 rgba(31, 27, 23, 0.05), 0 4px 12px rgba(31, 27, 23, 0.06);
  --sh-3: 0 2px 0 rgba(31, 27, 23, 0.06), 0 12px 32px rgba(31, 27, 23, 0.10);
}

html, body {
  height: 100%;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--paper);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Soft paper texture (subtle vertical noise) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 1200px 600px at 20% 0%, rgba(185, 138, 78, 0.04), transparent 70%),
    radial-gradient(ellipse 900px 600px at 100% 100%, rgba(110, 42, 30, 0.03), transparent 70%);
  z-index: 0;
}

/* =========================================================
   TOP APP BAR
   ========================================================= */
.appbar {
  position: relative;
  z-index: 10;
  height: var(--top-h);
  background: linear-gradient(180deg, #FFFEFB 0%, var(--paper) 100%);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-right: 18px;
  border-right: 1px solid var(--line);
}
.brand-mark {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--oxblood);
  color: var(--cream);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-serif);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: -0.02em;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1), 0 1px 2px rgba(110,42,30,0.2);
}
.brand-name {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1;
}
.brand-sub {
  font-size: 10.5px;
  color: var(--ink-3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 3px;
}

/* Version + view tabs */
.seg {
  display: inline-flex;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 2px;
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--ink-3);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color .15s, background .15s;
}
.seg button:hover { color: var(--ink); }
.seg button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: var(--sh-1), inset 0 0 0 1px var(--line);
}
.seg button kbd {
  font-family: var(--font-mono);
  font-size: 9.5px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0 4px;
  color: var(--ink-3);
  font-weight: 500;
  margin-left: 4px;
}
.seg button.active kbd { background: var(--cream); }

/* Search */
.search-wrap {
  flex: 1;
  max-width: 440px;
  position: relative;
}
.search-wrap svg {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 13px; height: 13px;
  color: var(--ink-4);
  pointer-events: none;
}
.search-input {
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 10px 7px 30px;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search-input::placeholder { color: var(--ink-4); }
.search-input:focus {
  border-color: var(--brass);
  box-shadow: 0 0 0 3px rgba(185, 138, 78, 0.15);
}
.search-kbd {
  position: absolute;
  right: 8px; top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-4);
  background: var(--paper-2);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--line);
  pointer-events: none;
}

/* Top stats */
.top-stats {
  display: flex;
  gap: 4px;
  margin-left: auto;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 12px;
  border-left: 1px solid var(--line);
  min-width: 56px;
}
.stat:first-child { border-left: 0; }
.stat-num {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.stat-lbl {
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
  margin-top: 2px;
}
.stat-new .stat-num { color: var(--oxblood); }
.stat-fix .stat-num { color: var(--brass-2); }

/* =========================================================
   SECONDARY TOOLBAR
   ========================================================= */
.toolbar {
  position: relative;
  z-index: 9;
  height: var(--bar-h);
  background: #FFFEFB;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-3);
  overflow: hidden;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.crumb-root {
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: var(--cream);
  color: var(--oxblood);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}
.crumb {
  cursor: pointer;
  color: var(--ink-3);
  transition: color .15s;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
  min-width: 0;
}
.crumb:hover { color: var(--ink); }
.crumb.current {
  color: var(--ink);
  font-weight: 600;
  flex-shrink: 0;
}
.crumb-sep {
  color: var(--ink-4);
  font-size: 11px;
  flex-shrink: 0;
}

.toolbar-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}
.tool-btn {
  background: transparent;
  border: 1px solid transparent;
  font: inherit;
  font-size: 11.5px;
  color: var(--ink-3);
  padding: 5px 10px;
  border-radius: 5px;
  cursor: pointer;
  transition: all .15s;
}
.tool-btn:hover {
  background: var(--paper-2);
  color: var(--ink);
}
.toolbar-legend {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-left: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
  font-size: 11px;
  color: var(--ink-3);
}
.legend-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 2px;
  margin-right: 5px;
  vertical-align: -1px;
}
.legend-dot.new { background: var(--oxblood); }
.legend-dot.fix { background: var(--brass); }

/* =========================================================
   MAIN LAYOUT
   ========================================================= */
.main {
  flex: 1;
  display: grid;
  grid-template-columns: var(--rail-w) var(--tree-w) 1fr;
  min-height: 0;
  background: var(--paper);
  position: relative;
}

#outline-view { display: contents; }
#outline-view.hidden { display: none; }
#map-view {
  grid-column: 1 / -1;
  background: var(--paper);
  overflow-y: auto;
  padding: 32px 40px 60px;
}
#map-view.hidden { display: none; }

/* =========================================================
   LEFT RAIL — MODULE LIST
   ========================================================= */
.rail {
  background: linear-gradient(180deg, #FFFEFB 0%, #F7F2E5 100%);
  border-right: 1px solid var(--line);
  padding: 16px 10px 16px;
  overflow-y: auto;
}
.rail-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-4);
  padding: 4px 10px 10px;
}

.rail-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  font: inherit;
  text-align: left;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  color: var(--ink-2);
  transition: background .12s, border-color .12s;
  margin-bottom: 2px;
  position: relative;
}
.rail-item:hover {
  background: rgba(255, 255, 255, 0.7);
  border-color: var(--line);
}
.rail-item.selected {
  background: #fff;
  border-color: var(--line-2);
  box-shadow: var(--sh-1);
}

.rail-num {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-4);
  min-width: 18px;
  font-variant-numeric: tabular-nums;
}

.rail-glyph {
  width: 26px; height: 26px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -0.02em;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15), 0 1px 2px rgba(0,0,0,0.08);
}
.rail-glyph-plum    { background: var(--c-plum); }
.rail-glyph-oxblood { background: var(--c-oxblood); }
.rail-glyph-brass   { background: var(--c-brass); }
.rail-glyph-forest  { background: var(--c-forest); }
.rail-glyph-ember   { background: var(--c-ember); }
.rail-glyph-magenta { background: var(--c-magenta); }
.rail-glyph-earth   { background: var(--c-earth); }
.rail-glyph-indigo  { background: var(--c-indigo); }
.rail-glyph-steel   { background: var(--c-steel); }
.rail-glyph-moss    { background: var(--c-moss); }
.rail-glyph-neutral { background: var(--c-neutral); }

.rail-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.rail-zh {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rail-en {
  font-size: 10.5px;
  color: var(--ink-3);
  letter-spacing: 0.01em;
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.rail-new-dot {
  background: var(--oxblood);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 9px;
  letter-spacing: 0;
  line-height: 1.3;
}
.rail-new-star {
  color: var(--oxblood);
  font-size: 12px;
  line-height: 1;
}

.rail-item.is-new::after {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 22px;
  background: var(--oxblood);
  border-radius: 0 2px 2px 0;
}

/* =========================================================
   MIDDLE — TREE
   ========================================================= */
.tree-pane {
  background: #FFFEFB;
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 14px 4px 60px 0;
  position: relative;
}
.tree-empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--ink-4);
  font-style: italic;
  font-size: 13px;
}

.tnode { position: relative; }

.tnode-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px 4px 12px;
  border-radius: 5px;
  cursor: pointer;
  position: relative;
  margin: 0 6px 0 0;
  transition: background .12s;
}
.tnode-row:hover { background: var(--paper-2); }
.tnode.selected > .tnode-row {
  background: var(--cream);
  box-shadow: inset 2px 0 0 var(--oxblood);
}
.tnode.match > .tnode-row { background: var(--hi); }

.tnode-rail {
  position: absolute;
  left: 4px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--line);
  border-radius: 1px;
  opacity: 0.4;
}
.tnode-rail-plum    { background: var(--c-plum); }
.tnode-rail-oxblood { background: var(--c-oxblood); }
.tnode-rail-brass   { background: var(--c-brass); }
.tnode-rail-forest  { background: var(--c-forest); }
.tnode-rail-ember   { background: var(--c-ember); }
.tnode-rail-magenta { background: var(--c-magenta); }
.tnode-rail-earth   { background: var(--c-earth); }
.tnode-rail-indigo  { background: var(--c-indigo); }
.tnode-rail-steel   { background: var(--c-steel); }
.tnode-rail-moss    { background: var(--c-moss); }
.tnode-rail-neutral { background: var(--c-neutral); }

.tnode-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  font-size: 9px;
  color: var(--ink-4);
  transition: transform .15s ease;
  flex-shrink: 0;
  user-select: none;
}
.tnode-toggle.open { transform: rotate(90deg); }
.tnode-toggle.leaf { color: transparent; font-size: 11px; }

.tnode-id {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-4);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  min-width: 36px;
  font-weight: 500;
}

.tnode-label {
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.35;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tnode-label mark {
  background: rgba(185, 138, 78, 0.3);
  color: var(--ink);
  padding: 0 1px;
  border-radius: 1px;
}

.tnode[data-depth="0"] > .tnode-row > .tnode-label {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.tnode[data-depth="0"] > .tnode-row {
  padding-top: 7px;
  padding-bottom: 7px;
  margin-top: 4px;
}
.tnode[data-depth="0"] > .tnode-row > .tnode-id {
  font-size: 11px;
  color: var(--brass-2);
  font-weight: 600;
}

.tnode[data-depth="1"] > .tnode-row > .tnode-label {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--ink);
}

.tag {
  font-size: 9px;
  font-weight: 700;
  padding: 1.5px 5px;
  border-radius: 3px;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.tag-new {
  background: var(--oxblood);
  color: var(--cream);
}
.tag-fix {
  background: var(--brass);
  color: #fff;
}

.tnode-count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-4);
  background: var(--paper-2);
  padding: 1px 6px;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* =========================================================
   RIGHT — DETAIL
   ========================================================= */
.detail-pane {
  background: var(--paper);
  overflow-y: auto;
  padding: 24px 32px 80px;
  position: relative;
}

/* Hero */
.detail-hero {
  margin: -4px -4px 24px;
  padding: 28px 32px 28px;
  background: linear-gradient(135deg, #FFFFFF 0%, var(--paper-2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  position: relative;
  overflow: hidden;
}
.detail-hero::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--c-neutral);
}
.detail-hero-plum::before    { background: var(--c-plum); }
.detail-hero-oxblood::before { background: var(--c-oxblood); }
.detail-hero-brass::before   { background: var(--c-brass); }
.detail-hero-forest::before  { background: var(--c-forest); }
.detail-hero-ember::before   { background: var(--c-ember); }
.detail-hero-magenta::before { background: var(--c-magenta); }
.detail-hero-earth::before   { background: var(--c-earth); }
.detail-hero-indigo::before  { background: var(--c-indigo); }
.detail-hero-steel::before   { background: var(--c-steel); }
.detail-hero-moss::before    { background: var(--c-moss); }

.detail-hero-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.detail-hero-id {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-3);
  background: #fff;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  letter-spacing: 0.04em;
}
.hero-pill {
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}
.hero-pill-new {
  background: var(--oxblood);
  color: var(--cream);
}
.hero-pill-fix {
  background: var(--brass);
  color: #fff;
}
.hero-pill-version {
  background: var(--ink);
  color: var(--cream);
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
}

.detail-title {
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0 0 6px;
}
.detail-subtitle {
  font-size: 13.5px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
  font-style: italic;
  margin-bottom: 16px;
}

.detail-meta {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--ink-3);
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}
.detail-meta b {
  font-family: var(--font-mono);
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Callouts */
.callout {
  display: flex;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--radius-l);
  margin-bottom: 18px;
  border: 1px solid;
}
.callout-new {
  background: var(--new-bg);
  border-color: rgba(110, 42, 30, 0.18);
}
.callout-fix {
  background: var(--fix-bg);
  border-color: rgba(185, 138, 78, 0.22);
}
.callout-icon {
  font-size: 18px;
  font-weight: 700;
  width: 28px; height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.callout-new .callout-icon {
  background: var(--oxblood);
  color: var(--cream);
}
.callout-fix .callout-icon {
  background: var(--brass);
  color: #fff;
}
.callout-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}
.callout-body {
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.55;
}

/* Cards grid */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 16px 18px;
  position: relative;
}
.card-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--brass-2);
  margin-bottom: 8px;
}
.card-body {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.65;
}
.card-standard {
  border-left: 3px solid var(--c-indigo);
}
.card-why {
  border-left: 3px solid var(--c-ember);
}
.card-example {
  border-left: 3px solid var(--c-forest);
}
.card-issue {
  border-left: 3px solid var(--brass);
  background: var(--fix-bg);
}
.card-fix {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--brass);
  color: var(--oxblood);
  font-weight: 600;
  font-size: 12px;
}

/* Mapping section */
.mapping {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 18px 20px;
  margin-bottom: 20px;
}
.mapping-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--oxblood);
  margin-bottom: 12px;
}
.mapping-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: center;
}
.mapping-from, .mapping-to {
  padding: 12px 14px;
  background: var(--paper-2);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}
.mapping-to {
  background: var(--cream);
  border-color: var(--line-2);
}
.mapping-tier {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.mapping-text {
  font-size: 12.5px;
  color: var(--ink);
  line-height: 1.5;
}
.mapping-arrow {
  font-size: 20px;
  color: var(--brass);
  font-weight: 300;
}

/* Children grid */
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-label {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.section-hint {
  font-size: 11px;
  color: var(--ink-4);
}

.children-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.child-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  font: inherit;
  transition: all .15s ease;
  position: relative;
  overflow: hidden;
}
.child-card:hover {
  border-color: var(--brass);
  box-shadow: var(--sh-2);
  transform: translateY(-1px);
}
.child-card.is-new {
  border-color: rgba(110, 42, 30, 0.2);
  background: linear-gradient(180deg, #fff 0%, var(--new-bg) 200%);
}
.child-card.is-new::before {
  content: '★';
  position: absolute;
  top: 8px; right: 10px;
  color: var(--oxblood);
  font-size: 10px;
}
.child-card.is-fix::before {
  content: '↻';
  position: absolute;
  top: 8px; right: 10px;
  color: var(--brass-2);
  font-size: 12px;
}
.child-card-id {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-4);
  margin-bottom: 6px;
  font-weight: 500;
}
.child-card-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
  margin-bottom: 10px;
}
.child-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}
.child-card-count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-4);
}
.child-card-tag {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
}

.leaf-section {
  padding: 20px 0;
}
.leaf-note {
  background: var(--cream);
  border: 1px dashed var(--line-2);
  border-radius: var(--radius);
  padding: 16px 18px;
  color: var(--ink-3);
  font-size: 12.5px;
  text-align: center;
  font-style: italic;
}

/* Empty detail (no selection) */
.empty-detail {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 8px 0;
}
.empty-title {
  font-family: var(--font-serif);
  font-size: 34px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 6px;
}
.empty-meta {
  font-size: 13px;
  color: var(--ink-3);
  margin-bottom: 28px;
  letter-spacing: 0.02em;
}
.empty-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  width: 100%;
  max-width: 640px;
  margin-bottom: 24px;
}
.empty-stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
}
.empty-stat b {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 700;
  color: var(--oxblood);
  letter-spacing: -0.02em;
  line-height: 1;
}
.empty-stat span {
  font-size: 11.5px;
  color: var(--ink-3);
  margin-top: 6px;
  letter-spacing: 0.02em;
}
.empty-hint {
  font-size: 12px;
  color: var(--ink-3);
}
.empty-hint kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: #fff;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  margin: 0 1px;
  color: var(--ink);
}

/* =========================================================
   MAP VIEW
   ========================================================= */
.map-header {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.map-title {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}
.map-sub {
  font-size: 13px;
  color: var(--ink-3);
  letter-spacing: 0.02em;
}

.map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.map-tile {
  background: #FFFEFB;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 18px 20px;
  cursor: pointer;
  position: relative;
  transition: all .2s ease;
  display: flex;
  flex-direction: column;
}
.map-tile:hover {
  border-color: var(--brass);
  box-shadow: var(--sh-2);
  transform: translateY(-2px);
}
.map-tile.is-new {
  background: linear-gradient(180deg, #fff 0%, rgba(251, 231, 220, 0.4) 100%);
}

.map-tile-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.map-tile-num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  background: var(--paper-2);
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
}
.map-tile-glyph {
  width: 32px; height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 16px;
}
.map-tile-plum    .map-tile-glyph { background: var(--c-plum); }
.map-tile-oxblood .map-tile-glyph { background: var(--c-oxblood); }
.map-tile-brass   .map-tile-glyph { background: var(--c-brass); }
.map-tile-forest  .map-tile-glyph { background: var(--c-forest); }
.map-tile-ember   .map-tile-glyph { background: var(--c-ember); }
.map-tile-magenta .map-tile-glyph { background: var(--c-magenta); }
.map-tile-earth   .map-tile-glyph { background: var(--c-earth); }
.map-tile-indigo  .map-tile-glyph { background: var(--c-indigo); }
.map-tile-steel   .map-tile-glyph { background: var(--c-steel); }
.map-tile-moss    .map-tile-glyph { background: var(--c-moss); }
.map-tile-neutral .map-tile-glyph { background: var(--c-neutral); }

.map-tile-flag {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  background: var(--oxblood);
  color: var(--cream);
  padding: 3px 7px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}
.map-tile-title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin-bottom: 2px;
}
.map-tile-en {
  font-size: 11px;
  color: var(--ink-3);
  font-style: italic;
  letter-spacing: 0.02em;
  margin-bottom: 12px;
}
.map-tile-bar {
  height: 3px;
  background: var(--paper-2);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 10px;
}
.map-tile-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brass) 0%, var(--oxblood) 100%);
  border-radius: 2px;
}
.map-tile-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--ink-3);
  margin-bottom: 14px;
}
.map-tile-stats b {
  font-family: var(--font-mono);
  color: var(--ink);
  font-weight: 600;
}
.map-stat-new {
  color: var(--oxblood);
  font-weight: 600;
}
.map-stat-fix {
  color: var(--brass-2);
  font-weight: 600;
}

.map-tile-children {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  margin-top: auto;
}
.map-child {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 3px 8px 3px 6px;
  border-radius: 3px;
  font-size: 11.5px;
  color: var(--ink-2);
  cursor: pointer;
  transition: background .12s;
}
.map-child:hover { background: var(--cream); }
.map-child-id {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-4);
  font-weight: 500;
  min-width: 28px;
}
.map-child-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.map-child.is-new .map-child-label::after {
  content: ' ★';
  color: var(--oxblood);
  font-size: 9px;
}
.map-child-more {
  color: var(--ink-4);
  font-style: italic;
  padding-left: 6px;
  font-size: 11px;
}

.map-compare {
  background: linear-gradient(135deg, #fff 0%, var(--paper-2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 24px 28px;
  margin-top: 24px;
}
.map-compare-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--oxblood);
  margin-bottom: 16px;
}
.map-compare-grid {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.compare-stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 110px;
}
.compare-stat b {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.compare-stat span {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 4px;
}
.compare-stat.compare-now b { color: var(--oxblood); }
.compare-stat.compare-add b { color: var(--brass-2); }
.compare-arrow {
  font-size: 24px;
  color: var(--brass);
  font-weight: 300;
}
.map-compare-note {
  font-size: 12.5px;
  color: var(--ink-2);
  font-style: italic;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  line-height: 1.6;
}

/* =========================================================
   STATUS BAR
   ========================================================= */
.statusbar {
  height: var(--status-h);
  background: var(--ink);
  color: var(--cream-2);
  border-top: 1px solid var(--ink);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 10px;
  font-size: 11px;
  letter-spacing: 0.02em;
  position: relative;
  z-index: 8;
}
.sb-item {
  color: var(--cream-2);
}
.sb-mono {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--brass);
  font-weight: 500;
}
.sb-path {
  color: #fff;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sb-sep {
  color: var(--ink-3);
}
.sb-spacer { flex: 1; }

/* =========================================================
   Scrollbars
   ========================================================= */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: 5px;
  border: 2px solid var(--paper);
}
::-webkit-scrollbar-thumb:hover { background: var(--brass); }

/* Responsive */
@media (max-width: 1100px) {
  :root { --rail-w: 220px; --tree-w: 320px; }
  .rail-en { display: none; }
}
@media (max-width: 900px) {
  :root { --rail-w: 200px; --tree-w: 280px; }
  .top-stats .stat:nth-child(n+4) { display: none; }
}
