/* 821-mindmap app styles. Tokens + base components come from BoardUI
 * (assets/boardui.css, copied from math-viz). This file only adds layout
 * and mindmap-specific rules. Zero external requests. */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; overflow-x: hidden; }
body {
  background: var(--bg);
  color: var(--color-text-primary, #1a1a1a);
  font-family: Inter, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 16px; line-height: 1.6;
  min-height: 100dvh;
}
a { color: var(--color-accent-600); }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--color-accent-400); outline-offset: 2px; border-radius: 6px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  background: var(--color-accent-600); color: #fff; padding: 8px 14px;
  border-radius: 999px; text-decoration: none; transition: top .15s;
}
.skip-link:focus { top: 12px; color: #fff; }

/* ---------- header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--color-background-primary, #fff);
  border-bottom: 1px solid var(--line, #e5e5e5);
}
.brand { display: flex; align-items: baseline; gap: 8px; text-decoration: none; color: inherit; }
.brand strong { font-size: 19px; font-weight: 700; letter-spacing: .2px; }
.brand span { font-size: 13px; color: var(--color-text-secondary); }
.app-nav { display: flex; gap: 4px; margin-left: auto; }
.app-nav a {
  padding: 7px 12px; border-radius: 999px; text-decoration: none;
  color: var(--color-text-secondary); font-size: 14px; font-weight: 500;
}
.app-nav a[aria-current="page"] { background: var(--color-accent-50); color: var(--color-accent-700); font-weight: 700; }
.search-wrap { position: relative; flex: 1 1 220px; max-width: 420px; min-width: 180px; }
.search-wrap input {
  width: 100%; padding: 9px 14px 9px 36px; font: inherit; font-size: 14px;
  border: 1px solid var(--line, #e5e5e5); border-radius: 999px;
  background: var(--color-background-secondary-default, #f7f7f7); color: inherit;
}
.search-wrap::before {
  content: ""; position: absolute; left: 12px; top: 50%; width: 14px; height: 14px;
  transform: translateY(-50%);
  background: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.4'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
}
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 60;
  max-height: min(60vh, 480px); overflow-y: auto;
  background: var(--color-background-primary, #fff);
  border: 1px solid var(--line, #e5e5e5); border-radius: 16px;
  box-shadow: 0 12px 32px rgba(0,0,0,.14); padding: 6px; list-style: none; margin: 0;
}
.search-results[hidden] { display: none; }
.search-results li a {
  display: block; padding: 9px 10px; border-radius: 10px;
  text-decoration: none; color: inherit;
}
.search-results li a:hover, .search-results li a:focus-visible { background: var(--color-accent-50); }
.search-results .sr-title { font-size: 14px; font-weight: 600; display: block; }
.search-results .sr-snip { font-size: 13px; color: var(--color-text-secondary); display: block; margin-top: 2px; }
.search-results .sr-empty { padding: 12px; color: var(--color-text-secondary); font-size: 14px; }

/* ---------- home ---------- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 28px 16px 64px; }
.hero h1 { font-size: 28px; line-height: 36px; margin: 0 0 6px; }
.hero p { color: var(--color-text-secondary); margin: 0 0 4px; max-width: 56em; }
.hero .exam-date { font-size: 14px; }
.course-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-top: 24px; }
.course-card {
  display: block; text-decoration: none; color: inherit;
  background: var(--color-background-primary, #fff);
  border: 1px solid var(--line, #e5e5e5); border-radius: 24px; padding: 22px;
}
.course-card:hover { border-color: var(--color-accent-400); }
.course-card h2 { font-size: 20px; margin: 0 0 4px; }
.course-card .book { font-size: 13px; color: var(--color-text-secondary); margin: 0 0 14px; }
.course-card .stats { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0 0 14px; padding: 0; }
.course-card .stats li {
  font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  background: var(--color-accent-50); color: var(--color-accent-700);
}
.course-card .go { font-size: 14px; font-weight: 600; color: var(--color-accent-600); }
.home-note { margin-top: 28px; font-size: 14px; color: var(--color-text-secondary); }
.home-note kbd {
  font: inherit; font-size: 13px; padding: 1px 7px; border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 6px; background: var(--color-background-primary, #fff);
}
.loading, .error { padding: 40px 16px; text-align: center; color: var(--color-text-secondary); }

/* ---------- mindmap ---------- */
.map-view { display: flex; flex-direction: column; height: calc(100dvh - 57px); min-height: 420px; }
.map-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 16px; border-bottom: 1px solid var(--line, #e5e5e5);
  background: var(--color-background-primary, #fff);
}
.map-toolbar h1 { font-size: 17px; margin: 0; margin-right: 4px; }
.map-toolbar .crumb { font-size: 13px; color: var(--color-text-secondary); }
.map-toolbar .spacer { flex: 1; }
.tool-btn {
  min-width: 40px; min-height: 40px; padding: 7px 12px;
  border: 1px solid var(--line, #e5e5e5); border-radius: 999px;
  background: var(--color-background-primary, #fff); color: inherit;
  font-size: 14px; font-weight: 600;
}
.tool-btn:hover { border-color: var(--color-accent-400); }
.tool-btn[aria-pressed="true"] { background: var(--color-accent-50); border-color: var(--color-accent-400); color: var(--color-accent-700); }
.zoom-label { font-size: 13px; min-width: 48px; text-align: center; font-variant-numeric: tabular-nums; }
.canvas {
  position: relative; flex: 1; overflow: hidden; touch-action: none;
  background:
    radial-gradient(circle, var(--line, #e5e5e5) 1px, transparent 1px) 0 0 / 24px 24px,
    var(--bg);
  outline-offset: -3px;
}
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.edges { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.edges path { fill: none; stroke: var(--color-neutral-400); stroke-width: 1.5; }
.node {
  position: absolute; width: 240px; min-height: 84px;
  background: var(--color-background-primary, #fff);
  border: 1.5px solid var(--line, #e5e5e5); border-radius: 16px;
  padding: 10px 12px 10px 12px; cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.node:hover { border-color: var(--color-accent-400); }
.node[aria-selected="true"] { border-color: var(--color-accent-500); box-shadow: 0 0 0 3px var(--color-accent-100); }
.node.root { background: var(--color-neutral-925, #121212); color: #fff; border-color: var(--color-neutral-925, #121212); }
.node.root .node-meta { color: rgba(255,255,255,.75); }
.node-title { font-size: 14px; font-weight: 600; line-height: 1.35; display: block; padding-right: 22px; }
.node-meta { font-size: 12px; color: var(--color-text-secondary); display: block; margin-top: 4px; }
.node-toggle {
  position: absolute; right: 8px; top: 8px; width: 26px; height: 26px;
  border: 1px solid var(--line, #e5e5e5); border-radius: 999px;
  background: var(--color-background-primary, #fff); color: inherit;
  font-size: 13px; line-height: 1; padding: 0; display: grid; place-items: center;
}
.node.root .node-toggle { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
.map-hint { padding: 8px 16px; font-size: 13px; color: var(--color-text-secondary); border-top: 1px solid var(--line, #e5e5e5); background: var(--color-background-primary, #fff); }

/* ---------- detail panel ---------- */
.detail {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 70;
  width: min(560px, 100vw); height: 100dvh;
  background: var(--color-background-primary, #fff);
  border-left: 1px solid var(--line, #e5e5e5);
  box-shadow: -12px 0 32px rgba(0,0,0,.14);
  display: flex; flex-direction: column;
}
.detail[hidden] { display: none; }
.detail-head {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--line, #e5e5e5);
}
.detail-head .back-btn {
  flex: none; min-height: 40px; padding: 7px 14px;
  border: 1px solid var(--line, #e5e5e5); border-radius: 999px;
  background: var(--color-background-primary, #fff); font-weight: 600; font-size: 14px;
}
.detail-head h2 { font-size: 18px; line-height: 1.4; margin: 2px 0 0; }
.detail-head .crumb { font-size: 12px; color: var(--color-text-secondary); display: block; margin-bottom: 2px; }
.detail-body { flex: 1; overflow-y: auto; padding: 18px 20px 48px; }
.detail-body section { margin-bottom: 26px; }
.detail-body h3 { font-size: 16px; margin: 0 0 8px; padding-bottom: 6px; border-bottom: 2px solid var(--color-accent-100); }
.detail-body p { margin: 0 0 10px; white-space: pre-wrap; overflow-wrap: break-word; }
.detail-body ul { margin: 0; padding-left: 20px; }
.detail-body li { margin-bottom: 6px; }
.formula-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.formula-list li {
  font-family: Georgia, "Times New Roman", serif; font-size: 15px;
  background: var(--color-background-secondary-default, #f7f7f7);
  border-radius: 12px; padding: 10px 12px; overflow-x: auto; white-space: pre-wrap;
  overflow-wrap: break-word;
}
.qa { border: 1px solid var(--line, #e5e5e5); border-radius: 16px; padding: 14px; margin-bottom: 12px; }
.qa h4 { font-size: 15px; margin: 0 0 6px; }
.qa .q-label, .qa .a-label { font-size: 12px; font-weight: 700; letter-spacing: .4px; color: var(--color-text-secondary); text-transform: uppercase; }
.qa .answer { white-space: pre-wrap; overflow-wrap: break-word; }
.qa .answer.missing { color: var(--color-text-secondary); font-style: italic; }
.qa-note { font-size: 13px; color: var(--color-text-secondary); }
.wrap > h1 { font-size: 24px; line-height: 32px; margin: 12px 0 4px; }
.qa .toggle-answer { margin-top: 8px; }
.exam-block { border: 1px solid var(--line, #e5e5e5); border-radius: 16px; padding: 14px; margin-bottom: 12px; }
.exam-block h4 { font-size: 15px; margin: 0 0 8px; }
.empty-note { color: var(--color-text-secondary); font-size: 14px; }

@media (max-width: 640px) {
  .brand span { display: none; }
  .app-nav { order: 3; margin-left: 0; }
  .search-wrap { order: 2; }
  .map-view { height: calc(100dvh - 104px); }
  .node { width: 208px; }
  .detail { width: 100vw; border-left: 0; }
  .hero h1 { font-size: 23px; line-height: 30px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
