:root {
  --ink: #12171d;
  --muted: #62707e;
  --muted-2: #82909e;
  --line: #d8e1e8;
  --soft-line: rgba(18, 23, 29, 0.1);
  --paper: #f4f7f8;
  --surface: #ffffff;
  --panel: #eef4f5;
  --navy: #172433;
  --navy-2: #24384b;
  --teal: #0a9c8e;
  --teal-dark: #08736a;
  --blue: #2f6db3;
  --amber: #d58a24;
  --green: #2f8c61;
  --red: #ba4545;
  --shadow: 0 20px 54px rgba(23, 36, 51, 0.14);
  --tight-shadow: 0 12px 28px rgba(23, 36, 51, 0.09);
  --radius: 8px;
  --sidebar: 276px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  background:
    linear-gradient(135deg, rgba(10, 156, 142, 0.12), transparent 32%),
    linear-gradient(180deg, #eef4f4 0%, var(--paper) 46%, #eaf0f3 100%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(340px, 0.88fr);
  gap: clamp(28px, 5vw, 64px);
  align-items: center;
  padding: clamp(24px, 6vw, 86px);
}

.login-brand {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  max-width: 800px;
}

.login-kicker {
  margin: 0 0 12px;
  color: var(--teal-dark);
  font-size: 14px;
  font-weight: 800;
}

.brand-mark {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #fff;
  background: linear-gradient(145deg, var(--navy), var(--teal-dark));
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-weight: 900;
  letter-spacing: 0;
}

.brand-mark.small {
  width: 42px;
  height: 42px;
  font-size: 14px;
  box-shadow: none;
}

.login-brand h1 {
  margin: 0;
  max-width: 720px;
  font-size: clamp(36px, 5.2vw, 68px);
  line-height: 1.05;
  letter-spacing: 0;
}

.login-brand p:not(.login-kicker) {
  margin: 22px 0 0;
  max-width: 590px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.85;
}

.login-panel {
  width: 100%;
  padding: 34px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--soft-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-panel h2,
.section-heading h3,
.chat-header h3 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: 0;
}

.login-panel p,
.section-heading p,
.chat-header p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.75;
}

label {
  display: grid;
  gap: 8px;
  margin-top: 20px;
  color: var(--navy);
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input {
  height: 48px;
  padding: 0 14px;
}

textarea {
  min-height: 118px;
  padding: 14px;
  resize: vertical;
  line-height: 1.7;
}

input:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(10, 156, 142, 0.14);
}

.primary-button,
.secondary-button,
.ghost-button,
.tab {
  min-height: 42px;
  border-radius: 7px;
  padding: 0 18px;
  border: 0;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0;
}

.primary-button {
  color: #fff;
  background: var(--teal-dark);
  box-shadow: 0 10px 20px rgba(8, 115, 106, 0.18);
}

.primary-button:hover {
  background: #065f58;
}

.secondary-button {
  color: var(--navy);
  background: #dcebe8;
  border: 1px solid rgba(8, 115, 106, 0.12);
}

.secondary-button:hover {
  background: #d0e5e1;
}

.ghost-button {
  width: 100%;
  color: #dbe8e7;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.login-panel .primary-button {
  width: 100%;
  margin-top: 24px;
}

.login-note {
  margin-top: 18px;
  padding: 12px 14px;
  color: var(--teal-dark);
  background: #e4f3f0;
  border-left: 4px solid var(--teal);
  border-radius: 6px;
  line-height: 1.65;
}

.workspace {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 28px;
  padding: 22px 18px;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(10, 156, 142, 0.14), transparent 30%),
    var(--navy);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 2px;
}

.side-brand strong,
.side-brand span {
  display: block;
}

.side-brand strong {
  font-size: 16px;
}

.side-brand span {
  margin-top: 5px;
  color: #b9c9c8;
  font-size: 12px;
}

.side-nav {
  display: grid;
  align-content: start;
  gap: 10px;
}

.tab {
  width: 100%;
  min-height: 72px;
  display: grid;
  gap: 4px;
  align-content: center;
  text-align: left;
  color: #dce8e6;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.tab span,
.tab small {
  display: block;
}

.tab span {
  font-size: 17px;
}

.tab small {
  color: #aebfbc;
  font-size: 12px;
  font-weight: 700;
}

.tab.active {
  color: var(--navy);
  background: #fff;
  border-color: #fff;
}

.tab.active small {
  color: var(--muted);
}

.side-footer {
  display: grid;
  gap: 14px;
}

.side-stat {
  padding: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
}

.side-stat span,
.side-stat strong {
  display: block;
}

.side-stat span {
  color: #aebfbc;
  font-size: 12px;
}

.side-stat strong {
  margin-top: 7px;
}

.main-panel {
  min-width: 0;
  padding: 24px clamp(18px, 3vw, 40px) 48px;
}

.hero-band,
.view {
  width: min(1240px, 100%);
  margin: 0 auto;
}

.hero-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 420px);
  gap: 28px;
  align-items: end;
  padding: 30px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(10, 156, 142, 0.28), transparent 52%),
    linear-gradient(120deg, var(--navy), #213951);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-band h2 {
  margin: 0;
  font-size: clamp(26px, 3vw, 42px);
  line-height: 1.16;
  letter-spacing: 0;
}

.hero-band p {
  margin: 14px 0 0;
  max-width: 760px;
  color: #d3dfde;
  line-height: 1.85;
}

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

.status-grid div {
  min-width: 0;
  padding: 16px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 7px;
}

.status-grid span,
.status-grid strong {
  display: block;
}

.status-grid span {
  color: #aebfbc;
  font-size: 12px;
}

.status-grid strong {
  margin-top: 8px;
  font-size: 21px;
  line-height: 1.2;
}

.view {
  display: none;
  padding-top: 24px;
}

.view.active {
  display: block;
}

.section-heading,
.chat-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 18px;
}

.topic-chip,
.safe-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  color: #064e49;
  background: #d9f0ec;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.agent-switcher {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.agent-tab {
  min-height: 96px;
  padding: 16px;
  text-align: left;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--soft-line);
  border-radius: var(--radius);
  box-shadow: var(--tight-shadow);
}

.agent-tab strong,
.agent-tab span {
  display: block;
}

.agent-tab strong {
  font-size: 18px;
}

.agent-tab span {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.agent-tab.active {
  color: #fff;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.12), transparent),
    var(--navy-2);
  border-color: rgba(255, 255, 255, 0.14);
}

.agent-tab.active span {
  color: #c8d7d5;
}

.agent-workbench {
  display: grid;
  grid-template-columns: minmax(280px, 0.34fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.agent-controls,
.agent-stage,
.chat-shell,
.exam-panel,
.exam-card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--soft-line);
  border-radius: var(--radius);
  box-shadow: var(--tight-shadow);
}

.agent-controls {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.agent-controls h4 {
  margin: 0;
  font-size: 18px;
}

.control-group {
  display: grid;
  gap: 8px;
}

.control-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  color: var(--navy);
  font-weight: 900;
}

.control-title output {
  color: var(--teal-dark);
  font-size: 13px;
}

input[type="range"] {
  height: auto;
  padding: 0;
  accent-color: var(--teal-dark);
}

.control-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

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

.metric-box {
  min-width: 0;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.metric-box span,
.metric-box strong {
  display: block;
}

.metric-box span {
  color: var(--muted);
  font-size: 12px;
}

.metric-box strong {
  margin-top: 6px;
  font-size: 17px;
  line-height: 1.25;
}

.agent-stage {
  min-width: 0;
  padding: 18px;
}

.agent-stage-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 14px;
}

.agent-stage-head h4 {
  margin: 0;
  font-size: 22px;
}

.agent-stage-head p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

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

.lesson-strip article {
  min-width: 0;
  padding: 13px 14px;
  background: #f2f7f7;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.lesson-strip span,
.lesson-strip strong {
  display: block;
}

.lesson-strip span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.lesson-strip strong {
  margin-top: 7px;
  color: var(--navy);
  font-size: 15px;
  line-height: 1.45;
}

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

.plot-card {
  min-width: 0;
  padding: 14px;
  background: #f7fafb;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.plot-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--navy);
}

.plot-head span {
  color: var(--muted-2);
  font-size: 12px;
}

canvas {
  width: 100%;
  aspect-ratio: 700 / 320;
  display: block;
  background: #fff;
  border: 1px solid #dfe7ed;
  border-radius: 7px;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.analysis-card {
  min-width: 0;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.analysis-card strong {
  display: block;
  color: var(--navy);
}

.analysis-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.practice-card {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-top: 14px;
  padding: 16px;
  color: var(--navy);
  background: #fff8eb;
  border: 1px solid #f0d7ae;
  border-radius: var(--radius);
}

.practice-card strong {
  display: block;
}

.practice-card p {
  margin: 8px 0 0;
  color: #72511b;
  line-height: 1.65;
}

.agent-chat-card {
  margin-top: 14px;
  padding: 16px;
  background: #f6faf9;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.agent-chat-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 12px;
}

.agent-chat-head strong,
.agent-chat-head span {
  display: block;
}

.agent-chat-head strong {
  color: var(--navy);
  font-size: 17px;
}

.agent-chat-head span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.agent-chat-log {
  max-height: 260px;
  min-height: 112px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.agent-chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
}

.agent-chat-form textarea {
  min-height: 84px;
}

.agent-chat-form .primary-button {
  min-width: 90px;
  height: 46px;
}

.chat-shell,
.exam-panel {
  padding: 22px;
}

.chat-log {
  height: min(50vh, 420px);
  min-height: 320px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: #f2f6f5;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.message {
  max-width: min(760px, 92%);
  padding: 13px 15px;
  border-radius: 7px;
  line-height: 1.75;
  white-space: pre-wrap;
}

.message.user {
  align-self: flex-end;
  color: #fff;
  background: var(--navy-2);
}

.message.assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--line);
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
  margin-top: 14px;
}

.chat-form .primary-button {
  min-width: 94px;
  height: 48px;
}

.exam-meta {
  padding: 14px 16px;
  color: var(--muted);
  background: #f2f6f5;
  border: 1px solid var(--line);
  border-radius: 7px;
  line-height: 1.7;
}

.exam-form {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.exam-card {
  padding: 20px;
}

.exam-card h4 {
  margin: 0 0 10px;
  font-size: 18px;
}

.exam-card .stem {
  color: #24313e;
  line-height: 1.9;
  white-space: pre-wrap;
}

.hint-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.hint-row span {
  padding: 6px 10px;
  color: #6a430b;
  background: #fff1d9;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.answer-tools {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 0.36fr);
  gap: 14px;
  align-items: stretch;
  margin-top: 14px;
}

.file-box {
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 14px;
  border: 1px dashed #9ab7b2;
  border-radius: 7px;
  background: #f7fbfa;
  color: var(--muted);
}

.file-box input {
  height: auto;
  padding: 10px;
}

.preview-image {
  max-width: 100%;
  max-height: 170px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.submit-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.submission-status {
  margin-top: 14px;
  line-height: 1.7;
}

.status-card {
  padding: 14px 16px;
  border-radius: 7px;
  background: #eef6f4;
  border-left: 4px solid var(--teal);
  white-space: pre-wrap;
}

.status-card.failed {
  background: #fff0ef;
  border-left-color: var(--red);
}

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

  .sidebar {
    position: static;
    height: auto;
    grid-template-columns: 1fr;
    gap: 16px;
  }

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

  .side-footer {
    grid-template-columns: 1fr auto;
    align-items: end;
  }

  .ghost-button {
    width: auto;
    min-width: 128px;
  }
}

@media (max-width: 980px) {
  .login-screen,
  .hero-band,
  .agent-workbench,
  .answer-tools {
    grid-template-columns: 1fr;
  }

  .agent-switcher,
  .canvas-grid,
  .lesson-strip,
  .analysis-grid {
    grid-template-columns: 1fr;
  }

  .status-grid,
  .metric-rail {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .practice-card,
  .section-heading,
  .chat-header {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 680px) {
  .login-screen {
    padding: 22px;
  }

  .login-brand {
    flex-direction: column;
  }

  .login-panel,
  .hero-band,
  .chat-shell,
  .exam-panel,
  .agent-stage,
  .agent-controls {
    padding: 18px;
  }

  .side-nav,
  .side-footer,
  .status-grid,
  .metric-rail,
  .agent-chat-form,
  .chat-form {
    grid-template-columns: 1fr;
  }

  .tab {
    min-height: 64px;
  }

  .main-panel {
    padding: 18px 14px 34px;
  }

  .agent-stage-head {
    flex-direction: column;
  }

  .submit-row {
    justify-content: stretch;
  }

  .submit-row .primary-button {
    width: 100%;
  }
}
