:root {
  color-scheme: light;
  --paper: #f5f1e8;
  --panel: rgba(255, 253, 248, .94);
  --ink: #262722;
  --muted: #6e7067;
  --green: #335e4e;
  --green-dark: #234438;
  --line: #d7d1c5;
  --red: #a03d3d;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: radial-gradient(circle at 10% 0%, #fffaf0 0, transparent 38%), var(--paper); }
header { display: flex; justify-content: space-between; align-items: end; gap: 24px; padding: 30px clamp(24px, 5vw, 72px) 22px; border-bottom: 1px solid var(--line); }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-family: "STSong", "Songti SC", serif; font-size: clamp(27px, 4vw, 45px); font-weight: 600; }
h2 { margin-bottom: 7px; font-size: 20px; }
.eyebrow { margin-bottom: 8px; color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
main { padding: 24px clamp(18px, 4vw, 60px) 60px; }
.panel { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); box-shadow: 0 10px 28px rgba(52, 45, 31, .07); }
.project-picker { max-width: 980px; margin: 0 auto; padding: 30px; }
.intro { max-width: 650px; }
.upload-card { display: grid; grid-template-columns: 1fr 1fr auto; gap: 14px; align-items: end; padding: 18px; border-radius: 12px; background: #efeadf; }
label { display: grid; gap: 7px; color: #575a52; font-size: 13px; font-weight: 650; }
input, select, button { min-height: 40px; border-radius: 9px; border: 1px solid #bbb6aa; font: inherit; }
input, select { width: 100%; padding: 8px 10px; background: #fff; color: var(--ink); }
input[type="range"] { min-height: auto; padding: 0; }
button { padding: 9px 16px; border-color: var(--green); background: var(--green); color: white; font-weight: 750; cursor: pointer; }
button:hover { background: var(--green-dark); }
button:disabled { cursor: wait; opacity: .58; }
button.secondary { border-color: #aaa69b; background: transparent; color: var(--ink); }
button.danger { border-color: var(--red); background: transparent; color: var(--red); }
.project-list { display: grid; gap: 10px; margin-top: 22px; }
.project-item { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.project-item strong { display: block; margin-bottom: 4px; }
.workspace { display: grid; grid-template-columns: minmax(300px, 340px) minmax(520px, 1fr); gap: 18px; align-items: start; }
.controls { position: static; display: grid; min-width: 0; width: 100%; gap: 22px; padding: 20px; overflow: hidden; }
.controls > *, .control-group > *, .selected-editor > * { min-width: 0; max-width: 100%; }
.control-group { display: grid; gap: 12px; min-width: 0; padding-top: 18px; border-top: 1px solid var(--line); }
.controls button, .controls input { width: 100%; max-width: 100%; }
.controls button { height: auto; white-space: normal; overflow-wrap: anywhere; }
.controls .hint, .controls .muted, .controls .message { max-width: 100%; overflow-wrap: anywhere; }
.selection-preview-wrap { display: grid; gap: 7px; color: #575a52; font-size: 13px; font-weight: 650; }
#selectionPreview, .preview-empty { display: block; width: 100%; max-width: 100%; aspect-ratio: 1; border: 1px solid #c8c0b3; border-radius: 8px; background: #fff; }
#selectionPreview { height: auto; }
.preview-empty { display: grid; place-items: center; padding: 18px; color: var(--muted); text-align: center; font-weight: 400; }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.canvas-panel { min-width: 0; padding: 18px; }
.panel-title { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 12px; }
.panel-title h2, .panel-title p { margin-bottom: 0; }
.panel-title p, .muted, .hint { color: var(--muted); font-size: 13px; }
.canvas-wrap { max-height: 72vh; overflow: auto; border-radius: 10px; background: #d9d5cc; }
canvas { display: block; cursor: crosshair; touch-action: none; }
.library-panel { grid-column: 1 / -1; padding: 20px; }
.glyph-library { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 14px; }
.glyph-card { padding: 10px; border: 1px solid var(--line); border-radius: 11px; background: white; cursor: pointer; }
.glyph-card:hover { border-color: var(--green); }
.glyph-preview { position: relative; aspect-ratio: 1; overflow: hidden; background: white; }
.glyph-preview img, .glyph-preview svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.glyph-preview img { object-fit: fill; }
.glyph-card footer { display: flex; justify-content: space-between; margin-top: 8px; font-size: 13px; }
.glyph-card footer strong { font-size: 20px; }
.message { min-height: 20px; color: var(--green); font-size: 13px; }
.message.error { color: var(--red); }
.hidden { display: none !important; }
@media (max-width: 850px) {
  .upload-card, .workspace { grid-template-columns: 1fr; }
  .library-panel { grid-column: auto; }
  header { align-items: start; }
}
