:root {
  color-scheme: light;
  --bg: #f8efe2;
  --paper: #fffaf2;
  --paper-2: #fff3df;
  --ink: #2a1714;
  --muted: #82685d;
  --line: #ead3aa;
  --accent: #c91f1f;
  --accent-2: #7f1010;
  --gold: #d6b25e;
  --blue: #6f261e;
  --sidebar: #841414;
  --input: #fffdf8;
  --shadow: 0 18px 50px rgba(94, 20, 17, 0.14);
  font-family: "Songti SC", "Noto Serif CJK SC", "PingFang SC", "Microsoft Yahei", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
}

body {
  font-size: 16px;
  line-height: 1.65;
  background:
    linear-gradient(90deg, rgba(132, 20, 20, 0.08) 0, transparent 240px),
    linear-gradient(180deg, #fbf2e5 0%, #fffaf2 44%, #f7ead8 100%);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--accent-2);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.app-shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 24px;
  border-right: 1px solid rgba(255, 232, 173, 0.32);
  color: #fff8e9;
  background:
    linear-gradient(180deg, #9f1717 0%, #7b1010 52%, #5b0b0b 100%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 6px;
  color: #ffe39a;
  background: rgba(255, 248, 233, 0.12);
  border: 1px solid rgba(255, 232, 173, 0.48);
  font-size: 24px;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.brand h1,
.brand p,
.topbar h2,
.lesson-hero h3,
.section-title h4 {
  margin: 0;
}

.brand h1 {
  max-width: 230px;
  color: #fff8e9;
  font-size: 21px;
  letter-spacing: 0;
  line-height: 1.25;
}

.brand p {
  color: rgba(255, 239, 200, 0.76);
  font-size: 14px;
}

.main {
  min-width: 0;
  padding: 28px clamp(20px, 4vw, 52px) 64px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-2);
  font-size: 14px;
  font-weight: 700;
}

.topbar h2 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.16;
}

.topbar-actions,
.date-row,
.tracker-actions,
.day-picker-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel,
.lesson-hero {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.panel {
  padding: 22px;
  margin-bottom: 18px;
  color: var(--ink);
}

.panel.compact {
  padding: 16px;
}

.lesson-hero {
  position: relative;
  overflow: hidden;
  padding: clamp(24px, 4vw, 42px);
  margin-bottom: 18px;
  background:
    linear-gradient(135deg, rgba(127, 16, 16, 0.1), transparent 40%),
    linear-gradient(180deg, #fffdf8 0%, #fff2df 100%);
}

.lesson-hero::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 6px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent), var(--gold));
}

.lesson-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.lesson-meta span {
  border: 1px solid rgba(127, 16, 16, 0.24);
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--accent-2);
  background: rgba(255, 248, 233, 0.82);
  font-size: 13px;
  font-weight: 700;
}

.lesson-hero h3 {
  max-width: 980px;
  font-size: clamp(30px, 5vw, 58px);
  line-height: 1.08;
  letter-spacing: 0;
}

.lesson-hero p {
  max-width: 880px;
  margin: 18px 0 0;
  color: #6d493f;
  font-size: 18px;
}

.learning-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
  gap: 18px;
  align-items: start;
}

.study-column {
  min-width: 0;
}

.insight-column {
  position: sticky;
  top: 18px;
  min-width: 0;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.lesson-panel {
  min-height: 100%;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.section-title span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 999px;
  color: #ffe9ad;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  font-weight: 700;
}

.section-title h4 {
  font-size: 20px;
}

.mini-card,
.search-prompts,
.question-box {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
  background:
    linear-gradient(180deg, rgba(255, 250, 242, 0.94), rgba(255, 243, 223, 0.88));
}

.mini-card strong,
.search-prompts strong,
.question-box strong {
  color: var(--accent-2);
}

.mini-card p,
.search-prompts p {
  margin: 6px 0 0;
}

.check-list {
  display: grid;
  gap: 9px;
  padding: 0;
  margin: 14px 0 0;
  list-style: none;
}

.check-list li {
  padding-left: 24px;
  position: relative;
}

.check-list li::before {
  content: "•";
  position: absolute;
  left: 6px;
  color: var(--accent);
  font-weight: 900;
}

.resource-list,
.source-library,
.week-plan,
.review-panel,
.source-tiers {
  display: grid;
  gap: 12px;
}

.resource-item,
.source-group,
.week-card,
.review-card,
.source-tier,
.source-method {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
  background: var(--input);
}

.resource-item {
  border-left: 4px solid var(--accent);
}

.resource-item strong,
.week-card strong,
.source-group strong {
  display: block;
  margin-bottom: 4px;
}

.resource-item p,
.week-card p,
.source-group p,
.review-card p {
  margin: 0;
  color: var(--muted);
}

.task-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.learning-loop {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.loop-step {
  min-height: 132px;
  border: 1px solid rgba(127, 16, 16, 0.18);
  border-radius: 6px;
  padding: 10px;
  background: #fff8ed;
}

.loop-step span {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 999px;
  color: #fff8ed;
  background: var(--accent-2);
  font-size: 13px;
  font-weight: 800;
}

.loop-step strong {
  display: block;
  margin-top: 8px;
  color: var(--accent-2);
}

.loop-step p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.note-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 12px;
}

.task-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid rgba(127, 16, 16, 0.18);
  border-radius: 6px;
  padding: 12px;
  background: #fff8ed;
}

.task-item input {
  width: 18px;
  height: 18px;
  margin-top: 4px;
  accent-color: var(--accent);
}

.task-item span {
  display: block;
  font-weight: 700;
}

.task-item small {
  display: block;
  color: var(--muted);
}

.field-label {
  display: block;
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--input);
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid rgba(201, 31, 31, 0.18);
  border-color: rgba(201, 31, 31, 0.62);
}

textarea {
  resize: vertical;
}

.hint,
.lede {
  color: var(--muted);
}

.hint {
  margin: 8px 0 0;
  font-size: 13px;
}

.lede {
  max-width: 860px;
  margin: 0 0 16px;
}

.icon-button,
.primary-button,
.secondary-button,
.text-button,
.tab-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--input);
  color: var(--ink);
}

.icon-button {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  font-size: 24px;
  line-height: 1;
}

.primary-button,
.secondary-button {
  min-height: 42px;
  padding: 9px 14px;
  font-weight: 700;
}

.primary-button {
  border-color: var(--accent);
  color: #fffdf7;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
}

.secondary-button:hover,
.icon-button:hover,
.text-button:hover,
.tab-button:hover {
  border-color: var(--accent);
}

.text-button {
  min-height: 34px;
  padding: 5px 9px;
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 700;
}

.nav-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 18px;
}

.tab-button {
  min-height: 42px;
  padding: 8px;
  font-weight: 700;
  color: #fff8e9;
  background: rgba(255, 248, 233, 0.08);
  border-color: rgba(255, 232, 173, 0.24);
}

.tab-button.active {
  border-color: rgba(255, 232, 173, 0.82);
  color: #6f100f;
  background: #ffe5a6;
}

.day-picker {
  padding: 14px;
}

.day-list {
  display: grid;
  gap: 8px;
  max-height: 52vh;
  overflow: auto;
  margin-top: 12px;
  padding-right: 4px;
}

.day-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  text-align: left;
  color: var(--ink);
  background: var(--input);
}

.day-card.active {
  border-color: var(--accent);
  background: #fff2df;
  box-shadow: inset 3px 0 0 var(--accent);
}

.day-card.done {
  border-color: rgba(201, 31, 31, 0.38);
  background: #fff7ea;
}

.day-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.day-card strong {
  display: block;
  margin-top: 2px;
  line-height: 1.35;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
}

.stat-grid span {
  display: block;
  color: var(--accent);
  font-size: 26px;
  font-weight: 800;
  line-height: 1.2;
}

.stat-grid small {
  color: var(--muted);
  font-size: 12px;
}

.sidebar .field-label,
.sidebar .hint,
.sidebar .stat-grid small {
  color: rgba(92, 52, 42, 0.72);
}

.sidebar .text-button {
  color: var(--accent-2);
  background: #fff8ed;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.source-group ul,
.week-card ul,
.review-card ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.question-box ol {
  margin: 8px 0 0;
  padding-left: 22px;
}

.visual-board {
  overflow: hidden;
}

.visual-map {
  display: grid;
  gap: 12px;
}

.visual-map svg {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(127, 16, 16, 0.08);
}

.visual-map p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.knowledge-focus-card {
  border: 1px solid rgba(127, 16, 16, 0.22);
  border-radius: 8px;
  padding: 16px;
  background:
    linear-gradient(180deg, #fffdf8 0%, #fff1d8 100%);
}

.knowledge-focus-card span {
  display: inline-flex;
  margin-bottom: 8px;
  border: 1px solid rgba(201, 31, 31, 0.24);
  border-radius: 999px;
  padding: 3px 9px;
  color: var(--accent-2);
  background: #fff8ed;
  font-size: 12px;
  font-weight: 800;
}

.knowledge-focus-card strong {
  display: block;
  color: var(--accent-2);
  font-size: 18px;
  line-height: 1.35;
}

.knowledge-focus-card p {
  margin-top: 8px;
}

.knowledge-card-grid {
  display: grid;
  gap: 10px;
}

.knowledge-card {
  border: 1px solid rgba(214, 178, 94, 0.56);
  border-radius: 8px;
  padding: 13px;
  background: #fffdf8;
}

.knowledge-card span {
  display: inline-block;
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.knowledge-card strong {
  display: block;
  color: var(--accent-2);
}

.knowledge-card p {
  margin-top: 5px;
}

.relation-block {
  margin-top: 16px;
}

.relation-block strong,
.source-tier strong,
.source-method strong {
  color: var(--accent-2);
}

.relation-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.relation-chips span {
  border: 1px solid rgba(201, 31, 31, 0.2);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--accent-2);
  background: #fff2df;
  font-size: 13px;
  font-weight: 700;
}

.source-tier p,
.source-method p {
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.source-tier ul {
  margin: 0;
  padding-left: 18px;
}

.card-lab-panel {
  overflow: hidden;
}

.card-toolbar {
  display: grid;
  gap: 12px;
}

.card-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.note-card-preview {
  margin-top: 14px;
  border: 1px solid rgba(127, 16, 16, 0.22);
  border-radius: 8px;
  padding: 12px;
  background:
    linear-gradient(180deg, rgba(127, 16, 16, 0.06), rgba(214, 178, 94, 0.12)),
    #fffdf8;
}

.knowledge-svg {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 18px 42px rgba(94, 20, 17, 0.18);
}

.source-methods {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.feishu-preview {
  max-height: 430px;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
  color: #341c17;
  background: #fffdf8;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  border-radius: 6px;
  padding: 12px 14px;
  color: #fffdf7;
  background: var(--accent-2);
  box-shadow: var(--shadow);
}

@media (max-width: 980px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .day-list {
    max-height: 320px;
  }

  .learning-layout,
  .content-grid,
  .task-grid,
  .learning-loop,
  .note-grid,
  .source-methods {
    grid-template-columns: 1fr;
  }

  .insight-column {
    position: static;
  }
}

@media (max-width: 620px) {
  .sidebar,
  .main {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
  }

  .topbar-actions {
    flex-direction: column;
  }

  .lesson-hero h3 {
    font-size: 32px;
  }

  .tracker-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .nav-tabs {
    grid-template-columns: repeat(2, 1fr);
  }
}
