:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --panel: #ffffff;
  --panel-soft: #f9fbfa;
  --line: #d8e2df;
  --line-strong: #c5d3cf;
  --text: #20312d;
  --muted: #687873;
  --accent: #176b5d;
  --accent-dark: #105348;
  --accent-soft: #e7f2ee;
  --blue: #3a6791;
  --warm: #a86a2d;
  --error: #a63a3a;
  --shadow: 0 14px 34px rgba(23, 53, 47, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

h1,
h2,
p {
  margin: 0;
}

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

h2 {
  font-size: 16px;
  line-height: 1.35;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  align-items: center;
  gap: 18px;
  min-height: 76px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
}

.brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

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

.topnav {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.topnav a {
  min-width: 86px;
  min-height: 34px;
  display: inline-grid;
  place-items: center;
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}

.topnav a.active {
  background: #ffffff;
  color: var(--accent);
  box-shadow: 0 1px 6px rgba(26, 68, 60, 0.08);
}

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

.generation-workspace {
  grid-template-columns: minmax(420px, 0.95fr) minmax(460px, 1.05fr);
  height: calc(100vh - 76px);
}

.pane {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

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

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.field-grid.identity {
  grid-template-columns: minmax(0, 1.7fr) minmax(120px, 0.6fr);
}

.project-list {
  margin: 12px 0;
}

.training-block {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

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

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

input {
  height: 40px;
  padding: 8px 11px;
}

textarea {
  min-height: 118px;
  padding: 11px;
  line-height: 1.65;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 107, 93, 0.12);
}

.output-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.result {
  min-height: 420px;
  resize: none;
  font-size: 15px;
}

button {
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

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

button.primary,
button.success {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

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

.message {
  min-height: 24px;
  margin-top: 10px;
  color: var(--muted);
  white-space: pre-wrap;
  line-height: 1.5;
}

.message.error {
  color: var(--error);
}

.message.warn {
  color: var(--warm);
}

.learning-page {
  display: grid;
  gap: 16px;
  padding: 18px;
}

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

.stat-card {
  min-height: 82px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.stat-card span {
  color: var(--accent);
  font-size: 25px;
  font-weight: 700;
  line-height: 1.1;
}

.stat-card label {
  display: block;
  color: var(--muted);
}

.learning-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.74fr) minmax(420px, 1.1fr) minmax(360px, 0.95fr);
  gap: 16px;
  min-height: calc(100vh - 198px);
}

.learning-sidebar,
.learning-content,
.learning-detail-pane {
  max-height: calc(100vh - 198px);
}

.record-list,
.rules-board,
.learning-detail {
  display: grid;
  gap: 10px;
}

.history-item,
.rule-item,
.text-block,
.evidence-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.history-title,
.detail-title {
  color: var(--text);
  font-weight: 700;
}

.item-meta,
.text-block-title {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.item-preview,
.rule-text {
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
}

.badge {
  width: fit-content;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #ffffff;
  font-size: 12px;
}

.badge.good {
  border-color: #b9d4cc;
  color: var(--accent);
  background: var(--accent-soft);
}

.item-actions button {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
}

.rule-heading {
  align-items: flex-start;
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.segmented button {
  min-height: 30px;
  min-width: 52px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.segmented button.active {
  background: #ffffff;
  color: var(--accent);
  box-shadow: 0 1px 6px rgba(26, 68, 60, 0.08);
}

.rule-section {
  display: grid;
  gap: 9px;
}

.rule-section-title {
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
}

.empty-text {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.text-block-content {
  max-height: 280px;
  margin: 0;
  overflow: auto;
  color: var(--text);
  white-space: pre-wrap;
  line-height: 1.6;
  font: inherit;
  font-size: 13px;
}

.learning-message {
  margin-top: 0;
}

@media (max-width: 1180px) {
  .generation-workspace,
  .learning-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .learning-sidebar,
  .learning-content,
  .learning-detail-pane {
    max-height: none;
  }
}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .topnav {
    width: 100%;
  }

  .topnav a {
    flex: 1;
  }

  .field-grid.identity,
  .learning-overview {
    grid-template-columns: 1fr;
  }

  .workspace,
  .learning-page {
    padding: 12px;
  }

  .pane {
    padding: 14px;
  }

  .result {
    min-height: 360px;
  }
}
