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

:root {
  --bg: #f8f9fb;
  --surface: #ffffff;
  --ink: #1a1a2e;
  --muted: #6b7280;
  --rule: #e5e7eb;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --tag-bg: #f0fdf4;
  --tag-ink: #15803d;
  --warn-bg: #fffbeb;
  --warn-ink: #92400e;
}

html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
}

/* ====== Top Bar ====== */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar h1 {
  font-size: 1.1rem;
  font-weight: 700;
  white-space: nowrap;
  color: var(--accent);
}
.search-input {
  flex: 1;
  max-width: 420px;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  font-size: 0.85rem;
  background: var(--bg);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--muted); }

/* ====== Layout ====== */
.app {
  display: flex;
  min-height: calc(100vh - 52px);
}

/* ====== Sidebar ====== */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--rule);
  padding: 1rem 0;
  overflow-y: auto;
}
.sidebar-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 1rem 0.5rem;
}
.step-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 1rem;
  border: none;
  background: none;
  color: var(--ink);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.1s;
  border-left: 3px solid transparent;
}
.step-btn:hover { background: var(--accent-soft); }
.step-btn.active {
  background: var(--accent-soft);
  border-left-color: var(--accent);
  font-weight: 600;
  color: var(--accent);
}

/* ====== Main ====== */
.main {
  flex: 1;
  padding: 1.5rem 2rem;
  overflow-y: auto;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60vh;
  color: var(--muted);
}
.empty-icon { font-size: 2.5rem; margin-bottom: 0.75rem; opacity: 0.5; }
.empty-state p { font-size: 0.95rem; }
.empty-hint { font-size: 0.8rem !important; margin-top: 0.25rem; }

/* ====== Step View ====== */
.step-header { margin-bottom: 1.5rem; }
.step-header h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 0.5rem; }
.opening-script {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1rem;
  border-radius: 0 6px 6px 0;
  font-size: 0.85rem;
  color: var(--ink);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}
.opening-script .label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

.branch-list { display: flex; flex-direction: column; gap: 0.5rem; }

/* ====== Branch Card ====== */
.branch-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
  transition: box-shadow 0.15s;
}
.branch-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.branch-card.open { border-color: var(--accent); }

.branch-trigger {
  width: 100%;
  text-align: left;
  padding: 0.7rem 1rem;
  border: none;
  background: none;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
  font-weight: 500;
}
.branch-trigger .arrow {
  font-size: 0.65rem;
  color: var(--muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.branch-card.open .arrow { transform: rotate(90deg); }

.branch-body { display: none; padding: 0 1rem 1rem; }
.branch-card.open .branch-body { display: block; }

/* ====== Response Block ====== */
.response-block {
  background: var(--tag-bg);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
}
.response-block .resp-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--tag-ink);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.3rem;
}
.response-block .resp-text {
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--ink);
}
.next-block {
  background: var(--warn-bg);
  border-radius: 6px;
  padding: 0.65rem 1rem;
  margin-top: 0.5rem;
}
.next-block .next-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--warn-ink);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.2rem;
}
.next-block .next-text {
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--ink);
}

/* ====== Search ====== */
.no-results {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}

/* ====== Responsive ====== */
@media (max-width: 700px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--rule);
    padding: 0.5rem 0;
    overflow-x: auto;
    white-space: nowrap;
  }
  .step-list { display: flex; padding: 0 0.5rem; }
  .step-btn { white-space: nowrap; border-left: none; border-bottom: 2px solid transparent; padding: 0.45rem 0.6rem; font-size: 0.78rem; }
  .step-btn.active { border-left: none; border-bottom-color: var(--accent); }
  .sidebar-title { display: none; }
  .main { padding: 1rem; }
  .topbar { padding: 0.6rem 1rem; }
  .topbar h1 { font-size: 0.95rem; }
}
