:root {
  --bg: #f7f5ef;
  --panel: #fffdf8;
  --text: #1d2528;
  --muted: #64706f;
  --line: #d9ded8;
  --blue: #245b89;
  --blue-weak: #e8f1f7;
  --green: #2f6f55;
  --green-weak: #e7f2ec;
  --amber: #a45f16;
  --amber-weak: #f8ecd8;
  --shadow: 0 16px 38px rgba(35, 43, 45, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  padding: 26px 32px;
  color: #fff;
  background: #671f28;
}

h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 760;
  letter-spacing: 0;
}

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 24px;
  padding: 24px 32px 40px;
}

.sidebar {
  position: sticky;
  top: 16px;
  align-self: start;
  display: grid;
  gap: 18px;
}

.search-panel,
.sidebar section,
.section-header,
.search-results,
.card,
.empty-state {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.sidebar section {
  padding: 16px;
}

.search-panel {
  padding: 16px;
}

.field-label,
.side-title {
  display: block;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.search-box {
  display: grid;
  grid-template-columns: 1fr 36px;
  min-height: 42px;
  border: 1px solid #b9c4c0;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.search-box:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(36, 91, 137, 0.15);
}

.search-box input {
  min-width: 0;
  padding: 10px 12px;
  border: 0;
  outline: 0;
  background: transparent;
}

.icon-button {
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 22px;
}

.icon-button:hover {
  color: var(--text);
  background: #eef1ee;
}

.scope-control {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.scope-control label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.subject-list,
.section-list {
  display: grid;
  gap: 8px;
}

.tab-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.tab-button:hover {
  background: #f1f4f1;
}

.tab-button.active {
  border-color: #9bb8b0;
  background: var(--green-weak);
}

.tab-count {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.nav-module {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.nav-module-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  padding: 8px 10px;
  cursor: pointer;
  list-style: none;
}

.nav-module-head::-webkit-details-marker {
  display: none;
}

.nav-module-head:hover {
  background: #f1f4f1;
}

.nav-module-title {
  min-width: 0;
  font-weight: 750;
}

.nav-module-title::before {
  content: "▸";
  display: inline-block;
  width: 16px;
  color: var(--blue);
  font-size: 12px;
}

.nav-module[open] .nav-module-title::before {
  content: "▾";
}

.nav-module-list {
  display: grid;
  gap: 6px;
  padding: 0 8px 8px;
}

.nav-module-list .tab-button {
  min-height: 36px;
  padding-left: 24px;
}

.content-area {
  min-width: 0;
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
  margin-bottom: 16px;
}

.section-header h2 {
  margin: 0 0 4px;
  font-size: 22px;
  letter-spacing: 0;
}

.section-header p {
  margin: 0;
  color: var(--muted);
}

.header-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.small-pill {
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--blue);
  background: var(--blue-weak);
  font-size: 12px;
  white-space: nowrap;
}

.cards {
  display: grid;
  gap: 16px;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.filter-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid #b9c4c0;
  border-radius: 8px;
  color: var(--text);
  background: #fff;
}

.filter-button:hover {
  border-color: var(--blue);
}

.filter-button.active {
  border-color: #9bb8b0;
  background: var(--green-weak);
}

.year-filter {
  align-items: center;
}

.select-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.year-select {
  min-width: 150px;
  min-height: 36px;
  padding: 7px 34px 7px 11px;
  border: 1px solid #b9c4c0;
  border-radius: 8px;
  color: var(--text);
  background: #fff;
  font: inherit;
}

.year-select:focus {
  border-color: var(--blue);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(36, 91, 137, 0.15);
}

.card {
  scroll-margin-top: 20px;
  padding: 16px;
}

.core-module {
  display: grid;
  gap: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.core-module-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
}

.core-module-head::-webkit-details-marker {
  display: none;
}

.core-module-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 760;
  letter-spacing: 0;
}

.core-module-title::before {
  content: "▸";
  color: var(--blue);
  font-size: 16px;
}

.core-module[open] .core-module-title::before {
  content: "▾";
}

.core-module-list {
  display: grid;
  gap: 12px;
  padding: 0 12px 12px;
}

.card.flash {
  outline: 3px solid rgba(164, 95, 22, 0.32);
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.card-title {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
  letter-spacing: 0;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tag {
  padding: 3px 8px;
  border-radius: 999px;
  color: #46605b;
  background: #eff3ef;
  font-size: 12px;
}

.tag.kind-answer {
  color: var(--amber);
  background: var(--amber-weak);
}

.tag.kind-question {
  color: var(--blue);
  background: var(--blue-weak);
}

.card-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.link-button,
.text-button {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 11px;
  border: 1px solid #b9c4c0;
  border-radius: 8px;
  color: var(--text);
  background: #fff;
  text-decoration: none;
  font-size: 14px;
}

.link-button:hover,
.text-button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.body-preview {
  margin: 0;
  color: #3e494b;
}

.full-text {
  margin: 0;
  padding: 12px;
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  background: #f8faf8;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.full-text-open {
  max-height: none;
  margin-top: 0;
  font-size: 16px;
  line-height: 1.75;
}

.experience-image {
  display: block;
  width: min(360px, 100%);
  height: auto;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.mock-set {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.mock-panel {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.mock-panel h4 {
  margin: 0 0 8px;
  font-size: 15px;
}

.mock-active .card-head {
  margin-bottom: 14px;
}

.search-results {
  padding: 16px;
  margin-bottom: 16px;
}

.search-results h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.result-list {
  display: grid;
  gap: 8px;
}

.result-button {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-align: left;
}

.result-button:hover {
  border-color: var(--blue);
}

.result-title {
  display: block;
  margin-bottom: 4px;
  font-weight: 720;
}

.result-meta,
.result-snippet {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

mark {
  padding: 0 2px;
  border-radius: 3px;
  background: #ffe18b;
}

.empty-state {
  padding: 26px;
  color: var(--muted);
}

@media (max-width: 900px) {
  .topbar {
    padding: 22px 18px;
  }

  .workspace {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .sidebar {
    position: static;
  }

  .subject-list,
  .section-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  h1 {
    font-size: 24px;
  }

  .subject-list,
  .section-list,
  .mock-set {
    grid-template-columns: 1fr;
  }

  .section-header,
  .card-head {
    flex-direction: column;
  }

  .card-actions,
  .header-tools {
    justify-content: flex-start;
  }
}
