:root {
  color-scheme: light;
  --paper: #f4efe4;
  --surface: #fffcf5;
  --ink: #293e43;
  --muted: #5b6c6c;
  --line: #d9d8c9;
  --accent: #a94831;
  --accent-soft: #f6e6d8;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--paper); line-height: 1.7; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { min-height: 44px; border: 1px solid #bfc8bf; border-radius: 8px; padding: 10px 14px; color: var(--ink); background: var(--surface); font-size: 13px; font-weight: 650; line-height: 1.5; cursor: pointer; transition: background .15s ease, border-color .15s ease; }
button:hover { background: #edf0e7; border-color: #7e9286; }
button:disabled { opacity: .46; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fffcf5; }
button.primary:hover { background: #923e2c; border-color: #923e2c; }
button.quiet { background: transparent; color: #805241; border-color: #cbbca9; }
button:focus-visible, a:focus-visible, input:focus-visible, [tabindex="-1"]:focus-visible { outline: 3px solid #237286; outline-offset: 4px; }
a { color: var(--ink); text-underline-offset: 4px; }
.page-shell { max-width: 1280px; margin: 0 auto; padding: 0 36px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 18px; min-height: 83px; border-bottom: 1px solid var(--line); }
.topbar a { display: inline-flex; align-items: center; min-height: 44px; font-family: Georgia, "Songti SC", serif; font-size: 18px; font-weight: 700; text-decoration: none; }
.topbar a:hover { text-decoration: underline; }
.topbar span { max-width: 48%; font-size: 12px; line-height: 1.6; color: var(--muted); text-align: right; }
.hero { padding: 43px 0 31px; max-width: 800px; }
.eyebrow { margin: 0 0 11px; font-size: 10px; line-height: 1.5; letter-spacing: .15em; font-weight: 800; color: var(--accent); overflow-wrap: anywhere; }
h1 { font-family: Georgia, "Songti SC", "STSong", serif; font-size: clamp(38px, 4.5vw, 56px); line-height: 1.2; letter-spacing: -.03em; font-weight: 700; margin: 0 0 17px; }
h1 span { color: var(--accent); }
.hero > p:last-child { margin: 0; max-width: 620px; font-size: 16px; color: #506369; line-height: 1.85; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 316px; gap: 23px; align-items: start; }
.stage-panel { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 17px; padding: 25px; box-shadow: 0 13px 34px rgb(41 56 53 / 5%); }
.section-heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 19px; }
.section-heading .eyebrow { margin-bottom: 7px; }
.section-heading h2 { font-family: Georgia, "Songti SC", "STSong", serif; margin: 0; font-size: 23px; font-weight: 700; line-height: 1.5; }
.state-badge { display: inline-block; max-width: 100%; padding: 4px 10px; border: 1px solid #c2cdbf; border-radius: 999px; background: #edf1e7; color: #4c6556; font-size: 10px; line-height: 1.7; font-weight: 650; }
.stage-shell { --scene-sky: #e7c49f; --scene-glow: #f9e7bf; --scene-body: #fff2cc; --scene-window: #736256; --scene-horizon: #c1b59b; --bird-ink: #273839; --bird-near: #3d5050; --bird-far: #334646; --bird-fold: #b8c4b6; --bird-eye: #fff0c5; overflow: hidden; border: 1px solid #bba98a; border-radius: 11px; background: var(--scene-sky); }
#stageShell[data-theme="moon"] { --scene-sky: #9aafbb; --scene-glow: #e5ebd8; --scene-body: #f2edcd; --scene-window: #4c626e; --scene-horizon: #7d959a; --bird-ink: #203743; --bird-near: #314d58; --bird-far: #29434e; --bird-fold: #a7bec0; --bird-eye: #f6edc9; border-color: #7c969e; }
#stageShell[data-theme="dawn"] { --scene-sky: #d5e1d5; --scene-glow: #f8e4c1; --scene-body: #fff0ce; --scene-window: #6d8275; --scene-horizon: #b1c2aa; --bird-ink: #29463f; --bird-near: #3c5b50; --bird-far: #324e46; --bird-fold: #b7c9b2; --bird-eye: #ffefd0; border-color: #9faf98; }
#stageCanvas { display: block; width: 100%; height: auto; aspect-ratio: 1000 / 560; cursor: crosshair; touch-action: manipulation; }
#stageCanvas:focus-visible { outline: 3px solid #285f75; outline-offset: -5px; }
.sky { fill: var(--scene-sky); }
.celestial-glow { fill: var(--scene-glow); opacity: .4; }
.celestial-body { fill: var(--scene-body); }
.window-lines { fill: none; stroke: var(--scene-window); stroke-width: 5; opacity: .5; }
.horizon { fill: var(--scene-horizon); opacity: .7; }
.paper-bird > polygon, .bird-far-wing, .bird-near-wing { fill: var(--bird-ink); stroke: var(--bird-ink); stroke-width: 2; stroke-linejoin: round; }
.bird-far-wing { fill: var(--bird-far); }
.bird-near-wing { fill: var(--bird-near); }
.bird-fold { fill: none; stroke: var(--bird-fold); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; opacity: .7; }
.bird-eye { fill: var(--bird-eye); stroke: none; }
.pose-info { margin: 12px 0 0; min-height: 20px; color: #62716d; font-size: 10px; line-height: 1.8; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.preview-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 17px; }
.preview-controls button { min-height: 46px; padding-inline: 18px; font-size: 13px; }
.preview-controls span { font-size: 11px; color: var(--muted); }
.small-note { margin: 9px 0 0; color: var(--muted); font-size: 11px; line-height: 1.85; }
.frame-selector { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; border-top: 1px solid #e0e1d4; padding-top: 20px; margin-top: 21px; }
.frame-selector button { position: relative; min-width: 0; min-height: 77px; padding: 13px 10px 10px; text-align: left; border-color: #d0d4c6; border-radius: 9px; background: #f4f3e9; }
.frame-selector button strong { display: block; font-size: 13px; line-height: 1.6; }
.frame-selector button span { display: block; margin-top: 3px; font-size: 10px; font-weight: 400; color: #657469; }
.frame-selector button[aria-pressed="true"] { background: #f6e6d9; border: 2px solid #aa5e42; padding: 12px 9px 9px; }
.frame-selector button[aria-pressed="true"]::after { content: "✓"; position: absolute; top: 9px; right: 10px; color: #8b432d; font-size: 12px; font-weight: 800; }
.game-status { min-height: 41px; color: #47615e; font-size: 12px; line-height: 1.85; margin: 16px 0 0; }
.notice { border: 1px solid #dfc3a6; border-radius: 8px; padding: 11px 13px; color: #785037; background: #fff0de; font-size: 12px; line-height: 1.8; overflow-wrap: anywhere; }
.editor-panel { display: grid; gap: 17px; min-width: 0; }
.editor-panel > section { padding: 21px; border: 1px solid var(--line); border-radius: 14px; background: rgb(255 252 245 / 75%); }
.editor-panel h2 { margin: 0 0 17px; font-size: 16px; line-height: 1.5; font-weight: 700; }
.editor-panel .eyebrow { font-size: 9px; margin-bottom: 8px; }
.range-control { margin-top: 12px; }
.range-control label { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 12px; font-weight: 650; line-height: 1.6; }
.range-control output { color: #975037; font-size: 12px; font-weight: 750; font-variant-numeric: tabular-nums; }
.range-control input[type="range"] { display: block; width: 100%; min-width: 0; min-height: 44px; margin: 0; padding: 0; accent-color: #a64d34; cursor: pointer; }
.range-control input:disabled { cursor: default; opacity: .45; }
.range-control p { margin: -2px 0 5px; font-size: 10px; line-height: 1.7; color: var(--muted); }
.theme-selector { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.theme-selector button { position: relative; min-width: 0; padding: 9px 4px; font-size: 11px; border-color: #c9cdbf; background: #f6f2e7; }
.theme-selector button[aria-pressed="true"] { border: 2px solid #a9583b; padding: 8px 3px; background: #f5e4d6; }
.theme-selector button[aria-pressed="true"]::after { content: " ✓"; color: #8c432b; font-weight: 800; }
.example-buttons { display: grid; gap: 9px; }
.example-buttons button { width: 100%; font-size: 12px; text-align: left; padding-inline: 13px; }
.keep-share { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 23px; margin-top: 24px; }
.keep-share article { min-width: 0; background: rgb(255 252 245 / 75%); border: 1px solid var(--line); border-radius: 14px; padding: 24px; }
.keep-share h2 { font-family: Georgia, "Songti SC", "STSong", serif; margin: 0 0 11px; font-size: 22px; line-height: 1.5; }
.keep-share article > p:not(.eyebrow) { color: #576b6a; font-size: 12px; line-height: 1.85; margin: 9px 0 0; }
.storage-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 19px; }
.storage-buttons button { font-size: 12px; padding-inline: 12px; }
#shareButton { margin-top: 19px; }
.keep-share article > .storage-status { margin-top: 12px; font-size: 11px; }
.storage-status:not(:empty) { padding: 9px 11px; background: #edf1e7; border-left: 3px solid #a7bca4; border-radius: 4px; color: #48604c; }
.storage-status.is-error { background: #fff0df; border-color: #bd8053; color: #815034; }
.share-fallback { margin-top: 13px; }
.share-fallback label { display: block; margin-bottom: 7px; color: #7a513a; font-size: 11px; line-height: 1.8; }
.share-fallback input { display: block; min-width: 0; width: 100%; min-height: 44px; padding: 10px; border: 1px solid #adbbb0; border-radius: 6px; background: #fffef9; color: var(--ink); font-size: 11px; }
footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 20px; padding: 32px 0 27px; color: var(--muted); font-size: 11px; }
footer a { display: inline-flex; align-items: center; min-height: 44px; }
dialog { width: min(450px, calc(100% - 32px)); max-width: none; max-height: calc(100dvh - 48px); overflow: auto; padding: 27px; margin: auto; background: var(--surface); color: var(--ink); border: 1px solid #bfc9bc; border-radius: 16px; box-shadow: 0 25px 90px rgb(27 42 43 / 24%); }
dialog::backdrop { background: rgb(32 44 43 / 48%); backdrop-filter: blur(3px); }
dialog h2 { margin: 0 0 12px; font-size: 22px; line-height: 1.4; }
dialog p { margin: 0 0 23px; color: #536764; font-size: 14px; overflow-wrap: anywhere; }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; }
.dialog-actions button { margin: 0; font-size: 12px; }

@media (max-width: 1060px) {
  .page-shell { padding: 0 25px; }
  .layout { grid-template-columns: minmax(0, 1fr) 284px; gap: 18px; }
  .stage-panel { padding: 21px; }
  .editor-panel > section { padding: 19px; }
  .keep-share { gap: 18px; }
  .keep-share article { padding: 21px; }
}

@media (max-width: 850px) {
  .page-shell { max-width: 760px; }
  .hero { padding: 34px 0 27px; }
  .hero h1 { font-size: 44px; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .editor-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .editor-panel .pose-editor { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 26px; }
  .pose-editor > .eyebrow, .pose-editor > h2, .pose-editor > .small-note { grid-column: 1 / -1; }
  .editor-panel .pose-editor h2 { margin-bottom: 2px; }
  .range-control { min-width: 0; margin-top: 13px; }
  .keep-share { gap: 16px; margin-top: 18px; }
}

@media (max-width: 540px) {
  .page-shell { padding: 0 16px; }
  .topbar { min-height: 69px; gap: 12px; }
  .topbar a { font-size: 15px; }
  .topbar span { max-width: 43%; font-size: 10px; }
  .hero { padding: 26px 0 22px; }
  .hero h1 { font-size: 37px; margin-bottom: 12px; }
  .hero > p:last-child { font-size: 14px; line-height: 1.8; }
  .hero .eyebrow { font-size: 9px; letter-spacing: .1em; }
  .stage-panel { padding: 16px; border-radius: 13px; }
  .section-heading { gap: 8px; margin-bottom: 14px; }
  .section-heading h2 { font-size: 20px; }
  .section-heading .eyebrow { font-size: 8px; margin-bottom: 6px; }
  .state-badge { padding: 3px 8px; font-size: 9px; }
  .stage-shell { border-radius: 8px; }
  .pose-info { margin-top: 10px; font-size: 9px; }
  .preview-controls { margin-top: 13px; gap: 8px; }
  .preview-controls button { flex: 1 1 auto; font-size: 12px; padding-inline: 12px; }
  .preview-controls span { width: 100%; font-size: 10px; }
  .small-note { font-size: 10px; }
  .frame-selector { gap: 7px; margin-top: 17px; padding-top: 16px; }
  .frame-selector button { min-height: 70px; padding: 12px 8px 9px; }
  .frame-selector button strong { font-size: 12px; }
  .frame-selector button span { font-size: 9px; }
  .frame-selector button[aria-pressed="true"] { padding: 11px 7px 8px; }
  .frame-selector button[aria-pressed="true"]::after { right: 7px; top: 7px; font-size: 10px; }
  .game-status { min-height: 0; margin-top: 13px; font-size: 11px; }
  .editor-panel { grid-template-columns: minmax(0, 1fr); gap: 13px; }
  .editor-panel > section { padding: 19px; border-radius: 12px; }
  .editor-panel .pose-editor { grid-column: auto; column-gap: 20px; }
  .range-control label { font-size: 11px; gap: 8px; }
  .range-control output { font-size: 11px; }
  .range-control p { font-size: 9px; }
  .editor-panel h2 { font-size: 15px; margin-bottom: 13px; }
  .theme-selector { gap: 8px; }
  .theme-selector button { font-size: 12px; }
  .example-buttons { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .example-buttons button { font-size: 11px; padding-inline: 10px; }
  .keep-share { grid-template-columns: minmax(0, 1fr); gap: 13px; margin-top: 15px; }
  .keep-share article { padding: 21px; border-radius: 12px; }
  .keep-share h2 { font-size: 21px; }
  .storage-buttons { gap: 7px; margin-top: 16px; }
  .storage-buttons button { flex: 1 1 auto; font-size: 11px; padding-inline: 10px; }
  #shareButton { width: 100%; margin-top: 16px; }
  footer { gap: 3px; padding: 23px 0; font-size: 10px; }
  dialog { padding: 22px; border-radius: 13px; }
  .dialog-actions { flex-direction: column; }
  .dialog-actions button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  button { transition: none; }
}
