:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --surface-strong: #eef6f5;
  --text: #17202a;
  --muted: #657182;
  --line: #dce3e8;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --teal-soft: #e1f3ef;
  --blue: #2563eb;
  --amber: #b45309;
  --amber-soft: #fff4dc;
  --red: #be123c;
  --red-soft: #ffe8ee;
  --green: #15803d;
  --green-soft: #e5f8eb;
  --shadow: 0 14px 34px rgba(29, 41, 57, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  border: 0;
  cursor: pointer;
}

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

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

.sidebar,
.memory-panel {
  background: #fbfcfd;
  border-color: var(--line);
  padding: 20px;
}

.sidebar {
  border-right: 1px solid var(--line);
}

.memory-panel {
  border-left: 1px solid var(--line);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: white;
  background: var(--teal);
}

.brand strong,
.brand span,
.course-item strong,
.course-item small,
.document-row strong,
.document-row span,
.history-item span,
.history-item small,
.task-button strong,
.task-button small {
  display: block;
}

.brand strong {
  font-size: 18px;
}

.bi {
  display: inline-grid;
  gap: 2px;
}

.bi small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  text-transform: none;
}

.brand span,
.course-item small,
.document-row span,
.history-item small,
.task-button small,
.eyebrow,
.empty-state span,
.metric span,
.parse-message,
.policy-box li,
.check-chip small,
.summary-card span,
.summary-card small,
.sidebar-note span {
  color: var(--muted);
  font-size: 12px;
}

.course-form {
  margin-top: 28px;
}

.form-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.form-title select {
  width: 112px;
  height: 34px;
  padding: 0 8px;
}

.course-form label,
.settings-grid label span,
.requirement-box span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 800;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 42px;
  gap: 8px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
  border-radius: 8px;
  outline: none;
}

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

textarea {
  min-height: 106px;
  padding: 12px;
  resize: vertical;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.icon-button,
.upload-button,
.primary-action,
.secondary-action,
.task-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: 8px;
}

.icon-button {
  color: white;
  background: var(--teal);
}

.icon-button.quiet {
  width: 34px;
  height: 34px;
  min-height: 34px;
  color: var(--muted);
  background: transparent;
}

.icon-button.quiet:hover {
  color: var(--red);
  background: var(--red-soft);
}

.course-list,
.history-list {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.course-entry,
.history-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: center;
  gap: 4px;
  border-radius: 8px;
}

.course-item,
.history-item {
  display: grid;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  border-radius: 8px;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.course-item {
  grid-template-columns: 10px 1fr 18px;
  padding: 10px;
}

.course-entry.active,
.history-entry.active {
  background: var(--surface-strong);
}

.course-entry .icon-button,
.history-entry .icon-button {
  justify-self: end;
}

.course-color {
  width: 10px;
  height: 36px;
  border-radius: 999px;
}

.sidebar-note {
  display: grid;
  gap: 4px;
  margin-top: 22px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

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

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.language-control {
  display: grid;
  gap: 4px;
  min-width: 132px;
}

.language-control span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.language-control select {
  height: 42px;
  min-width: 132px;
}

.eyebrow {
  font-weight: 900;
  margin: 0 0 6px;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.14;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 18px;
}

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

.summary-card {
  display: grid;
  grid-template-columns: 38px 1fr;
  align-items: center;
  gap: 2px 10px;
  min-height: 82px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.summary-card div {
  display: grid;
  grid-row: span 3;
  place-items: center;
  width: 38px;
  height: 38px;
  color: var(--teal);
  background: var(--teal-soft);
  border-radius: 8px;
}

.summary-card strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.82fr) minmax(380px, 1.18fr);
  gap: 18px;
}

.left-column {
  display: grid;
  gap: 18px;
  align-content: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

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

.upload-button,
.primary-action,
.secondary-action {
  flex: 0 0 auto;
  padding: 0 14px;
  font-weight: 800;
}

.upload-button {
  color: white;
  background: var(--teal);
}

.upload-button.disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.primary-action {
  color: white;
  background: var(--blue);
}

.secondary-action {
  color: var(--text);
  border: 1px solid var(--line);
  background: white;
}

.secondary-action:hover {
  border-color: #c2ccd4;
  background: var(--surface-muted);
}

.upload-button input {
  display: none;
}

.spin {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.parse-message {
  margin: -4px 0 12px;
}

.document-list,
.result-list,
.generated-stack {
  display: grid;
  gap: 10px;
}

.document-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto 34px;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.document-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: var(--teal);
  background: var(--teal-soft);
  border-radius: 8px;
}

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

.task-button {
  min-height: 64px;
  justify-content: flex-start;
  padding: 0 12px;
  color: var(--text);
  border: 1px solid var(--line);
  background: var(--surface-muted);
  font-weight: 800;
  text-align: left;
}

.task-button.selected {
  color: var(--teal-dark);
  border-color: rgba(15, 118, 110, 0.45);
  background: var(--teal-soft);
}

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

.settings-grid.knowledge-settings {
  grid-template-columns: minmax(0, 1fr);
}

.settings-grid label span,
.requirement-box span {
  margin-bottom: 8px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 68px;
  padding-top: 22px;
}

.toggle-row input {
  width: 18px;
  height: 18px;
}

.toggle-row span {
  margin: 0;
  color: var(--text);
  line-height: 1.25;
  white-space: normal;
}

.requirement-box {
  display: block;
  margin-top: 14px;
}

.output-panel {
  min-height: calc(100vh - 210px);
}

.output-heading {
  position: sticky;
  top: 0;
  z-index: 1;
  padding-bottom: 12px;
  background: white;
}

.safety-pill,
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  white-space: nowrap;
  font-weight: 900;
}

.safety-pill {
  padding: 10px 13px;
  font-size: 13px;
}

.status-badge {
  padding: 6px 9px;
  font-size: 12px;
}

.safety-pill.clear,
.status-badge.clear,
.status-badge.pass,
.check-chip.pass {
  color: var(--green);
  background: var(--green-soft);
}

.safety-pill.sensitive,
.status-badge.sensitive,
.status-badge.review,
.check-chip.review {
  color: var(--amber);
  background: var(--amber-soft);
}

.safety-pill.blocked,
.status-badge.blocked,
.check-chip.blocked {
  color: var(--red);
  background: var(--red-soft);
}

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

.check-chip {
  display: grid;
  grid-template-columns: 18px auto;
  align-items: center;
  column-gap: 6px;
  row-gap: 2px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.check-chip span {
  font-size: 13px;
  font-weight: 900;
}

.check-chip small {
  grid-column: 2;
}

.result-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.result-item.blocked {
  border-color: rgba(190, 18, 60, 0.28);
  background: #fff8fa;
}

.result-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.rich-text {
  color: #344054;
  font-size: 15px;
  line-height: 1.68;
  overflow-wrap: anywhere;
}

.rich-text p {
  margin: 10px 0 0;
}

.rich-text ul {
  display: grid;
  gap: 6px;
  margin: 10px 0 0;
  padding-left: 20px;
}

.rich-text li {
  padding-left: 2px;
}

.rich-text code {
  padding: 1px 5px;
  border-radius: 6px;
  background: #eef2f7;
  font-size: 0.94em;
}

.rich-text mjx-container {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.result-body {
  margin-top: 10px;
}

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

.meta-list span {
  border-radius: 999px;
  padding: 4px 8px;
  background: #eef2f7;
}

.answer-box {
  margin-top: 10px;
  padding: 10px 12px;
  color: #1f3b2c;
  background: #edf8ef;
  border-radius: 8px;
}

.answer-box.rich-text {
  color: #1f3b2c;
}

.answer-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.answer-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 172px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  padding: 18px;
}

.empty-state strong {
  color: var(--text);
  margin-top: 8px;
}

.empty-state.compact {
  min-height: 120px;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 20px;
}

.metric {
  padding: 12px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
  background: white;
}

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

.history-entry {
  border: 1px solid var(--line);
  background: white;
}

.history-entry.active {
  background: var(--surface-strong);
}

.history-item {
  padding: 10px 0 10px 12px;
}

.policy-box {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid #eadbb6;
  border-radius: 8px;
  background: #fffaf0;
}

.policy-box div {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--amber);
}

.policy-box ul {
  margin: 10px 0 0;
  padding-left: 18px;
}

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

  .memory-panel {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

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

@media (max-width: 940px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .workspace {
    padding: 18px;
  }

  .topbar,
  .panel-heading,
  .result-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .main-grid {
    grid-template-columns: 1fr;
  }

  .output-panel {
    min-height: auto;
  }
}

@media (max-width: 620px) {
  .summary-strip,
  .task-grid,
  .settings-grid,
  .metric-strip {
    grid-template-columns: 1fr;
  }

  .document-row {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .document-row .status-badge,
  .document-row .icon-button {
    grid-column: 2;
    justify-self: start;
  }

  h1 {
    font-size: 24px;
  }
}
