:root {
  --bg: #f6f4ef;
  --surface: #fffdf8;
  --ink: #202124;
  --muted: #69716f;
  --line: #ded8cc;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --accent-soft: #d9f3ec;
  --gold: #b7791f;
  --blue: #2563eb;
  --red: #b91c1c;
  --shadow: 0 18px 44px rgba(53, 42, 28, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  line-height: 1.55;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px clamp(18px, 4vw, 48px);
  background: rgba(246, 244, 239, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(24px, 3vw, 36px);
}

h2 {
  margin-bottom: 0;
  font-size: 26px;
}

h3 {
  margin-bottom: 12px;
  font-size: 18px;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.countdown {
  display: grid;
  grid-template-columns: auto auto;
  align-items: baseline;
  min-width: 178px;
  padding: 12px 16px;
  border: 1px solid #b7ded5;
  border-radius: 8px;
  background: #ebfbf7;
  color: var(--accent-dark);
  text-align: right;
}

.countdown span:first-child {
  font-size: 32px;
  font-weight: 800;
}

.countdown small {
  margin-left: 4px;
  font-weight: 700;
}

.countdown span:last-child {
  grid-column: 1 / 3;
  color: var(--ink);
  font-weight: 700;
}

.layout {
  display: grid;
  grid-template-columns: 176px minmax(0, 1fr);
  gap: 22px;
  width: min(1220px, calc(100% - 32px));
  margin: 22px auto 48px;
}

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

.nav-button,
.ghost-button,
.primary-button,
.choice-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.nav-button {
  padding: 10px 12px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.nav-button.active,
.nav-button:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.content {
  min-width: 0;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel,
.card,
.drill,
.wrong-item,
.cram-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  padding: 20px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 16px;
}

.focus-panel {
  border-color: #a7d9d0;
  background: linear-gradient(180deg, #f9fffc, #fffdf8);
}

.privacy-panel {
  border-color: #bfd7ff;
  background: #f7fbff;
}

.privacy-panel h3 {
  color: #1d4ed8;
}

.large-text {
  margin-bottom: 10px;
  font-size: 20px;
  font-weight: 700;
}

.muted {
  color: var(--muted);
}

.route-list {
  display: grid;
  gap: 12px;
}

.route-list div {
  display: grid;
  gap: 2px;
}

.route-list span {
  color: var(--muted);
}

.meter {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7e0d4;
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 180ms ease;
}

.compact-list {
  margin: 0;
  padding-left: 20px;
}

.plan-panel {
  margin-top: 16px;
}

.plan-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.plan-day {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf6;
}

.plan-day.today {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.plan-day strong {
  display: block;
  margin-bottom: 8px;
}

.select {
  min-height: 42px;
  max-width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

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

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

.card {
  padding: 18px;
}

.card h3 {
  color: var(--accent-dark);
}

.learning-note {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.learning-note div {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid #d7ebe6;
  border-radius: 8px;
  background: #f2fbf8;
}

.learning-note strong {
  color: var(--accent-dark);
}

.learning-note span {
  color: var(--ink);
}

.glossary-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.term-button {
  min-height: 32px;
  padding: 4px 9px;
  border: 1px solid #a7d9d0;
  border-radius: 999px;
  background: #f2fbf8;
  color: var(--accent-dark);
  cursor: pointer;
  font-weight: 700;
}

.term-explain,
.mini-feedback {
  margin-top: 10px;
  padding: 12px;
  border-radius: 8px;
  background: #f7f3ea;
}

.card-quiz,
.mini-quiz {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid #dbe4f0;
  border-radius: 8px;
  background: #f8fbff;
}

.card-quiz p {
  margin-bottom: 10px;
}

.card-quiz-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-choice {
  min-height: 34px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  cursor: pointer;
}

.mini-choice.selected {
  border-color: var(--blue);
  background: #eef5ff;
}

.mini-feedback.correct {
  border: 1px solid #86efac;
  background: #ecfdf5;
}

.mini-feedback.wrong {
  border: 1px solid #fecaca;
  background: #fef2f2;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.tag {
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
  font-weight: 700;
}

.warning {
  margin-top: 12px;
  padding: 10px 12px;
  border-left: 4px solid var(--gold);
  background: #fff7e6;
}

.quiz-panel {
  max-width: 840px;
}

.quiz-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  color: var(--muted);
  font-weight: 700;
}

.choice-list {
  display: grid;
  gap: 10px;
}

.choice-button {
  width: 100%;
  padding: 12px 14px;
  background: #fbfaf6;
  text-align: left;
}

.choice-button.selected {
  border-color: var(--blue);
  background: #eef5ff;
}

.text-answer {
  width: 100%;
  min-height: 96px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  resize: vertical;
}

.quiz-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.primary-button,
.ghost-button {
  padding: 9px 14px;
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
  font-weight: 700;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.ghost-button {
  background: var(--surface);
  color: var(--ink);
}

.ghost-button:hover {
  border-color: var(--accent);
}

.feedback {
  margin-top: 16px;
  padding: 14px;
  border-radius: 8px;
  background: #f3f4f6;
}

.feedback.correct {
  border: 1px solid #86efac;
  background: #ecfdf5;
}

.feedback.wrong {
  border: 1px solid #fecaca;
  background: #fef2f2;
}

.drill-list,
.wrong-list,
.cram-list {
  display: grid;
  gap: 16px;
}

.drill,
.wrong-item,
.cram-item {
  padding: 18px;
}

.step-list {
  margin: 0;
  padding-left: 22px;
}

.formula {
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #eef5ff;
  color: #1e3a8a;
  font-weight: 700;
}

.answer {
  color: var(--accent-dark);
  font-weight: 800;
}

.animation-panel {
  overflow: hidden;
}

.animation-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1.25fr) minmax(260px, 0.75fr);
  gap: 18px;
  align-items: stretch;
}

.animation-stage {
  min-height: 360px;
  padding: 18px;
  border: 1px solid #c9ded8;
  border-radius: 8px;
  background: #f4fbf8;
}

.animation-side {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf6;
}

.animation-steps {
  margin-top: 16px;
}

.step-meter {
  margin-bottom: 10px;
}

.state-board,
.pv-board,
.deadlock-board,
.banker-board,
.paging-board,
.memory-board,
.timeline-board,
.disk-board {
  position: relative;
  min-height: 320px;
}

.state-zone {
  position: absolute;
  display: grid;
  place-items: center;
  width: 30%;
  min-height: 100px;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: white;
  text-align: center;
}

.state-zone span {
  color: var(--accent-dark);
  font-size: 24px;
  font-weight: 800;
}

.ready-zone { left: 2%; top: 34%; }
.cpu-zone { left: 35%; top: 10%; }
.blocked-zone { right: 2%; top: 56%; }

.moving-dot {
  position: absolute;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.28);
  transition: all 280ms ease;
}

.state-board.ready .moving-dot { left: 14%; top: 62%; }
.state-board.cpu .moving-dot { left: 46%; top: 38%; }
.state-board.blocked .moving-dot { left: 74%; top: 74%; }

.pv-board {
  display: grid;
  grid-template-columns: 120px 1fr 150px;
  gap: 16px;
  align-items: center;
}

.counter-card,
.critical-room,
.wait-line {
  display: grid;
  place-items: center;
  min-height: 130px;
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: white;
  text-align: center;
  font-weight: 800;
}

.pv-board.counter .counter-card,
.pv-board.inside .critical-room,
.pv-board.queue .wait-line,
.pv-board.wake .wait-line {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.deadlock-board {
  display: grid;
  place-items: center;
}

.road {
  position: absolute;
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  border-radius: 8px;
  background: white;
  border: 2px solid var(--line);
  color: var(--accent-dark);
  font-weight: 900;
}

.road-top { top: 20px; }
.road-right { right: 64px; }
.road-bottom { bottom: 20px; }
.road-left { left: 64px; }

.center-label {
  display: grid;
  place-items: center;
  width: 150px;
  height: 150px;
  border: 3px solid var(--accent);
  border-radius: 50%;
  background: var(--accent-soft);
  text-align: center;
  font-weight: 900;
}

.banker-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-content: center;
}

.banker-board div,
.address-box,
.page-table,
.frame,
.time-slice {
  display: grid;
  place-items: center;
  min-height: 92px;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: white;
  text-align: center;
  font-weight: 800;
}

.banker-board div:nth-child(2),
.paging-board.table .page-table,
.address-box.physical {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.paging-board {
  display: grid;
  grid-template-columns: 1fr 44px 1fr 44px 1fr;
  gap: 10px;
  align-items: center;
}

.arrow {
  color: var(--accent-dark);
  font-size: 28px;
  font-weight: 900;
  text-align: center;
}

.memory-board,
.timeline-board {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

.frame {
  width: 92px;
  min-height: 118px;
}

.time-slice {
  min-width: 96px;
}

.disk-board {
  display: grid;
  align-items: center;
}

.disk-line {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 50%;
  height: 6px;
  border-radius: 999px;
  background: #d8d2c6;
}

.disk-head,
.disk-request {
  position: absolute;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: white;
  font-weight: 900;
}

.disk-head {
  left: 35%;
  top: calc(50% - 80px);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.disk-request {
  top: calc(50% + 26px);
}

.disk-request.r1 { left: 25%; }
.disk-request.r2 { left: 52%; }
.disk-request.r3 { left: 72%; }

.mini-input {
  width: min(340px, 100%);
  min-height: 40px;
  margin-right: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.empty-state {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.7);
  color: var(--muted);
  text-align: center;
}

.cram-item {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 16px;
}

.cram-item strong {
  color: var(--accent-dark);
}

@media (max-width: 860px) {
  .topbar {
    position: static;
    align-items: stretch;
    flex-direction: column;
  }

  .countdown {
    width: 100%;
    text-align: left;
  }

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

  .sidebar {
    position: static;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav-button {
    text-align: center;
  }

  .dashboard-grid,
  .cards-grid,
  .plan-list,
  .animation-layout {
    grid-template-columns: 1fr;
  }

  .animation-stage {
    min-height: 300px;
  }

  .pv-board,
  .banker-board,
  .paging-board {
    grid-template-columns: 1fr;
  }

  .arrow {
    transform: rotate(90deg);
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .cram-item {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .layout {
    width: min(100% - 20px, 1220px);
  }

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

  h2 {
    font-size: 22px;
  }
}
