:root{color-scheme:light;--ink:#212e2b;--paper:#faf6ed;--muted:#52615a;--line:#d9d3c6;--accent:#8d3028}
*{box-sizing:border-box}
body{margin:0;background:#f1ece2;color:var(--ink);font-family:"Source Han Sans SC","Microsoft YaHei",sans-serif}
header{display:flex;align-items:center;gap:16px;padding:22px max(24px,calc((100vw - 1240px)/2));background:#faf7ef;border-bottom:1px solid var(--line)}
h1,h2,p{margin:0} h1{font:700 30px KaiTi,STKaiti,serif;letter-spacing:.12em} header p{font-size:13px;color:var(--muted);margin-top:5px}
.seal{background:var(--accent);color:#fff6e8;display:grid;place-items:center;width:44px;height:46px;border-radius:5px;font:27px KaiTi,serif;box-shadow:inset 0 0 0 3px #8d3028,inset 0 0 0 4px #e0a99d}
main{display:grid;grid-template-columns:minmax(300px,380px) minmax(0,1fr);gap:20px;max-width:1288px;margin:auto;padding:22px 24px}
.editor,.stage{border:1px solid var(--line);border-radius:10px}
.editor{background:var(--paper);padding:20px;align-self:start}
h2{font-size:17px;letter-spacing:.08em} .editor h2{margin-bottom:14px}
label{display:block;font-size:13px;font-weight:700;margin:12px 0 5px}
input,select,textarea,button{font:inherit} input,select,textarea{width:100%;padding:8px 10px;border:1px solid #c8c2b5;border-radius:5px;background:#fffdf7;color:var(--ink)}
textarea{resize:vertical;line-height:1.6} .pair{display:grid;grid-template-columns:1fr 1fr;gap:10px}
input[type=color]{width:72px;height:36px;padding:3px 5px;cursor:pointer}
.hint{font-size:12px;color:var(--muted);margin:6px 0;line-height:1.6} details{margin-top:10px;border-bottom:1px solid var(--line);padding-bottom:10px;font-size:13px} summary{cursor:pointer}
#readings{display:grid;grid-template-columns:repeat(auto-fill,minmax(51px,1fr));gap:5px;max-height:200px;overflow:auto;padding:6px 2px}
#readings label{margin:0;text-align:center;font-weight:400} #readings input{padding:4px;text-align:center}
button{margin-top:17px;width:100%;border:0;border-radius:5px;padding:11px;background:var(--accent);color:white;cursor:pointer} button:hover{background:#6e211b} button:disabled{opacity:.6;cursor:default}
:focus-visible{outline:2px solid #8d3028;outline-offset:2px}
.stage{position:sticky;top:12px;align-self:start;background:#e5e0d3;padding:15px 18px 22px;text-align:center;min-width:0}
.stagebar{display:flex;justify-content:space-between;align-items:center;margin-bottom:14px} #size{font-size:12px;color:var(--muted)}
canvas{display:block;width:auto;height:auto;max-width:100%;max-height:calc(100vh - 165px);margin:auto;background:#f8f3e9;box-shadow:0 8px 24px #252b2440}
@media(max-width:760px){main{grid-template-columns:1fr;padding:12px;gap:12px}header{padding:15px}.stage{order:-1;top:0;z-index:1;padding:8px 12px 12px}.stagebar{margin-bottom:8px}canvas{max-height:32vh;max-height:32svh}}

/* Editor layout */
:root {
  --ink: #26382f;
  --muted: #59655d;
  --paper: #fffcf5;
  --line: #dcd3c3;
  --accent: #923c2f;
  --serif: KaiTi, STKaiti, "Noto Serif CJK SC", SimSun, serif;
}
body { background: #f2ece0; }
.masthead {
  display: block;
  padding: 0;
  background: #faf7ef;
  border-bottom: 1px solid var(--line);
  color: #212e2b;
}
.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 1320px;
  margin: auto;
  padding: 22px clamp(16px, 4vw, 42px);
}
.brand h1 { font: bold 35px/1.1 var(--serif); letter-spacing: .1em; }
.brand p { margin-top: 5px; color: #52615a; font-size: 12px; letter-spacing: .1em; }
.seal { flex: none; width: 48px; height: 50px; background: #a84837; }
main {
  grid-template-columns: minmax(300px, 410px) minmax(0, 1fr);
  gap: clamp(16px, 2.6vw, 34px);
  max-width: 1320px;
  padding: 26px clamp(16px, 4vw, 42px) 42px;
}
.editor { display: grid; gap: 14px; min-width: 0; padding: 0; border: 0; background: transparent; }
.panel {
  padding: 17px 20px 19px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: 0 3px 12px #48381e09;
}
.editor h2, .stage h2 { font: bold 22px/1.25 var(--serif); letter-spacing: .06em; }
.editor h2 { margin: 0; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
input, select, textarea { min-width: 0; padding: 9px 11px; border-radius: 7px; }
#poem { font: 18px/1.6 var(--serif); }
.pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
input[type=file] { font-size: 12px; }
input::file-selector-button {
  margin-right: 9px;
  padding: 5px 9px;
  border: 0;
  border-radius: 4px;
  background: #e9eee7;
  color: var(--ink);
  cursor: pointer;
}
details { padding: 8px 10px; border: 0; border-radius: 7px; background: #eeeae0; }
summary { font-weight: 700; }
button { border-radius: 7px; font-weight: 700; letter-spacing: .07em; }
.hint:empty { display: none; }
.stage { border-radius: 12px; background: #e3e5d9; }
.stagebar { align-items: center; padding-bottom: 10px; border-bottom: 1px solid #bfc5b7; }
#size { font-variant-numeric: tabular-nums; }
canvas { box-shadow: 0 9px 22px #273d3340; }
.preview-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.preview-actions button { width: auto; margin: 0; padding: 6px 10px; font-size: 12px; letter-spacing: 0; }
#export-preview {
  width: min(960px, calc(100% - 24px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
}
#export-preview::backdrop { background: #17241ec0; }
.dialog-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; }
.export-image-frame { height: 74vh; height: 74dvh; overflow: auto; padding: 12px; background: #e3e5d9; }
#export-image { display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; margin: auto; }
#export-image.is-zoomed { max-width: none; max-height: none; }
@media (max-width: 760px) {
  main { grid-template-columns: minmax(0, 1fr); padding: 12px; gap: 12px; }
  .brand { padding-block: 14px; }
  .brand h1 { font-size: 29px; }
  .stage h2 { font-size: 18px; }
  .stagebar { padding-bottom: 6px; }
  .panel { padding-inline: 15px; }
  .stagebar { flex-wrap: wrap; }
}
