:root {
  color-scheme: light;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  color: #25223e;
  background: #f7f7fc;
  --ink: #25223e;
  --muted: #64617a;
  --purple: #5236b5;
  --line: #e7e4f0;
  --song: "SimSun", "Songti SC", "Noto Serif CJK SC", serif;
  --roman: "Times New Roman", serif;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
button, textarea, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .52; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 3px solid #9a85e7; outline-offset: 3px; }
[hidden] { display: none !important; }
.icon-library, .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.shell { width: min(1168px, calc(100% - 64px)); margin-inline: auto; }
.topbar { background: #fff; border-bottom: 1px solid #ece9f4; }
.topbar-inner { min-height: 69px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 11px; font-size: 1rem; font-weight: 750; letter-spacing: .055em; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; color: #fff; background: #5a41bd; border-radius: 11px; }
.topbar-note { font-size: .875rem; color: var(--muted); }
.hero { position: relative; display: flex; align-items: center; isolation: isolate; overflow: hidden; min-height: 223px; margin: 28px 0 24px; padding: 38px 48px; border: 1px solid #e7defe; border-radius: 20px; background: linear-gradient(111deg, #f0eafd 0%, #eae3ff 61%, #ded6fa 100%); }
.hero::before, .hero::after { content: ""; position: absolute; z-index: -1; right: -30px; top: 50%; width: 436px; height: 436px; border: 1px solid #ffffff99; border-radius: 50%; transform: translateY(-50%); }
.hero::after { right: -112px; width: 500px; height: 500px; }
.hero-copy { position: relative; max-width: 73%; }
h1 { margin: 0; color: #282045; font-size: clamp(2rem, 4vw, 3.3rem); line-height: 1.28; font-weight: 800; letter-spacing: .055em; }
.hero p { margin: 15px 0 0; color: #514568; line-height: 1.65; }
.hero-art { position: absolute; z-index: -1; right: 60px; top: 50%; width: 235px; height: 168px; transform: translateY(-50%); }
.flashcard { position: absolute; width: 99px; height: 121px; display: grid; align-content: center; justify-items: center; gap: 2px; border: 1px solid #fff; border-radius: 17px; box-shadow: 0 14px 24px #43318626; }
.flashcard span { font: 1.24rem var(--roman); }
.flashcard strong { font: 700 2.55rem var(--song); }
.flashcard-front { top: 27px; right: 96px; transform: rotate(-12deg); color: #432a95; background: #fff; }
.flashcard-back { top: 21px; right: 38px; transform: rotate(14deg); color: #3c2782; background: #d3c3fc; border-color: #eee5ff; }
.art-spark { position: absolute; right: 11px; top: 15px; width: 24px; height: 24px; color: #684cb8; }
.art-dot { position: absolute; display: block; border-radius: 50%; background: #a68de1; }
.art-dot-one { top: 41px; left: 12px; width: 7px; height: 7px; }
.art-dot-two { bottom: 13px; right: 22px; width: 9px; height: 9px; background: #fff; }
.workspace { display: grid; grid-template-columns: minmax(0, 365px) minmax(0, 1fr); gap: 24px; align-items: start; padding-bottom: 44px; }
.panel { padding: 25px; background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 5px 19px #29204a08; }
h2 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 1.27rem; line-height: 1.4; letter-spacing: .02em; }
.section-icon { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 9px; color: #573bb2; background: #f0eaff; }
.panel-intro { margin: 11px 0 22px; font-size: .9rem; color: var(--muted); line-height: 1.6; }
.input-tools, .input-meta, .result-heading, .result-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.input-tools { margin-bottom: 8px; font-size: .875rem; font-weight: 650; }
.input-meta { margin: 5px 0 16px; color: var(--muted); font-size: .875rem; }
.text-button { min-height: 36px; border: 0; border-radius: 6px; padding: 3px 6px; color: var(--purple); background: transparent; font-size: .875rem; font-weight: 650; }
.text-button:hover { background: #f1ebff; }
.text-button.quiet { color: var(--muted); }
textarea { display: block; width: 100%; min-height: 229px; resize: vertical; padding: 13px 14px; border: 1px solid #ded8ed; border-radius: 10px; color: var(--ink); background: #faf9fd; line-height: 1.75; }
textarea::placeholder { color: #77728b; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 44px; padding: 8px 17px; border: 1px solid transparent; border-radius: 9px; font-weight: 650; white-space: nowrap; }
.primary { color: #fff; background: var(--purple); }
.primary:hover:not(:disabled) { background: #422788; }
.generate { width: 100%; }
.switch { display: flex; gap: 2px; padding: 4px; border-radius: 10px; background: #f2eff9; }
.result-heading { flex-wrap: wrap; }
.switch button { padding: 6px 10px; min-height: 33px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; font-size: .875rem; font-weight: 650; white-space: nowrap; }
.switch button[aria-pressed="true"] { color: #4c31a2; background: #fff; box-shadow: 0 1px 4px #37266a20; }
.switch button:hover { color: #4c31a2; }
.preview-options { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; margin: 11px 0 16px; }
.preview-options .panel-intro { margin: 0; }
#practice-options { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: .875rem; white-space: nowrap; }
#answer-width { appearance: none; min-height: 35px; padding: 4px 30px 4px 9px; border: 1px solid #ded8ed; border-radius: 7px; color: var(--ink); background: linear-gradient(45deg, transparent 50%, #665b85 50%) calc(100% - 13px) 54% / 5px 5px no-repeat, linear-gradient(135deg, #665b85 50%, transparent 50%) calc(100% - 8px) 54% / 5px 5px no-repeat #fff; }
.paper { container-type: inline-size; max-height: min(640px, 75vh); min-height: 308px; overflow: auto; padding: 24px; border: 1px solid var(--line); border-radius: 12px; background: #fcfbff; scrollbar-color: #c7bde4 transparent; }
.paper h3 { margin: 1px 0 20px; text-align: center; font-size: 1.28rem; letter-spacing: .09em; }
.word-group + .word-group { margin-top: 17px; }
.word-grid { display: grid; grid-template-columns: repeat(var(--columns), minmax(0, 1fr)); gap: 1px; overflow: hidden; border: 1px solid #ebe7f3; border-radius: 8px; background: #ebe7f3; }
.word-grid[data-kind="short"] { --word-width: 2.25em; }
.word-grid[data-kind="three"] { --word-width: 3.4em; }
.word-grid[data-kind="long"] { --word-width: 4.5em; }
.word-grid[data-kind="extra"] { --word-width: 7em; }
.word-cell { display: grid; grid-template-columns: var(--word-width) minmax(0, 1fr); align-items: baseline; align-content: center; justify-items: start; min-height: 55px; min-width: 0; gap: 8px; padding: 8px 10px; background: #fff; }
.word-cell.empty-cell { min-height: 0; }
.word-text { font: 700 1rem/1.3 var(--song); overflow-wrap: anywhere; }
.word-grid:not([data-kind="extra"]) .word-text { white-space: nowrap; }
.reading { max-width: 100%; min-height: 27px; padding: 1px 4px; color: #5942a7; background: transparent; border: 1px solid transparent; border-radius: 4px; font: 1.06rem/1.25 var(--roman); text-align: start; overflow-wrap: anywhere; }
.reading:hover { background: #f2ebff; border-color: #ded0f7; }
.reading.invalid { color: #922b48; }
.reading.pending { color: #797287; }
.reading-input { width: 100%; min-height: 27px; padding: 1px 3px; color: #352365; border: 1px solid #9d86dd; border-radius: 4px; background: #faf7ff; font: 1rem/1.25 var(--roman); }
.practice-cell { min-height: 55px; }
.answer { white-space: nowrap; font-family: var(--song); display: inline-flex; align-items: baseline; }
.answer-space { display: inline-block; width: var(--answer-width); min-width: 0; }
.answer { max-width: 100%; }
@container (max-width: 600px) {
  .word-grid[data-kind="short"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .word-grid[data-kind="short"] .empty-cell { display: none; }
}
@container (max-width: 540px) {
  .word-grid[data-kind="three"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .word-grid[data-kind="three"] .empty-cell { display: none; }
}
@container (max-width: 415px) {
  .word-grid[data-kind="long"] { grid-template-columns: minmax(0, 1fr); }
  .word-grid[data-kind="long"] .empty-cell { display: none; }
  .word-grid[data-kind="three"][data-width], .word-grid[data-kind="short"][data-width] { grid-template-columns: minmax(0, 1fr); }
}
@container (max-width: 245px) {
  .word-grid[data-kind="short"] { grid-template-columns: minmax(0, 1fr); }
  .word-grid[data-kind="extra"] { --word-width: 5em; }
}
.word-grid[data-mode="characters"] {
  --prompt-min: 4rem;
  --min-cell: calc(var(--prompt-min) + var(--answer-track) + 24px);
  --column-share: calc(100% / var(--columns));
  grid-template-columns: repeat(auto-fill, minmax(min(100%, max(var(--min-cell), var(--column-share))), 1fr));
  gap: 0;
  background: #fff;
}
.word-grid[data-mode="characters"][data-kind="three"] { --prompt-min: 6rem; }
.word-grid[data-mode="characters"][data-kind="long"] { --prompt-min: 7rem; }
.word-grid[data-mode="characters"][data-kind="extra"] { --prompt-min: min(12rem, 50%); }
.pinyin-cell { display: flex; flex-wrap: wrap; gap: 4px; box-shadow: inset -1px -1px #ebe7f3; }
.pinyin-prompt { flex: 1 1 var(--prompt-min); font: 1.06rem/1.25 var(--roman); overflow-wrap: anywhere; }
.word-grid[data-mode="characters"][data-kind="extra"] .pinyin-prompt { flex-grow: 0; }
.pinyin-cell .answer { flex: 0 1 var(--answer-track); }
.paper-placeholder { display: grid; place-items: center; min-height: 250px; text-align: center; color: var(--muted); }
.error { color: #922b48; font-size: .875rem; line-height: 1.5; margin: 0 0 12px; }
.result-footer { margin-top: 17px; flex-wrap: wrap; }
.result-footer > span { color: var(--muted); font-size: .875rem; }
.middot { padding: 0 2px; }
@media (max-width: 930px) {
  .workspace { grid-template-columns: minmax(0, .86fr) minmax(0, 1.4fr); gap: 17px; }
  .panel { padding: 18px; }
  .paper { padding: 17px; }
  .hero-art { right: 24px; }
}
@media (max-width: 710px) {
  .shell { width: calc(100% - 32px); }
  .topbar-inner { min-height: 60px; }
  .hero { margin: 16px 0; min-height: 162px; padding: 22px; border-radius: 14px; }
  .hero-copy { max-width: 100%; }
  .hero p { margin-top: 9px; max-width: 23em; }
  .hero-art { display: none; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 16px; padding-bottom: 25px; }
  textarea { min-height: 160px; }
}
@media (max-width: 430px) {
  .panel { padding: 14px; }
  .topbar-note { display: none; }
  .hero { padding: 20px; }
  h1 { font-size: clamp(1.5rem, 6.9vw, 2rem); }
  h2 { font-size: 1.05rem; gap: 6px; }
  .section-icon { width: 29px; height: 29px; }
  .switch button { padding-inline: 6px; }
  .paper { padding: 12px; }
  .practice-cell { padding-inline: 7px; }
}
