: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; }
html, body { min-height: 100%; }
body { display: flex; flex-direction: column; margin: 0; min-height: 100vh; min-height: 100dvh; 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 { flex: 1 0 auto; width: 100%; 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; }
.project-overview { display: grid; max-width: 1180px; margin: 0 auto; padding: 30px; gap: 26px; }
.overview-heading { display: flex; justify-content: space-between; align-items: start; gap: 20px; }
.overview-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.add-pages-card { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 14px; padding: 18px; border-radius: 12px; background: #efeadf; }
.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; }
.duplicate-comparison { display: grid; gap: 10px; padding: 12px; border: 1px solid #d7b77d; border-radius: 10px; background: #fff8e8; }
.duplicate-comparison p { margin: 5px 0 0; }
.duplicate-glyphs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.duplicate-card { display: grid; gap: 5px; width: 100%; padding: 6px; border-color: var(--line); background: #fff; color: var(--ink); font-size: 11px; text-align: left; }
.duplicate-card:hover, .duplicate-card.selected { border-color: var(--red); background: #fff1ee; }
.duplicate-card img { width: 100%; aspect-ratio: 1; object-fit: fill; border-radius: 5px; background: #fff; }
.decision-buttons { display: grid; 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: default; 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-card[draggable="true"] { cursor: grab; }
.glyph-card.dragging { cursor: grabbing; opacity: .42; }
.glyph-card.drag-target { border-color: var(--red); box-shadow: 0 0 0 3px rgba(160, 61, 61, .15); }
.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; }
.overview-library-title label { min-width: 150px; }
.glyph-dialog { width: min(90vw, 680px); padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
.glyph-dialog::backdrop { background: rgba(24, 28, 24, .62); }
.glyph-dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.glyph-dialog-heading h2 { margin: 0; font-size: 28px; }
.glyph-dialog-preview { position: relative; width: min(78vw, 600px); max-height: 72vh; margin: auto; aspect-ratio: 1; background: #fff; }
.glyph-dialog-preview img, .glyph-dialog-preview svg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.export-dialog { width: min(92vw, 680px); padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
.export-dialog::backdrop { background: rgba(24, 28, 24, .62); }
.export-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 18px 0; }
.export-dialog form > button[type="submit"] { width: 100%; }
.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, .add-pages-card, .workspace, .export-fields { grid-template-columns: 1fr; }
  .overview-heading { display: grid; }
  .library-panel { grid-column: auto; }
  header { align-items: start; }
}
.product-footer { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; width: 100%; padding: 18px clamp(18px, 4vw, 60px); border-top: 1px solid var(--line); background: #efeadf; color: var(--muted); }
.product-footer strong { color: var(--ink); font-family: "STSong", "Songti SC", serif; font-size: 17px; font-weight: 600; line-height: 1.25; }
.product-footer p { margin: 3px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.product-footer-links { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.product-footer-links a { color: var(--ink); text-decoration-color: #aaa69b; text-underline-offset: 3px; }
.product-footer-links a:hover { color: var(--green); }
@media (max-width: 620px) {
  .product-footer { align-items: flex-start; flex-direction: column; gap: 12px; padding-top: 16px; padding-bottom: 16px; }
  .product-footer-links { align-items: flex-start; justify-content: flex-start; flex-direction: column; gap: 10px; }
}
