:root {
  --ink: #16201d;
  --muted: #63706b;
  --paper: #fbfcf8;
  --panel: #ffffff;
  --line: #dce5de;
  --teal: #147c72;
  --teal-soft: #e5f4f1;
  --amber: #bc7a19;
  --amber-soft: #fff3da;
  --blue: #2e5d8a;
  --blue-soft: #e6eff7;
  --rose: #a94b5b;
  --rose-soft: #f8e8ec;
  --shadow: 0 20px 50px rgba(22, 32, 29, 0.08);
  font-family:
    Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  max-width: 100%;
  overflow-x: hidden;
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(135deg, #f6f9f4 0%, #eef5f3 45%, #f8f5ef 100%);
  overflow-wrap: anywhere;
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.control-panel {
  position: sticky;
  top: 0;
  min-width: 0;
  height: 100vh;
  overflow: auto;
  padding: 28px;
  border-right: 1px solid var(--line);
  background: rgba(251, 252, 248, 0.88);
  backdrop-filter: blur(18px);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--teal);
  font-size: 24px;
  font-weight: 800;
}

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

h1 {
  font-size: 24px;
}

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

.scenario-card,
.workspace section,
.workspace article {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.scenario-card {
  padding: 18px;
}

.section-title {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-title p {
  margin: 0;
  font-weight: 800;
  overflow-wrap: anywhere;
}

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

textarea {
  width: 100%;
  min-height: 210px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--ink);
  background: #fbfdfb;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(20, 124, 114, 0.22);
  outline-offset: 2px;
}

.primary-action {
  width: 100%;
  min-height: 44px;
  margin-top: 14px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--teal);
  font-weight: 800;
  transition: transform 160ms ease, background 160ms ease;
}

.primary-action.compact {
  margin-top: 0;
}

.secondary-action {
  min-height: 44px;
  border: 1px solid rgba(20, 124, 114, 0.35);
  border-radius: 8px;
  color: var(--teal);
  background: var(--teal-soft);
  font-weight: 800;
}

.secondary-action:hover {
  border-color: var(--teal);
  background: #d7eee9;
}

.primary-action:hover {
  background: #0f695f;
  transform: translateY(-1px);
}

.scenario-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.scenario-option {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  text-align: left;
  padding: 0 14px;
  font-weight: 700;
}

.scenario-option.is-active,
.scenario-option:hover {
  border-color: rgba(20, 124, 114, 0.45);
  background: var(--teal-soft);
}

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

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

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

.header-metrics div {
  min-height: 68px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

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

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

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(360px, 1.1fr);
  gap: 18px;
  box-shadow: none;
  border: 0;
  background: transparent;
}

.rag-panel {
  padding: 18px;
}

.rag-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.85fr) minmax(0, 1.15fr);
  gap: 14px;
}

.rag-controls {
  display: grid;
  gap: 12px;
}

.upload-box {
  display: grid;
  gap: 6px;
  min-height: 86px;
  align-content: center;
  border: 1px dashed rgba(20, 124, 114, 0.45);
  border-radius: 8px;
  padding: 14px;
  background: #fbfdfb;
}

.upload-box strong {
  color: var(--ink);
}

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

#courseUpload {
  width: 100%;
  min-height: 40px;
  color: var(--muted);
}

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

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

.rag-stats div,
.empty-state,
.rag-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.rag-stats div {
  padding: 10px;
}

.rag-stats strong {
  display: block;
  font-size: 20px;
}

.rag-stats span,
.rag-card span {
  color: var(--muted);
  font-size: 12px;
}

.rag-results {
  display: grid;
  gap: 10px;
  align-content: start;
}

.empty-state,
.rag-card {
  padding: 14px;
}

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

.rag-card div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.workspace section,
.workspace article {
  padding: 18px;
}

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

.profile-item,
.agent-step,
.resource-card,
.path-item,
.diagnosis-item,
.tutor-answer,
.metric-row {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.profile-item {
  min-height: 86px;
  padding: 12px;
}

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

.profile-item strong {
  display: block;
  margin-top: 8px;
  line-height: 1.45;
}

.learning-map {
  width: 100%;
  min-height: 220px;
}

.learning-map path {
  fill: none;
  stroke: #8ab8af;
  stroke-width: 8;
  stroke-linecap: round;
}

.learning-map circle {
  fill: #fff;
  stroke: var(--teal);
  stroke-width: 4;
}

.learning-map text {
  fill: var(--ink);
  font-size: 18px;
  font-weight: 800;
  text-anchor: middle;
}

.agent-flow {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  gap: 10px;
  overflow-x: auto;
}

.agent-step {
  min-height: 112px;
  padding: 12px;
}

.agent-step small {
  color: var(--teal);
  font-weight: 800;
}

.agent-step strong {
  display: block;
  margin: 8px 0;
  line-height: 1.35;
}

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

.split-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  box-shadow: none;
  border: 0;
  background: transparent;
  padding: 0 !important;
}

.split-grid.wide {
  grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr);
}

.diagnosis-list,
.path-timeline,
.evaluation-panel {
  display: grid;
  gap: 10px;
}

.diagnosis-item {
  padding: 12px;
}

.diagnosis-item b {
  display: inline-block;
  margin-bottom: 5px;
}

.diagnosis-item p,
.tutor-answer p,
.resource-card p,
.path-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.resources-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(190px, 1fr));
  gap: 12px;
  overflow-x: auto;
}

.resource-card {
  min-height: 220px;
  padding: 14px;
}

.resource-card:nth-child(1) {
  background: linear-gradient(180deg, #fff, var(--teal-soft));
}

.resource-card:nth-child(2) {
  background: linear-gradient(180deg, #fff, var(--blue-soft));
}

.resource-card:nth-child(3) {
  background: linear-gradient(180deg, #fff, var(--amber-soft));
}

.resource-card:nth-child(4) {
  background: linear-gradient(180deg, #fff, #eaf5e6);
}

.resource-card:nth-child(5) {
  background: linear-gradient(180deg, #fff, var(--rose-soft));
}

.resource-type {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  color: var(--teal);
  background: rgba(20, 124, 114, 0.1);
  font-size: 12px;
  font-weight: 800;
}

.resource-card h3,
.path-item h3 {
  margin: 12px 0 8px;
  font-size: 16px;
  line-height: 1.35;
}

.path-item {
  position: relative;
  padding: 14px 14px 14px 54px;
}

.path-item::before {
  content: attr(data-day);
  position: absolute;
  top: 14px;
  left: 14px;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.metric-row {
  padding: 12px;
}

.meter {
  height: 10px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf0ed;
}

.meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--amber));
}

.score-block {
  display: grid;
  min-height: 120px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: radial-gradient(circle at 35% 25%, #2d998e, var(--teal));
}

.score-block strong {
  font-size: 44px;
}

.recommendations {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.7;
}

.source-list {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 320px minmax(0, 1fr);
  }

  .dashboard-grid,
  .rag-layout,
  .split-grid,
  .split-grid.wide {
    grid-template-columns: 1fr;
  }

  .resources-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
    width: 100vw;
    max-width: 100%;
    overflow-x: hidden;
  }

  .control-panel {
    position: relative;
    width: 100%;
    max-width: 100%;
    height: auto;
    padding: 18px;
  }

  .workspace {
    width: 100%;
    max-width: 100%;
    padding: 18px;
    overflow-x: hidden;
  }

  h1 {
    font-size: 22px;
  }

  h2 {
    font-size: 24px;
    line-height: 1.3;
  }

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

  .header-metrics,
  .profile-grid,
  .rag-actions,
  .rag-stats,
  .resources-grid {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .scenario-card,
  .scenario-option,
  textarea,
  .workspace section,
  .workspace article {
    max-width: 100%;
  }

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