:root {
  color-scheme: light;
  --bg: #eef2f3;
  --surface: #ffffff;
  --surface-soft: #f7f9fa;
  --border: #d8e0e4;
  --text: #182229;
  --muted: #667681;
  --primary: #235f73;
  --primary-dark: #174657;
  --accent: #4e7d46;
  --warn: #ad6b24;
  --danger: #ad3e3e;
  --shadow: 0 12px 32px rgba(24, 34, 41, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 18px;
  background: #17262d;
  color: #f7fbfc;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: #f5c96a;
  color: #17262d;
  font-weight: 800;
}

.brand-title {
  font-size: 18px;
  font-weight: 800;
}

.brand-subtitle {
  margin-top: 3px;
  color: #a8bac1;
  font-size: 13px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #d7e3e7;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: #233942;
  border-color: #3b5660;
  color: #ffffff;
}

.sidebar-footer {
  display: grid;
  gap: 10px;
  margin-top: auto;
}

.server-state {
  padding: 10px;
  border: 1px solid #35505a;
  border-radius: 6px;
  color: #c7d7dc;
  font-size: 13px;
}

.server-state.ok {
  border-color: #668b5f;
  color: #dff2d8;
}

.server-state.bad {
  border-color: #9d5b5b;
  color: #f5d8d8;
}

.main {
  min-width: 0;
  padding: 28px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.25;
}

h2 {
  font-size: 17px;
}

.topbar p,
.login-form p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.user-area {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  white-space: nowrap;
}

.login-panel {
  display: grid;
  min-height: calc(100vh - 160px);
  place-items: center;
}

.login-form,
.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-form {
  display: grid;
  width: min(430px, 100%);
  gap: 16px;
  padding: 24px;
}

.workspace {
  display: grid;
  gap: 18px;
}

.metric-grid,
.profile-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card {
  display: grid;
  gap: 8px;
  min-height: 128px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.metric-card strong {
  font-size: 28px;
  line-height: 1.1;
}

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

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

input,
select {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

label input,
label select {
  color: var(--text);
  font-size: 14px;
}

.primary-button,
.secondary-button {
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-weight: 700;
}

.primary-button {
  background: var(--primary);
  color: #ffffff;
}

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

.secondary-button {
  background: #ffffff;
  border-color: var(--border);
  color: var(--text);
}

.secondary-button:hover {
  border-color: #a8bac1;
}

.full {
  width: 100%;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  gap: 18px;
}

.split-layout.relaxed {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.6fr);
}

.panel {
  min-width: 0;
  overflow: hidden;
}

.card-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.list-card {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

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

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

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

td:nth-child(2),
td:nth-child(3),
td:nth-child(4) {
  white-space: nowrap;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-button {
  min-height: 32px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  font-size: 13px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e7edf0;
  color: #43545d;
  font-size: 12px;
  font-weight: 700;
}

.status.draft {
  background: #e8eef0;
}

.status.pending_review {
  background: #fff0d9;
  color: var(--warn);
}

.status.published {
  background: #e4f0df;
  color: var(--accent);
}

.status.rejected {
  background: #f5dddd;
  color: var(--danger);
}

.detail-panel {
  min-height: 520px;
}

.book-summary {
  padding: 14px;
}

.summary-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.summary-list > div {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.summary-list > div:last-child {
  border-bottom: 0;
}

.summary-list strong {
  font-size: 13px;
}

.summary-list span {
  color: #3b4850;
  font-size: 14px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.empty-state {
  padding: 42px 18px;
  color: var(--muted);
  text-align: center;
}

.unit-list {
  display: grid;
  gap: 12px;
  max-height: 640px;
  overflow: auto;
  padding: 14px;
}

.unit-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

.unit-item:hover {
  border-color: #9eb5bd;
}

.unit-title {
  font-weight: 800;
}

.unit-text {
  display: -webkit-box;
  overflow: hidden;
  color: #3b4850;
  font-size: 13px;
  line-height: 1.65;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  padding: 3px 7px;
  border-radius: 999px;
  background: #e8f0f2;
  color: var(--primary);
  font-size: 12px;
}

.task-mini {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.task-mini span {
  padding: 3px 7px;
  border-radius: 6px;
  background: #f4f0e6;
  color: #71551d;
  font-size: 12px;
}

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

.form-panel {
  display: grid;
  gap: 14px;
  padding: 0 18px 18px;
}

.form-panel .panel-header {
  margin: 0 -18px;
}

.form-panel.compact {
  max-width: 620px;
}

.checkbox-line {
  display: flex;
  flex-direction: row;
  gap: 8px;
  align-items: center;
}

.checkbox-line input {
  min-height: auto;
}

.review-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.review-item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 14px;
}

.book-card {
  display: grid;
  gap: 12px;
  min-height: 250px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

.book-cover {
  display: grid;
  min-height: 110px;
  place-items: center;
  border-radius: 8px;
  background: #e8f0f2;
  color: var(--primary);
  font-size: 42px;
  font-weight: 800;
}

.book-card-body {
  display: grid;
  gap: 7px;
}

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

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

.reader-panel {
  min-height: 680px;
}

.reading-text {
  display: grid;
  gap: 16px;
  padding: 18px;
  font-size: 16px;
  line-height: 1.9;
}

.reader-tags {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.task-list {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.task-list article {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

.task-list article span {
  color: #3b4850;
  line-height: 1.55;
}

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

.ability-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.ability-panel.is-empty {
  background: #f8faf9;
}

.ability-button {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: var(--soft);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  font-weight: 700;
  cursor: pointer;
}

.ability-button:disabled {
  color: var(--muted);
  cursor: not-allowed;
}

.ability-button span {
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.ability-button:disabled span {
  background: #c8d1d0;
}

.ability-task-list {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.ability-panel.is-collapsed .ability-task-list {
  display: none;
}

.ability-task-list article {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  align-items: start;
  padding: 8px;
  border-radius: 6px;
  background: #fff;
}

.ability-task-card {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 6px 8px;
  align-items: start;
  width: 100%;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.ability-task-card:hover,
.ability-task-card.active {
  border-color: #14b8a6;
  background: #f0fdfa;
}

.ability-task-card strong {
  grid-row: span 2;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.ability-task-card span {
  color: var(--text);
  line-height: 1.45;
}

.ability-task-card small {
  color: var(--muted);
  line-height: 1.45;
}

.ability-more {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  padding: 4px 2px;
}

.ability-task-list article strong {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.reading-highlight {
  border-radius: 4px;
  background: #fef08a;
  padding: 0 2px;
}

.practice-panel {
  display: grid;
  gap: 10px;
  margin-top: 2px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

.practice-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.practice-header strong {
  color: #0d9488;
}

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

.practice-question {
  color: var(--text);
  font-weight: 700;
  line-height: 1.55;
}

.practice-evidence {
  border-left: 3px solid #14b8a6;
  padding: 8px 10px;
  background: #f8faf9;
  color: #3b4850;
  line-height: 1.55;
}

.practice-actions {
  display: flex;
  justify-content: flex-end;
}

.practice-feedback {
  white-space: normal;
  color: #1f2933;
  line-height: 1.65;
}

.diagnosis-content {
  padding: 4px 14px 14px;
}

.empty-state.small {
  padding: 16px;
}

.muted {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

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

.dialogue-source {
  display: grid;
  gap: 8px;
}

.dialogue-source-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  color: var(--muted);
  font-size: 13px;
}

.dialogue-source-header span {
  font-weight: 700;
}

.dialogue-source-header small {
  overflow: hidden;
  max-width: 170px;
  color: #7a8a92;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialogue-source-text {
  max-height: 220px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fbfcfc;
  color: var(--text);
  font-size: 14px;
  line-height: 1.75;
  white-space: pre-wrap;
}

textarea {
  width: 100%;
  resize: vertical;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  line-height: 1.5;
}

.dialogue-panel {
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr) auto;
  min-height: 620px;
}

.message-list {
  display: grid;
  align-content: start;
  gap: 12px;
  overflow: auto;
  padding: 16px;
  background: #fbfcfc;
}

.message {
  display: grid;
  gap: 6px;
  max-width: 78%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

.message.user {
  justify-self: end;
  background: #e8f0f2;
}

.message.assistant {
  justify-self: start;
}

.message.error {
  justify-self: start;
  border-color: #e2b0b0;
  background: #fff3f3;
}

.message-role {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.message-text {
  white-space: pre-wrap;
  line-height: 1.65;
}

.message-text p,
.practice-feedback p {
  margin: 0 0 8px;
}

.message-text p:last-child,
.practice-feedback p:last-child {
  margin-bottom: 0;
}

.message-text ul,
.message-text ol,
.practice-feedback ul,
.practice-feedback ol {
  display: grid;
  gap: 5px;
  margin: 6px 0 8px;
  padding-left: 18px;
}

.message-text li,
.practice-feedback li {
  line-height: 1.6;
}

.message-text h3,
.message-text h4,
.message-text h5,
.practice-feedback h3,
.practice-feedback h4,
.practice-feedback h5 {
  margin: 8px 0 6px;
  font-size: 14px;
  line-height: 1.45;
}

.message-text code,
.practice-feedback code {
  padding: 1px 5px;
  border-radius: 6px;
  background: rgba(9, 9, 11, 0.08);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 0.92em;
}

.dialogue-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--border);
  background: var(--surface-soft);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  display: none;
  max-width: min(420px, calc(100vw - 48px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #17262d;
  color: #ffffff;
  box-shadow: var(--shadow);
  font-size: 14px;
}

.toast.show {
  display: block;
}

.student-body {
  background: #edf3f0;
}

.student-shell {
  min-height: 100vh;
  padding: 22px;
}

.student-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  max-width: 1240px;
  margin: 0 auto 18px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.student-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
}

.student-workspace {
  display: grid;
  gap: 18px;
  max-width: 1240px;
  margin: 0 auto;
}

.student-hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.student-hero p {
  margin-top: 7px;
  color: var(--muted);
}

.student-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.student-tab {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font-weight: 800;
}

.student-tab.active,
.student-tab:hover {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.student-view {
  display: none;
}

.student-view.active {
  display: block;
}

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

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    gap: 14px;
    padding: 18px;
  }

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

  .nav-item {
    min-height: 38px;
    text-align: center;
  }

  .sidebar-footer {
    margin-top: 0;
  }

  .split-layout,
  .form-grid,
  .dialogue-layout,
  .reader-layout,
  .metric-grid,
  .profile-grid,
  .card-grid {
    grid-template-columns: 1fr;
  }

  .message {
    max-width: 100%;
  }

  .dialogue-form {
    grid-template-columns: 1fr;
  }

  .topbar,
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .main {
    padding: 22px;
  }

  .student-shell {
    padding: 16px;
  }

  .student-header,
  .student-hero,
  .student-actions {
    align-items: stretch;
    flex-direction: column;
  }

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

/* Visual alignment with the original demo HTML pages. */
:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-soft: #fafafa;
  --border: rgba(24, 24, 27, 0.08);
  --text: #09090b;
  --muted: #71717a;
  --primary: #14b8a6;
  --primary-dark: #0d9488;
  --accent: #0f766e;
  --warn: #d97706;
  --danger: #dc2626;
  --shadow: 0 20px 40px -24px rgba(9, 9, 11, 0.22);
  --soft-shadow: 0 4px 20px -10px rgba(9, 9, 11, 0.08);
}

body {
  background: #fafafa;
  color: #09090b;
  font-family:
    "Inter",
    "Microsoft YaHei",
    "PingFang SC",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

body:not(.student-body) .app-shell {
  display: block;
  min-height: 100vh;
}

body:not(.student-body) .sidebar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 22px;
  align-items: center;
  min-height: 66px;
  padding: 0 28px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  background: rgba(255, 255, 255, 0.86);
  color: #09090b;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: #09090b;
  color: #ffffff;
  box-shadow: 0 10px 24px -14px rgba(9, 9, 11, 0.5);
}

.brand-title {
  color: #09090b;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  color: #71717a;
}

body:not(.student-body) .nav-list {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 0;
}

body:not(.student-body) .nav-item {
  width: auto;
  flex: 0 0 auto;
  min-height: 66px;
  padding: 0 11px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: #52525b;
  font-size: 14px;
  font-weight: 650;
  text-align: center;
}

body:not(.student-body) .nav-item:hover,
body:not(.student-body) .nav-item.active {
  border-color: #14b8a6;
  background: transparent;
  color: #0d9488;
}

body:not(.student-body) .sidebar-footer {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 0;
}

body:not(.student-body) .sidebar-footer .server-state {
  max-width: 210px;
}

body:not(.student-body) .main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 24px 80px;
}

.topbar,
.student-hero,
.student-header {
  border: 1px solid var(--border);
  border-radius: 24px;
  background: #ffffff;
  box-shadow: var(--soft-shadow);
}

.topbar {
  padding: 24px;
}

h1 {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

h2 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.login-form,
.panel,
.metric-card,
.book-card,
.student-tab {
  border: 1px solid var(--border);
  border-radius: 24px;
  background: #ffffff;
  box-shadow: var(--soft-shadow);
}

.login-form,
.form-panel {
  padding: 22px;
}

.form-panel .panel-header {
  margin: -22px -22px 2px;
}

.panel-header {
  padding: 18px 20px;
  background: #ffffff;
}

input,
select,
textarea {
  min-height: 46px;
  border-color: #e4e4e7;
  border-radius: 16px;
  background: #fafafa;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #18181b;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(9, 9, 11, 0.08);
}

.primary-button,
.secondary-button,
.mini-button {
  border-radius: 14px;
  font-weight: 750;
}

.primary-button {
  background: #09090b;
  color: #ffffff;
  box-shadow: 0 12px 24px -18px rgba(9, 9, 11, 0.7);
}

.primary-button:hover {
  background: #27272a;
}

.secondary-button,
.mini-button {
  background: #ffffff;
  border-color: #e4e4e7;
  color: #27272a;
}

.secondary-button:hover,
.mini-button:hover {
  border-color: #99f6e4;
  background: #f0fdfa;
  color: #0d9488;
}

.metric-grid,
.profile-grid {
  gap: 16px;
}

.metric-card {
  min-height: 132px;
}

.metric-card strong {
  font-size: 32px;
  letter-spacing: -0.04em;
}

.split-layout,
.form-grid,
.dialogue-layout,
.reader-layout {
  gap: 20px;
}

.list-card,
.unit-item,
.review-item,
.task-list article {
  border-color: #f1f1f2;
  border-radius: 20px;
  background: #ffffff;
}

.unit-item:hover,
.book-card:hover,
.task-list article:hover {
  transform: translateY(-2px);
  border-color: #ccfbf1;
  box-shadow: 0 20px 40px -24px rgba(20, 184, 166, 0.28);
}

.book-card {
  transition:
    transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 0.28s ease,
    border-color 0.28s ease;
}

.book-cover {
  min-height: 150px;
  border-radius: 20px;
  background:
    radial-gradient(circle at 15% 10%, rgba(20, 184, 166, 0.18), transparent 34%),
    linear-gradient(135deg, #f0fdfa, #f8fafc);
  color: #134e4a;
}

.status {
  min-height: 27px;
  border-radius: 10px;
  background: #f4f4f5;
  color: #52525b;
}

.status.pending_review {
  background: #fffbeb;
  color: #b45309;
}

.status.published {
  background: #f0fdfa;
  color: #0d9488;
}

.status.rejected {
  background: #fef2f2;
  color: #b91c1c;
}

.tag {
  border-radius: 9px;
  background: #f0fdfa;
  color: #0d9488;
  font-weight: 700;
}

.reading-text {
  color: #3f3f46;
  font-family:
    "Noto Serif SC",
    "Songti SC",
    "SimSun",
    serif;
  font-size: 17px;
  line-height: 2.1;
}

.reader-panel {
  min-height: 650px;
}

.message-list {
  background: #ffffff;
}

.message {
  border-radius: 20px;
  box-shadow: 0 8px 24px -20px rgba(9, 9, 11, 0.2);
}

.message.user {
  background: #09090b;
  color: #ffffff;
}

.message.user .message-role {
  color: #d4d4d8;
}

.message.assistant {
  border-color: #ccfbf1;
  background: #f0fdfa;
  color: #134e4a;
}

.dialogue-form {
  background: #ffffff;
}

.toast {
  border-radius: 18px;
  background: rgba(9, 9, 11, 0.92);
  backdrop-filter: blur(10px);
}

.student-shell {
  max-width: 1280px;
  margin: 0 auto;
}

.student-body {
  background: #fafafa;
}

.student-header {
  position: sticky;
  top: 18px;
  z-index: 40;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.student-hero {
  padding: 26px;
}

.student-tabs {
  gap: 12px;
}

.student-tab {
  min-height: 48px;
  box-shadow: none;
}

.student-tab.active,
.student-tab:hover {
  border-color: #09090b;
  background: #09090b;
  color: #ffffff;
}

@media (max-width: 1180px) {
  body:not(.student-body) .sidebar {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 14px 18px;
  }

  body:not(.student-body) .nav-list {
    order: 3;
  }

  body:not(.student-body) .sidebar-footer {
    flex-wrap: wrap;
  }
}

@media (max-width: 980px) {
  body:not(.student-body) .nav-list {
    grid-template-columns: none;
  }

  body:not(.student-body) .nav-item {
    min-height: 42px;
    padding: 0 10px;
  }

  .topbar {
    padding: 20px;
  }

  h1 {
    font-size: 28px;
  }
}

/* Student immersive reading page. */
.student-body .student-shell {
  width: min(1840px, calc(100vw - 32px));
  max-width: none;
  padding-bottom: 34px;
}

.student-body[data-student-view="reader"] .student-shell {
  width: min(1920px, calc(100vw - 24px));
}

.student-workspace {
  width: 100%;
  max-width: none;
}

.student-workspace[data-active-view="reader"] {
  gap: 12px;
}

.student-workspace[data-active-view="reader"] .student-hero {
  display: none;
}

.student-workspace[data-active-view="reader"] .student-tabs {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: min(520px, 100%);
  margin: 0 auto;
}

.immersive-reader-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 410px;
  gap: 18px;
  align-items: start;
  min-height: calc(100vh - 170px);
}

.immersive-reading-pane {
  position: relative;
  min-width: 0;
  min-height: calc(100vh - 170px);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: var(--soft-shadow);
  overflow: hidden;
}

.immersive-reader-bar {
  position: sticky;
  top: 86px;
  z-index: 15;
  display: grid;
  grid-template-columns: minmax(210px, 0.75fr) minmax(220px, 1fr) minmax(260px, 0.95fr);
  gap: 16px;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.reader-return {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.reader-return > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.reader-return span,
.reader-selectors span,
.reader-progress span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.reader-return strong {
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-progress {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.reader-progress-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e7eb;
}

.reader-progress-track i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: #09090b;
  transition: width 0.22s ease;
}

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

.reader-selectors label {
  display: grid;
  gap: 4px;
}

.reader-selectors select {
  min-height: 38px;
  border-radius: 10px;
  font-size: 13px;
}

.reader-document {
  width: min(780px, calc(100% - 144px));
  min-height: calc(100vh - 245px);
  margin: 0 auto;
  padding: 34px 0 70px;
}

.reader-document-heading {
  display: grid;
  gap: 8px;
  justify-items: center;
  margin-bottom: 28px;
  text-align: center;
}

.reader-document-heading h2 {
  font-family:
    "Noto Serif SC",
    "Songti SC",
    "SimSun",
    serif;
  font-size: clamp(24px, 2.2vw, 34px);
  letter-spacing: 0;
}

.reader-document-heading span {
  display: inline-flex;
  min-height: 4px;
  align-items: center;
  padding-top: 8px;
  border-top: 4px solid #14b8a6;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.reader-document .reading-text {
  padding: 0;
  color: #52525b;
  font-size: 18px;
  line-height: 2.35;
}

.reader-document .reader-tags {
  justify-content: center;
  margin-bottom: 24px;
  padding: 0 0 18px;
}

.reader-document .reading-text p {
  margin: 0;
}

.reader-page-button {
  position: absolute;
  top: clamp(230px, 48vh, 520px);
  z-index: 12;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid #e4e4e7;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #18181b;
  box-shadow: 0 16px 34px -24px rgba(9, 9, 11, 0.45);
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.reader-page-button span {
  display: inline-flex;
  width: 24px;
  height: 24px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #09090b;
  color: #ffffff;
  font-size: 18px;
  line-height: 1;
}

.reader-page-button strong {
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.reader-page-button:hover {
  border-color: #99f6e4;
  background: #f0fdfa;
  color: #0d9488;
}

.reader-page-button:disabled {
  opacity: 0.36;
  cursor: not-allowed;
}

.reader-page-button:disabled:hover {
  border-color: #e4e4e7;
  background: rgba(255, 255, 255, 0.92);
  color: #18181b;
}

.reader-page-button-left {
  left: 18px;
}

.reader-page-button-right {
  right: 18px;
}

.reader-ai-dock {
  position: sticky;
  top: 86px;
  display: grid;
  grid-template-rows: auto minmax(120px, 1fr) auto;
  gap: 12px;
  min-width: 0;
  height: calc(100vh - 190px);
  min-height: 520px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: var(--soft-shadow);
  overflow: hidden;
}

.reader-ai-tabs {
  display: grid;
  gap: 10px;
  min-width: 0;
  min-height: 0;
  min-height: 190px;
  max-height: min(260px, 34vh);
  overflow: auto;
  padding-right: 8px;
  scrollbar-gutter: stable;
}

.reader-ai-dock .ability-tab-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 6px;
  border-radius: 12px;
  background: #f4f4f5;
}

.reader-ai-dock .ability-button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #71717a;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.reader-ai-dock .ability-button.active {
  background: #ffffff;
  color: #09090b;
  box-shadow: 0 8px 20px -16px rgba(9, 9, 11, 0.45);
}

.reader-ai-dock .ability-button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.reader-ai-dock .ability-button span {
  min-width: 21px;
  height: 21px;
  border-radius: 999px;
  background: #e4e4e7;
  color: #52525b;
  font-size: 11px;
}

.reader-ai-dock .ability-button.active span {
  background: #09090b;
  color: #ffffff;
}

.ability-card-list {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.reader-ai-dock .ability-task-card {
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 6px 9px;
  min-width: 0;
  padding: 10px;
  border-color: #f1f1f2;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: none;
  overflow: hidden;
}

.reader-ai-dock .ability-task-card:hover,
.reader-ai-dock .ability-task-card.active {
  border-color: #99f6e4;
  background: #f0fdfa;
}

.reader-ai-dock .ability-task-card strong {
  grid-row: auto;
  width: 24px;
  height: 24px;
  background: #f4f4f5;
  color: #52525b;
}

.reader-ai-dock .ability-task-card span {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}

.reader-ai-dock .ability-task-card small {
  display: -webkit-box;
  overflow: hidden;
  color: #71717a;
  font-size: 12px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.reader-ai-dock .ability-more {
  padding: 0 4px;
  color: #71717a;
}

.reader-ai-dock .practice-panel {
  margin: 0;
  padding: 12px;
  border-color: #ccfbf1;
  border-radius: 12px;
  background: #f8fffd;
}

.reader-ai-dock .practice-panel.empty-state {
  border-color: #f1f1f2;
  background: #fafafa;
}

.reader-ai-dock .practice-evidence {
  max-height: 110px;
  overflow: auto;
  border-left-color: #14b8a6;
  border-radius: 0 8px 8px 0;
  font-size: 12px;
}

.reader-ai-dock .practice-question {
  font-size: 13px;
}

.reader-ai-dock .message-list {
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  padding: 8px 8px 8px 0;
  background: #ffffff;
}

.reader-ai-dock .message {
  min-width: 0;
  max-width: 92%;
  overflow: hidden;
  border-radius: 14px;
  box-shadow: none;
}

.reader-ai-dock .message-text {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.reader-ai-dock .message .tag-list {
  min-width: 0;
  overflow: hidden;
}

.reader-ai-dock .message .tag {
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.reader-ai-dock .message.user {
  border-color: #09090b;
  background: #09090b;
  color: #ffffff;
}

.reader-ai-dock .message.assistant {
  border-color: #ccfbf1;
  background: #f0fdfa;
  color: #134e4a;
}

.reader-ai-dock .message.streaming .message-text::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 4px;
  border-radius: 999px;
  background: currentColor;
  vertical-align: middle;
  opacity: 0.45;
}

.reader-ai-dock .message.error {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.reader-ai-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: #ffffff;
  overflow: hidden;
}

.reader-ai-form textarea {
  min-height: 38px;
  border-radius: 12px;
  font-size: 13px;
}

.reader-context-hint {
  display: flex;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 32px;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  padding: 7px 10px;
  border: 1px solid #e4e4e7;
  border-radius: 999px;
  background: #fafafa;
  color: #52525b;
  font-size: 12px;
  line-height: 1.35;
}

.reader-context-hint strong {
  flex: 0 0 auto;
  color: #0d9488;
  font-size: 12px;
}

.reader-context-hint span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-ai-input-row {
  display: flex;
  width: 100%;
  max-width: 100%;
  gap: 8px;
  align-items: stretch;
  min-width: 0;
  overflow: hidden;
}

.reader-ai-input-row textarea {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  min-height: 46px;
  max-height: 130px;
  resize: vertical;
}

.reader-ai-input-row .primary-button {
  flex: 0 0 68px;
  min-height: 46px;
  width: 68px;
  padding: 0;
}

.reader-ai-input-row .primary-button:disabled {
  opacity: 0.72;
  cursor: wait;
}

.reading-highlight {
  border-radius: 3px;
  background: #fde68a;
  color: #3f3f46;
  box-shadow: 0 0 0 2px rgba(253, 230, 138, 0.5);
}

@media (max-width: 1280px) {
  .immersive-reader-layout {
    grid-template-columns: minmax(0, 1fr) 380px;
  }

  .reader-page-button {
    min-width: 50px;
    padding: 0 12px;
  }

  .reader-page-button strong {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .immersive-reader-bar {
    grid-template-columns: 1fr;
    top: 78px;
  }

  .reader-ai-dock {
    top: 78px;
    height: calc(100vh - 185px);
  }
}

@media (max-width: 980px) {
  .student-body .student-shell,
  .student-body[data-student-view="reader"] .student-shell {
    width: min(100% - 24px, 760px);
    padding: 12px 0 28px;
  }

  .immersive-reader-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .immersive-reading-pane {
    min-height: auto;
  }

  .immersive-reader-bar,
  .reader-ai-dock {
    position: static;
  }

  .reader-document {
    width: min(100% - 32px, 720px);
    min-height: auto;
    padding: 28px 0 44px;
  }

  .reader-page-button {
    position: static;
    min-width: 0;
    margin: 0 8px 18px;
  }

  .reader-page-button-left {
    float: left;
  }

  .reader-page-button-right {
    float: right;
  }

  .reader-ai-dock {
    height: auto;
    min-height: 560px;
  }

  .reader-ai-tabs {
    max-height: none;
  }

}

@media (max-width: 640px) {
  .student-workspace[data-active-view="reader"] .student-tabs {
    width: 100%;
  }

  .reader-selectors,
  .reader-progress {
    grid-template-columns: 1fr;
  }

  .reader-document .reading-text {
    font-size: 16px;
    line-height: 2.1;
  }
}
