:root {
  --bg: #eef2f7;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #64748b;
  --line: #d7dfeb;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --red: #ef4444;
  --yellow: #ffd400;
  --blue: #2563eb;
  --green: #15803d;
  --amber: #b45309;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}
button, input { font: inherit; }

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

.sidebar {
  background: #13272d;
  color: #e7f2f4;
  padding: 18px 14px;
  overflow-y: auto;
}

.brand {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #19a28d;
  color: white;
  font-weight: 800;
  font-size: 20px;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}
.brand p {
  margin: 3px 0 0;
  color: #a7bbc0;
  font-size: 12px;
}

.reference-link {
  display: block;
  margin: 0 0 12px;
  padding: 10px 11px;
  border: 1px solid rgba(142, 228, 211, .45);
  border-radius: 8px;
  color: #ecfffb;
  background: rgba(25, 162, 141, .18);
  text-decoration: none;
  font-weight: 800;
}
.reference-link:hover {
  background: rgba(25, 162, 141, .28);
}

.course-list {
  display: grid;
  gap: 8px;
}

.course-btn {
  width: 100%;
  min-height: 52px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  background: rgba(255,255,255,.04);
  color: #dcecef;
  text-align: left;
  padding: 9px 10px;
  cursor: pointer;
}

.course-btn strong {
  display: block;
  font-size: 14px;
}
.course-btn span {
  display: block;
  font-size: 12px;
  color: #9db2b7;
  margin-top: 2px;
}
.course-btn.active {
  background: #e8fffa;
  color: #0f3f3a;
  border-color: #8ee4d3;
}
.course-btn.active span { color: #426761; }

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

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

.eyebrow {
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}
.topbar h2 {
  margin: 2px 0 0;
  font-size: 22px;
  line-height: 1.25;
}

.toolbar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.icon-btn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-size: 24px;
  cursor: pointer;
}
.counter {
  min-width: 76px;
  text-align: center;
  font-weight: 700;
  color: var(--muted);
}

.lesson {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 318px;
  gap: 14px;
  align-items: start;
}

.stage-card,
.lesson-panel,
.steps-strip {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stage-card {
  padding: 10px;
  overflow: hidden;
}

.image-frame {
  position: relative;
  width: 100%;
  overflow: auto;
  max-height: calc(100vh - 154px);
  background: #f8fafc;
}
.image-frame img {
  display: block;
  width: 100%;
  height: auto;
}

.hotspot {
  position: absolute;
  border: 4px solid var(--red);
  border-radius: 6px;
  background: rgba(255, 255, 255, .05);
  box-shadow: 0 0 0 7px rgba(239, 68, 68, .13);
  cursor: pointer;
  pointer-events: auto;
  transition: left .18s ease, top .18s ease, width .18s ease, height .18s ease;
}
.hotspot:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}
.hotspot::after {
  content: "";
  position: absolute;
  right: -13px;
  bottom: -13px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 10px rgba(239, 68, 68, .15);
}
.cursor-pointer {
  position: absolute;
  left: 0;
  top: 0;
  width: 34px;
  height: 34px;
  pointer-events: none;
  background: center / contain no-repeat
    url("data:image/svg+xml,%3Csvg width='42' height='42' viewBox='0 0 42 42' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M9 4L33 23.5L21.8 25.2L17.1 37L9 4Z' fill='white'/%3E%3Cpath d='M9 4L33 23.5L21.8 25.2L17.1 37L9 4Z' stroke='%23111827' stroke-width='2.5' stroke-linejoin='round'/%3E%3Cpath d='M21.2 25.4L29.2 34.6' stroke='%23111827' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E");
  filter: drop-shadow(0 8px 12px rgba(17, 24, 39, .25));
  transform: translate(-6px, -4px);
  transition: left .18s ease, top .18s ease;
}

.lesson-panel {
  padding: 14px;
  display: grid;
  gap: 12px;
}
.panel-block {
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}
.panel-block:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}
.step-label {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eaf2ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 800;
}
.lesson-panel h3 {
  margin: 8px 0 6px;
  font-size: 17px;
}
.lesson-panel p { margin: 0; color: #334155; }
.note {
  margin-top: 10px;
  padding: 9px 10px;
  background: rgba(255, 244, 153, .62);
  color: #6b5000;
  border: 1px solid rgba(245, 158, 11, .35);
  border-radius: 8px;
  font-weight: 700;
}

.check-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 7px;
}
.check-list li {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 7px;
  color: #334155;
}
.check-list li::before {
  content: "✓";
  color: var(--green);
  font-weight: 900;
}

.quiz-options {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.quiz-options button {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 38px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.quiz-options button:hover {
  border-color: #6ee7d8;
  background: #ecfffb;
}
.quiz-feedback {
  margin-top: 8px;
  font-weight: 800;
  min-height: 22px;
}
.quiz-feedback.ok { color: var(--green); }
.quiz-feedback.bad { color: var(--red); }

.steps-strip {
  margin-top: 14px;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 8px;
}
.step-chip {
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-align: left;
  padding: 8px 9px;
  cursor: pointer;
}
.step-chip strong {
  display: block;
  font-size: 12px;
  color: var(--muted);
}
.step-chip span {
  display: block;
  font-weight: 700;
  margin-top: 2px;
}
.step-chip.active {
  border-color: #0f766e;
  background: #ecfffb;
}

@media (max-width: 1100px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .course-list { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
  .lesson { grid-template-columns: 1fr; }
  .image-frame { max-height: none; }
}

@media (max-width: 640px) {
  .workspace { padding: 12px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar h2 { font-size: 19px; }
}

.reference-page {
  min-height: 100vh;
  background: var(--bg);
  padding: 22px;
}
.reference-shell {
  width: min(1160px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 16px;
}
.reference-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}
.reference-header h1 {
  margin: 0;
  font-size: 28px;
}
.back-link {
  color: var(--brand-dark);
  font-weight: 800;
  text-decoration: none;
}
.reference-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.reference-card,
.reference-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.reference-card h2,
.reference-section h2 {
  margin: 0 0 10px;
  font-size: 19px;
}
.reference-card ul,
.reference-section ul {
  margin: 0;
  padding-left: 20px;
}
.reference-card li,
.reference-section li {
  margin: 6px 0;
}
.reference-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}
.reference-table th,
.reference-table td {
  border: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
}
.reference-table th {
  background: #eef7f5;
}
.template-box {
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #f1d48a;
  background: rgba(255, 244, 153, .42);
  white-space: pre-line;
  font-weight: 700;
}
@media (max-width: 900px) {
  .reference-grid { grid-template-columns: 1fr; }
  .reference-header { align-items: flex-start; flex-direction: column; }
}
