:root {
  color-scheme: light;
  --paper: #f1efe7;
  --paper-strong: #e7e3d8;
  --ink: #151515;
  --muted: #6f6b62;
  --line: #c9c5ba;
  --line-dark: #8c887f;
  --accent: #e23d28;
  --white: #fffefa;
  --focus: #1b60d1;
  --topbar-h: 68px;
  font-family: "Public Sans", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--paper); }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

button,
input { font: inherit; }

button,
label { -webkit-tap-highlight-color: transparent; }

button { color: inherit; }

button:focus-visible,
input:focus-visible,
label:has(input:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: square;
  stroke-linejoin: miter;
  flex: 0 0 auto;
}

.icon-large { width: 24px; height: 24px; }

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  height: var(--topbar-h);
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr) auto;
  align-items: center;
  border-bottom: 1px solid var(--ink);
  background: color-mix(in srgb, var(--paper) 96%, transparent);
  backdrop-filter: blur(12px);
}

.brand {
  align-self: stretch;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 18px;
  border-right: 1px solid var(--ink);
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-family: "Songti TC", "Noto Serif TC", serif;
  font-size: 20px;
  line-height: 1;
}

.brand-copy { display: grid; gap: 1px; }
.brand-copy b { font-size: 15px; letter-spacing: .08em; }
.brand-copy small { color: var(--muted); font: 10px/1.2 ui-monospace, "SFMono-Regular", Menlo, monospace; letter-spacing: .09em; }

.file-meta {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
  padding: 0 20px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #2f7b49; }
.muted { color: var(--muted); }

.top-actions { display: flex; height: 100%; }

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 16px;
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: transparent;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button-dark { border-radius: 0; border-width: 0 0 0 1px; padding-inline: 24px; background: var(--ink); color: var(--paper); }
.button-dark:hover { background: #343434; }
.button-ghost { height: 100%; border-width: 0 0 0 1px; border-radius: 0; }
.button-ghost:hover { background: var(--paper-strong); }
.button-accent { border-color: var(--accent); background: var(--accent); color: #fff; }
.button-accent:hover { background: #be2e1d; }

.workspace {
  min-height: calc(100vh - var(--topbar-h));
  display: grid;
  grid-template-columns: 340px minmax(480px, 1fr) 270px;
}

.controls,
.output-panel {
  background: var(--paper);
}

.controls { border-right: 1px solid var(--ink); }
.output-panel { border-left: 1px solid var(--ink); padding: 20px 18px; }

.panel-heading { padding: 27px 20px 25px; border-bottom: 1px solid var(--ink); }
.panel-heading h1 { max-inline-size: 11ch; margin: 10px 0 12px; font-size: clamp(28px, 2.3vw, 39px); line-height: .98; letter-spacing: -.055em; text-wrap: balance; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }

.eyebrow {
  color: var(--muted);
  font: 700 10px/1.2 ui-monospace, "SFMono-Regular", Menlo, monospace;
  letter-spacing: .11em;
}

.control-section { border-bottom: 1px solid var(--ink); }

.section-toggle {
  width: 100%;
  min-height: 49px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.section-toggle:hover { background: var(--paper-strong); }
.section-toggle > span { display: flex; align-items: baseline; gap: 12px; }
.section-toggle small { color: var(--accent); font: 700 10px ui-monospace, "SFMono-Regular", Menlo, monospace; }
.section-toggle b { font-size: 14px; }
.section-toggle .icon { transition: transform 180ms ease; }
.section-toggle[aria-expanded="false"] .icon { transform: rotate(-90deg); }

.section-body { padding: 0 20px 20px; }
.section-body.is-collapsed { display: none; }

.upload-box {
  min-height: 82px;
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 14px;
  border: 1px dashed var(--line-dark);
  background: var(--white);
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.upload-box:hover { border-color: var(--accent); background: #fff; }
.upload-box > span { display: grid; gap: 3px; }
.upload-box small { color: var(--muted); font-size: 11px; }
.upload-box input { position: absolute; opacity: 0; pointer-events: none; }

.text-button {
  min-height: 40px;
  margin: 3px 0 -12px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.preset-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

.preset {
  min-height: 94px;
  display: grid;
  grid-template-columns: 32px 1fr;
  grid-template-rows: 1fr auto;
  align-items: end;
  gap: 2px 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.preset:hover { border-color: var(--ink); }
.preset.is-active { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.preset b { align-self: end; font-size: 12px; }
.preset small { grid-column: 2; color: currentColor; opacity: .62; font: 9px ui-monospace, "SFMono-Regular", Menlo, monospace; letter-spacing: .08em; }

.preset-glyph { grid-row: 1 / 3; width: 30px; height: 55px; align-self: stretch; opacity: .9; }
.preset-glyph.dots { background: radial-gradient(circle, currentColor 1.4px, transparent 1.7px) 0 0/7px 7px; }
.preset-glyph.stretch { background: repeating-linear-gradient(to bottom, currentColor 0 2px, transparent 2px 6px); clip-path: polygon(0 8%, 100% 0, 72% 28%, 100% 38%, 54% 58%, 100% 76%, 0 100%); }
.preset-glyph.outline { border: 2px solid currentColor; border-radius: 48% 52% 40% 60%; transform: rotate(-9deg) scale(.78); }
.preset-glyph.terrain { background: repeating-radial-gradient(ellipse at 30% 55%, transparent 0 5px, currentColor 6px 7px, transparent 8px 10px); }

.slider-list { display: grid; gap: 14px; }
.range-row { display: grid; gap: 7px; }
.range-row > span { display: flex; justify-content: space-between; font-size: 12px; }
.range-row output { color: var(--accent); font: 700 11px ui-monospace, "SFMono-Regular", Menlo, monospace; }

input[type="range"] {
  width: 100%;
  height: 18px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  accent-color: var(--accent);
}

input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: var(--line-dark); }
input[type="range"]::-webkit-slider-thumb { width: 14px; height: 14px; margin-top: -6px; border: 0; border-radius: 50%; background: var(--accent); -webkit-appearance: none; }
input[type="range"]::-moz-range-track { height: 2px; background: var(--line-dark); }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: var(--accent); }

.color-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding-top: 3px; }
.color-row label { display: grid; gap: 4px; color: var(--muted); font-size: 10px; }
.color-row input { width: 100%; height: 35px; padding: 2px; border: 1px solid var(--line); background: transparent; cursor: pointer; }
.color-row span { font: 9px ui-monospace, "SFMono-Regular", Menlo, monospace; }

.switch-list { display: grid; gap: 8px; padding-top: 3px; }
.switch-row { min-height: 34px; display: flex; align-items: center; justify-content: space-between; cursor: pointer; font-size: 12px; }
.switch-row input { position: absolute; opacity: 0; }
.switch-row i { position: relative; width: 34px; height: 18px; border: 1px solid var(--line-dark); background: transparent; transition: background-color 160ms ease; }
.switch-row i::after { content: ""; position: absolute; width: 12px; height: 12px; top: 2px; left: 2px; background: var(--line-dark); transition: transform 160ms ease, background-color 160ms ease; }
.switch-row input:checked + i { border-color: var(--ink); background: var(--ink); }
.switch-row input:checked + i::after { transform: translateX(16px); background: var(--paper); }

.field { display: grid; gap: 6px; color: var(--muted); font-size: 11px; }
.field + .field,
.field-grid { margin-top: 10px; }
.field input { min-height: 42px; width: 100%; border: 1px solid var(--line); border-radius: 0; background: var(--white); padding: 0 11px; color: var(--ink); }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.stage {
  min-width: 0;
  display: grid;
  grid-template-rows: 50px minmax(0, 1fr) 60px;
  background: #d6d2c8;
}

.stage-toolbar,
.stage-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 18px;
  border-bottom: 1px solid var(--ink);
  background: var(--paper);
}

.stage-toolbar > div:first-child { display: flex; align-items: baseline; gap: 12px; }
.stage-toolbar b { font-size: 12px; }
.stage-toolbar span,
.stage-footer span { color: var(--muted); font: 10px ui-monospace, "SFMono-Regular", Menlo, monospace; letter-spacing: .04em; }
.zoom-meta { display: flex; gap: 16px; }

.canvas-shell {
  min-height: 560px;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 28px;
  background-image: linear-gradient(45deg, rgba(21,21,21,.04) 25%, transparent 25%), linear-gradient(-45deg, rgba(21,21,21,.04) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(21,21,21,.04) 75%), linear-gradient(-45deg, transparent 75%, rgba(21,21,21,.04) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

#artboard {
  display: block;
  width: auto;
  height: min(73vh, 760px);
  max-width: 100%;
  max-height: calc(100vh - 220px);
  background: var(--paper);
  box-shadow: 0 16px 45px rgba(21,21,21,.19), 0 0 0 1px rgba(21,21,21,.22);
}

.stage-footer { border-top: 1px solid var(--ink); border-bottom: 0; }
.stage-footer .button { min-width: 166px; }

.output-panel section + section { margin-top: 30px; }
.output-panel h2 { margin: 7px 0 13px; font-size: 18px; letter-spacing: -.025em; }

.ratio-list { display: grid; gap: 7px; }
.ratio {
  min-height: 62px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.ratio:hover { border-color: var(--ink); }
.ratio.is-active { border-color: var(--ink); background: var(--white); box-shadow: inset 3px 0 var(--accent); }
.ratio > span:last-child { display: grid; gap: 3px; }
.ratio b { font-size: 12px; }
.ratio small { color: var(--muted); font: 9px ui-monospace, "SFMono-Regular", Menlo, monospace; }
.ratio-shape { justify-self: center; display: block; border: 1.5px solid currentColor; }
.ratio-shape.portrait { width: 19px; height: 24px; }
.ratio-shape.square { width: 21px; height: 21px; }
.ratio-shape.story { width: 15px; height: 27px; }

.summary-section { padding-top: 24px; border-top: 1px solid var(--line-dark); }
.summary-list { margin: 0; }
.summary-list > div { min-height: 37px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); }
.summary-list > div:last-child { border-bottom: 1px solid var(--line); }
.summary-list dt { color: var(--muted); font-size: 11px; }
.summary-list dd { margin: 0; text-align: right; font-size: 11px; }
.swatch { display: inline-block; width: 14px; height: 14px; margin-left: -1px; border: 1px solid rgba(21,21,21,.35); vertical-align: middle; }
.swatch.paper { background: #f1efe7; }
.swatch.ink { background: #151515; }
.swatch.accent { background: #e23d28; }

.note-card { padding: 15px; border: 1px solid var(--ink); background: var(--ink); color: var(--paper); }
.note-card .eyebrow { color: #aaa79d; }
.note-card p { margin: 12px 0 0; font-family: "Songti TC", "Noto Serif TC", serif; font-size: 19px; line-height: 1.35; letter-spacing: .02em; }

.privacy-note { display: flex; align-items: flex-start; gap: 10px; margin-top: 30px; color: var(--muted); }
.privacy-note > span { margin-top: 4px; color: #2f7b49; font-size: 10px; }
.privacy-note p { margin: 0; font-size: 10px; line-height: 1.55; }
.privacy-note b { color: var(--ink); }

noscript { display: block; padding: 20px; background: var(--accent); color: white; }

@media (max-width: 1160px) {
  .topbar { grid-template-columns: 300px minmax(0, 1fr) auto; }
  .workspace { grid-template-columns: 300px minmax(440px, 1fr); }
  .output-panel { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 24px; border-top: 1px solid var(--ink); border-left: 0; }
  .output-panel section + section { margin-top: 0; }
  .privacy-note { display: none; }
}

@media (max-width: 820px) {
  :root { --topbar-h: 60px; }
  .topbar { grid-template-columns: 1fr auto; }
  .brand { border-right: 0; padding-inline: 14px; }
  .file-meta { display: none; }
  .button-ghost { display: none; }
  .button-dark { padding-inline: 16px; }
  .button-dark .icon { display: none; }
  .workspace { display: block; }
  .controls { border-right: 0; }
  .panel-heading { padding-top: 22px; }
  .stage { min-height: 720px; border-top: 1px solid var(--ink); }
  .canvas-shell { min-height: 560px; padding: 22px 14px; }
  #artboard { width: auto; max-width: 92vw; height: auto; max-height: 72vh; }
  .output-panel { display: grid; grid-template-columns: 1fr 1fr; }
  .note-card { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
  .brand-copy small { display: none; }
  .top-actions .button { font-size: 12px; }
  .panel-heading h1 { font-size: 34px; }
  .stage-toolbar > div:first-child { display: grid; gap: 1px; }
  .zoom-meta span:last-child { display: none; }
  .canvas-shell { min-height: 500px; }
  .stage-footer { padding-block: 8px; }
  .stage-footer > span { display: none; }
  .stage-footer .button { width: 100%; }
  .output-panel { grid-template-columns: 1fr; }
  .note-card { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
