:root {
  color-scheme: light;
  --yellow-50: #fffdf0;
  --yellow-100: #fff8ca;
  --yellow-200: #ffef9e;
  --yellow-400: #f6d85e;
  --yellow-500: #e8bd32;
  --ink: #493f16;
  --muted: #80764d;
  --line: #eadf9d;
  --surface: #fffef8;
  --shadow: 0 18px 50px rgba(102, 84, 20, 0.12);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; color: var(--ink); background: linear-gradient(145deg, #fff8c9 0%, #fffdf1 48%, #fff8d8 100%); }
button, input { font: inherit; }
button { color: inherit; }

.topbar { min-height: 84px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px clamp(20px, 4vw, 64px); border-bottom: 1px solid rgba(126, 105, 28, .12); background: rgba(255, 254, 246, .88); backdrop-filter: blur(18px); }
.brand { display: flex; align-items: center; gap: 14px; }
.brand h1 { margin: 0; font-size: 1.25rem; line-height: 1.25; letter-spacing: .02em; }
.brand p { margin: 5px 0 0; color: var(--muted); font-size: .82rem; }
.brand-mark { width: 44px; height: 44px; display: grid; grid-template-columns: 1.55fr 1fr; grid-template-rows: 1fr 1.25fr; gap: 3px; padding: 7px; background: var(--yellow-400); border-radius: 12px; box-shadow: inset 0 0 0 1px rgba(73, 63, 22, .08); }
.brand-mark span { display: block; background: var(--ink); }
.brand-mark span:nth-child(2), .brand-mark span:nth-child(3) { background: #fff9d0; }
.canvas-badge { padding: 10px 14px; border: 1px solid var(--line); background: var(--yellow-100); font-size: .82rem; font-weight: 700; }

.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 14px clamp(20px, 4vw, 64px); background: rgba(255, 252, 226, .76); border-bottom: 1px solid var(--line); }
.step { min-width: 0; display: flex; align-items: center; gap: 12px; padding: 11px 14px; color: #786d45; border: 1px solid transparent; }
.step b { flex: 0 0 auto; width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid #cfc17b; border-radius: 50%; font-size: .82rem; }
.step span { font-size: .9rem; font-weight: 700; }
.step small { display: block; margin-top: 2px; font-weight: 400; color: #9b9169; }
.step.is-active { background: var(--surface); color: var(--ink); border-color: var(--line); box-shadow: 0 6px 20px rgba(92, 76, 17, .07); }
.step.is-active b { color: #fff; background: var(--ink); border-color: var(--ink); }

.workspace { display: grid; grid-template-columns: minmax(350px, 410px) minmax(520px, 1fr); gap: 22px; max-width: 1580px; margin: 0 auto; padding: 24px clamp(20px, 4vw, 64px) 48px; align-items: start; }
.control-panel, .preview-panel { background: rgba(255, 254, 248, .96); border: 1px solid rgba(218, 200, 111, .8); box-shadow: var(--shadow); }
.control-panel { min-width: 0; }
.panel-section { padding: 24px; border-bottom: 1px solid #eee5b2; }
.panel-section:last-child { border-bottom: 0; }
.section-heading { display: grid; grid-template-columns: 42px 1fr; gap: 12px; margin-bottom: 18px; }
.section-heading.compact { margin-bottom: 15px; }
.section-number { width: 42px; height: 42px; display: grid; place-items: center; background: var(--yellow-100); color: #766210; font-weight: 800; font-size: .78rem; border: 1px solid #f2df7b; }
.section-heading h2 { margin: 0; font-size: 1rem; line-height: 1.4; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: .79rem; line-height: 1.55; }

.drop-zone { min-height: 142px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; border: 1.5px dashed #c8af35; background: #fffbe0; cursor: pointer; transition: .18s ease; }
.drop-zone:hover, .drop-zone.is-dragging { background: #fff4aa; border-color: #8e771c; transform: translateY(-1px); }
.drop-zone input { position: absolute; opacity: 0; pointer-events: none; }
.upload-icon { width: 35px; height: 35px; display: grid; place-items: center; color: #fff; background: var(--ink); border-radius: 50%; font-size: 1.35rem; line-height: 1; }
.drop-zone strong { margin-top: 4px; font-size: .95rem; }
.drop-zone small { color: var(--muted); }
.upload-summary { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; padding: 10px 12px; background: var(--yellow-50); color: var(--muted); font-size: .82rem; border-left: 3px solid var(--yellow-500); }
.upload-summary[hidden], .empty-order[hidden] { display: none; }
.text-button { padding: 5px 8px; border: 0; background: transparent; color: #705f16; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.template-list { display: grid; gap: 9px; }
.template-card { width: 100%; display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 12px; padding: 11px; text-align: left; border: 1px solid #e7dca4; background: #fffef8; cursor: pointer; transition: .16s ease; }
.template-card:hover { border-color: #c4a822; background: #fffcec; }
.template-card.is-selected { border-color: #8b7416; background: var(--yellow-100); box-shadow: inset 4px 0 0 var(--yellow-500); }
.template-card strong, .template-card small { display: block; }
.template-card strong { font-size: .88rem; }
.template-card small { margin-top: 3px; color: var(--muted); font-size: .72rem; line-height: 1.4; }
.template-card em { font-style: normal; font-size: .72rem; font-weight: 800; color: #756116; background: #fff8c4; padding: 4px 6px; border: 1px solid #ead66f; }
.template-mini { width: 52px; height: 46px; display: grid; gap: 2px; padding: 4px; background: #786f47; }
.template-mini i { display: block; background: #fff8ca; }
.mini-five { grid-template-columns: repeat(2, 1fr); grid-template-rows: 1.5fr 1fr 1fr; }
.mini-five i:first-child { grid-column: 1 / 3; }
.mini-two { grid-template-rows: 1fr 1fr; }
.mini-sidebar { grid-template-columns: .45fr 1fr; grid-template-rows: repeat(3, 1fr); }
.mini-sidebar i:first-child { grid-row: 1 / 4; }
.mini-three-left, .mini-three-right { grid-template-columns: 1fr .3fr; grid-template-rows: repeat(3, 1fr); }
.mini-three-left i:nth-child(1) { grid-column: 1; grid-row: 1; }
.mini-three-left i:nth-child(2) { grid-column: 1; grid-row: 2; }
.mini-three-left i:nth-child(3) { grid-column: 1; grid-row: 3; }
.mini-three-left i:last-child { grid-column: 2; grid-row: 1 / 4; background: #fff; }
.mini-three-right { grid-template-columns: .3fr 1fr; }
.mini-three-right i:first-child { grid-column: 1; grid-row: 1 / 4; background: #fff; }
.mini-three-right i:nth-child(2) { grid-column: 2; grid-row: 1; }
.mini-three-right i:nth-child(3) { grid-column: 2; grid-row: 2; }
.mini-three-right i:nth-child(4) { grid-column: 2; grid-row: 3; }
.mini-five-middle { grid-template-columns: repeat(2, 1fr); grid-template-rows: 1.2fr .42fr .7fr .7fr; }
.mini-five-middle i:first-child, .mini-five-middle i:nth-child(2) { grid-column: 1 / 3; }
.mini-five-middle i:nth-child(2) { background: #fff; }

.text-settings { display: grid; gap: 11px; margin-bottom: 13px; }
.text-settings[hidden] { display: none; }
.sidebar-settings { margin-bottom: 13px; padding: 13px; border: 1px solid #e3d582; background: #fffbe0; }
.sidebar-settings[hidden] { display: none; }
.sidebar-setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sidebar-setting-row strong, .sidebar-setting-row small { display: block; }
.sidebar-setting-row strong { color: #5d501b; font-size: .8rem; }
.sidebar-setting-row small { margin-top: 3px; color: var(--muted); font-size: .7rem; }
.sidebar-fixed-status { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 7px; margin-top: 10px; padding-top: 9px; border-top: 1px solid #eee2a3; }
.sidebar-fixed-status small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #c8b75f; }
.sidebar-settings.is-ready .status-dot { background: #6d9666; box-shadow: 0 0 0 3px rgba(109, 150, 102, .14); }
.sidebar-settings.is-ready .sidebar-fixed-status small { color: #486344; }
.sidebar-fixed-status .text-button[hidden] { display: none; }
.text-settings > label, .color-setting, .background-upload-row { color: #6f6540; font-size: .78rem; font-weight: 700; }
.text-settings input[type="text"] { width: 100%; height: 42px; margin-top: 6px; padding: 0 11px; border: 1px solid #d9cd8e; background: #fff; color: var(--ink); outline: none; }
.text-settings input[type="text"]:focus { border-color: #9a8015; box-shadow: 0 0 0 3px rgba(232, 189, 50, .18); }
.text-color-setting { min-width: 0; margin: 0; padding: 0; border: 0; }
.text-color-setting legend { margin-bottom: 6px; padding: 0; color: #6f6540; font-size: .78rem; font-weight: 700; }
.segmented-control { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.segmented-control label { position: relative; cursor: pointer; }
.segmented-control input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-control span { min-height: 38px; display: flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid #d9cd8e; background: #fff; font-size: .78rem; font-weight: 700; }
.segmented-control span::before { content: ""; width: 15px; height: 15px; border: 1px solid #9a8d55; background: #fff; }
.segmented-control .black-swatch::before { background: #1c1a16; border-color: #1c1a16; }
.segmented-control input:checked + span { border-color: #8b7416; background: var(--yellow-100); box-shadow: inset 3px 0 0 var(--yellow-500); }
.color-setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.color-control { display: flex; align-items: center; gap: 8px; height: 38px; padding: 5px 9px 5px 5px; border: 1px solid #d9cd8e; background: #fff; }
.color-control input { width: 34px; height: 27px; padding: 0; border: 0; background: transparent; cursor: pointer; }
.color-control output { color: var(--muted); font-size: .76rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.background-upload { margin-top: 13px; padding-top: 13px; border-top: 1px solid #eee5b2; }
.background-upload-row, .background-file-info { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.file-button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; padding: 0 12px; border: 1px solid #bda736; background: #fff9d3; color: #5f5017; cursor: pointer; }
.file-button:hover { background: #fff1a6; }
.file-button input { position: absolute; opacity: 0; pointer-events: none; }
.background-file-info { min-width: 0; margin-top: 7px; }
.background-file-info small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.background-file-info .text-button[hidden] { display: none; }
.setting-help { display: block; margin-top: 5px; color: #9a916e; font-size: .7rem; line-height: 1.45; }

.empty-order { padding: 24px 12px; text-align: center; color: #a0966e; background: #fffdf0; border: 1px dashed #ded29a; font-size: .8rem; }
.thumbnail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; max-height: 330px; overflow: auto; scrollbar-width: thin; }
.thumbnail { position: relative; aspect-ratio: 16 / 9; background: #eae5cc; border: 2px solid transparent; cursor: grab; overflow: hidden; }
.thumbnail.is-used { border-color: #9b7f10; }
.thumbnail.is-dragging { opacity: .4; }
.thumbnail img { width: 100%; height: 100%; display: block; object-fit: cover; }
.thumbnail .slot-number { position: absolute; top: 3px; left: 3px; min-width: 20px; height: 20px; display: grid; place-items: center; padding: 0 4px; color: #fff; background: rgba(58, 49, 14, .9); font-size: .68rem; font-weight: 800; }
.thumbnail .file-name { position: absolute; right: 0; bottom: 0; left: 0; padding: 12px 4px 3px; overflow: hidden; color: #fff; background: linear-gradient(transparent, rgba(35, 30, 10, .8)); text-overflow: ellipsis; white-space: nowrap; font-size: .61rem; }

.preview-panel { position: sticky; top: 16px; min-width: 0; padding: 24px; }
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.preview-toolbar h2 { margin: 4px 0 0; font-size: 1.16rem; }
.eyebrow { color: #887629; font-size: .72rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.export-button { min-height: 46px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 20px; border: 0; background: var(--ink); color: #fff; font-weight: 800; cursor: pointer; box-shadow: 0 7px 18px rgba(60, 50, 11, .2); }
.export-button:hover:not(:disabled) { background: #6b5c1c; transform: translateY(-1px); }
.export-button:disabled { opacity: .38; cursor: not-allowed; box-shadow: none; }
.notice { margin-bottom: 12px; padding: 10px 12px; color: #755f09; background: var(--yellow-100); border-left: 3px solid var(--yellow-500); font-size: .8rem; }
.notice.is-ready { color: #486344; background: #edf6e9; border-left-color: #6d9666; }
.canvas-stage { min-height: 460px; display: grid; place-items: center; padding: 18px; background-color: #ebe5bd; background-image: linear-gradient(45deg, rgba(255,255,255,.35) 25%, transparent 25%), linear-gradient(-45deg, rgba(255,255,255,.35) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(255,255,255,.35) 75%), linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.35) 75%); background-size: 22px 22px; background-position: 0 0, 0 11px, 11px -11px, -11px 0; }
#previewCanvas { display: block; width: min(100%, 540px); height: auto; max-height: calc(100vh - 275px); object-fit: contain; box-shadow: 0 15px 35px rgba(67, 56, 14, .22); background: #667f5d; }
.privacy-note { display: flex; align-items: center; justify-content: center; gap: 7px; margin: 14px 0 0; color: var(--muted); font-size: .75rem; }
.privacy-note span { width: 18px; height: 18px; display: grid; place-items: center; background: var(--yellow-100); border-radius: 50%; font-weight: 800; }

.toast { position: fixed; z-index: 10; right: 24px; bottom: 24px; max-width: min(360px, calc(100vw - 48px)); padding: 12px 16px; color: #fff; background: #493f16; box-shadow: 0 12px 30px rgba(41, 34, 8, .25); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }

@media (max-width: 1000px) {
  .workspace { grid-template-columns: 1fr; }
  .preview-panel { position: static; }
  #previewCanvas { max-height: none; }
}
@media (max-width: 720px) {
  .topbar { padding: 14px 16px; }
  .canvas-badge { display: none; }
  .steps { grid-template-columns: repeat(4, minmax(68px, 1fr)); gap: 4px; padding: 8px; }
  .step { justify-content: center; padding: 8px 4px; }
  .step span { font-size: .7rem; }
  .step small { display: none; }
  .step b { width: 25px; height: 25px; }
  .workspace { padding: 12px 10px 28px; gap: 12px; }
  .panel-section, .preview-panel { padding: 17px; }
  .preview-toolbar { align-items: flex-end; }
  .export-button { min-height: 42px; padding: 0 13px; font-size: .82rem; }
  .canvas-stage { min-height: 0; padding: 10px; }
}
