:root {
  color-scheme: light;
  --paper: #f6e7c9;
  --wine: #511d27;
  --gold: #e6bb7e;
  --card: #fff4da;
  --evergreen: #203d32;
  --ruby: #9c3d37;
  --brass: #ad803a;
  --line: #d8c9ab;
  --muted: #6d6354;
  --serif: "Songti SC", "Noto Serif CJK SC", SimSun, Georgia, serif;
  --sans: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--evergreen);
  font: 14px/1.5 var(--sans);
  background:
    radial-gradient(ellipse at 50% 0%, #963e45aa, transparent 65%),
    repeating-linear-gradient(130deg, transparent 0 10px, #ffdebb05 10px 12px),
    var(--wine);
  min-height: 100vh;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .46; }
button:focus-visible, canvas:focus-visible, summary:focus-visible { outline: 2px solid var(--ruby); outline-offset: 3px; }
button svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
h1, h2, p { margin: 0; }
h1, h2 { font-family: var(--serif); }
.masthead {
  max-width: 1600px;
  min-height: 132px;
  margin: 0 auto 16px;
  padding: 0 35px;
  color: var(--card);
  position: relative;
  isolation: isolate;
  display: flex;
  justify-content: center;
  align-items: center;
}
.masthead::before, .masthead::after {
  content: "";
  position: absolute;
  z-index: -1;
  top: -21px;
  width: min(34vw, 475px);
  height: 155px;
  background: url(assets/garland.webp) no-repeat left top / contain;
  pointer-events: none;
}
.masthead::before { left: 0; }
.masthead::after { right: 0; transform: scaleX(-1); }
.masthead-actions { display: flex; align-items: center; gap: 15px; }
.brand-copy { text-align: center; }
.brand-copy h1 { font-size: clamp(29px, 4.3vw, 55px); line-height: 1.12; letter-spacing: .14em; font-weight: 800; text-shadow: 0 3px #31191e80; }
.brand-copy h1::before, .brand-copy h1::after { content: "✦"; font-size: .37em; color: var(--gold); display: inline-block; vertical-align: .55em; margin-inline: .32em; letter-spacing: 0; }
.masthead-actions { position: absolute; right: 32px; bottom: 14px; }
.masthead .primary { background: #fcdea6; color: #51232c; border-color: #fff0cb; box-shadow: 0 3px 0 #30161d80; font-weight: 750; }
.masthead .primary:hover:not(:disabled) { background: #fff1cc; }
.brand-copy p { margin-top: 6px; font-size: 11px; letter-spacing: .28em; color: #f2cd91; }
.save-state { font-size: 12px; color: #f8dfb6; }
.help-button { min-height: 44px; padding: 0 12px; border: 1px solid #e6bb7e99; border-radius: 8px; background: #35151b80; color: var(--card); white-space: nowrap; }
.help-button:hover { background: #6c3039; }
.help-button:focus-visible { outline-color: var(--gold); }
.save-state:not(:empty)::before { content: "●"; color: #dfb87d; font-size: 8px; margin-right: 6px; vertical-align: 1px; }
.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  background: var(--evergreen);
  color: var(--card);
  border: 1px solid var(--evergreen);
  padding: 0 19px;
  border-radius: 8px;
  white-space: nowrap;
}
.primary:hover:not(:disabled) { background: #315344; }
.workshop {
  max-width: 1600px;
  margin: auto;
  padding: 0 32px 30px;
  display: grid;
  grid-template-columns: minmax(186px, 230px) minmax(0, 1fr) minmax(250px, 327px);
  align-items: start;
  gap: 16px;
}
.panel {
  min-width: 0;
  border: 1px solid #dda964;
  border-radius: 13px;
  background: var(--paper);
  padding: 16px;
  box-shadow: inset 0 0 0 3px #9a65331f, 0 7px 22px #260f1770;
}
.trees {
  background: linear-gradient(155deg, #364e3c, #203c31 45%, #1b3128);
  color: var(--card);
  box-shadow: inset 0 0 0 3px #e4a8581e, 0 7px 22px #260f1770;
}
.trees .tree-option, .trees .segmented { color: var(--evergreen); }
.trees .starts legend, .trees .inspiration p { color: #f0d4a9; }
.trees .inspiration { border-color: #e2bd784d; }
.trees .inspiration summary span { color: var(--gold); }
.backdrops { margin: 17px 0 13px; }
.trees .backdrops h2 { font-size: 16px; margin-bottom: 8px; color: #f4d49c; }
.backdrop-options { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 5px; }
.backdrop-option {
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 4px;
  border-radius: 6px;
  border: 1px solid #c3975866;
  padding: 3px 2px 5px;
  background: #1c332a;
  color: #f1dfb9;
  font-size: 10px;
  line-height: 1.2;
}
.backdrop-option[aria-pressed="true"] { border-color: #ffdda4; background: #5b432f; color: #fff4d6; }
.backdrop-option:hover { border-color: #ffdda4; }
.backdrop-option img { width: 100%; aspect-ratio: 1.45; object-fit: cover; border-radius: 3px; pointer-events: none; }
.backdrop-option:focus-visible { outline-color: var(--gold); }
.panel h2 { font-size: 20px; letter-spacing: .06em; font-weight: 800; margin-bottom: 13px; }
.tree-options { display: grid; gap: 8px; }
.tree-option {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 91px;
  padding: 7px;
  background: #f4ebd6;
  display: grid;
  grid-template-columns: 56px 1fr;
  align-items: center;
  gap: 8px;
  text-align: left;
  position: relative;
}
.tree-option:hover { border-color: var(--brass); }
.tree-option[aria-pressed="true"] { background: #e5eadb; border-color: #668273; box-shadow: inset 0 0 0 1px #668273; }
.tree-option img { display: block; width: 100%; height: 73px; object-fit: contain; }
.tree-option strong { display: block; font-size: 13px; }
.tree-option small { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
.starts { padding: 0; border: 0; margin: 18px 0 14px; min-width: 0; }
.starts legend { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.segmented { display: flex; border: 1px solid var(--line); background: #eae0c9; padding: 3px; border-radius: 7px; gap: 2px; }
.segmented button {
  flex: 1 0 auto;
  border: 0;
  background: transparent;
  padding: 6px 9px;
  border-radius: 4px;
  font-size: 12px;
  min-height: 33px;
  white-space: nowrap;
}
.segmented button:hover { background: #f8efdf; }
.segmented button[aria-pressed="true"] { background: var(--card); box-shadow: 0 1px 3px #4c321825; font-weight: 700; }
.inspiration { border-top: 1px solid var(--line); padding-top: 12px; font-size: 12px; }
.inspiration summary { cursor: pointer; min-height: 28px; font-weight: 600; padding: 4px 0; }
.inspiration summary span { color: var(--ruby); }
.inspiration p { color: var(--muted); line-height: 1.75; margin-top: 6px; }
.studio { min-width: 0; }
.picture {
  height: clamp(460px, calc(100svh - 216px), 790px);
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border-radius: 13px;
  border: 2px solid #dbad69;
  background: #19352f;
  box-shadow: 0 0 0 3px #2d201fa0, 0 12px 32px #250d1a91;
}
.picture::after {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid #f6ce88a1;
  border-radius: 9px;
  pointer-events: none;
}
#scene { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#scene:focus-visible { outline-color: #ffe1a5; outline-offset: -4px; }
#scene:active { cursor: grabbing; }
#scene.placing { cursor: crosshair; }
.loading { position: absolute; top: 50%; inset-inline: 0; text-align: center; color: var(--card); pointer-events: none; padding-inline: 20px; }
.scene-top, .scene-bottom { position: absolute; display: flex; }
.scene-top { top: 14px; left: 14px; }
.scene-bottom { bottom: 14px; right: 14px; gap: 8px; }
.picture.depth-on {
  box-shadow: 0 0 0 3px #2d201fa0, 0 18px 40px #1a0a128f, inset 0 -18px 40px #00000022;
}
.depth-controls #toggle-depth {
  min-width: 52px;
  font-size: 12px;
  letter-spacing: .04em;
  font-weight: 700;
}
.depth-controls #toggle-depth[aria-pressed="true"] {
  background: #fff0cb30;
  color: #ffe7b0;
}
.glass { background: #132923ef; color: #fff5df; border: 1px solid #f4d79765; border-radius: 8px; display: flex; align-items: center; }
.glass button {
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  min-width: 40px;
  min-height: 40px;
  padding: 0 7px;
  border-radius: 6px;
  color: inherit;
}
.glass button:hover:not(:disabled) { background: #fff0cb24; }
.glass button:focus-visible { outline-color: #ffe1a5; outline-offset: -3px; }
.zoom-controls > button { font-size: 20px; }
.zoom-controls #reset-view { font-size: 12px; font-variant-numeric: tabular-nums; min-width: 52px; }
.placement, .edit-item {
  position: absolute;
  top: 14px;
  right: 14px;
  max-width: calc(100% - 103px);
  padding-left: 10px;
  font-size: 12px;
}
.placement button { margin-left: 7px; color: #ffdb90; font-size: 12px; white-space: nowrap; }
.edit-item > span { margin-right: 6px; }
.swatches { display: grid; grid-template-columns: repeat(3, 24px); }
.swatches button { min-width: 24px; min-height: 22px; padding: 0; }
.swatches button::after {
  content: "";
  width: 13px;
  height: 13px;
  border: 1px solid #fff8dd99;
  border-radius: 50%;
  background: var(--swatch);
}
.swatches button[aria-pressed="true"]::after { outline: 1px solid #fff5dd; outline-offset: 2px; }
.overlap { position: absolute; z-index: 2; max-width: calc(100% - 18px); flex-wrap: wrap; padding: 4px; }
.overlap img { width: 25px; height: 30px; object-fit: contain; }
.studio-footer { display: flex; align-items: center; justify-content: space-between; gap: 9px; padding: 12px 0 0; }
.studio-footer p { font-size: 12px; color: #f6ddb7; }
.lights { display: flex; align-items: center; gap: 6px; }
.lights > span:first-child { color: var(--gold); font-size: 18px; }
.lights-label { color: #f6ddb7; font-size: 12px; white-space: nowrap; margin-right: 2px; }
.materials-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 5px; }
.material-count { color: var(--muted); font-size: 11px; }
.categories { display: flex; justify-content: space-between; gap: 2px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.categories button {
  flex: 0 0 auto;
  background: none;
  border: 0;
  font-size: 12px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 6px 3px 8px;
}
.categories button[aria-pressed="true"] { color: var(--ruby); border-color: var(--ruby); font-weight: 700; }
.item-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  max-height: clamp(430px, calc(100svh - 291px), 720px);
  overflow-y: auto;
  scrollbar-color: #b68e5e #ecdcb9;
  scrollbar-width: thin;
  padding: 3px;
  margin: -3px;
}
.item-option {
  display: grid;
  justify-items: center;
  align-items: center;
  gap: 5px;
  min-width: 0;
  min-height: 85px;
  padding: 6px 2px;
  border: 1px solid #e4d7bc;
  border-radius: 8px;
  background: radial-gradient(ellipse at 50% 40%, #fffaee, #eee1c6);
  font-size: 10px;
  line-height: 1.18;
}
.item-option img { width: 96%; max-width: 50px; height: 49px; object-fit: contain; filter: drop-shadow(0 3px 2px #54402232); pointer-events: none; }
.item-option:hover { border-color: var(--brass); }
.item-option[aria-pressed="true"] { border-color: var(--ruby); box-shadow: inset 0 0 0 1px var(--ruby); background: #f5e1d5; }
.photo-dialog { border: 1px solid var(--line); border-radius: 14px; padding: 16px; color: var(--evergreen); background: var(--card); width: min(740px, calc(100% - 24px)); }
.photo-dialog::backdrop { background: #0c211dd1; }
.photo-heading, .photo-actions { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.photo-heading { margin-bottom: 11px; }
.photo-actions { margin-top: 12px; }
.close { border: 0; background: transparent; font-size: 23px; min-width: 42px; min-height: 42px; }
.photo-paper { display: grid; place-items: center; background: #eee0c4; padding: 7px; border-radius: 6px; }
.photo-paper canvas { display: block; max-width: 100%; max-height: 64svh; width: auto; height: auto; object-fit: contain; }
.photo-status { margin-top: 8px; color: var(--muted); }
.help-dialog { width: min(620px, calc(100% - 24px)); max-height: calc(100svh - 32px); overflow-y: auto; overscroll-behavior: contain; padding: 20px; border: 1px solid var(--gold); border-radius: 14px; background: var(--card); color: var(--evergreen); box-shadow: 0 20px 70px #180a1580; }
.help-dialog::backdrop { background: #0c211dd1; }
.help-dialog h2 { font-size: 24px; }
.help-intro { color: var(--muted); line-height: 1.8; }
.help-steps { margin: 18px 0; padding-left: 26px; }
.help-steps li { padding-left: 5px; margin-bottom: 15px; }
.help-steps li::marker { color: var(--ruby); font-weight: 700; }
.help-steps h3 { margin: 0 0 4px; font-size: 15px; }
.help-steps p, .help-shortcuts p { font-size: 13px; line-height: 1.8; color: var(--muted); }
.help-shortcuts { border-top: 1px solid var(--line); padding-top: 12px; }
.help-shortcuts summary { cursor: pointer; padding-block: 4px; font-weight: 600; }
.help-shortcuts p { margin-top: 8px; }
.help-actions { display: flex; justify-content: flex-end; margin-top: 18px; }
@media (max-width: 1050px) {
  .workshop { padding-inline: 18px; gap: 11px; grid-template-columns: 165px minmax(0, 1fr) 198px; }
  .masthead { padding-inline: 21px; }
  .panel { padding: 11px; }
  .tree-option { grid-template-columns: 42px 1fr; gap: 5px; }
  .item-options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .masthead-actions { right: 20px; }
  .studio-footer { flex-wrap: wrap; }
}
@media (max-width: 780px) {
  .masthead { padding: 12px 12px 8px; min-height: 93px; margin-bottom: 8px; flex-direction: column; gap: 12px; }
  .masthead::before, .masthead::after { top: -4px; width: min(26vw, 190px); }
  .masthead-actions { position: static; }
  .masthead-actions .save-state { display: none; }
  .brand-copy h1::before, .brand-copy h1::after { display: none; }
  .masthead-actions { gap: 8px; }
  .brand-copy p { font-size: 10px; margin-top: 3px; }
  .workshop { display: flex; flex-direction: column; padding: 0 10px 22px; gap: 10px; }
  .workshop > * { width: 100%; }
  .trees {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 8px;
    align-items: center;
    padding: 8px;
  }
  .trees h2 { font-size: 16px; grid-column: 1; margin: 0 0 5px; }
  .tree-options { grid-row: 2; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .tree-option { display: flex; flex-direction: column; gap: 1px; min-height: 65px; text-align: center; padding: 3px 1px; }
  .tree-option img { height: 40px; }
  .tree-option strong { font-size: 11px; white-space: nowrap; }
  .tree-option small { display: none; }
  .starts { grid-column: 2; grid-row: 2; margin: 0; align-self: end; padding-bottom: 4px; }
  .starts .segmented button { padding-inline: 5px; }
  .backdrops {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 58px minmax(0,1fr);
    align-items: center;
    gap: 5px;
    margin: 7px 0 0;
  }
  .trees .backdrops h2 { font-size: 12px; margin: 0; }
  .backdrop-option {
    grid-template-columns: 24px minmax(0,1fr);
    min-height: 32px;
    gap: 3px;
    padding: 3px;
    align-items: center;
    text-align: center;
  }
  .inspiration { grid-column: 1 / -1; margin-top: 5px; padding-top: 4px; }
  .inspiration summary { padding-block: 2px; min-height: 24px; }
  .picture { height: clamp(340px, 46svh, 530px); }
  .studio-footer { padding-top: 7px; justify-content: space-between; }
  .materials { padding: 10px; }
  .materials h2 { font-size: 17px; margin-bottom: 5px; }
  .categories { justify-content: flex-start; gap: 14px; margin-bottom: 8px; }
  .item-options { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 63px; overflow-x: auto; max-height: none; padding: 3px 3px 7px; }
  .item-option { min-height: 71px; }
  .item-option img { height: 39px; }
  .primary { padding-inline: 11px; }
}
@media (max-width: 390px) {
  .studio-footer p { flex: 1 1 125px; font-size: 11px; }
  .lights-label, .lights > span:first-child { display: none; }
  .masthead-actions .save-state { display: none; }
  .edit-item > span { max-width: 52px; }
  .edit-item > button { min-width: 34px; }
}
.studio-link { color: #ffe3ad; font-weight: 650; text-underline-offset: 4px; white-space: nowrap; }
@media (min-width:781px) and (max-width:1120px) { .masthead-actions .save-state { display:none; } }
