:root {
  color-scheme: dark;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: #171513;
  color: #f8f4eb;
  --ink: #f8f4eb;
  --stage: #171513;
  --preview-background: #26221f;
  --panel: #1c1917;
  --line: #38312e;
  --muted: #b4a69e;
  --accent: #d3b0b5;
  --masthead-size: 58px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
h1, h2, p { margin: 0; }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; opacity: .48; }
button:focus, input:focus { outline: 1px solid var(--accent); outline-offset: 3px; }

.masthead {
  height: var(--masthead-size);
  height: calc(var(--masthead-size) + var(--safe-area-inset-top, env(safe-area-inset-top, 0px)));
  padding-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
  position: relative;
  display: grid;
  align-items: center; justify-items: center;
  border-bottom: 1px solid #2e2724;
}
.history-tools {
  position: absolute;
  right: 8px;
  right: calc(8px + var(--safe-area-inset-right, env(safe-area-inset-right, 0px)));
  display: flex;
}
.history-tools button {
  display: grid;
  align-items: center; justify-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
}
.history-tools button:disabled { opacity: .3; }
.history-tools button:hover:not(:disabled) { background: var(--line); }
.history-tools svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}
@media (max-width: 319px) { .history-tools button { width: 35px; } }
.wordmark {
  display: inline-flex;
  align-items: baseline;
  font-family: "Bodoni MT", Didot, "Times New Roman", serif;
  font-size: 38px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: .018em;
  color: #f6f1e8;
}
.wordmark-a {
  position: relative;
  width: .63em;
  height: .67em;
  width: .94cap;
  height: 1cap;
  margin-left: -.037em;
  margin-right: -.055em;
}
.wordmark-a::before, .wordmark-a::after {
  content: "";
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  background: currentColor;
}
.wordmark-a::before {
  clip-path: polygon(
    46% 0%, 54% 0%, 87% 88%, 91% 95%, 99% 96%, 99% 100%, 67% 100%, 67% 96%,
    73% 94%, 73% 88%, 45% 15%, 19% 89%, 19% 94%, 27% 96%, 27% 100%,
    1% 100%, 1% 96%, 9% 94%, 14% 88%
  );
}
.wordmark-a::after { clip-path: polygon(21% 57%, 78% 53%, 74% 60%, 18% 64%); }
.wordmark-y { letter-spacing: 0; }
@media (min-width: 721px) { .wordmark { font-size: 40px; } }

.workspace {
  min-height: calc(100vh - var(--masthead-size));
  min-height: calc(100svh - var(--masthead-size));
  display: grid;
  grid-template-rows: auto 1fr;
}
.artboard {
  --art-width: calc(112.5vh - 400px);
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 14px 9px 12px;
  padding: clamp(5px, calc(3.4svh - 12px), 24px) 9px clamp(7px, calc(2svh - 3px), 17px);
  background: var(--preview-background);
}
.stage {
  width: 100%;
  min-width: 232px;
  max-width: var(--art-width);
  position: relative;
  isolation: isolate;
}
.stage::before { content: ""; display: block; padding-top: var(--stage-height, 88.8889%); }
@media (min-height: 907px) { .artboard { --art-width: 620px; } }
@supports (width: min(100%, 620px)) {
  .artboard { --art-width: min(100%, 620px, max(232px, calc(112.5vh - 400px))); }
  .stage.portrait { max-width: min(var(--art-width), max(232px, calc(75vh - 240px))); }
}
@supports (width: min(100%, 100svh)) {
  .artboard { --art-width: min(100%, 620px, max(232px, calc(112.5svh - 400px))); }
  .stage.portrait { max-width: min(var(--art-width), max(232px, calc(75svh - 240px))); }
}
@supports (aspect-ratio: 1) {
  .stage { aspect-ratio: var(--stage-ratio, 720 / 640); }
  .stage::before { display: none; }
}
#preview, .slots { position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%; display: block; }
.startup-hint { position: absolute; top: 46%; left: 0; width: 100%; text-align: center; color: var(--muted); font-size: 14px; }
.camera-art-status {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--panel);
  font-size: 12px;
  white-space: nowrap;
}
.camera-art-status button { margin-left: 8px; }
.slots { pointer-events: none; }
.slot { position: absolute; pointer-events: auto; padding: 0; border: 0; background: transparent; }
.slot.filled { cursor: grab; touch-action: none; }
.slot.dragging { cursor: grabbing; }
.stage.swapping .slot { cursor: crosshair; }
.slot:focus { outline: none; background: rgba(211, 176, 181, .208); box-shadow: inset 0 0 0 2px var(--accent); }
@media (hover: hover) {
  .slot:hover:not(.dragging) { background: rgba(248, 244, 235, .04); }
}
.stage-meta {
  width: 100%;
  min-width: 232px;
  max-width: var(--art-width);
  min-height: 19px;
  padding-left: 9px; padding-right: 9px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
#progress { margin-left: auto; letter-spacing: .055em; }

.workbench {
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding-bottom: 13px;
  padding-bottom: calc(13px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
}
.workbench-inner { max-width: 590px; margin: 0 auto; padding-left: 16px; padding-right: 16px; min-width: 0; }
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--line);
}
.tabs button {
  position: relative;
  min-height: 45px;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: .1em;
}
.tabs button[aria-selected="true"] { color: var(--ink); }
.tabs button[aria-selected="true"]::after {
  content: "";
  position: absolute;
  height: 1px;
  width: 32px;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
}
.tabs button:hover { color: var(--ink); }
.panels { min-height: 142px; display: grid; align-items: center; }
.shape-panel { display: grid; align-items: center; min-width: 0; }
.templates {
  display: flex;
  align-items: center;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
  scrollbar-color: #5e504c transparent;
  padding: 4px 2px;
}
.template {
  flex: 0 0 65px;
  min-height: 66px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5px 3px;
  border: 1px solid #393130;
  border-radius: 8px;
  background: #25201e;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  scroll-margin-inline: 3px;
}
.template canvas { width: 34px; height: 30px; object-fit: contain; display: block; }
.template[aria-pressed="true"] { background: #2b2323; border-color: #bc9aa0; color: var(--ink); }
.template:focus { outline-offset: 1px; }

.shape-layouts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-gap: 6px;
  margin-top: 6px;
  padding: 7px 2px 9px;
  border-top: 1px solid var(--line);
}
.shape-layout {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 3px 6px;
  border: 1px solid #493c39;
  border-radius: 7px;
  background: #25201e;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.shape-layout canvas { width: 33px; height: 29px; object-fit: contain; margin-right: 5px; }
.shape-layout[aria-pressed="true"] { border-color: #bc9aa0; background: #2b2323; color: var(--ink); }

.photo-panel { display: grid; align-content: center; padding-top: 5px; padding-bottom: 5px; grid-gap: 4px; }
.photo-prompt { min-height: 35px; display: flex; align-items: center; color: var(--muted); font-size: 13px; }
.inspector-heading { display: flex; justify-content: space-between; align-items: center; }
.inspector-heading h2 { font-size: 13px; font-weight: 550; color: var(--ink); }
.photo-actions { display: flex; }
.text-button {
  min-height: 40px;
  padding: 0 8px;
  background: transparent;
  border: 0;
  border-radius: 5px;
  font-size: 12px;
  white-space: nowrap;
}
.done { color: var(--ink); min-width: 44px; }
.remove { color: var(--accent); }
.crop-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; grid-gap: 6px; }
.reset-crop { color: var(--accent); }
.swap-panel p { color: var(--muted); font-size: 13px; line-height: 1.65; padding-top: 7px; padding-bottom: 10px; }

.zoom-control {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 34px;
  align-items: center;
  grid-gap: 9px;
  color: var(--muted);
  font-size: 12px;
}
.zoom-control output { white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.zoom-control input {
  --fill: 0%;
  --track: linear-gradient(to right, var(--accent) var(--fill), #4a3f3b var(--fill));
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 38px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.zoom-control input::-webkit-slider-runnable-track { height: 2px; background: var(--track); }
.zoom-control input::-moz-range-track { height: 2px; background: var(--track); }
.zoom-control input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -6px;
  background: var(--ink);
  border-radius: 50%;
}
.zoom-control input::-moz-range-thumb { width: 14px; height: 14px; border: none; background: var(--ink); border-radius: 50%; }
.tool-button {
  flex: 1 1 0;
  min-height: 41px;
  padding: 0 5px;
  white-space: nowrap;
  border: 1px solid #493c39;
  border-radius: 6px;
  background: transparent;
  font-size: 13px;
}

.letter-controls {
  min-height: 52px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  grid-gap: 6px 10px;
  padding: 6px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.letter-controls input {
  min-width: 0;
  height: 36px;
  padding: 0 12px;
  border: 1px solid #493c39;
  border-radius: 6px;
  background: #25201e;
  color: var(--ink);
  font-size: 16px;
}
.letter-controls .tool-button { min-height: 36px; padding-left: 15px; padding-right: 15px; }
.letter-error { grid-column: 2 / -1; color: var(--accent); line-height: 1.5; }
.digit-controls {
  padding: 5px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.digit-options {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  grid-gap: 3px;
  margin-top: 4px;
}
.digit-options button {
  min-height: 44px;
  padding: 0;
  border: 1px solid #493c39;
  border-radius: 6px;
  background: #25201e;
  color: var(--ink);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.digit-options button[aria-pressed="true"] {
  background: #2b2323;
  border-color: var(--accent);
}
.letter-reserve {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  grid-gap: 10px;
  padding: 6px 0 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.reserve-photos { display: flex; overflow-x: auto; padding: 2px; scrollbar-width: thin; }
.reserve-photo {
  width: 44px;
  height: 44px;
  flex: none;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #25201e;
}
.reserve-photo canvas { display: block; width: 100%; height: 100%; border-radius: 3px; }
.reserve-photo[aria-pressed="true"] { border-color: var(--accent); }
.reserve-photo:focus { outline-offset: 0; }

.dial-title-trigger {
  position: absolute;
  top: 50%; left: 50%;
  width: 40%;
  height: 45%;
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 50%;
  background: transparent;
}
.dial-controls {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  grid-gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.dial-controls textarea, .reel-fields textarea, .reel-fields input {
  min-width: 0;
  padding: 6px 12px;
  border: 1px solid #493c39;
  border-radius: 6px;
  background: #25201e;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  line-height: 1.25;
  resize: vertical;
}
.dial-controls textarea:focus, .reel-fields textarea:focus {
  outline: 1px solid var(--accent);
  outline-offset: 3px;
}

.reel-controls {
  margin-top: 6px;
  padding: 10px 0 4px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.reel-controls h2 { color: var(--ink); font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.reel-fields {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  align-items: start;
  grid-gap: 4px 9px;
}
.reel-fields input { min-height: 34px; }
.reel-fields textarea { resize: none; }
.reel-color { display: flex; align-items: center; margin-top: 3px; }
.reel-color .roof-swatch::before { border: 1px solid #9b8c83; }

.roof-controls {
  min-height: 49px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.roof-controls > span { flex: none; }
.roof-palette { display: flex; align-items: center; }
.roof-swatch, .custom-roof {
  position: relative;
  display: grid;
  align-items: center; justify-items: center;
  width: 34px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
}
.roof-swatch::before {
  content: "";
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: var(--swatch);
}
.roof-swatch[aria-pressed="true"]::after, .custom-roof.custom-active::after {
  content: "";
  position: absolute;
  top: 5px; right: 3px; bottom: 5px; left: 3px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  pointer-events: none;
}
.custom-roof input {
  -webkit-appearance: none;
  appearance: none;
  width: 23px;
  height: 23px;
  padding: 0;
  border: 1px solid #73635e;
  border-radius: 50%;
  background: #25201e;
  cursor: pointer;
}
.custom-roof input::-webkit-color-swatch-wrapper { padding: 0; }
.custom-roof input::-webkit-color-swatch { border: 0; border-radius: 50%; opacity: 0; }
.custom-roof input::-moz-color-swatch { border: 0; border-radius: 50%; opacity: 0; }
.custom-roof.custom-active input::-webkit-color-swatch { opacity: 1; }
.custom-roof.custom-active input::-moz-color-swatch { opacity: 1; }
.custom-roof span { position: absolute; pointer-events: none; line-height: 1; }
.custom-roof.custom-active span { display: none; }

.primary-bar { padding-top: 10px; border-top: 1px solid var(--line); }
.web-export-hint { margin-top: 7px; text-align: right; font-size: 11px; color: var(--muted); }
.primary {
  min-height: 49px;
  width: 100%;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 7px;
  background: var(--ink);
  color: var(--stage);
  font-size: 14px;
  font-weight: 650;
  letter-spacing: .04em;
}
.follow-hint {
  display: flex;
  align-items: center;
  margin-top: 9px;
  padding: 3px 3px 3px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  font-size: 13px;
}
.follow-hint p { flex: 1; }
.follow-hint button { min-height: 44px; }
.follow-action {
  padding: 0 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--accent);
}
@media (hover: hover) {
  .template:hover { border-color: #7c6765; }
  .text-button:hover, .tool-button:hover:enabled { background: #312725; }
  .primary:hover:enabled { background: #e9ded3; }
}
.action-icon { position: relative; display: inline-block; width: 14px; height: 14px; }
.action-icon::before, .action-icon::after { content: ""; position: absolute; }
.plus-icon::before { background: currentColor; height: 1px; width: 12px; top: 6px; left: 1px; }
.plus-icon::after { background: currentColor; width: 1px; height: 12px; top: 1px; left: 6.5px; }
.download-icon { border-bottom: 1px solid; }
.download-icon::before { height: 9px; left: 6.5px; top: 0; border-left: 1px solid; }
.download-icon::after { width: 5px; height: 5px; left: 4px; top: 4px; border: solid; border-width: 0 1px 1px 0; transform: rotate(45deg); }

.toast {
  position: fixed;
  top: calc(var(--masthead-size) + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  width: max-content;
  max-width: calc(100% - 38px);
  pointer-events: none;
  border-radius: 6px;
  border: 1px solid #544543;
  background: #302725;
  color: var(--ink);
  padding: 8px 12px;
  font-size: 12px;
  line-height: 1.55;
  opacity: 0;
  transition: opacity 130ms ease;
}
.toast.visible { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

.history-tools > * + * { margin-left: 1px; }
.stage-meta > * + * { margin-left: 8px; }
.templates > * + *, .photo-actions > :not([hidden]) ~ :not([hidden]), .reserve-photos > * + * { margin-left: 6px; }
.template > * + * { margin-top: 3px; }
.inspector-heading > * + * { margin-left: 12px; }
.reel-color > * + * { margin-left: 8px; }
.roof-controls > * + * { margin-left: 5px; }
.roof-palette > * + * { margin-left: 3px; }
.primary > * + * { margin-left: 9px; }
.templates, .reserve-photos { -webkit-overflow-scrolling: touch; }
@supports selector(:focus-visible) {
  button:focus:not(:focus-visible), input:focus:not(:focus-visible), textarea:focus:not(:focus-visible) { outline: none; }
  .slot:focus:not(:focus-visible) { box-shadow: none; background: transparent; }
}
