:root {
  color-scheme: light;
  --ink: #162033;
  --muted: #637087;
  --line: #dfe5ee;
  --panel: #ffffff;
  --page: #f5f7fb;
  --blue: #2563eb;
  --blue-dark: #1746a2;
  --green: #198754;
  --amber: #a16207;
  --red: #b42318;
  --violet: #6d28d9;
  --shadow: 0 18px 40px rgba(22, 32, 51, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
}

.sidebar {
  background: #101827;
  color: #eef4ff;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #ffffff;
  color: #101827;
  font-weight: 900;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  color: #cbd7ef;
  background: transparent;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
}

.nav button.active,
.nav button:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

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

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

.eyebrow {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  font-size: 30px;
  line-height: 1.2;
}

h2 {
  font-size: 20px;
  line-height: 1.25;
}

h3 {
  font-size: 16px;
  line-height: 1.3;
}

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

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

.dashboard-grid {
  grid-template-columns: minmax(0, 1.5fr) minmax(310px, 0.9fr);
  align-items: start;
}

.subject-grid {
  grid-template-columns: repeat(4, minmax(170px, 1fr));
}

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

.panel {
  padding: 20px;
}

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

.subject-card {
  padding: 18px;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: left;
  color: var(--ink);
}

.subject-card:hover {
  border-color: #9cb7ff;
  transform: translateY(-1px);
}

.subject-code {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
}

.english { background: #2563eb; }
.chinese { background: #dc2626; }
.mathematics { background: #198754; }
.economics { background: #7c3aed; }

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

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

.item:last-child {
  border-bottom: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #edf2ff;
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.pill.warn {
  background: #fff7ed;
  color: var(--amber);
}

.pill.good {
  background: #ecfdf3;
  color: var(--green);
}

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

.primary,
.secondary,
.danger {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  font-weight: 750;
}

.primary {
  background: var(--blue);
  color: #fff;
}

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

.secondary {
  background: #e9eef7;
  color: var(--ink);
}

.secondary.active-lite {
  background: #dbe7ff;
  color: var(--blue-dark);
}

.danger {
  background: #fff1f0;
  color: var(--red);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(430px, 100%);
  padding: 28px;
}

.form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-weight: 700;
  font-size: 14px;
}

input,
textarea,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  padding: 0 12px;
  color: var(--ink);
}

input:focus,
textarea:focus,
select:focus {
  outline: 3px solid rgba(37, 99, 235, 0.18);
  border-color: var(--blue);
}

textarea {
  min-height: 86px;
  padding: 11px 12px;
  resize: vertical;
  line-height: 1.5;
}

.error {
  color: var(--red);
  font-weight: 700;
  min-height: 20px;
}

.success {
  color: var(--green);
  font-weight: 700;
}

.teacher-layout,
.settings-layout,
.tool-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.history-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.workspace {
  min-height: 400px;
  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: 16px;
}

.message-stack {
  display: grid;
  align-content: start;
  gap: 12px;
  max-height: 62vh;
  overflow-y: auto;
  padding-right: 4px;
}

.voice-dock {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.voice-dock .voice-strip {
  margin-bottom: 0;
}

.message {
  max-width: 720px;
  padding: 14px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--line);
}

.message p {
  margin-top: 8px;
  line-height: 1.6;
}

.message.user {
  justify-self: end;
  background: #edf2ff;
  border-color: #b9c8ff;
}

.message.assistant {
  justify-self: start;
  background: #ffffff;
}

.examiner-box {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #7c2d12;
  min-height: auto;
  line-height: 1.6;
}

.coach-h {
  margin: 14px 0 6px;
  font-size: 15px;
}

.teaching-card {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  display: grid;
  gap: 8px;
}

.teaching-card p {
  margin: 0;
  line-height: 1.55;
}

.message-tools {
  margin-top: 8px;
  align-items: center;
}

.secondary.mini {
  min-height: 26px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
}

.message.system {
  max-width: 100%;
  background: #fff7ed;
  border-color: #fed7aa;
  color: #7c2d12;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.composer input {
  min-width: 0;
}

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

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

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

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

.model-grid .metric strong {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.split-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.status-box {
  padding: 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f8fafc;
  min-height: 72px;
}

.status-box.good {
  background: #ecfdf3;
  border-color: #b7ebc9;
  color: var(--green);
}

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

.inline-check input[type="checkbox"] {
  width: auto;
  min-height: auto;
  border: none;
  background: transparent;
  padding: 0;
  accent-color: var(--blue);
}

.small {
  font-size: 13px;
}

.compact-form {
  margin-top: 0;
  gap: 12px;
}

.page-tabs {
  margin-bottom: 18px;
}

.classical-texts-panel {
  margin-bottom: 18px;
}

.classical-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.classical-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
}

.classical-card:hover {
  border-color: #9cb7ff;
  transform: translateY(-1px);
}

@media (max-width: 900px) {
  .classical-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.rich-item {
  align-items: flex-start;
}

.rich-item p {
  margin-top: 6px;
  line-height: 1.5;
}

.practice-list,
.search-results {
  margin-top: 16px;
}

.report-score {
  width: 86px;
  height: 86px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  background: #ecfdf3;
  color: var(--green);
  font-size: 34px;
  font-weight: 900;
}

.preline {
  white-space: pre-line;
  margin-top: 12px;
}

.recorder-strip,
.voice-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.voice-captions p {
  margin: 4px 0;
}

.compact-status {
  min-height: auto;
  margin-bottom: 12px;
}

@media (max-width: 980px) {
  .shell,
  .dashboard-grid,
  .teacher-layout,
  .settings-layout,
  .tool-layout,
  .history-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
  }

  .nav {
    grid-template-columns: repeat(9, minmax(86px, 1fr));
    overflow-x: auto;
  }

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

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

  .topbar,
  .item,
  .composer,
  .split-form {
    grid-template-columns: 1fr;
    display: grid;
  }

  .subject-grid,
  .metrics,
  .model-grid {
    grid-template-columns: 1fr;
  }
}
