:root {
  color-scheme: light;
  --ink: #1f2523;
  --muted: #68736f;
  --line: #dce3df;
  --paper: #fbfcfa;
  --panel: #ffffff;
  --soft: #eef5f1;
  --accent: #28685c;
  --accent-2: #be5b39;
  --accent-3: #3a6f99;
  --dark: #22352f;
  --shadow: 0 18px 45px rgba(33, 43, 39, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

button {
  border: 0;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #edf4f0;
}

.auth-card {
  width: min(460px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.brand {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 14px;
  align-items: center;
}

.brand-auth {
  margin-bottom: 24px;
}

.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e8c766;
  color: var(--dark);
  font-weight: 800;
}

.brand h1,
.topbar h2,
.section-header h3 {
  margin: 0;
  line-height: 1.2;
}

.brand h1 {
  font-size: 22px;
}

.eyebrow,
.section-kicker,
.nav-title {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0;
}

.auth-form,
.resource-form {
  display: grid;
  gap: 14px;
}

.auth-form label,
.resource-form label {
  display: grid;
  gap: 8px;
  color: #39423f;
  font-size: 14px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfdfc;
  color: var(--ink);
}

input,
select {
  height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 128px;
  padding: 12px;
  resize: vertical;
  line-height: 1.6;
}

#loginMessage,
#resourceMessage {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.primary-button {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 6px;
  color: #fff;
  background: var(--accent);
}

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

.app-shell.practice-fullscreen {
  display: block;
  background: var(--paper);
}

.app-shell.practice-fullscreen .sidebar,
.app-shell.practice-fullscreen .topbar,
.app-shell.practice-fullscreen .summary-band,
.app-shell.practice-fullscreen #studentView > .review-panel {
  display: none;
}

.app-shell.practice-fullscreen .workspace {
  min-height: 100vh;
  padding: 0;
}

.app-shell.practice-fullscreen .student-layout,
.app-shell.practice-fullscreen .content-grid {
  display: block;
}

.app-shell.practice-fullscreen .practice-panel {
  min-height: 100vh;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.app-shell.practice-fullscreen .practice-panel > .section-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.app-shell.practice-fullscreen #practiceBody {
  max-width: 920px;
  margin: 0 auto;
  padding-bottom: 42px;
}

.sidebar {
  background: var(--dark);
  color: #f7fbf7;
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.sidebar .eyebrow,
.sidebar .nav-title {
  color: #b9c8c1;
}

.user-panel {
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.user-panel strong,
.user-panel span {
  display: block;
}

.user-panel strong {
  font-size: 18px;
}

.user-panel span {
  margin: 5px 0 12px;
  color: #c8d7d0;
  font-size: 13px;
}

.ghost-dark-button {
  width: 100%;
  min-height: 36px;
  margin-top: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.password-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.password-form label {
  display: grid;
  gap: 6px;
  color: #e6efea;
  font-size: 13px;
}

.password-form input {
  height: 38px;
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.16);
  color: #fff;
}

#passwordMessage {
  margin: 0;
  color: #c8d7d0;
  font-size: 13px;
  line-height: 1.45;
}

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

.course-select-label {
  display: grid;
  gap: 8px;
  color: #dbe7e1;
  font-size: 13px;
}

.course-select-label select {
  height: 44px;
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.course-select-label option {
  color: var(--ink);
}

.quick-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.quick-nav button {
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-weight: 700;
}

.course-button {
  width: 100%;
  min-height: 58px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #f9fcfa;
  text-align: left;
}

.course-button.active {
  background: #f9fcfa;
  color: var(--ink);
}

.course-button.locked {
  opacity: 0.56;
  cursor: default;
}

.course-button strong,
.course-button span {
  display: block;
}

.course-button strong {
  font-size: 15px;
}

.course-button span {
  margin-top: 4px;
  font-size: 12px;
  color: currentColor;
}

.workspace {
  min-width: 0;
  padding: 28px;
  display: grid;
  gap: 22px;
}

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

.topbar h2 {
  font-size: 30px;
}

.progress-card {
  width: 220px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.progress-card span {
  display: block;
  margin-bottom: 10px;
  font-weight: 700;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--soft);
}

#progressFill {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 180ms ease;
}

.summary-band {
  display: grid;
  grid-template-columns: 1fr minmax(280px, 420px);
  gap: 18px;
  align-items: center;
  padding: 22px;
  border-radius: 8px;
  background: #edf4f0;
  border: 1px solid #d9e5df;
}

.summary-band p:last-child {
  margin: 0;
  font-size: 18px;
  line-height: 1.65;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.summary-grid div {
  min-height: 82px;
  padding: 14px;
  border-radius: 8px;
  background: #fff;
  display: grid;
  align-content: center;
}

.summary-grid strong {
  font-size: 24px;
}

.summary-grid span {
  color: var(--muted);
  font-size: 13px;
}

.student-layout,
.admin-layout {
  display: grid;
  gap: 22px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(280px, 390px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.content-grid.detail-mode {
  grid-template-columns: minmax(0, 1fr);
}

.module-column,
.practice-panel,
.review-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.module-column,
.practice-panel {
  min-height: 620px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.ghost-button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.module-list,
#practiceBody,
.resource-list,
.student-table,
.admin-stats,
.resource-form {
  padding: 18px;
}

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

.module-group-title {
  margin: 8px 2px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.module-card {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-align: left;
}

.module-card.active {
  border-color: var(--accent);
  background: #f2faf6;
}

.module-card.done {
  border-color: #8fbaa9;
}

.module-card strong {
  display: block;
  font-size: 16px;
}

.module-card span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.save-state {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.detail-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.question-block {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 14px;
  background: #fff;
}

.question-block h4 {
  margin: 0 0 12px;
  font-size: 16px;
}

.option-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  align-items: start;
  margin: 10px 0;
  color: #303a36;
}

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

.hint-box {
  padding: 14px;
  border-left: 4px solid var(--accent-2);
  background: #fff8f4;
  color: #553729;
  line-height: 1.6;
  border-radius: 4px;
  margin-bottom: 14px;
}

.resource-list,
.knowledge-list {
  display: grid;
  gap: 10px;
}

.resource-item,
.knowledge-card,
.student-row,
.stat-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.resource-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.knowledge-list {
  padding: 18px 18px 0;
}

.knowledge-card {
  padding: 0;
  overflow: hidden;
}

.knowledge-card summary {
  padding: 14px;
  cursor: pointer;
  font-weight: 700;
}

.knowledge-card ul,
.mindmap-branch ul {
  margin: 0;
  padding: 0 18px 16px 34px;
  color: #33413c;
  line-height: 1.7;
}

.resource-item strong,
.student-row strong {
  display: block;
}

.resource-item span,
.student-row span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.download-link {
  min-height: 36px;
  display: inline-grid;
  place-items: center;
  padding: 0 12px;
  border-radius: 6px;
  color: #fff;
  background: var(--accent-3);
  text-decoration: none;
}

.download-link.secondary {
  background: var(--accent);
}

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

.mindmap-panel {
  display: grid;
  gap: 14px;
}

.mindmap-visual {
  position: relative;
  min-height: 520px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(40, 104, 92, 0.07) 1px, transparent 1px),
    linear-gradient(rgba(58, 111, 153, 0.07) 1px, transparent 1px),
    #fbfdfb;
  background-size: 28px 28px;
}

.mindmap-center {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  width: 190px;
  min-height: 112px;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  align-content: center;
  padding: 18px;
  border: 3px solid #e8c766;
  border-radius: 999px;
  background: #fff;
  box-shadow: var(--shadow);
  text-align: center;
}

.mindmap-center span {
  color: var(--muted);
  font-size: 14px;
}

.mindmap-center strong {
  font-size: 24px;
}

.mindmap-line {
  position: absolute;
  left: 50%;
  top: 50%;
  background: rgba(40, 104, 92, 0.22);
  transform: translate(-50%, -50%);
}

.mindmap-line.horizontal {
  width: 74%;
  height: 2px;
}

.mindmap-line.vertical {
  width: 2px;
  height: 72%;
}

.mindmap-node {
  position: absolute;
  width: min(220px, 34%);
  min-height: 118px;
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--accent);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 30px rgba(33, 43, 39, 0.08);
}

.mindmap-node h4 {
  margin: 0 0 8px;
  font-size: 17px;
}

.mindmap-node p {
  margin: 0;
  color: #495551;
  line-height: 1.55;
  font-size: 14px;
}

.mindmap-node.top-left {
  left: 7%;
  top: 8%;
}

.mindmap-node.top-right {
  right: 7%;
  top: 8%;
}

.mindmap-node.mid-left {
  left: 5%;
  top: 50%;
  transform: translateY(-50%);
}

.mindmap-node.mid-right {
  right: 5%;
  top: 50%;
  transform: translateY(-50%);
}

.mindmap-node.bottom-left {
  left: 7%;
  bottom: 8%;
}

.mindmap-node.bottom-right {
  right: 7%;
  bottom: 8%;
}

.mindmap-node.blue {
  border-left-color: var(--accent-3);
}

.mindmap-node.gold {
  border-left-color: #d5a72f;
}

.mindmap-node.red {
  border-left-color: var(--accent-2);
}

.mindmap-flow {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  align-items: center;
}

.mindmap-flow div {
  min-height: 52px;
  display: grid;
  place-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #26332f;
  text-align: center;
  font-weight: 700;
}

.mindmap-flow span {
  display: none;
}

.mindmap-branch {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.mindmap-index {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #e8c766;
  color: var(--dark);
  font-weight: 800;
}

.mindmap-branch h4 {
  margin: 4px 0 10px;
}

.mindmap-branch ul {
  padding-left: 20px;
}

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

.stat-card strong {
  display: block;
  font-size: 24px;
}

.stat-card span {
  color: var(--muted);
  font-size: 13px;
}

.student-table {
  display: grid;
  gap: 10px;
  padding-top: 0;
}

.student-row {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 1fr 1fr;
  gap: 12px;
  align-items: center;
}

@media (max-width: 1080px) {
  .app-shell,
  .content-grid,
  .summary-band {
    grid-template-columns: 1fr;
  }

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

  .progress-card {
    width: 100%;
  }

  .admin-stats,
  .student-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .workspace,
  .sidebar,
  .auth-page {
    padding: 18px;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    min-height: auto;
  }

  .brand h1 {
    font-size: 20px;
  }

  .user-panel {
    padding: 14px;
  }

  .topbar h2 {
    font-size: 24px;
  }

  .summary-grid,
  .admin-stats,
  .student-row,
  .resource-item {
    grid-template-columns: 1fr;
  }

  .section-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .mindmap-visual {
    min-height: auto;
    padding: 16px;
    display: grid;
    gap: 12px;
  }

  .mindmap-line {
    display: none;
  }

  .mindmap-center,
  .mindmap-node {
    position: static;
    width: 100%;
    transform: none;
  }

  .mindmap-center {
    border-radius: 8px;
  }

  .mindmap-flow {
    grid-template-columns: 1fr;
  }
}
