:root {
  --ink: #1f2933;
  --sub: #5b6b7a;
  --line: #d7e0e0;
  --line-soft: #e8efee;
  --accent: #0e7c6b;
  --accent-deep: #0a5f54;
  --accent-light: #e6f4f1;
  --warm: #e8590c;
  --bg: #f4f8f7;
  --card: #ffffff;
  --shadow: 0 10px 28px rgba(31, 41, 51, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

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

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

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

/* Login */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: linear-gradient(135deg, rgba(14,124,107,.97), rgba(42,167,146,.97));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  transition: opacity .2s ease;
}

.login-overlay.is-hidden {
  display: none;
}

.login-card {
  width: min(100%, 420px);
  background: #fff;
  border-radius: 24px;
  padding: 34px 30px 26px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .2);
  text-align: center;
}

.login-icon {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: var(--accent-light);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  font-weight: 700;
  margin-bottom: 16px;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 24px;
  letter-spacing: .5px;
}

.login-card > p {
  margin: 0 0 22px;
  color: var(--sub);
}

.login-field {
  display: block;
  margin: 12px 0;
  text-align: left;
}

.login-field span {
  display: block;
  margin: 0 0 6px;
  color: #48605a;
  font-size: 13px;
  font-weight: 700;
}

.login-field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  min-height: 46px;
  color: var(--ink);
  background: #fbfdfd;
  outline: none;
}

.login-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 124, 107, .12);
}

.login-error {
  min-height: 20px;
  margin: 4px 0 6px;
  color: #c0392b;
  font-size: 13px;
  font-weight: 600;
}

.login-submit {
  width: 100%;
  margin-top: 8px;
}

.login-hint {
  margin-top: 18px;
  color: #9aa9a4;
  font-size: 12px;
}

.logout-btn {
  color: #8a4a1d;
  border-color: #ecd3bc;
  background: #fff7f0;
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.topbar-inner {
  max-width: 1500px;
  margin: 0 auto;
  padding: 12px 18px 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, #0e7c6b, #2aa792);
  font-size: 26px;
  font-weight: 700;
  box-shadow: 0 6px 14px rgba(14, 124, 107, 0.22);
}

.brand h1 {
  margin: 0;
  font-size: 19px;
  letter-spacing: 0.5px;
  line-height: 1.2;
}

.brand p {
  margin: 3px 0 0;
  color: var(--sub);
  font-size: 12px;
}

.topnav {
  display: flex;
  gap: 8px;
  flex: none;
}

.nav-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: #48605a;
  border-radius: 999px;
  padding: 10px 16px;
  min-height: 42px;
  font-size: 14px;
  font-weight: 600;
}

.nav-btn.is-active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

/* Layout */
.layout {
  max-width: 1500px;
  margin: 0 auto;
  padding: 22px 18px 48px;
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.builder-panel,
.preview-panel {
  min-width: 0;
}

.builder-panel {
  position: sticky;
  top: 82px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: #bfd2cc transparent;
}

.panel-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 6px 18px rgba(31, 41, 51, 0.04);
}

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

.panel-title h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0.3px;
}

.field {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  color: var(--sub);
  font-size: 13px;
}

.field span {
  font-weight: 600;
}

.field input,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  min-height: 44px;
  color: var(--ink);
  background: #fbfdfd;
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 124, 107, 0.12);
}

.text-btn {
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 4px 6px;
  font-size: 12px;
  font-weight: 600;
}

/* Exercise cards */
.type-controls {
  display: grid;
  gap: 10px;
}

.type-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfdfd;
  padding: 12px;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.type-card.is-on {
  border-color: #9fcec4;
  background: var(--accent-light);
}

.type-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.type-head label {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  color: #27453e;
}

.type-head input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.type-card p {
  margin: 5px 0 0 29px;
  color: var(--sub);
  font-size: 12px;
}

.type-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 11px 0 0 29px;
}

.count-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.count-picker button {
  width: 32px;
  height: 32px;
  border: 1px solid #b9d5ce;
  background: #fff;
  color: var(--accent-deep);
  border-radius: 10px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}

.count-picker input {
  width: 48px;
  border: 1px solid var(--line);
  border-radius: 10px;
  height: 32px;
  text-align: center;
  color: var(--ink);
  background: #fff;
}

.param-select {
  max-width: 110px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  min-height: 32px;
  padding: 4px 8px;
  color: #42564f;
  font-size: 12px;
}

/* Switch rows */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--line-soft);
  cursor: pointer;
}

.switch-row:first-of-type {
  border-top: 0;
}

.switch-row span {
  color: #31554b;
}

.switch-row b {
  display: block;
  font-size: 14px;
}

.switch-row small {
  color: var(--sub);
  font-size: 12px;
}

.switch-row input[type="checkbox"] {
  width: 46px;
  height: 28px;
  accent-color: var(--accent);
  flex: none;
  transform: scale(1.08);
}

/* DB child/history controls */
.inline-actions {
  display: flex;
  gap: 8px;
  margin: -2px 0 12px;
}

.mini-btn {
  flex: 1;
  border: 1px solid #b9d5ce;
  background: var(--accent-light);
  color: var(--accent-deep);
  border-radius: 10px;
  min-height: 38px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 700;
}

.ghost-mini {
  background: #fff;
  color: #48605a;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.history-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  color: #48605a;
}

.history-list li:first-child {
  border-top: 0;
}

.history-list time {
  color: #8aa09a;
  white-space: nowrap;
}

.history-empty {
  color: #8aa09a;
  font-size: 12px;
  margin: 8px 0 0;
}

/* Buttons */
.primary-btn,
.ghost-btn {
  border: 0;
  border-radius: 13px;
  padding: 12px 16px;
  min-height: 48px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.2px;
}

.primary-btn {
  background: linear-gradient(135deg, #0e7c6b, #14907c);
  color: #fff;
  box-shadow: 0 8px 16px rgba(14, 124, 107, 0.22);
}

.primary-btn:not(:disabled):hover {
  filter: brightness(1.05);
}

.ghost-btn {
  background: #fff;
  color: var(--accent-deep);
  border: 1px solid #b9d5ce;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, rgba(244, 248, 247, 0), var(--bg) 26%);
  padding: 18px 0 2px;
}

.sticky-actions .primary-btn {
  width: 100%;
}

/* Workspace */
.preview-panel {
  background: #e6eeec;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 16px;
  min-height: 720px;
}

.workspace-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--sub);
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.workspace-head h2 {
  margin: 0;
  font-size: 18px;
  color: #24463f;
}

.workspace-actions {
  display: flex;
  gap: 10px;
  flex: none;
}

.empty-state {
  border: 1.5px dashed #bad2cc;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.62);
  padding: 50px 20px;
  text-align: center;
  color: #58716b;
}

.empty-art {
  font-size: 44px;
  margin-bottom: 8px;
}

.empty-state h3 {
  margin: 0 0 6px;
  color: #24463f;
  font-size: 18px;
}

.empty-state p {
  margin: 0;
  font-size: 14px;
}

.worksheet-stage {
  display: grid;
  gap: 24px;
  align-items: start;
  justify-content: center;
}

/* A4 worksheet page */
.worksheet-page {
  background: #fff;
  width: min(100%, 210mm);
  min-height: 297mm;
  margin: 0 auto;
  padding: 12mm 14mm 14mm;
  box-shadow: 0 10px 28px rgba(31, 41, 51, 0.13);
  position: relative;
  color: #141414;
  display: flex;
  flex-direction: column;
}

.worksheet-page.print-large {
  font-size: 16px;
}

.worksheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1.6px solid #282828;
  padding-bottom: 7px;
  margin-bottom: 8px;
}

.worksheet-header h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 1px;
}

.header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  color: #1f1f1f;
  font-size: 12.5px;
  white-space: nowrap;
}

.worksheet-footer {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px dashed #787878;
  color: #666;
  font-size: 11.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* Pinyin annotation */
.pinyin-annotated ruby,
.py ruby {
  ruby-align: center;
  ruby-position: over;
  font-size: inherit;
  line-height: 1.4;
}

.pinyin-annotated rt,
.py rt {
  font-size: 58%;
  color: #a00202;
}

.pinyin-annotated {
  letter-spacing: 1px;
}

/* Section blocks */
.worksheet-block {
  margin-top: 13px;
  break-inside: avoid;
  page-break-inside: avoid;
}

.section-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-weight: 700;
  margin: 0 0 5px;
  font-size: 15px;
}

.section-title .section-mark {
  color: #0e7c6b;
  font-weight: 800;
}

.section-title p {
  margin: 0;
  font-weight: 500;
  color: #333;
  font-size: 12.5px;
}

.exercise-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
}

.exercise-grid.count-compare {
  gap: 14px 24px;
}

.exercise-item {
  min-width: 150px;
  flex: 1 1 150px;
  max-width: 330px;
  font-size: 16px;
  line-height: 1.7;
  color: #161616;
}

.prompt {
  margin: 0 0 4px;
  font-weight: 600;
}

.statement {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  min-height: 32px;
}

.blank-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  border: 1px solid #333;
  margin: 0 3px;
}

.dots {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin: 4px 0 6px;
}

.dot {
  width: 16px;
  height: 16px;
  border: 1.4px solid #222;
  border-radius: 50%;
  background: #f8f8f8;
}

.option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  border: 1.1px solid #333;
  border-radius: 6px;
  margin: 0 3px;
}

.compare-symbol {
  display: inline-block;
  min-width: 30px;
  text-align: center;
}

.compare-row {
  align-items: center;
}

.compare-circle {
  width: 34px;
  height: 34px;
  border: 1.6px solid #333;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  background: #fff;
}

.print-large .compare-circle {
  width: 40px;
  height: 40px;
  border-width: 2px;
}

/* Tian zi ge */
.tian-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(38px, 1fr));
  max-width: 280px;
  gap: 5px;
  margin-bottom: 4px;
}

.tian-cell {
  aspect-ratio: 1;
  border: 1px solid #5f5f5f;
  position: relative;
  font-size: 30px;
  background-image:
    linear-gradient(to right, transparent calc(50% - 0.5px), #c5c5c5 calc(50% - 0.5px), #c5c5c5 calc(50% + 0.5px), transparent calc(50% + 0.5px)),
    linear-gradient(to bottom, transparent calc(50% - 0.5px), #c5c5c5 calc(50% - 0.5px), #c5c5c5 calc(50% + 0.5px), transparent calc(50% + 0.5px));
  font-size: 34px;
  font-family: "Kaiti SC", "STKaiti", "KaiTi", serif;
  display: flex;
  align-items: center;
  justify-content: center;
}

.print-large .tian-cell {
  font-size: 36px;
}

.tian-cell.is-trace {
  color: #a3a3a3;
}

.pinyin-above {
  text-align: center;
  font-size: 12px;
  color: #4b4b4b;
  margin: 2px 0;
  letter-spacing: 1px;
}

.hanzi-row {
  margin-bottom: 10px;
}

.hanzi-label {
  margin: 0 0 5px;
  font-weight: 700;
}

/* Pinyin four-line */
.pinyin-line {
  margin-bottom: 10px;
}

.pinyin-label {
  margin: 0 0 3px;
  color: #222;
  font-weight: 700;
}

.pinyin-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(40px, 1fr));
  max-width: 280px;
  gap: 6px;
}

.pinyin-cell {
  position: relative;
  height: 34px;
  background-image:
    linear-gradient(to bottom, transparent 0, transparent calc(25% - 0.5px), #d66 0, #d66 calc(25% + 0.5px), transparent 0, transparent calc(50% - 0.5px), #d66 0, #d66 calc(50% + 0.5px), transparent 0, transparent calc(75% - 0.5px), #d66 0, #d66 calc(75% + 0.5px), transparent 0, transparent 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 25px;
  font-family: "PingFang SC", sans-serif;
}

.pinyin-cell.is-trace {
  color: #b5b5b5;
}

.pinyin-grid .pinyin-cell {
  font-size: 21px;
}

/* Column math */
.column-math-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 28px;
}

.column-math-item {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  min-width: 150px;
}

.column-math-number {
  font-weight: 700;
  min-width: 22px;
}

.column-math-figure {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 92px;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}

.column-math-figure > span {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-height: 26px;
}

.column-math-figure .column-line {
  width: 86px;
  border-top: 1.4px solid #333;
  margin-top: 2px;
}

/* Word problems */
.word-problem-list,
.poetry-list {
  padding-left: 22px;
  margin: 0;
  display: grid;
  gap: 8px;
}

.word-problem-item,
.poetry-item {
  break-inside: avoid;
  page-break-inside: avoid;
}

.word-problem-item p,
.poetry-item p {
  margin: 0 0 3px;
  line-height: 1.6;
}

.answer-space {
  border-bottom: 1px dotted #8a8a8a;
  min-height: 24px;
  margin-bottom: 3px;
  color: #333;
}

/* Clock */
.clock-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
}

.clock-item {
  width: 150px;
  text-align: center;
}

.clock-item p {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 600;
}

.clock-face {
  width: 108px;
  height: 108px;
}

/* Sequence and language */
.sequence-blank {
  vertical-align: middle;
}

.pinyin-word-grid,
.word-formation-grid,
.antonym-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
}

.pinyin-word-item {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
}

.pinyin-word-num,
.word-formation-item strong,
.antonym-item strong {
  min-width: 26px;
}

.pinyin-word-pinyin {
  color: #a00202;
  font-weight: 700;
}

.pinyin-word-line {
  color: #555;
  letter-spacing: 1px;
}

.word-formation-item,
.antonym-item {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
}

/* Coloring */
.coloring-title {
  margin: 0 0 8px;
  font-weight: 700;
}

.coloring-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6mm;
}

.coloring-item {
  border: 1px solid #8d8d8d;
  border-radius: 8px;
  padding: 7mm;
  display: grid;
  grid-template-columns: 1fr;
  gap: 5mm;
  align-items: stretch;
}

.coloring-art {
  min-width: 0;
}

.coloring-art svg {
  width: 100%;
  height: auto;
  max-height: 95mm;
  display: block;
  margin: 0 auto;
}

.coloring-art p {
  margin: 3px 0 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
}

.coloring-advice {
  background: #f7faf9;
  border: 1px solid #d8e4e0;
  border-left: 4px solid #0e7c6b;
  border-radius: 8px;
  padding: 5mm 7mm;
  font-size: 11.5px;
  color: #31483f;
}

.coloring-advice b {
  font-size: 13px;
  color: #0b5c50;
  margin-bottom: 3px;
}

.coloring-advice ul {
  margin: 3px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 5px 16px;
  line-height: 1.55;
}

.coloring-advice li {
  position: relative;
  padding-left: 12px;
}

.coloring-advice li::before {
  content: "·";
  position: absolute;
  left: 0;
  color: #0e7c6b;
  font-weight: 800;
}

.coloring-page .coloring-art svg {
  max-height: 150mm;
}

.coloring-page .coloring-art p {
  font-size: 15px;
}

.coloring-page .coloring-advice {
  font-size: 13px;
}

.coloring-page .coloring-advice b {
  font-size: 15px;
}

/* Answer page */
.answer-page .worksheet-header h1 {
  font-size: 17px;
}

.answer-grid {
  column-count: 2;
  column-gap: 28px;
  margin-top: 12px;
}

.answer-item {
  break-inside: avoid;
  page-break-inside: avoid;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 6px;
  margin-bottom: 8px;
  padding: 3px 5px;
  border-bottom: 1px dotted #b5b5b5;
  font-size: 13.5px;
}

.answer-item .num {
  color: #666;
  font-variant-numeric: tabular-nums;
}

.answer-item .val {
  font-weight: 700;
  color: #0b5c50;
}

/* Footer */
.site-footer {
  max-width: 1500px;
  margin: 0 auto;
  padding: 0 18px 26px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #7b8e89;
  font-size: 12px;
}

/* Mobile / iPad */
@media (max-width: 960px) {
  .topbar-inner {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .topnav {
    width: 100%;
  }

  .nav-btn {
    flex: 1;
  }

  .layout {
    grid-template-columns: 1fr;
    padding-top: 16px;
  }

  .builder-panel {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .workspace-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace-actions {
    width: 100%;
  }

  .workspace-actions button {
    flex: 1;
  }
}

@media (max-width: 560px) {
  .layout {
    padding-left: 10px;
    padding-right: 10px;
  }

  .preview-panel {
    padding: 10px;
    border-radius: 16px;
  }

  .worksheet-page {
    padding: 8mm 6mm 8mm;
    min-height: 0;
  }

  .header-meta {
    font-size: 10px;
    gap: 4px 7px;
  }

  .exercise-grid {
    gap: 10px;
  }

  .exercise-item {
    min-width: 120px;
    flex-basis: 120px;
  }

  .tian-row,
  .pinyin-grid {
    grid-template-columns: repeat(3, minmax(46px, 1fr));
    max-width: 100%;
  }

  .tian-cell {
    font-size: 27px;
  }

  .print-large .tian-cell {
    font-size: 32px;
  }

  .answer-grid {
    column-count: 1;
  }

  .coloring-list {
    grid-template-columns: 1fr;
  }

  .coloring-art svg {
    max-height: 72mm;
  }

  .coloring-advice {
    padding: 4mm;
  }
}

/* 用户管理 */
.current-user {
  align-self: center;
  color: #e6f7f4;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
  background: rgba(13, 32, 32, 0.55);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-overlay.is-hidden {
  display: none;
}

.modal-card {
  width: min(980px, 100%);
  max-height: calc(100vh - 48px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #f7fbfa;
  border-radius: 20px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.26);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid #e2ece9;
  background: #fff;
}

.modal-head h2 {
  margin: 0;
  color: #163b38;
}

.modal-close {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: #eef4f3;
  color: #4f6a66;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.user-modal-body {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(360px, 1.1fr);
  gap: 16px;
  padding: 20px;
  overflow: auto;
}

.user-form,
.user-list-panel {
  background: #fff;
  border: 1px solid #e2ece9;
  border-radius: 14px;
  padding: 16px;
}

.user-form h3,
.user-list-head h3 {
  margin: 0 0 12px;
  color: #163b38;
  font-size: 16px;
}

.user-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.user-form .field + .field {
  margin-top: 12px;
}

.compact-switch {
  margin: 14px 0;
}

.form-message {
  min-height: 18px;
  margin: 6px 0;
  color: #0e7c6b;
  font-size: 13px;
}

.form-message.is-error {
  color: #bb3e32;
}

.user-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid #e2ece9;
  border-radius: 12px;
  background: #fbfdfc;
}

.user-row.is-disabled {
  opacity: 0.58;
}

.user-row-main {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.user-row-main b {
  color: #163b38;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-row-main span {
  color: #6e8782;
  font-size: 12px;
}

.user-row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.user-row-actions button {
  border: 0;
  background: #eef4f3;
  color: #285e58;
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 12px;
  cursor: pointer;
}

.user-row-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.user-row-actions .danger-text {
  background: #fdeeec;
  color: #bb3e32;
}

@media (max-width: 720px) {
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .modal-card {
    width: 100%;
    max-height: 94vh;
    border-radius: 20px 20px 0 0;
  }

  .user-modal-body {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .user-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .user-row-actions {
    justify-content: flex-start;
  }
}

/* Print */
@page {
  size: A4 portrait;
  margin: 0;
}

@media print {
  html,
  body {
    background: #fff;
  }

  .no-print,
  .topbar,
  .builder-panel,
  .workspace-head,
  .site-footer {
    display: none !important;
  }

  .layout {
    display: block;
    padding: 0;
    margin: 0;
  }

  .preview-panel {
    background: #fff;
    border: 0;
    padding: 0;
    border-radius: 0;
    min-height: 0;
  }

  .worksheet-stage {
    display: block;
  }

  .worksheet-page {
    width: 210mm;
    min-height: 297mm;
    margin: 0;
    padding: 12mm 14mm 14mm;
    box-shadow: none;
    page-break-after: always;
    break-after: page;
  }

  .worksheet-page:last-child {
    page-break-after: auto;
    break-after: auto;
  }

  .worksheet-block,
  .exercise-item,
  .answer-item {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
