:root {
  --ink: #263528;
  --green: #2f7d4a;
  --mint: #a8dfb0;
  --sun: #ffc857;
  --orange: #ff8a4c;
  --blue: #7cc7ff;
  --paper: #fff9e9;
  --line: rgba(38, 53, 40, .16);
  --shadow: 0 18px 54px rgba(71, 50, 16, .16);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }

/* ── TeachAny Banner ── */
.ta-banner {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: min(1180px, calc(100% - 24px));
  margin: 0 auto;
  padding: 14px 0 6px;
  text-decoration: none;
  transition: opacity .2s;
}
.ta-banner:hover { opacity: .82; }
.ta-banner-icon {
  width: 48px;
  height: 48px;
  border-radius: 13px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .18);
  flex: 0 0 auto;
}
.ta-banner-text {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", "Helvetica Neue", sans-serif;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -.02em;
  background: linear-gradient(135deg, #1a5c2e, #2f7d4a 40%, #45a565);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
body {
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 12% 12%, rgba(255,200,87,.42), transparent 28%),
    radial-gradient(circle at 88% 4%, rgba(124,199,255,.34), transparent 24%),
    radial-gradient(circle at 74% 86%, rgba(168,223,176,.45), transparent 32%),
    #fff4d8;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(47,125,74,.18) 1.2px, transparent 1.2px);
  background-size: 24px 24px;
  opacity: .45;
}
.app-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 24px));
  margin: 0 auto;
  padding: 24px 0 38px;
  display: grid;
  gap: 16px;
}
.picker-card {
  border: 2px solid rgba(47,125,74,.18);
  border-radius: 28px;
  background: rgba(255,249,233,.88);
  box-shadow: var(--shadow);
  padding: clamp(18px, 3vw, 30px);
}
h1 {
  margin: 0 0 18px;
  font-size: clamp(34px, 5vw, 62px);
  line-height: 1;
  letter-spacing: -.04em;
  font-family: "Songti SC", "STSong", serif;
}
.picker-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
label { display: grid; gap: 7px; }
label span { font-size: 13px; font-weight: 900; color: #526354; }
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fffefa;
  color: var(--ink);
  padding: 13px 14px;
  font: inherit;
  outline: none;
}
select:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(47,125,74,.14); }
.item-picker { margin-top: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; align-items: center; }
button, .actions a {
  border: 0;
  border-radius: 16px;
  padding: 13px 18px;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  text-decoration: none;
}
button { background: linear-gradient(180deg, var(--green), #24663b); color: #fff9e9; }
.actions a, .ghost-action { background: #fffefa; color: var(--green); border: 1px solid var(--line); }
.ghost-action:hover, .actions a:hover { box-shadow: 0 0 0 4px rgba(47,125,74,.1); }
#previewFrame {
  width: 100%;
  height: min(74vh, 760px);
  min-height: 560px;
  border: 2px solid rgba(47,125,74,.18);
  border-radius: 28px;
  background: #101525;
  box-shadow: var(--shadow);
}
.reader-modal {
  position: fixed;
  inset: 0;
  z-index: 99;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(20, 26, 22, .58);
  backdrop-filter: blur(8px);
}
.reader-modal.show { display: flex; }
.reader-card {
  width: min(980px, 100%);
  height: min(86vh, 900px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 26px;
  background: #fffefa;
  box-shadow: 0 28px 90px rgba(0,0,0,.26);
}
.reader-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.reader-head p { margin: 0 0 4px; color: var(--green); font-weight: 900; }
.reader-head h2 { margin: 0; font-size: 24px; }
.reader-head button { white-space: nowrap; }
.reader-body {
  flex: 1;
  overflow-y: auto;
  padding: 28px clamp(22px, 5vw, 64px);
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: 20px;
  line-height: 2.05;
}
/* ── 基本段落 ── */
.reader-body p { margin: 0 0 14px; text-indent: 2em; }
.reader-body .reader-loading { color: #6b705d; text-indent: 0; }

/* ── 课文标题 ── */
.reader-body .rt-title {
  margin: 0 0 6px;
  text-indent: 0;
  text-align: center;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: .06em;
  color: var(--ink);
  font-family: "Songti SC", "STSong", serif;
}
/* ── 作者行 ── */
.reader-body .rt-author {
  margin: 0 0 20px;
  text-indent: 0;
  text-align: center;
  font-size: 15px;
  color: #7a7d6a;
  letter-spacing: .08em;
}
/* ── 章节/分段标题 ── */
.reader-body .rt-section {
  margin: 28px 0 10px;
  text-indent: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--green);
  border-left: 4px solid var(--green);
  padding-left: 12px;
}
/* ── 诗歌/儿歌行 ── */
.reader-body .rt-verse {
  text-indent: 0;
  text-align: center;
  margin: 0 0 6px;
  font-size: 21px;
  line-height: 2.3;
  letter-spacing: .12em;
}
/* ── 引文/名言 ── */
.reader-body .rt-quote {
  margin: 14px 2em;
  padding: 12px 18px;
  text-indent: 0;
  border-left: 4px solid var(--sun);
  background: rgba(255, 200, 87, .12);
  border-radius: 0 12px 12px 0;
  font-style: italic;
  color: #5c4a12;
}
/* ── 对话行 ── */
.reader-body .rt-dialogue {
  text-indent: 2em;
  position: relative;
  padding-left: .6em;
}
.reader-body .rt-dialogue::before {
  content: "";
  position: absolute;
  left: 0;
  top: .45em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--orange);
}

/* ── 生字注音 ruby ── */
.reader-body ruby.rt-char {
  position: relative;
  color: var(--green);
  font-weight: 700;
  border-bottom: 2px dotted rgba(47, 125, 74, .35);
  padding-bottom: 1px;
  cursor: help;
}
.reader-body ruby.rt-char rt {
  font-size: .52em;
  font-weight: 400;
  color: #c25821;
  letter-spacing: 0;
}

/* ── 本课生字卡片 ── */
.char-card {
  margin: 32px 0 8px;
  border: 2px solid rgba(47, 125, 74, .18);
  border-radius: 20px;
  background: linear-gradient(135deg, #f4fdf6, #fefcf2);
  overflow: hidden;
}
.cc-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  background: rgba(47, 125, 74, .07);
  font-weight: 900;
  font-size: 16px;
  color: var(--green);
  border-bottom: 1px solid rgba(47, 125, 74, .12);
}
.cc-icon { font-size: 20px; }
.cc-count {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  background: var(--green);
  color: #fff;
  padding: 2px 10px;
  border-radius: 20px;
}
.cc-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 16px 20px;
}
.cc-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid rgba(47, 125, 74, .15);
  border-radius: 12px;
  font-size: 22px;
  font-family: "Songti SC", "STSong", "SimSun", serif;
  transition: transform .15s, box-shadow .15s;
}
.cc-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(47, 125, 74, .18);
}
.cc-item ruby rt {
  font-size: .5em;
  color: #c25821;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
}
/* ── 自制游戏按钮 ── */
.custom-game-btn {
  background: linear-gradient(135deg, #ff8a4c, #ffc857) !important;
  color: #4a2800 !important;
  border: none !important;
  font-weight: 900;
  animation: glow-pulse 2.5s ease-in-out infinite;
}
.custom-game-btn:hover { box-shadow: 0 0 0 4px rgba(255,138,76,.25); }
@keyframes glow-pulse {
  0%, 100% { box-shadow: 0 2px 12px rgba(255,138,76,.2); }
  50% { box-shadow: 0 2px 22px rgba(255,138,76,.45); }
}

/* ── 自制游戏弹窗 ── */
.custom-card { max-width: 860px; height: min(92vh, 960px); }
.custom-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px clamp(16px, 4vw, 32px);
  display: grid;
  gap: 20px;
}
.custom-body h3 {
  margin: 0 0 10px;
  font-size: 17px;
  color: var(--green);
  display: flex; align-items: center; gap: 6px;
}
.custom-body h3 span {
  background: var(--green);
  color: #fff;
  font-size: 13px;
  padding: 1px 10px;
  border-radius: 20px;
  font-weight: 600;
}
.custom-body h4 {
  margin: 0 0 8px;
  font-size: 14px;
  color: #526354;
  display: flex; align-items: center; gap: 8px;
}
.select-all-btn {
  font-size: 11px !important;
  padding: 3px 10px !important;
  border-radius: 12px !important;
  background: rgba(47,125,74,.08) !important;
  color: var(--green) !important;
  border: 1px solid rgba(47,125,74,.2) !important;
  cursor: pointer;
}
.select-all-btn:hover { background: rgba(47,125,74,.16) !important; }

.preset-group { margin-bottom: 14px; }
.preset-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.preset-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 14px;
  border: 1.5px solid var(--line);
  border-radius: 20px;
  font-size: 13px;
  background: #fffefa;
  cursor: pointer;
  transition: all .15s;
  user-select: none;
}
.preset-chip:hover { border-color: var(--green); background: rgba(47,125,74,.05); }
.preset-chip.active {
  border-color: var(--green);
  background: linear-gradient(135deg, rgba(47,125,74,.12), rgba(168,223,176,.22));
  color: var(--green);
  font-weight: 700;
}
.preset-chip .chip-check {
  width: 16px; height: 16px;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 10px;
  transition: all .15s;
}
.preset-chip.active .chip-check {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.custom-input-section { border-top: 1px solid var(--line); padding-top: 16px; }
.custom-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.custom-form label { display: grid; gap: 4px; }
.custom-form label span { font-size: 12px; font-weight: 700; color: #526354; }
.custom-form input, .custom-form textarea, .custom-form select {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffefa;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  outline: none;
}
.custom-form input:focus, .custom-form textarea:focus, .custom-form select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47,125,74,.1);
}
.custom-form .full-width { grid-column: 1 / -1; }
.custom-form button { justify-self: start; margin-top: 4px; }

.selected-section { border-top: 1px solid var(--line); padding-top: 16px; }
.selected-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 36px;
}
.selected-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 600;
  background: linear-gradient(135deg, rgba(47,125,74,.1), rgba(168,223,176,.18));
  color: var(--green);
  border: 1px solid rgba(47,125,74,.2);
}
.selected-tag .remove-tag {
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  opacity: .5;
  transition: opacity .15s;
}
.selected-tag .remove-tag:hover { opacity: 1; }

.generate-bar {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  text-align: center;
}
.generate-bar button {
  width: 100%;
  padding: 16px;
  font-size: 18px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--green), #45a565);
  color: #fff;
  font-weight: 900;
  border: none;
  cursor: pointer;
  transition: all .2s;
}
.generate-bar button:disabled {
  opacity: .4;
  cursor: not-allowed;
  background: #ccc;
}
.generate-bar button:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(47,125,74,.35);
}
.gen-status {
  margin: 10px 0 0;
  font-size: 14px;
  color: #526354;
  min-height: 24px;
}
.gen-status .progress-bar {
  display: block;
  margin: 8px auto 0;
  width: 100%;
  max-width: 400px;
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}
.gen-status .progress-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--green), var(--mint));
  transition: width .3s;
}

@media (max-width: 720px) {
  .app-shell { width: min(100% - 16px, 1180px); padding-top: 12px; }
  .picker-card { border-radius: 20px; padding: 16px; }
  .picker-row { grid-template-columns: 1fr; }
  .actions { display: grid; }
  #previewFrame { min-height: 520px; border-radius: 20px; }
  .custom-form { grid-template-columns: 1fr; }
  .custom-card { height: 96vh; }
}
