:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #5b6776;
  --line: #dbe3ec;
  --teal: #0f766e;
  --teal-dark: #0b5f59;
  --red: #b42318;
  --amber: #9a6700;
  --blue: #2563eb;
  --shadow: 0 18px 45px rgba(22, 34, 51, 0.12);
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  min-height: 38px;
  padding: 0 12px;
  cursor: pointer;
}

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

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

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

.sidebar {
  border-right: 1px solid var(--line);
  background: #eef3f7;
  padding: 24px;
  overflow-y: auto;
}

.brand-block h1,
.trainer-toolbar h2,
.control-section h2,
.learning-section h3,
.answer-panel h3,
.empty-state h3 {
  margin: 0;
  letter-spacing: 0;
}

.brand-block h1 {
  font-size: 28px;
}

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

.subtitle {
  color: var(--muted);
  line-height: 1.7;
}

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

.metrics-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
}

.metrics-grid span {
  display: block;
  font-size: 26px;
  font-weight: 800;
}

.metrics-grid small {
  color: var(--muted);
}

.control-section {
  margin-top: 22px;
}

.control-section label,
.control-section h2 {
  display: block;
  margin-bottom: 9px;
  font-size: 15px;
  font-weight: 800;
}

#searchInput {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
}

.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tag-list,
.hint-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 6px 10px;
  color: var(--muted);
}

.tag-chip.active {
  border-color: var(--teal);
  background: #e6f4f1;
  color: var(--teal-dark);
  font-weight: 700;
}

.ghost-button {
  background: transparent;
  min-height: 32px;
}

.danger-button {
  width: 100%;
  border-color: #f1b4ae;
  color: var(--red);
}

.toggle-row {
  display: flex !important;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 600 !important;
}

.compact-options {
  display: grid;
  gap: 12px;
}

.trainer {
  padding: 28px;
  min-width: 0;
}

.trainer-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.trainer-toolbar h2 {
  font-size: 24px;
  line-height: 1.35;
}

.toolbar-actions,
.image-actions,
.self-review {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.case-panel {
  min-height: calc(100vh - 104px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 22px;
}

.case-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.case-meta a {
  color: var(--blue);
  text-decoration: none;
}

.learning-section {
  margin-top: 22px;
}

.learning-section p,
.answer-panel p {
  white-space: pre-wrap;
  line-height: 1.85;
  margin: 10px 0 0;
}

.image-stage {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 360px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfd;
  overflow: hidden;
}

.image-stage img {
  display: block;
  max-width: 100%;
  max-height: 72vh;
  object-fit: contain;
  cursor: zoom-in;
}

.image-actions {
  margin-top: 10px;
}

.answer-gate {
  margin-top: 24px;
}

.primary-button {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
  min-width: 140px;
  font-weight: 800;
}

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

.answer-panel {
  margin-top: 22px;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}

.diagnosis-block {
  border-left: 4px solid var(--teal);
  padding-left: 14px;
}

.diagnosis-block p {
  font-size: 18px;
  font-weight: 800;
}

.self-review {
  margin-top: 18px;
}

.self-review button[data-active="true"],
#favoriteButton[data-active="true"] {
  border-color: var(--amber);
  background: #fff7df;
  color: var(--amber);
  font-weight: 800;
}

.empty-state {
  padding: 72px 20px;
  text-align: center;
}

.empty-state p {
  color: var(--muted);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(10, 18, 28, 0.86);
  padding: 54px 20px 20px;
}

.lightbox[hidden] {
  display: none;
}

.lightbox img {
  max-width: 96vw;
  max-height: 88vh;
  object-fit: contain;
  background: #fff;
}

.lightbox button {
  position: fixed;
  top: 14px;
  right: 18px;
}

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

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

  .trainer {
    padding: 18px;
  }

  .trainer-toolbar {
    display: grid;
  }
}

@media (max-width: 560px) {
  .sidebar,
  .case-panel {
    padding: 16px;
  }

  .trainer {
    padding: 12px;
  }

  .trainer-toolbar h2 {
    font-size: 20px;
  }

  .toolbar-actions button,
  .image-actions button,
  .self-review button {
    flex: 1 1 42%;
  }

  .image-stage {
    min-height: 230px;
  }
}
