/* =========================================================================
   Painting, Lately — stylesheet
   Each painting hangs in its own room: a deep wall in a colour taken from the
   painting, a museum wall label beside it, and nothing else in the way. The
   interface is a quiet drawer of stickers on the left and a small floating
   dock under the painting. One accent: Vermeer's ultramarine.
   ========================================================================= */

/* ---------- 1. Tokens ---------- */
:root {
  --ui: #F8F7F4;             /* top bar and drawer */
  --ui-raised: #FFFFFF;
  --ui-line: #E4E0D8;
  --ui-hover: #EFEDE7;
  --ink: #191817;
  --muted: #5E5A53;          /* 6.4:1 on --ui */
  --control-line: #8A8378;   /* 3.5:1 on --ui: borders that identify a control */
  --accent: #2B47A6;         /* ultramarine, Vermeer's most precious blue */
  --accent-hover: #213A8C;
  --accent-soft: rgba(43, 71, 166, 0.09);
  --wall: #2f3a42;           /* set per painting by app.js */
  --wall-ink: #EEE9E0;
  --wall-muted: #B8B1A5;
  --placard: #F3EFE7;
  --focus: #2B47A6;
  --focus-on-wall: #F2C14E;
  --danger: #A12C22;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --out: cubic-bezier(.22, 1, .36, 1);          /* settles smoothly */
  --spring: cubic-bezier(.34, 1.56, .64, 1);     /* overshoots a touch */
  --fast: 180ms;
  --top-h: 64px;
  --drawer-w: 356px;
  --ratio: 0.8981;           /* painting width / height, set per painting by app.js */
  --handle: 30px;
  /* The painting's height: the window minus the top bar and room for the dock. */
  --art-h: max(340px, calc(100vh - var(--top-h) - 150px));
}
@supports (height: 1svh) { :root { --art-h: max(340px, calc(100svh - var(--top-h) - 150px)); } }
@media (pointer: coarse) { :root { --handle: 44px; } }

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15.5px/1.5 var(--sans); color: var(--ink); background: var(--ui); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p, figure, ol { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
img { max-width: 100%; }
button, input { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); text-underline-offset: 3px; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.canvas-area :focus-visible, .dock :focus-visible, .toolbar :focus-visible, .coach :focus-visible { outline-color: var(--focus-on-wall); }
.placard :focus-visible, .popover :focus-visible, .sheet :focus-visible { outline-color: var(--focus); }
[tabindex="-1"]:focus { outline: none; }
[tabindex="-1"]:focus-visible { outline: 2px dashed var(--focus); outline-offset: 4px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.skip-link { position: absolute; left: 16px; top: -100px; z-index: 80; padding: 8px 14px; background: var(--ui-raised); border: 2px solid var(--focus); border-radius: 8px; }
.skip-link:focus { top: 8px; }
.muted { color: var(--muted); }

/* ---------- 3. Controls ---------- */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 9px 18px;
  border: 1px solid var(--control-line); border-radius: 12px;
  background: var(--ui-raised); color: var(--ink);
  font-weight: 600; font-size: 15px; line-height: 1.2; cursor: pointer;
  transition: background-color var(--fast), border-color var(--fast), color var(--fast), transform 260ms var(--spring), box-shadow var(--fast);
}
.button:hover { border-color: var(--ink); }
.button:active { transform: scale(0.97); }
.button--quiet { border-color: transparent; background: transparent; }
.button--quiet:hover { background: var(--ui-hover); border-color: transparent; }
.button--primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 6px 16px -8px rgba(43, 71, 166, 0.7); }
.button--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.button--danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.button--block { width: 100%; }
.button--large { width: 100%; min-height: 52px; font-size: 16.5px; }
.button[aria-disabled="true"], .link-button[aria-disabled="true"], .dock__button[aria-disabled="true"] { opacity: 0.4; cursor: not-allowed; }
.button[aria-disabled="true"]:active, .dock__button[aria-disabled="true"]:active { transform: none; }
.button--primary[aria-disabled="true"]:hover { background: var(--accent); border-color: var(--accent); }

.ghost-button, .link-button {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px;
  border: 0; border-radius: 10px; background: none; color: var(--ink); font-weight: 600; font-size: 15px; cursor: pointer;
  transition: background-color var(--fast);
}
.ghost-button:hover, .link-button:hover { background: var(--ui-hover); }
.help-button { gap: 8px; }
.help-button__icon { display: grid; place-items: center; width: 22px; height: 22px; border: 1.5px solid currentColor; border-radius: 50%; font-size: 13px; font-weight: 700; }
.link-button { padding: 0 8px; margin-left: -8px; }
.text-link { font-weight: 600; }
.close-button {
  display: grid; place-items: center; width: 36px; height: 36px; flex: none; border: 0; border-radius: 50%;
  background: none; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; transition: background-color var(--fast);
}
.close-button:hover { background: var(--ui-hover); color: var(--ink); }
@media (pointer: coarse) { .close-button { width: 44px; height: 44px; } }

/* ---------- 4. Top bar ---------- */
.topbar {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 16px;
  height: var(--top-h); padding-inline: 20px; background: var(--ui); border-bottom: 1px solid var(--ui-line);
}
.brand { display: flex; align-items: baseline; gap: 12px; min-width: 0; white-space: nowrap; }
.brand__name { font-family: var(--serif); font-size: 20px; font-weight: 700; letter-spacing: 0.005em; }
.brand__sub { overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 14px; }
.topbar__end { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.topbar__frame { min-width: 118px; }
body[data-view="result"] .topbar__frame, body[data-view="result"] .rooms { visibility: hidden; }

/* The three rooms: a thumbnail and a name each. */
.rooms { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--ui-hover); }
.painting-choice {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 14px 4px 4px; border: 0; border-radius: 10px;
  background: none; cursor: pointer; text-align: left; color: var(--muted); font-weight: 600; font-size: 14px;
  transition: background-color var(--fast), color var(--fast), box-shadow var(--fast);
}
.painting-choice img { display: block; width: 38px; height: 38px; object-fit: cover; border-radius: 7px; transition: transform 300ms var(--spring); }
.painting-choice:hover { color: var(--ink); }
.painting-choice:hover img { transform: scale(1.06); }
.painting-choice__meta { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.painting-choice[aria-pressed="true"] { background: var(--ui-raised); color: var(--ink); box-shadow: 0 1px 3px rgba(25, 24, 23, 0.14); }

main[data-state="booting"] .view { visibility: hidden; }
.boot-notice { display: none; }
main[data-state="booting"] .boot-notice { display: block; max-width: 60ch; margin: 24px; padding: 16px; border: 1px solid var(--control-line); animation: boot-notice 0.01s 2.5s both; }
@keyframes boot-notice { from { visibility: hidden; } to { visibility: visible; } }

/* ---------- 5. Editor layout ---------- */
.editor { display: grid; grid-template-columns: var(--drawer-w) minmax(0, 1fr); height: calc(100vh - var(--top-h)); min-height: 520px; }
@supports (height: 1svh) { .editor { height: calc(100svh - var(--top-h)); } }
.editor--result { grid-template-columns: 380px minmax(0, 1fr); }

/* ---------- 6. The drawer ---------- */
.drawer { min-width: 0; overflow-y: auto; overscroll-behavior: contain; background: var(--ui); border-right: 1px solid var(--ui-line); }
.drawer__tabs {
  position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 8px 14px 0; background: var(--ui); border-bottom: 1px solid var(--ui-line);
}
.drawer__tab { min-height: 46px; border: 0; background: none; color: var(--muted); font-weight: 600; font-size: 14.5px; cursor: pointer; transition: color var(--fast); }
.drawer__tab:hover, .drawer__tab[aria-selected="true"] { color: var(--ink); }
.drawer__indicator {
  position: absolute; left: 14px; bottom: -1px; width: calc((100% - 28px) / 3); height: 2px; border-radius: 2px; background: var(--ink);
  transform: translateX(calc(var(--tab-index, 0) * 100%)); transition: transform 420ms var(--out);
}
.panel { display: grid; gap: 16px; align-content: start; padding: 18px 18px 44px; animation: panel-in 320ms var(--out); }
/* Entrances move but never start invisible: content must show even if an animation never runs. */
@keyframes panel-in { from { transform: translateY(6px); } to { transform: none; } }
.panel__title { font-family: var(--serif); font-size: 26px; font-weight: 700; line-height: 1.15; }
.panel__count { margin-left: 6px; font-size: 13.5px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.panel__lead { color: var(--muted); font-size: 14.5px; }
.panel__subtitle { font-size: 14px; font-weight: 650; color: var(--ink); }
.panel__hint { color: var(--muted); font-size: 14px; }
.panel__hint:empty { display: none; }
.panel__fine { color: var(--muted); font-size: 13px; }

/* Sticker tiles: the sticker itself, no box, lifting when you reach for it. */
.tray-groups { display: grid; gap: 26px; }
.shelf { display: grid; gap: 8px; }
.tile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.prop-tile {
  position: relative; display: grid; gap: 6px; justify-items: center; align-content: start;
  width: 100%; height: 100%; padding: 10px 6px 10px; border: 0; border-radius: 16px;
  background: none; cursor: pointer; text-align: center; transition: background-color var(--fast), box-shadow var(--fast);
}
.prop-tile:hover { background: var(--ui-hover); }
.prop-tile__thumb { display: grid; place-items: center; width: 100%; height: 108px; touch-action: none; cursor: grab; }
.prop-tile__thumb img {
  max-width: 88%; max-height: 100px; object-fit: contain; pointer-events: none; -webkit-user-drag: none; user-select: none;
  filter: drop-shadow(2px 4px 4px rgba(25, 15, 6, 0.3)); transition: transform 380ms var(--spring), filter 380ms var(--out);
}
.prop-tile:hover .prop-tile__thumb img { transform: translateY(-5px) rotate(-3deg) scale(1.05); filter: drop-shadow(5px 10px 9px rgba(25, 15, 6, 0.28)); }
.prop-tile:active .prop-tile__thumb img { transform: scale(0.96); }
.prop-tile__label { font-size: 13px; font-weight: 600; line-height: 1.25; color: var(--ink); overflow-wrap: anywhere; }
.prop-tile[aria-pressed="true"] { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }

.placement { display: grid; gap: 8px; padding: 14px; border-radius: 14px; background: var(--accent-soft); animation: panel-in 260ms var(--out); }
.placement__text { font-weight: 600; }
.placement__buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.placement__buttons .button--primary { flex: 1 1 auto; }
.cap-warning { padding: 10px 12px; border-radius: 10px; background: #F6E2DE; color: var(--danger); font-weight: 600; font-size: 14.5px; }

.mine { display: grid; gap: 8px; margin-top: 4px; }
.sticker-tile { display: grid; justify-items: stretch; gap: 0; }
.sticker-tile__delete {
  justify-self: center; min-height: 32px; padding: 0 10px; border: 0; border-radius: 8px; background: none; cursor: pointer;
  color: var(--danger); font-size: 13px; font-weight: 600;
}
.sticker-tile__delete:hover { background: #F6E2DE; }
@media (pointer: coarse) { .sticker-tile__delete { min-height: 44px; } }

/* Captions */
.field { display: grid; gap: 6px; }
.field__label { font-weight: 650; font-size: 14.5px; }
.field__input { width: 100%; min-height: 48px; padding: 10px 14px; border: 1px solid var(--control-line); border-radius: 12px; background: var(--ui-raised); font-size: 17px; font-family: var(--serif); transition: border-color var(--fast), box-shadow var(--fast); }
.field__input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); outline: none; }
.field__input::placeholder { color: #7A746A; opacity: 1; font-style: italic; }
.field__help { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 13px; }
.field__count { font-variant-numeric: tabular-nums; }
.caption-ideas, .caption-styles { display: grid; gap: 8px; }
.idea-list { display: flex; flex-wrap: wrap; gap: 6px; }
.idea {
  min-height: 36px; padding: 4px 14px; border: 0; border-radius: 999px; background: var(--ui-hover); cursor: pointer;
  font-family: var(--serif); font-size: 15px; font-style: italic; transition: background-color var(--fast), transform 260ms var(--spring);
}
.idea:hover { background: #E5E2DA; }
.idea:active { transform: scale(0.96); }
@media (pointer: coarse) { .idea { min-height: 44px; } }
.segmented { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 4px; border-radius: 12px; background: var(--ui-hover); }
.segmented__button { min-height: 38px; padding: 4px 6px; border: 0; border-radius: 9px; background: none; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--muted); transition: background-color var(--fast), color var(--fast), box-shadow var(--fast); }
.segmented__button[aria-pressed="true"] { background: var(--ui-raised); color: var(--ink); box-shadow: 0 1px 3px rgba(25, 24, 23, 0.16); }
.caption-preview { display: grid; place-items: center; min-height: 150px; padding: 16px; border-radius: 16px; background: var(--wall); transition: background-color 600ms var(--out); }
.caption-preview canvas { display: block; max-width: 100%; height: auto; filter: drop-shadow(2px 3px 3px rgba(20, 12, 4, 0.4)); }
.caption-preview canvas.is-placeholder { opacity: 0.55; }

/* ---------- 7. The room ---------- */
.canvas-area {
  position: relative; min-width: 0; overflow: hidden; container-type: inline-size;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 28px 36px 104px; background-color: var(--wall); color: var(--wall-ink);
  transition: background-color 700ms var(--out);
}
/* A soft spotlight on the wall; the colour underneath changes smoothly per painting. */
.canvas-area::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 55% 60% at 46% 40%, rgba(255, 244, 222, 0.16), rgba(255, 244, 222, 0) 70%), linear-gradient(rgba(0, 0, 0, 0) 70%, rgba(0, 0, 0, 0.18));
}
.canvas-area:focus { outline: none; }
.room { position: relative; display: flex; align-items: flex-end; justify-content: center; gap: 28px; width: 100%; }
.artwork { flex: none; }
/* The stage is exactly the painting's box, sized to fit the room beside the label. */
.stage { position: relative; width: min(calc(100cqw - 72px - 248px), calc(var(--art-h) * var(--ratio))); }
.placard {
  position: relative; flex: none; display: grid; gap: 3px; width: 220px; margin-bottom: 6%; padding: 14px 16px 6px;
  background: var(--placard); color: var(--ink); border-radius: 3px; box-shadow: 0 14px 28px -16px rgba(0, 0, 0, 0.7);
  animation: placard-in 500ms var(--out);
}
@keyframes placard-in { from { transform: translateY(8px); } to { transform: none; } }
.placard__title { font-family: var(--serif); font-size: 18px; font-weight: 700; line-height: 1.2; }
.placard__meta { font-size: 13px; color: var(--muted); }
.placard__intro { margin-top: 6px; font-family: var(--serif); font-style: italic; font-size: 14.5px; line-height: 1.4; }
.placard__story {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: calc(100% + 16px); min-height: 44px; margin: 8px -8px 0; padding: 0 8px;
  border: 0; border-top: 1px solid #DCD6CA; border-radius: 0 0 6px 6px; background: none; cursor: pointer; text-align: left; font-size: 13.5px; font-weight: 650; color: var(--accent);
  transition: background-color var(--fast);
}
.placard__story::after { content: "▾"; font-size: 12px; transition: transform 300ms var(--out); }
.placard__story[aria-expanded="true"]::after { transform: rotate(180deg); }
.placard__story:hover { background: rgba(43, 71, 166, 0.06); }

/* The dock: undo, redo, before/after, layers. */
.dock {
  position: absolute; left: 50%; bottom: 22px; z-index: 4; display: flex; align-items: center; gap: 2px; padding: 5px;
  transform: translateX(-50%); border-radius: 16px; color: var(--wall-ink);
  background: rgba(18, 17, 16, 0.78); box-shadow: 0 16px 34px -14px rgba(0, 0, 0, 0.7), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
body[data-view="result"] .dock { display: none; }
.dock__button {
  display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 12px; border: 0; border-radius: 11px;
  background: none; color: inherit; font-weight: 600; font-size: 14px; cursor: pointer; transition: background-color var(--fast), transform 240ms var(--spring);
}
.dock__button:hover { background: rgba(255, 255, 255, 0.1); }
.dock__button:active { transform: scale(0.95); }
.dock__button[aria-expanded="true"] { background: rgba(255, 255, 255, 0.16); }
.dock__button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.dock__divider { width: 1px; height: 22px; margin-inline: 4px; background: rgba(255, 255, 255, 0.16); }
@media (pointer: coarse) { .dock__button { min-height: 44px; } }
.compare { display: inline-flex; gap: 2px; }
.compare__button {
  min-height: 40px; padding: 0 12px; border: 0; border-radius: 11px; background: none; cursor: pointer;
  color: rgba(238, 233, 224, 0.62); font-weight: 600; font-size: 14px; transition: background-color var(--fast), color var(--fast);
}
.compare__button:hover { color: var(--wall-ink); }
.compare__button[aria-pressed="true"] { color: var(--wall-ink); background: rgba(255, 255, 255, 0.16); }
@media (pointer: coarse) { .compare__button { min-height: 44px; } }
.compare--light { justify-self: start; padding: 4px; border-radius: 12px; background: var(--ui-hover); }
.compare--light .compare__button { color: var(--muted); }
.compare--light .compare__button:hover { color: var(--ink); }
.compare--light .compare__button[aria-pressed="true"] { color: var(--ink); background: var(--ui-raised); box-shadow: 0 1px 3px rgba(25, 24, 23, 0.16); }

/* Status: a short toast above the dock. */
.status {
  position: absolute; left: 50%; bottom: 84px; z-index: 4; max-width: min(520px, 86%); padding: 8px 16px;
  border-radius: 999px; background: rgba(18, 17, 16, 0.86); color: var(--wall-ink); font-size: 14px; text-align: center;
  pointer-events: none; opacity: 0; transform: translate(-50%, 8px); transition: opacity 260ms var(--out), transform 360ms var(--out);
}
.status.is-visible { opacity: 1; transform: translate(-50%, 0); }
.status:empty { visibility: hidden; }
.credit { position: absolute; right: 20px; bottom: 30px; z-index: 3; max-width: 230px; font-size: 12px; line-height: 1.35; text-align: right; color: var(--wall-muted); }
@media (max-width: 1240px) { .credit { display: none; } }

/* ---------- 8. Story menu and layers sheet ---------- */
.popover, .sheet {
  position: absolute; z-index: 6; display: grid; gap: 14px; align-content: start; padding: 18px;
  overflow-y: auto; overscroll-behavior: contain; background: #FBFAF7; color: var(--ink);
  border-radius: 18px; box-shadow: 0 30px 60px -24px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(0, 0, 0, 0.06);
}
.popover { animation: pop-in 300ms var(--out); }
/* The story menu opens beside the wall label it belongs to, over the painting's edge. */
.story-menu { right: calc(100% + 14px); bottom: -8px; width: 340px; max-height: calc(100vh - var(--top-h) - 120px); transform-origin: 100% 100%; text-align: left; }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(0.97); } to { opacity: 1; transform: none; } }
.sheet { top: 16px; right: 16px; bottom: 92px; width: 340px; animation: sheet-in 380ms var(--out); }
@keyframes sheet-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
.popover__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.popover__title { font-size: 17px; font-weight: 700; }
.popover__lead { margin-top: -8px; color: var(--muted); font-size: 13.5px; }

.stories { display: grid; gap: 8px; }
.chip {
  position: relative; display: grid; gap: 2px; width: 100%; min-height: 44px; padding: 12px 40px 12px 14px;
  border: 1px solid var(--ui-line); border-radius: 14px; background: var(--ui-raised); text-align: left; cursor: pointer;
  transition: border-color var(--fast), box-shadow var(--fast), transform 260ms var(--spring);
}
.chip:hover { border-color: var(--control-line); }
.chip:active { transform: scale(0.98); }
.chip__label { font-size: 15.5px; font-weight: 650; }
.chip__prompt { font-family: var(--serif); font-size: 14px; font-style: italic; color: var(--muted); }
.chip[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.chip[aria-pressed="true"]::after { content: "✓"; position: absolute; right: 14px; top: 12px; color: var(--accent); font-weight: 800; }
.example { display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--ui-line); }
.example__pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: center; }
.scene--thumb { border-radius: 4px; box-shadow: 0 0 0 1px rgba(25, 24, 23, 0.14); }

.item-list { display: flex; flex-wrap: wrap; gap: 6px; }
.item-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 4px 12px 4px 6px;
  border: 1px solid var(--ui-line); border-radius: 12px; background: var(--ui-raised); font-weight: 600; font-size: 14px; cursor: pointer;
}
.item-chip img { width: 30px; height: 28px; object-fit: contain; }
.item-chip[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.adjust { display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--ui-line); }
.adjust-groups { display: grid; gap: 14px; }
.adjust-group { display: grid; gap: 6px; }
.adjust-group__label { font-size: 13px; font-weight: 600; color: var(--muted); }
.adjust-group__row { display: flex; flex-wrap: wrap; gap: 6px; }
.adjust-group__row .button, .dpad .button { border-color: var(--ui-line); background: var(--ui-raised); }
.dpad { display: grid; grid-template-columns: repeat(3, minmax(56px, auto)); grid-template-areas: ". up ." "left center right" ". down ."; gap: 4px; justify-content: start; }
.dpad .button { padding-inline: 8px; }
.dpad__up { grid-area: up; } .dpad__left { grid-area: left; } .dpad__center { grid-area: center; }
.dpad__right { grid-area: right; } .dpad__down { grid-area: down; }

/* ---------- 9. The painting ---------- */
.scene {
  position: relative; width: 100%; aspect-ratio: 2000 / 2227; background: #3a3b36;
  box-shadow: 0 30px 60px -24px rgba(0, 0, 0, 0.75), 0 3px 8px rgba(0, 0, 0, 0.35);
}
.stage .scene { view-transition-name: artwork; }
.scene__painting { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-select: none; -webkit-user-drag: none; transition: opacity 260ms ease; }
.scene[data-image="loading"] .scene__painting { opacity: 0.25; }
.scene[data-image="error"] .scene__painting { visibility: hidden; }
/* Props are clipped at the painting edge, exactly as in the exported PNG. */
.scene__clip { position: absolute; inset: 0; overflow: hidden; }
.prop {
  position: absolute; display: block; height: auto; max-width: none; transform-origin: 50% 50%;
  pointer-events: none; user-select: none; -webkit-user-select: none; -webkit-user-drag: none;
  /* Light comes from the left in all three paintings, so shadows fall right. */
  filter: drop-shadow(3px 4px 4px rgba(25, 15, 6, 0.38));
}
.prop.is-flipped { filter: drop-shadow(-3px 4px 4px rgba(25, 15, 6, 0.38)); } /* mirrored with the prop, so mirror it back */
.prop.is-new { animation: settle 420ms var(--spring); }
@keyframes settle { 0% { scale: 1.16; opacity: 0.5; } 55% { scale: 0.97; opacity: 1; } 100% { scale: 1; } }
.scene--thumb .prop { filter: drop-shadow(1px 1px 1px rgba(25, 15, 6, 0.35)); }
/* Only placed props capture touch; the rest of the page keeps scrolling. */
.scene--interactive .prop { pointer-events: auto; cursor: grab; touch-action: none; }
.stage.is-moving .prop, .stage.is-moving .scene { cursor: grabbing; }
.stage.is-armed .scene, .stage.is-armed .prop { cursor: crosshair; }
.stage.is-armed .scene::after, .stage.is-drop-target .scene::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 0 3px rgba(242, 193, 78, 0.95); animation: fade-in 200ms ease-out;
}

/* Selection: an unclipped layer over the same box, so handles can sit outside it. */
.handles { position: absolute; inset: 0; pointer-events: none; }
.selection { position: absolute; outline: 1px solid rgba(255, 250, 240, 0.95); box-shadow: 0 0 0 2px rgba(25, 24, 23, 0.7); animation: fade-in 160ms ease-out; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.handle { position: absolute; width: var(--handle); height: var(--handle); margin: calc(var(--handle) / -2) 0 0 calc(var(--handle) / -2); pointer-events: auto; touch-action: none; }
.handle::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 13px; height: 13px; margin: -6.5px 0 0 -6.5px;
  background: #fff; border: 2px solid var(--accent); border-radius: 50%; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  transition: transform 200ms var(--spring);
}
.handle:hover::after { transform: scale(1.25); }
.handle--corner[data-corner="nw"] { left: -4px; top: -4px; cursor: nwse-resize; }
.handle--corner[data-corner="ne"] { left: calc(100% + 4px); top: -4px; cursor: nesw-resize; }
.handle--corner[data-corner="sw"] { left: -4px; top: calc(100% + 4px); cursor: nesw-resize; }
.handle--corner[data-corner="se"] { left: calc(100% + 4px); top: calc(100% + 4px); cursor: nwse-resize; }
.handle--rotate { left: 50%; top: -36px; cursor: grab; }
.handle--rotate::before { content: ""; position: absolute; left: 50%; top: 50%; width: 1.5px; height: 30px; margin-left: -0.75px; background: rgba(255, 250, 240, 0.9); }
.toolbar {
  position: absolute; left: 0; top: 0; z-index: 2; display: flex; gap: 2px; padding: 4px; border-radius: 12px;
  background: rgba(18, 17, 16, 0.92); color: var(--wall-ink); box-shadow: 0 12px 26px -10px rgba(0, 0, 0, 0.7);
  pointer-events: auto; animation: toolbar-in 220ms var(--out);
}
@keyframes toolbar-in { from { opacity: 0; transform: translateY(4px); } }
.stage.is-gesturing .toolbar { visibility: hidden; }
.toolbar__button { min-height: 34px; padding: 4px 12px; border: 0; border-radius: 8px; background: transparent; color: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap; transition: background-color var(--fast); }
.toolbar__button:hover { background: rgba(255, 255, 255, 0.12); }
.toolbar__button--danger { color: #F4A99F; }
@media (pointer: coarse) { .toolbar__button { min-height: 44px; } }

.drag-ghost {
  position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none;
  transform: translate(-50%, -50%) rotate(calc(-2deg + var(--tilt, 0deg))) scale(1.06);
  filter: drop-shadow(8px 16px 14px rgba(20, 12, 4, 0.45)); opacity: 0.78;
  transition: opacity var(--fast), transform 120ms linear;
}
.drag-ghost.is-over { opacity: 1; transform: translate(-50%, -50%) rotate(var(--tilt, 0deg)) scale(1); }
body.is-dragging-prop { cursor: grabbing; user-select: none; -webkit-user-select: none; }

.image-error { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 14px; padding: 12px 16px; border-radius: 12px; background: #F6E2DE; color: var(--ink); }

/* ---------- 10. Guidance ---------- */
.coach {
  position: fixed; z-index: 60; width: 300px; padding: 14px 16px 12px; border-radius: 16px;
  background: #171615; color: var(--wall-ink); box-shadow: 0 22px 44px -18px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.coach.is-in { animation: coach-in 420ms var(--out); }
@keyframes coach-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.coach::before { content: ""; position: absolute; width: 14px; height: 14px; background: #171615; transform: rotate(45deg); }
.coach[data-side="none"]::before { display: none; }
.coach[data-side="right"]::before { left: -6px; top: calc(50% - 7px); }
.coach[data-side="below"]::before { top: -6px; left: calc(var(--arrow-x, 50%) - 7px); }
.coach[data-side="above"]::before { bottom: -6px; left: calc(var(--arrow-x, 50%) - 7px); }
.coach__step { font-size: 12.5px; color: var(--wall-muted); }
.coach__text { margin-top: 2px; font-size: 15px; line-height: 1.45; }
.coach__buttons { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.coach__skip { min-height: 36px; padding: 0 6px; border: 0; background: none; color: var(--wall-muted); font-size: 13.5px; cursor: pointer; }
.coach__skip:hover { color: var(--wall-ink); }
.coach__next { min-height: 36px; padding: 0 14px; border: 0; border-radius: 10px; background: var(--wall-ink); color: #171615; font-weight: 650; font-size: 14px; cursor: pointer; transition: transform 240ms var(--spring); }
.coach__next:active { transform: scale(0.96); }
@media (pointer: coarse) { .coach__skip, .coach__next { min-height: 44px; } }
.coach-ghost { position: fixed; left: 0; top: 0; z-index: 59; pointer-events: none; filter: drop-shadow(8px 16px 14px rgba(20, 12, 4, 0.45)); opacity: 0; }

/* ---------- 11. Result ---------- */
.drawer--result .panel { gap: 18px; padding-top: 22px; }
.canvas-area--result { padding: 28px 36px; }
.canvas-area--result::before { background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(255, 244, 222, 0.14), rgba(255, 244, 222, 0) 70%); }
.framed { width: min(100%, calc((var(--art-h) - 40px) * var(--ratio) + 64px)); display: grid; gap: 16px; }
.framed__mat { padding: clamp(14px, 2.4vw, 32px); background: #F6F1E7; box-shadow: 0 30px 60px -22px rgba(0, 0, 0, 0.8); }
.framed__mat .scene { box-shadow: 0 0 0 1px rgba(90, 70, 40, 0.35); view-transition-name: artwork; }
.framed__label { display: grid; gap: 4px; color: var(--wall-ink); }
.framed__title { font-family: var(--serif); font-weight: 600; font-size: clamp(20px, 2vw, 26px); line-height: 1.2; overflow-wrap: anywhere; }
.framed__credit { font-size: 14px; color: var(--wall-muted); }
.download { display: grid; gap: 8px; }
.download__note { font-size: 14px; color: var(--muted); }
.download__status { font-size: 14px; }
.download__status:empty { display: none; }
.download__status.is-error { color: var(--danger); font-weight: 600; }
.download__extra { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.download__extra:not(:has(:not([hidden]))) { display: none; }
.link-button--back { justify-self: start; color: var(--muted); }
.mood { display: grid; gap: 6px; padding: 16px; border-radius: 16px; background: var(--ui-hover); }
.mood__name { font-family: var(--serif); font-size: 19px; font-weight: 700; }
.mood__prompt { font-family: var(--serif); font-style: italic; color: var(--muted); }
.mood__props { display: flex; gap: 8px; margin: 4px 0; }
.mood__props img { width: 44px; height: 42px; object-fit: contain; filter: drop-shadow(1px 2px 2px rgba(25, 15, 6, 0.3)); }
.mood .button { justify-self: start; }
.fresh { display: grid; justify-items: start; }

/* Smooth changes between paintings and into the frame. */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 320ms; animation-timing-function: var(--out); }
::view-transition-group(artwork) { animation-duration: 520ms; animation-timing-function: var(--out); }

/* ---------- 12. Dialogs ---------- */
.dialog { width: min(92vw, 440px); padding: 0; border: 0; border-radius: 18px; background: #FBFAF7; color: var(--ink); box-shadow: 0 30px 70px -24px rgba(0, 0, 0, 0.7); }
.dialog[open] { animation: pop-in 320ms var(--out); }
.dialog::backdrop { background: rgba(18, 17, 16, 0.6); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.dialog__form { display: grid; gap: 14px; padding: 24px; }
.dialog__title { font-family: var(--serif); font-size: 21px; }
.dialog__message:empty { display: none; }
.dialog__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.dialog__actions .button { flex: 1 1 auto; }
.dialog--wide { width: min(94vw, 760px); }
.sticker { display: grid; gap: 14px; padding: 22px; }
.sticker__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sticker__step { display: grid; gap: 12px; }
.sticker__status { min-height: 1.4em; font-size: 15px; color: var(--muted); }
.sticker__status.is-error { color: var(--danger); font-weight: 600; }
.sticker__buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.sticker__buttons .button--primary { margin-left: auto; }
.sticker__paint { display: flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 600; cursor: pointer; }
.sticker__paint input { width: 20px; height: 20px; accent-color: var(--accent); }
.sticker__video { display: block; width: 100%; max-height: 58vh; border-radius: 10px; background: #1d1f1d; transform: scaleX(-1); /* mirror view; the photo is mirrored the same way */ }
/* The canvas keeps its own ratio: auto size, capped by both max values. */
.sticker__canvas { display: block; width: auto; height: auto; max-width: 100%; max-height: 54vh; margin-inline: auto; border-radius: 8px; touch-action: none; cursor: crosshair; background: repeating-conic-gradient(#e2dccf 0 25%, #f3eee5 0 50%) 0 0 / 20px 20px; }

/* Welcome */
.dialog--welcome { width: min(94vw, 900px); overflow: hidden; }
.welcome { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
.welcome__art { display: grid; place-items: center; padding: 34px; background: var(--wall); }
.welcome__pair { position: relative; width: min(100%, 300px); }
.welcome__pair .scene { box-shadow: 0 24px 44px -18px rgba(0, 0, 0, 0.8); }
/* The remix wipes across the original and back: before, after, before. */
.welcome__remix { position: absolute !important; inset: 0; animation: wipe 6s var(--out) infinite; }
@keyframes wipe { 0%, 14% { clip-path: inset(0 100% 0 0); } 40%, 78% { clip-path: inset(0 0 0 0); } 100% { clip-path: inset(0 100% 0 0); } }
.welcome__text { display: grid; gap: 18px; align-content: center; padding: 38px 36px; }
.welcome__kicker { font-size: 13.5px; font-weight: 650; color: var(--accent); }
.welcome__title { margin-top: -10px; font-family: var(--serif); font-size: 31px; line-height: 1.12; }
.welcome__steps { display: grid; gap: 12px; padding: 0; list-style: none; counter-reset: step; }
.welcome__steps li { position: relative; padding-left: 40px; color: var(--muted); font-size: 15px; counter-increment: step; }
.welcome__steps li::before {
  content: counter(step); position: absolute; left: 0; top: -1px; display: grid; place-items: center; width: 27px; height: 27px;
  border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13.5px;
}
.welcome__steps strong { color: var(--ink); font-weight: 650; }
.welcome__buttons { display: grid; gap: 4px; justify-items: start; margin-top: 4px; }
.welcome__buttons .button { width: auto; padding-inline: 26px; }

/* ---------- 13. Medium screens ---------- */
@media (max-width: 1099px) {
  :root { --drawer-w: 300px; }
  .brand__sub { display: none; }
  .painting-choice { padding-right: 4px; }
  .painting-choice__title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .editor--result { grid-template-columns: 320px minmax(0, 1fr); }
  .room { flex-direction: column; align-items: center; gap: 14px; }
  .stage { width: min(100cqw - 48px, calc((var(--art-h) - 90px) * var(--ratio))); }
  .placard { width: auto; max-width: 100%; margin: 0; grid-template-columns: auto 1fr auto; align-items: baseline; column-gap: 10px; padding: 8px 8px 8px 14px; }
  .placard__intro { display: none; }
  .placard__story { width: auto; margin: 0; border: 0; border-radius: 8px; }
  .story-menu { right: auto; left: 50%; bottom: calc(100% + 12px); margin-left: -170px; transform-origin: 50% 100%; }
  .canvas-area { padding-inline: 24px; }
}

/* ---------- 14. Phones: the painting, then the drawer ---------- */
@media (max-width: 759px) {
  :root { --art-h: 56vh; --top-h: auto; }
  @supports (height: 1svh) { :root { --art-h: 56svh; } }
  .topbar { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "brand end" "rooms rooms"; row-gap: 8px; height: auto; padding: 10px 14px; }
  .brand { grid-area: brand; }
  .brand__name { font-size: 19px; }
  .topbar__end { grid-area: end; gap: 4px; }
  .help-button { width: 44px; justify-content: center; padding: 0; }
  .help-button__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .topbar__frame { min-width: 0; }
  .rooms { grid-area: rooms; justify-content: space-between; }
  .painting-choice { flex: 1; justify-content: center; padding: 4px; }
  .editor, .editor--result { display: flex; flex-direction: column; height: auto; min-height: 0; }
  /* No size container here: it would trap the bottom sheets below inside it. */
  .canvas-area { order: 1; overflow: visible; padding: 18px 14px 90px; container-type: normal; }
  .stage { width: min(100%, calc(var(--art-h) * var(--ratio))); }
  .placard { grid-template-columns: 1fr auto; }
  .placard__meta { display: none; }
  .drawer { order: 2; overflow: visible; border-right: 0; }
  .drawer__tabs { top: 0; }
  .panel { padding: 16px 14px 32px; }
  .tile-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .credit { display: block; position: static; max-width: none; margin-top: 12px; text-align: center; }
  .dock { bottom: 16px; max-width: calc(100% - 28px); }
  /* Icons only on phones; the words stay for screen readers. */
  .dock__button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .dock__button { padding: 0 11px; }
  .compare__button { padding: 0 10px; }
  .dock__divider { margin-inline: 2px; }
  /* A transform on the label would trap its fixed story sheet inside it. */
  .placard { animation: none; }
  .status { top: 10px; bottom: auto; transform: translate(-50%, -8px); }
  .status.is-visible { transform: translate(-50%, 0); }
  .popover, .sheet, .story-menu {
    position: fixed; left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 78vh; margin: 0;
    border-radius: 20px 20px 0 0; padding-bottom: 28px; animation: sheet-up 380ms var(--out);
  }
  @keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
  .editor--result .drawer { order: 2; }
  .canvas-area--result { padding: 22px 14px; }
  .framed { width: min(100%, calc(var(--art-h) * var(--ratio) + 40px)); }
  .welcome { grid-template-columns: 1fr; }
  .welcome__art { padding: 22px; }
  .welcome__pair { width: min(62%, 220px); }
  .welcome__text { padding: 22px 20px 24px; gap: 14px; }
  .welcome__title { font-size: 25px; }
  .coach { width: auto; left: 14px !important; right: 14px; }
}

/* ---------- 15. Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important; scroll-behavior: auto !important;
  }
  .welcome__remix { clip-path: none; }
}
