/* =========================================================
   波士顿新移民安居融入指南 — 版式与视觉体系
   ========================================================= */

:root {
  --bg: #f4f1ea;
  --bg-soft: #fffcf6;
  --ink: #2a241f;
  --ink-muted: #5b5248;
  --ink-faint: #8a7f73;
  --line: #e2d9cb;
  --line-strong: #d0c4b2;

  /* 波士顿 / 学府港城主色 */
  --crimson: #a51c30;
  --crimson-deep: #7a1524;
  --river: #1c4e80;
  --river-soft: #e7eef6;
  --autumn: #b86b2b;
  --autumn-soft: #f7ebe0;
  --ivy: #2f6b4f;
  --ivy-soft: #e7f2eb;
  --gold: #c4922a;
  --gold-soft: #faf3e3;

  --sidebar-w: 320px;
  --content-max: 900px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(42, 36, 31, 0.06);
  --shadow-soft: 0 4px 16px rgba(42, 36, 31, 0.05);

  --font-body: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", serif;
  --font-ui: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-display: "Avenir Next", "Segoe UI", "PingFang SC", "Hiragino Sans GB", system-ui, sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.85;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--river);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--crimson);
}

/* ========== 侧边栏 ========== */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: linear-gradient(165deg, #1a1520 0%, #2a2030 42%, #1e2433 100%);
  color: #f6f1e8;
  display: flex;
  flex-direction: column;
  z-index: 100;
  box-shadow: 8px 0 32px rgba(20, 16, 24, 0.2);
  overflow: hidden;
}

.sidebar-brand {
  padding: 28px 24px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand .kicker {
  display: block;
  font-family: var(--font-ui);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #e2b86a;
  margin-bottom: 10px;
}

.sidebar-brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: 0.02em;
}

.sidebar-brand p {
  margin: 10px 0 0;
  font-family: var(--font-ui);
  font-size: 12.5px;
  line-height: 1.55;
  color: rgba(246, 241, 232, 0.68);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 28px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.sidebar-nav::-webkit-scrollbar {
  width: 6px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
}

.nav-part {
  margin-bottom: 8px;
}

.nav-part-title {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  background: transparent;
  color: #fff;
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 650;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.nav-part-title:hover {
  background: rgba(255, 255, 255, 0.07);
}

.nav-part-title .part-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: rgba(226, 184, 106, 0.2);
  color: #f0d48a;
  font-size: 11px;
  flex-shrink: 0;
}

.nav-part-title .chev {
  margin-left: auto;
  opacity: 0.55;
  font-size: 11px;
  transition: transform 0.2s ease;
}

.nav-part.open .nav-part-title .chev {
  transform: rotate(90deg);
}

.nav-sub {
  display: none;
  list-style: none;
  margin: 2px 0 8px 28px;
  padding: 0;
}

.nav-part.open .nav-sub {
  display: block;
}

.nav-sub a {
  display: block;
  color: rgba(246, 241, 232, 0.72);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.45;
  text-decoration: none;
  padding: 8px 10px 8px 12px;
  border-left: 2px solid transparent;
  border-radius: 0 8px 8px 0;
  transition: all 0.18s ease;
}

.nav-sub a:hover,
.nav-sub a.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  border-left-color: #e2b86a;
}

.sidebar-footer {
  padding: 14px 20px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-family: var(--font-ui);
  font-size: 11.5px;
  color: rgba(246, 241, 232, 0.45);
  line-height: 1.5;
}

/* ========== 主内容 ========== */

.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
}

.mobile-bar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 90;
  background: rgba(26, 21, 32, 0.96);
  backdrop-filter: blur(10px);
  color: #fff;
  padding: 12px 16px;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
}

.mobile-bar button {
  border: 0;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.page {
  max-width: calc(var(--content-max) + 96px);
  margin: 0 auto;
  padding: 36px 48px 120px;
}

/* ========== 封面 ========== */

.cover {
  position: relative;
  border-radius: 22px;
  overflow: hidden;
  padding: 56px 48px 48px;
  background:
    radial-gradient(circle at 10% 20%, rgba(165, 28, 48, 0.14), transparent 30%),
    radial-gradient(circle at 90% 10%, rgba(28, 78, 128, 0.14), transparent 28%),
    linear-gradient(145deg, #fffcf6 0%, #f0ebe1 48%, #e8e0d2 100%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  margin-bottom: 36px;
}

.cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(42, 36, 31, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(42, 36, 31, 0.03) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.35), transparent 70%);
  pointer-events: none;
}

.cover-inner {
  position: relative;
  z-index: 1;
}

.cover .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-ui);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--crimson);
  font-weight: 700;
  margin-bottom: 18px;
}

.cover .eyebrow::before {
  content: "◆";
  color: var(--gold);
}

.cover h2 {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-size: clamp(32px, 4vw, 48px);
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.cover .subtitle {
  margin: 0 0 28px;
  max-width: 34em;
  font-size: 18px;
  line-height: 1.75;
  color: var(--ink-muted);
}

.cover-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.cover-meta span {
  font-family: var(--font-ui);
  font-size: 12.5px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  color: var(--ink-muted);
}

/* ========== 引言 ========== */

.intro {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px 34px;
  margin-bottom: 48px;
  box-shadow: var(--shadow-soft);
}

.intro h3 {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--ink);
}

.intro p {
  margin: 0 0 14px;
  color: var(--ink-muted);
}

.intro p:last-child {
  margin-bottom: 0;
}

/* ========== 章节 ========== */

.part-banner {
  margin: 72px 0 28px;
  padding: 28px 30px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #1a1520, #2c3d55);
  color: #fff;
  box-shadow: var(--shadow);
}

.part-banner .part-num {
  font-family: var(--font-ui);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #e2b86a;
  margin-bottom: 8px;
}

.part-banner h2 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 700;
  line-height: 1.3;
}

.part-banner p {
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
  max-width: 48em;
  font-size: 15.5px;
}

section.chapter {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 36px 38px 42px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-soft);
  scroll-margin-top: 24px;
}

section.chapter h3 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  scroll-margin-top: 24px;
}

section.chapter .lead {
  margin: 0 0 24px;
  color: var(--ink-muted);
  font-size: 16.5px;
}

section.chapter h4 {
  margin: 34px 0 12px;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 680;
  color: var(--ink);
  scroll-margin-top: 24px;
}

section.chapter h5 {
  margin: 24px 0 10px;
  font-family: var(--font-ui);
  font-size: 15.5px;
  font-weight: 700;
  color: var(--river);
  letter-spacing: 0.01em;
}

section.chapter p {
  margin: 0 0 16px;
}

section.chapter ul,
section.chapter ol {
  margin: 0 0 18px;
  padding-left: 1.35em;
}

section.chapter li {
  margin-bottom: 8px;
}

section.chapter li::marker {
  color: var(--crimson);
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 20px 0 24px;
}

.mini-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 18px 18px 16px;
}

.mini-card h6 {
  margin: 0 0 8px;
  font-family: var(--font-ui);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--crimson);
}

.mini-card p {
  margin: 0;
  font-size: 15px;
  color: var(--ink-muted);
}

/* ========== 提示框 ========== */

.alert-box {
  margin: 22px 0;
  padding: 18px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}

.alert-box .alert-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 700;
  margin-bottom: 8px;
}

.alert-box p,
.alert-box li {
  font-size: 15.5px;
}

.alert-box p:last-child,
.alert-box ul:last-child,
.alert-box ol:last-child {
  margin-bottom: 0;
}

.alert-box.concept {
  background: var(--river-soft);
  border-color: #c5d7ea;
  color: #173a5f;
}

.alert-box.concept .alert-title {
  color: var(--river);
}

.alert-box.warn {
  background: var(--autumn-soft);
  border-color: #edc9ae;
  color: #5c3018;
}

.alert-box.warn .alert-title {
  color: #9a4518;
}

.alert-box.tip {
  background: var(--ivy-soft);
  border-color: #bfd9c8;
  color: #1f4634;
}

.alert-box.tip .alert-title {
  color: var(--ivy);
}

.alert-box.star {
  background: var(--gold-soft);
  border-color: #ecd7a5;
  color: #5c4314;
}

.alert-box.star .alert-title {
  color: #8a6414;
}

/* ========== 表格 ========== */

.table-wrap {
  margin: 20px 0 26px;
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.55;
}

thead th {
  background: var(--river);
  color: #fff;
  text-align: left;
  padding: 12px 14px;
  font-weight: 650;
  white-space: nowrap;
}

tbody td {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  color: var(--ink-muted);
  vertical-align: top;
}

tbody tr:nth-child(even) {
  background: #faf7f1;
}

tbody tr:hover {
  background: #f3ecdf;
}

/* ========== 时间轴 ========== */

.timeline {
  position: relative;
  margin: 28px 0 12px;
  padding-left: 28px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: linear-gradient(180deg, var(--crimson), var(--river), var(--ivy));
  border-radius: 999px;
}

.timeline-item {
  position: relative;
  margin-bottom: 22px;
  padding: 18px 20px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -24px;
  top: 26px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--crimson);
  box-shadow: 0 0 0 4px rgba(165, 28, 48, 0.12);
}

.timeline-item .t-label {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--crimson);
  margin-bottom: 6px;
}

.timeline-item h5 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 17px;
  color: var(--ink);
}

.timeline-item p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 15px;
}

/* ========== 步骤 ========== */

.steps {
  counter-reset: step;
  list-style: none;
  margin: 18px 0 24px;
  padding: 0;
}

.steps li {
  counter-increment: step;
  position: relative;
  padding: 14px 16px 14px 58px;
  margin-bottom: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 14px;
  top: 14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--river);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.key {
  display: inline;
  padding: 0.05em 0.35em;
  border-radius: 4px;
  background: rgba(28, 78, 128, 0.08);
  color: var(--river);
  font-weight: 650;
  font-family: var(--font-ui);
  font-size: 0.92em;
}

.redline {
  color: var(--crimson);
  font-weight: 700;
}

.checklist {
  list-style: none;
  padding-left: 0;
}

.checklist li {
  position: relative;
  padding-left: 28px;
}

.checklist li::before {
  content: "☐";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--ivy);
  font-size: 16px;
}

.divider {
  height: 1px;
  background: var(--line);
  border: 0;
  margin: 34px 0;
}

.page-end {
  margin-top: 56px;
  padding: 24px 0 0;
  border-top: 1px solid var(--line);
  color: var(--ink-faint);
  font-family: var(--font-ui);
  font-size: 13px;
  text-align: center;
}

.back-top {
  display: inline-block;
  margin-bottom: 28px;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--ink-muted);
  text-decoration: none;
}

.back-top:hover {
  color: var(--crimson);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 24, 0.4);
  z-index: 95;
}

.sidebar-overlay.show {
  display: block;
}

@media (max-width: 980px) {
  .page {
    padding: 28px 28px 96px;
  }

  section.chapter,
  .intro,
  .cover {
    padding-left: 24px;
    padding-right: 24px;
  }

  .chapter-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .page {
    padding: 18px 16px 80px;
  }

  .cover {
    padding: 32px 20px 28px;
    border-radius: 16px;
  }

  section.chapter {
    padding: 24px 18px 28px;
  }

  body {
    font-size: 16px;
  }
}
