:root {
  --bg: #eef1df;
  --ink: #1d2b24;
  --muted: #687266;
  --panel: #fbf8ea;
  --line: rgba(54, 64, 49, .18);
  --gold: #c6943d;
  --green: #4d7d57;
  --blue: #417e93;
  --shadow: 0 18px 60px rgba(32, 45, 34, .18);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(120deg, rgba(77,125,87,.16), transparent 32%), linear-gradient(220deg, rgba(198,148,61,.18), transparent 38%), var(--bg);
  font-family: Inter, "Noto Sans TC", "PingFang TC", system-ui, sans-serif;
}
button, textarea, select { font: inherit; }
.app-shell { padding: 22px; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  max-width: 1500px;
  margin: 0 auto 18px;
}
.eyebrow {
  margin: 0 0 5px;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(30px, 4vw, 54px); line-height: 1; }
.token-status {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 300px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(251,248,234,.82);
}
.token-status small { display: block; color: var(--muted); }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(77,125,87,.15); }
.workspace {
  display: grid;
  grid-template-columns: 150px minmax(620px, 1fr) 360px;
  gap: 16px;
  max-width: 1500px;
  margin: 0 auto;
  align-items: start;
}
.workspace > * { min-width: 0; }
.chapter-rail, .lesson-panel, .map-stage, .image-api-panel, .region-panel {
  border: 1px solid var(--line);
  background: rgba(251,248,234,.84);
  box-shadow: var(--shadow);
  border-radius: 8px;
}
.chapter-rail { display: flex; flex-direction: column; gap: 8px; padding: 12px; }
.chapter {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-weight: 900;
}
.chapter.active, .chapter:hover { color: var(--ink); border-color: rgba(77,125,87,.28); background: rgba(77,125,87,.12); }
.map-stage { position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; }
.map-stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #dbe5c7; }
.nodes { position: absolute; inset: 0; }
.node {
  position: absolute;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  transform: translate(-50%, -50%);
  cursor: pointer;
}
.node.active, .node:hover { background: rgba(255,232,139,.2); box-shadow: 0 0 0 4px rgba(255,248,208,.72), 0 0 24px rgba(255,217,92,.95); }
.lesson-panel { padding: 20px; }
.panel-heading { display: flex; justify-content: space-between; margin-bottom: 14px; color: var(--green); font-size: 13px; font-weight: 900; }
.lesson-panel h2 { margin-bottom: 10px; font-size: 28px; line-height: 1.1; }
.lesson-panel p { color: var(--muted); line-height: 1.7; }
.region-visual {
  position: relative;
  margin: 16px 0 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.42);
}
.region-visual img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #dbe5c7;
}
.region-lesson-map {
  position: absolute;
  inset: 0 0 32px;
  pointer-events: none;
}
.lesson-pin {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 128px;
  min-height: 28px;
  padding: 5px 8px;
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 999px;
  color: #211a11;
  background: rgba(255,248,222,.88);
  box-shadow: 0 8px 22px rgba(0,0,0,.22);
  font-size: 11px;
  font-weight: 900;
  line-height: 1.2;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
}
.lesson-pin span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lesson-pin.active {
  color: #fffdf4;
  background: #1f2a24;
  box-shadow: 0 0 0 3px rgba(198,148,61,.52), 0 12px 28px rgba(0,0,0,.3);
}
.lesson-pin.boss {
  border-color: rgba(198,148,61,.85);
  background: rgba(198,148,61,.92);
}
.lesson-pin.boss.active {
  background: #6f1f22;
}
.region-visual figcaption {
  padding: 9px 11px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.4;
}
.lesson-meta { display: grid; gap: 10px; margin: 18px 0; }
.lesson-meta div { padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.45); }
.lesson-meta dt { margin-bottom: 5px; color: var(--green); font-size: 12px; font-weight: 900; }
.lesson-meta dd { margin: 0; line-height: 1.55; }
.sword, .toolchain, .lesson-list, .lesson-detail { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.gems, #toolTags { display: flex; flex-wrap: wrap; gap: 8px; }
.gem, .tool { display: inline-flex; align-items: center; min-height: 30px; padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 900; }
.gem { color: #27402e; background: rgba(77,125,87,.16); }
.gem.active { color: #3c2b0c; background: rgba(198,148,61,.34); }
.tool { color: #25414a; background: rgba(65,126,147,.14); }
.lesson-buttons {
  display: grid;
  gap: 8px;
}
.lesson-button {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255,255,255,.42);
  cursor: pointer;
  text-align: left;
  line-height: 1.35;
}
.lesson-button b {
  color: var(--ink);
}
.lesson-button.active {
  border-color: rgba(198,148,61,.68);
  color: var(--ink);
  background: rgba(198,148,61,.16);
}
.lesson-button.boss {
  border-color: rgba(111,31,34,.22);
}
.lesson-detail-body {
  display: grid;
  gap: 10px;
}
.lesson-script-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.46);
}
.lesson-script-card h4 {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 12px;
}
.lesson-script-card p {
  margin: 0;
  color: var(--ink);
  line-height: 1.55;
}
.lesson-script-card p + pre,
.lesson-script-card p + p {
  margin-top: 8px;
}
.lesson-script-card ol {
  margin: 0;
  padding-left: 18px;
}
.lesson-script-card li {
  margin-bottom: 6px;
  color: var(--muted);
  line-height: 1.5;
}
.lesson-script-card pre {
  max-height: 260px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf4;
  color: var(--ink);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.region-panel, .image-api-panel { max-width: 1500px; margin: 18px auto 0; padding: 22px; }
.section-title { max-width: 760px; }
.section-title h2 { margin-bottom: 8px; font-size: 30px; }
.section-title p { color: var(--muted); line-height: 1.7; }
.region-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}
.region-card {
  min-height: 230px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255,255,255,.48);
  cursor: pointer;
  text-align: left;
  box-shadow: 0 10px 28px rgba(32,45,34,.08);
}
.region-card:nth-child(1) { background: linear-gradient(150deg, rgba(118,162,101,.18), rgba(255,255,255,.62)); }
.region-card:nth-child(2) { background: linear-gradient(150deg, rgba(65,126,147,.18), rgba(255,255,255,.62)); }
.region-card:nth-child(3) { background: linear-gradient(150deg, rgba(198,148,61,.26), rgba(255,255,255,.62)); }
.region-card:nth-child(4) { background: linear-gradient(150deg, rgba(89,91,132,.16), rgba(255,255,255,.62)); }
.region-card.active {
  border-color: rgba(198,148,61,.62);
  box-shadow: 0 0 0 4px rgba(198,148,61,.18), 0 16px 34px rgba(32,45,34,.14);
}
.region-card span {
  display: inline-flex;
  margin-bottom: 14px;
  padding: 5px 9px;
  border-radius: 999px;
  color: #3c2b0c;
  background: rgba(198,148,61,.28);
  font-size: 12px;
  font-weight: 900;
}
.region-card h3 {
  margin-bottom: 8px;
  font-size: 22px;
  line-height: 1.15;
}
.region-card b {
  display: block;
  margin-bottom: 10px;
  color: var(--green);
  font-size: 14px;
}
.region-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}
.api-grid { display: grid; grid-template-columns: 1.05fr 1fr 1fr; gap: 16px; margin-top: 18px; }
.prompt-builder, .api-flow, .api-result { padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.5); }
.curriculum-grid {
  display: grid;
  grid-template-columns: 1.2fr .9fr .9fr;
  gap: 16px;
  margin-top: 18px;
}
.material-list, .course-routing, .material-preview {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.5);
}
.material-list h3, .course-routing h3, .material-preview h3 {
  margin-bottom: 12px;
}
#sourceGrid {
  display: grid;
  gap: 10px;
}
.material-card {
  display: grid;
  gap: 7px;
  width: 100%;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255,255,255,.58);
  cursor: pointer;
  text-align: left;
}
.material-card.active {
  border-color: rgba(198,148,61,.72);
  background: rgba(198,148,61,.15);
}
.material-card span {
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
}
.material-card h4 {
  margin: 0;
  font-size: 16px;
}
.material-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}
.course-routing ol {
  margin: 0;
  padding-left: 20px;
}
.course-routing li {
  margin-bottom: 12px;
  line-height: 1.55;
}
.course-routing span {
  display: block;
  color: var(--muted);
}
.material-preview-image {
  display: block;
  width: 100%;
  margin: 10px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.source-link {
  display: inline-flex;
  margin-top: 6px;
  color: #25414a;
  font-weight: 900;
  text-decoration: none;
}
label { display: grid; gap: 7px; margin-top: 12px; color: var(--green); font-size: 13px; font-weight: 900; }
select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fffdf4; color: var(--ink); }
select { min-height: 42px; padding: 0 10px; }
textarea { min-height: 164px; padding: 12px; resize: vertical; line-height: 1.55; }
.primary-action { margin-top: 12px; min-height: 44px; padding: 0 16px; border: 0; border-radius: 8px; background: var(--green); color: #fff; cursor: pointer; font-weight: 900; }
.api-flow ol { margin: 0; padding-left: 20px; }
.api-flow li { margin: 0 0 12px; line-height: 1.55; }
.api-flow span { display: block; color: var(--muted); }
.result-box { min-height: 210px; padding: 14px; border: 1px dashed rgba(65,126,147,.45); border-radius: 8px; background: rgba(65,126,147,.08); }
.result-box p { margin-bottom: 8px; line-height: 1.55; }
.status { display: inline-flex; margin-bottom: 10px; padding: 5px 9px; border-radius: 999px; font-size: 12px; font-weight: 900; }
.idle { color: #25414a; background: rgba(65,126,147,.16); }
.done { color: #3c2b0c; background: rgba(198,148,61,.34); }
.safety-note { display: grid; gap: 5px; margin-top: 12px; color: var(--muted); line-height: 1.55; }
.safety-note b { color: var(--ink); }
@media (max-width: 1180px) {
  .workspace, .api-grid, .curriculum-grid, .region-grid { grid-template-columns: 1fr; }
  .chapter-rail { flex-direction: row; overflow-x: auto; }
  .chapter { min-width: 120px; }
  .topbar { align-items: start; }
}
@media (max-width: 720px) {
  .app-shell { padding: 14px; }
  .topbar { display: grid; }
}
