:root {
  --bg: #F7F5F0;
  --surface: #FFFFFF;
  --surface-alt: #EFECE6;
  --surface-hover: #E6E2DA;
  --border: rgba(20, 20, 19, 0.09);
  --border-strong: rgba(20, 20, 19, 0.18);
  --text: #141413;
  --text-secondary: #57544E;
  --text-muted: #848078;
  --primary: #141413;
  --primary-hover: #2C2C2A;
  --on-primary: #F7F5F0;
  --primary-soft: rgba(20, 20, 19, 0.05);
  --primary-border: rgba(20, 20, 19, 0.20);
  --brass: #9E7A3C;
  --accent: #059669;
  --emerald: #059669;
  --emerald-soft: rgba(5, 150, 105, 0.10);
  --emerald-border: rgba(5, 150, 105, 0.28);
  --amber: #D97706;
  --amber-soft: rgba(217, 119, 6, 0.10);
  --amber-border: rgba(217, 119, 6, 0.28);
  --red: #DC2626;
  --red-soft: rgba(220, 38, 38, 0.10);
  --red-border: rgba(220, 38, 38, 0.28);
  --purple: #7C3AED;
  --purple-soft: rgba(124, 58, 237, 0.10);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 6px 20px -4px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 18px 42px -8px rgba(0, 0, 0, 0.14);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --font-display: "Instrument Serif", "PingFang SC", "Hiragino Sans GB", Georgia, serif;
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-serif: var(--font-display);
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

[data-theme="dark"] {
  --bg: #111317;
  --surface: #171A20;
  --surface-alt: #1E222A;
  --surface-hover: #262B35;
  --border: rgba(242, 240, 235, 0.10);
  --border-strong: rgba(242, 240, 235, 0.22);
  --text: #F2F0EB;
  --text-secondary: #A9AEB8;
  --text-muted: #767C87;
  --primary: #F2F0EB;
  --primary-hover: #E0DDD5;
  --on-primary: #111317;
  --primary-soft: rgba(242, 240, 235, 0.09);
  --primary-border: rgba(242, 240, 235, 0.26);
  --brass: #C9A96E;
  --accent: #34D399;
  --emerald: #34D399;
  --emerald-soft: rgba(52, 211, 153, 0.12);
  --emerald-border: rgba(52, 211, 153, 0.30);
  --amber: #F59E0B;
  --amber-soft: rgba(245, 158, 11, 0.12);
  --amber-border: rgba(245, 158, 11, 0.30);
  --red: #EF4444;
  --red-soft: rgba(239, 68, 68, 0.12);
  --red-border: rgba(239, 68, 68, 0.30);
  --purple: #A78BFA;
  --purple-soft: rgba(167, 139, 250, 0.12);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.40);
  --shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.60);
  --shadow-lg: 0 20px 44px -8px rgba(0, 0, 0, 0.75);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select {
  font-family: inherit;
  color: inherit;
}

.mono {
  font-family: var(--font-mono);
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(250, 249, 246, 0.86);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

[data-theme="dark"] .topbar {
  background: rgba(17, 19, 23, 0.86);
}

.topbar-inner {
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--on-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.brand-text {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.brand-name {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.badge-free {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.search-trigger {
  flex: 1;
  max-width: 440px;
  margin-left: auto;
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.search-trigger:hover {
  border-color: var(--primary);
  background: var(--surface);
}

.search-trigger-text {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  text-align: left;
}

.kbd-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-icon-text, .btn-icon, .btn-cart {
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 11px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-icon {
  width: 36px;
  padding: 0;
  justify-content: center;
}

.btn-icon-text:hover, .btn-icon:hover, .btn-cart:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-cart {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.cart-count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.lang-select {
  appearance: none;
  -webkit-appearance: none;
  height: 36px;
  padding: 0 30px 0 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background-color: var(--surface-alt);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23F2F0EB' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px 12px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  vertical-align: middle;
  cursor: pointer;
}

[data-theme="light"] .lang-select,
[data-theme="light"] .catalog-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23141413' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

.lang-select:hover {
  border-color: var(--text-muted);
}
[data-theme="light"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: none; }

/* Main Container */
.app-root {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 40px 80px;
  min-height: calc(100vh - 64px);
}

@media (min-width: 1220px) {
  .app-root {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}

@media (max-width: 720px) {
  .app-root {
    padding: 0 18px 64px;
  }
}

/* Buttons & Pills */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-alt);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.btn-active-emerald {
  background: var(--emerald-soft);
  border: 1.5px solid var(--emerald);
  color: var(--emerald);
}

.btn-active-amber {
  background: var(--amber-soft);
  border: 1.5px solid var(--amber);
  color: var(--amber);
}

.btn-active-primary {
  background: var(--primary);
  border: 1.5px solid var(--primary);
  color: var(--on-primary);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.pill:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

/* Catalog Home — Swiss-Editorial Architectural Masthead */
.hero-banner {
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg width='32' height='32' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='1' cy='1' r='0.9' fill='rgba(242,240,235,0.09)'/%3E%3C/svg%3E");
  background-size: 32px 32px;
  border: none;
  border-bottom: 1px solid var(--border);
  margin: 0 -40px 40px;
  padding: 84px 40px 68px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
}

[data-theme="light"] .hero-banner {
  background-image: url("data:image/svg+xml,%3Csvg width='32' height='32' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='1' cy='1' r='0.9' fill='rgba(20,20,19,0.11)'/%3E%3C/svg%3E");
}

@media (max-width: 720px) {
  .hero-banner {
    margin: 0 -18px 28px;
    padding: 52px 18px 44px;
  }
}

.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass);
}

.hero-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(46px, 5.8vw, 74px);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.18;
  max-width: 860px;
  color: var(--text);
}

.hero-title-italic {
  display: block;
  margin-top: 10px;
  font-style: italic;
  color: var(--text-secondary);
}

:lang(zh) .hero-title-italic,
:lang(zh-TW) .hero-title-italic,
:lang(ja) .hero-title-italic,
:lang(ko) .hero-title-italic {
  font-style: normal;
}

.hero-desc {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 15.5px;
  max-width: 560px;
  line-height: 1.6;
}

.hero-spotlight-search {
  margin-top: 12px;
  width: 100%;
  max-width: 580px;
  height: 54px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.hero-spotlight-search:hover {
  border-color: var(--primary);
  background: var(--surface-alt);
}

.hero-spotlight-text {
  flex: 1;
  text-align: left;
  font-size: 14.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero-quick-jump {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.quick-jump-label {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-right: 2px;
}

.quick-jump-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background-color 0.15s;
}

.quick-jump-chip:hover {
  border-color: var(--primary);
  color: var(--text);
  background: var(--surface-alt);
}

.pinned-section {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.pinned-inline-label {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-right: 4px;
}

.pinned-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pinned-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.pinned-chip .mono {
  color: var(--brass);
  font-weight: 600;
}

.pinned-chip:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.system-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
  margin-bottom: 18px;
}

.system-tab {
  padding: 10px 2px 12px;
  border-radius: 0;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

.system-tab:hover {
  background: transparent;
  color: var(--text);
}

.system-tab.active {
  background: transparent;
  border-bottom-color: var(--text);
  color: var(--text);
  box-shadow: none;
}

.count-badge {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--text-muted);
}

.filter-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.quick-filter-input {
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  min-width: 220px;
}

.quick-filter-input:focus {
  outline: none;
  border-color: var(--primary);
}

.catalog-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.catalog-filter-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.catalog-select {
  appearance: none;
  -webkit-appearance: none;
  height: 34px;
  padding: 0 28px 0 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23F2F0EB' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 12px 12px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
}

.catalog-count-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.subject-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

@media (max-width: 960px) {
  .subject-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

.subject-card {
  background: var(--surface);
  border: none;
  border-radius: 0;
  padding: 28px;
  min-height: 176px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: background-color 0.15s ease;
  cursor: pointer;
}

.subject-card:hover {
  background: var(--surface-alt);
}

.subject-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.subject-code-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.subject-code-strong {
  color: var(--text);
  font-weight: 600;
}

.dot-sep {
  opacity: 0.5;
}

.subject-go-link {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.subject-card:hover .subject-go-link {
  color: var(--text);
}

.interactive-dot-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--emerald);
}

.interactive-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--emerald);
}

.board-code-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.board-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-alt);
  color: var(--text-secondary);
}

.code-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
}

.pin-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  font-size: 15px;
  line-height: 1;
}

.pin-btn.pinned {
  color: var(--amber);
}

.subject-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
}

.subject-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 10px;
}

.subject-card-foot {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.demo-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--emerald-soft);
  color: var(--emerald);
}

.preview-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--text-muted);
}

/* Subject Workspace */
.workspace-header {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 4px 0 20px;
  margin-bottom: 20px;
}

.breadcrumb-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.breadcrumb a {
  color: var(--primary);
  font-weight: 600;
}

.workspace-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.workspace-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(32px, 3.8vw, 46px);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.1;
  display: flex;
  align-items: center;
  gap: 14px;
}

.workspace-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 8px;
  padding: 0;
  background: transparent;
  border: none;
  margin-top: 16px;
}

.ws-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface-hover);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s;
}

.ws-tab-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  white-space: nowrap;
  flex-shrink: 0;
}

.ws-tab.active .ws-tab-badge {
  background: rgba(255, 255, 255, 0.18);
  color: var(--on-primary);
  border-color: transparent;
}

[data-theme="dark"] .ws-tab.active .ws-tab-badge {
  background: rgba(9, 9, 11, 0.18);
}

.ws-tab:hover {
  background: var(--surface-hover);
  border-color: var(--text-muted);
  color: var(--text);
}

[data-theme="dark"] .ws-tab:hover {
  background: var(--surface-hover);
}

.ws-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
  font-weight: 650;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.24);
}

/* Split Layout */
.split-layout {
  display: grid;
  grid-template-columns: 270px 1fr;
  gap: 18px;
  align-items: start;
}

.sidebar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  position: sticky;
  top: 76px;
}

.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chapter-item {
  width: 100%;
  text-align: left;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chapter-item:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.chapter-item.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
}

.chapter-item.active .count-badge {
  background: rgba(255, 255, 255, 0.18);
  color: var(--on-primary);
}

[data-theme="dark"] .chapter-item.active .count-badge {
  background: rgba(20, 20, 19, 0.16);
}

/* Question Cards */
.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 26px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.question-card:hover {
  border-color: var(--border-strong);
}

.q-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.q-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.diff-easy {
  background: var(--emerald-soft);
  color: var(--emerald);
  border: 1px solid var(--emerald-border);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.diff-medium {
  background: var(--amber-soft);
  color: var(--amber);
  border: 1px solid var(--amber-border);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.diff-hard {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid var(--red-border);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.marks-badge {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-alt);
  color: var(--text);
}

.q-stem {
  font-family: var(--font-serif);
  font-size: 15.5px;
  line-height: 1.75;
  margin-bottom: 14px;
  color: var(--text);
}

.q-diagram {
  margin: 12px 0;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  display: flex;
  justify-content: center;
  overflow-x: auto;
}

.q-subparts {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.q-subpart {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0 6px 14px;
  border-radius: 0;
  border-left: 2px solid var(--border-strong);
  background: transparent;
}

.mcq-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.mcq-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
}

.mcq-option:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--surface-alt);
}

.mcq-option.correct {
  border-color: var(--emerald);
  background: var(--emerald-soft);
  color: var(--emerald);
  font-weight: 600;
}

.mcq-option.wrong {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
}

.mcq-letter {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}

.mcq-feedback {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mcq-feedback.correct {
  background: var(--emerald-soft);
  color: var(--emerald);
  border: 1px solid var(--emerald-border);
}

.mcq-feedback.wrong {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid var(--red-border);
}

.q-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.q-action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.q-drawer {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  font-size: 14px;
}

.q-drawer.ms {
  border-left: 4px solid var(--emerald);
}

.q-drawer.ws {
  border-left: 4px solid var(--primary);
}

.q-drawer.tip {
  border-left: 4px solid var(--amber);
  background: var(--amber-soft);
}

.ms-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
}

.ms-row:last-child {
  border-bottom: none;
}

.ms-code {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--emerald-soft);
  color: var(--emerald);
  flex-shrink: 0;
}

/* Revision Notes */
.note-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
}

.note-bilingual-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 12px;
}

.note-box {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  margin-bottom: 14px;
}

.note-box.formula {
  border-left: 4px solid var(--primary);
  background: var(--primary-soft);
}

.note-box.tip {
  border-left: 4px solid var(--amber);
  background: var(--amber-soft);
}

/* Flashcards */
.flashcard-stage {
  max-width: 680px;
  margin: 0 auto;
}

.flashcard-scene {
  perspective: 1100px;
  height: 290px;
  margin: 16px 0;
  cursor: pointer;
}

.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  transform-style: preserve-3d;
}

.flashcard-inner.flipped {
  transform: rotateY(180deg);
}

.flashcard-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.flashcard-back {
  transform: rotateY(180deg);
  background: var(--primary-soft);
  border-color: var(--primary-border);
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.data-table th, .data-table td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.data-table th {
  background: var(--surface-alt);
  font-weight: 700;
  color: var(--text-secondary);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 16px 24px;
  overflow-y: auto;
}

.modal-card {
  width: 100%;
  max-width: 680px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.cmd-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.cmd-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  outline: none;
}

.cmd-results {
  max-height: 400px;
  overflow-y: auto;
  padding: 8px;
}

.cmd-item {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
}

.cmd-item:hover, .cmd-item.selected {
  background: var(--primary-soft);
  color: var(--primary);
}

/* Toast */
.toast-root {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--text);
  color: var(--surface);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
}

/* Progress bar */
.progress-track {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: var(--surface-alt);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--emerald);
  border-radius: 999px;
  transition: width 0.25s;
}

/* Print Sheet */
.print-sheet {
  display: none;
}

/* ===== UI/UX Polish & Academic Craft Enhancements ===== */
.stat-chip-val,
.code-badge,
.mock-timer,
.progress-fill,
.marks-pill {
  font-variant-numeric: tabular-nums;
}

.hero-title,
.workspace-title {
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.note-col,
.drawer-body {
  max-width: 68ch;
  line-height: 1.65;
}

.btn,
.pill,
.ws-tab,
.mcq-option {
  transition: transform 0.12s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.btn:active:not(:disabled),
.pill:active:not(:disabled),
.mcq-option:active:not(:disabled) {
  transform: scale(0.98);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

@keyframes drawerReveal {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.drawer-box {
  animation: drawerReveal 0.18s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .drawer-box {
    animation: none;
  }
  .btn,
  .pill,
  .ws-tab,
  .mcq-option {
    transition: none;
  }
}

/* Partner Sponsor Banner & Taobao Booklet CTA */
.partner-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.partner-banner,
.booklet-cta-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.partner-banner {
  border-left: 1px solid var(--border);
}

.booklet-cta-card {
  border-left: 1px solid var(--border);
  background: var(--surface-alt);
}

.partner-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.partner-tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.partner-title {
  font-size: 14px;
  font-weight: 650;
  color: var(--text);
}

.partner-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.partner-cta {
  flex-shrink: 0;
  white-space: nowrap;
  text-decoration: none;
}

/* Past Papers Archive Hub */
.pp-filter-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.pp-stats-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.pp-stats-pill {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--surface-alt);
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.pp-year-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Past Papers Swiss Architectural Ledger */
.pp-sessions-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
}

.pp-ledger-row {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 28px;
  padding: 22px 0;
  border-bottom: 1px solid var(--border);
}

@media (max-width: 780px) {
  .pp-ledger-row {
    grid-template-columns: 1fr;
    gap: 14px;
  }
}

.pp-ledger-year {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pp-ledger-year-num {
  font-size: 26px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--text);
}

.pp-ledger-session {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--brass);
}

.pp-ledger-meta-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.pp-ledger-papers {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pp-paper-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
}

.pp-paper-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 500;
}

.pp-paper-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pp-dl-qp {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

.pp-dl-qp:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.pp-dl-ms {
  background: var(--emerald-soft);
  border-color: var(--emerald-border);
  color: var(--emerald);
}

.pp-dl-ms:hover {
  border-color: var(--emerald);
}

@media (max-width: 900px) {
  .split-layout {
    grid-template-columns: 1fr;
  }
  .sidebar-card {
    position: static;
  }
  .note-bilingual-grid {
    grid-template-columns: 1fr;
  }
  .brand-sub, .badge-free {
    display: none;
  }
}

@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .topbar, .app-root, #modal-root, .toast-root, .partner-strip {
    display: none !important;
  }
  .print-sheet {
    display: block !important;
    padding: 0;
    font-family: var(--font-sans);
    color: #000000;
  }
  .print-header {
    border-bottom: 2px solid #000;
    padding-bottom: 12px;
    margin-bottom: 20px;
  }
  .print-question {
    margin-bottom: 24px;
    page-break-inside: avoid;
  }
  .print-lines {
    height: 70px;
    border-bottom: 1px dashed #cbd5e1;
    margin-top: 8px;
  }
  .print-ms-section {
    page-break-before: always;
  }
}
