@font-face {
  font-family: Geist;
  font-weight: 100 900;
  font-display: swap;
  src: url(geist-latin.woff2) format('woff2');
}

:root {
  --surface: #f4f4f2;
  --sidebar: #ffffff;
  --ink: #1c1d1f;
  --muted: #76797d;
  --hairline: #e5e5e2;
  --control: #ececea;
  --control-hover: #e1e1de;
  --focus: #3b6fe0;
  --tape: #f5c518;
  --on-ink: #ffffff;
  --ink-hover: #3a3c40;
  --field: #ffffff;
  --warning: #b45309;
  --raised: #ffffff;
  color-scheme: light dark;
  font-family: Geist, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--surface);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface: #161718;
    --sidebar: #1f2022;
    --ink: #ececea;
    --muted: #9a9da2;
    --hairline: #303235;
    --control: #2a2c2f;
    --control-hover: #36393c;
    --focus: #6b93f0;
    --on-ink: #161718;
    --ink-hover: #cfd0cd;
    --field: #161718;
    --warning: #f59e0b;
    --raised: #44474b;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; display: grid; grid-template-columns: 370px 1fr; height: 100vh; height: 100dvh; overflow: hidden; }
h1, h2, h3, p { margin: 0; }
button, input { font: inherit; color: inherit; }
button {
  border: none; background: var(--control); border-radius: 8px;
  padding: .45em .9em; cursor: pointer; white-space: nowrap; font-weight: 500;
  transition: background-color .15s;
}
button:hover { background: var(--control-hover); }
button:disabled { opacity: .35; cursor: default; }
button.primary { background: var(--ink); color: var(--on-ink); }
button.primary:hover { background: var(--ink-hover); }
button.danger { background: #e5484d; color: #fff; }
button.danger:hover { background: #cc3b40; }
button.with-icon { display: inline-flex; align-items: center; gap: 6px; }
button.quiet { background: transparent; color: var(--muted); }
button.quiet:hover { background: var(--control); color: var(--ink); }
button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
input[type="number"] { width: 4.5em; padding: .35em .5em; border: 1px solid var(--hairline); border-radius: 6px; background: var(--field); }
input[type="checkbox"], input[type="range"] { accent-color: var(--ink); }
select { font: inherit; color: inherit; padding: .35em .5em; border: 1px solid var(--hairline); border-radius: 6px; background: var(--field); }
.hint { color: var(--muted); font-size: 13px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

aside { background: var(--sidebar); border-right: 1px solid var(--hairline); overflow-y: auto; scrollbar-gutter: stable; padding: 28px 22px; display: grid; gap: 28px; align-content: start; }
aside h1 { font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
.logo { display: inline-flex; align-items: center; gap: 8px; }
.logo svg { width: 26px; height: 26px; }
aside h2 { font-size: 14px; font-weight: 600; }
aside section { display: grid; gap: 12px; }
.credit a { color: inherit; text-underline-offset: .15em; }
.credit .version {
  display: inline-block; margin-right: 6px; padding: 1px 6px; border-radius: 999px; background: var(--control);
  color: var(--ink); font: 600 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; vertical-align: 1px;
}
.credit a:hover { color: var(--ink); }
.section-head { display: flex; justify-content: space-between; align-items: center; }
.setting-row .row { display: flex; flex-wrap: wrap; gap: 6px; flex-shrink: 0; }
.setting-row.stacked { flex-direction: column; align-items: stretch; gap: 10px; }
button.destructive { color: #e5484d; }

.backup { display: grid; justify-items: start; gap: 2px; margin: 0 -8px; padding-top: 16px; border-top: 1px solid var(--hairline); }

.pieces-list { list-style: none; margin: 0 -8px; padding: 0; display: grid; gap: 2px; }
.pieces-list input[type="checkbox"], .collection-head input[type="checkbox"] { width: 20px; height: 20px; margin: 0; cursor: pointer; }
.collections { display: contents; }
.collection { display: grid; gap: 6px; }
.collection:has(.pieces-list, .empty-collection) + .collection { margin-top: 12px; }
.collection:not(:has(.pieces-list, .empty-collection)) + .collection { margin-top: -8px; }
.collection-head { display: flex; gap: 4px; align-items: center; margin: 0 -8px; padding: 6px 8px; border-radius: 10px; background: var(--control); }
.collection-head.drop-target { box-shadow: inset 0 0 0 2px var(--focus); }
.chevron svg { transition: transform .15s; }
.chevron[aria-expanded="true"] svg { transform: rotate(90deg); }
.collection-head .quiet { padding: 4px 8px; font-size: 13px; }
.collection-head .hint { margin-right: 4px; }
.collection-head :is(.quiet, .icon):hover { background: var(--control-hover); }
.collection-name { flex: 1; width: 0; font-size: 15px; font-weight: 600; padding: .2em .4em; border: 1px solid transparent; border-radius: 6px; background: transparent; }
.collection-name:hover { border-color: var(--control-hover); }
.collection-name:focus { border-color: var(--ink); background: var(--field); outline: none; }
.empty-collection { padding: 12px; border: 1px dashed var(--hairline); border-radius: 10px; text-align: center; }
.pieces-list li {
  display: grid; grid-template-columns: auto 48px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 8px; border-radius: 10px; cursor: grab;
}
.pieces-list li:hover { background: var(--surface); }
.pieces-list li.off img { opacity: .35; }
.pieces-list li.highlighted { background: var(--surface); box-shadow: inset 0 0 0 2px var(--ink); }
.pieces-list li.drop-target { box-shadow: inset 0 2px 0 var(--focus); }
.pieces-list img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; display: block; }
.piece-controls { display: flex; flex-wrap: wrap; gap: 4px; }
.piece-controls button { font-size: 12px; padding: .2em .6em; border-radius: 6px; gap: 4px; }
/* The delete button shows on hover; touch screens have no hover, so it stays visible there. */
@media (hover: hover) {
  .pieces-list li > [data-action="delete-piece"] { opacity: 0; }
  .pieces-list li:hover > [data-action="delete-piece"], .pieces-list li > [data-action="delete-piece"]:focus-visible { opacity: 1; }
}

.settings { display: grid; gap: 12px; margin-top: 16px; }
.settings label { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.presets { width: 100%; border-collapse: collapse; }
.presets th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding-bottom: 6px; }
.presets td { padding: 2px 4px 2px 0; }
.presets input { width: 3.6em; }
.presets input[type="color"] { width: 36px; height: 28px; padding: 2px; }
.preset-color { display: inline-flex; align-items: center; }
#frame-settings { width: min(560px, 92vw); }

main { display: grid; grid-template-rows: auto auto 1fr; grid-template-columns: minmax(0, 1fr); min-height: 0; }
.walls { display: flex; align-items: center; gap: 8px; padding: 20px 32px 0; overflow-x: auto; }
.wall-tabs { display: flex; gap: 2px; padding: 2px; border-radius: 10px; background: var(--control); }
.wall-tabs:not(:has(button)) { display: none; }
.wall-tabs button { background: transparent; color: var(--muted); }
.wall-tabs button:hover { background: transparent; color: var(--ink); }
.wall-tabs button[aria-current="true"] { background: var(--raised); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .12); }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 16px 32px; }
.toolbar:empty { display: none; }
.toolbar .back { padding-left: .5em; margin-right: 10px; }
.toolbar .title { font-size: 18px; font-weight: 600; letter-spacing: -.01em; margin-right: auto; min-width: 0; flex: 1 1 0; }
/* A long title gives way before the buttons wrap. */
/* The padding keeps the name field's outline inside the clipped area. */
.toolbar .title > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 3px 6px; margin: -3px -6px; }
.toolbar label { display: flex; align-items: center; gap: 6px; color: var(--muted); margin-right: 8px; }
.content { overflow: auto; scrollbar-gutter: stable; padding: 8px 32px 32px; min-height: 0; }
body.dragging-files .content { outline: 2px dashed var(--muted); outline-offset: -8px; border-radius: 16px; }

.empty { max-width: 36rem; margin: 14vh auto; display: grid; gap: 14px; justify-items: start; }
.empty h2 { font-size: 32px; font-weight: 600; line-height: 1.25; letter-spacing: -.02em; text-wrap: balance; }
.empty .hint { font-size: 16px; text-wrap: pretty; }
.empty button { font-size: 15px; }
.empty-icon { width: 64px; height: 64px; padding: 14px; border-radius: 14px; background: var(--sidebar); box-shadow: 0 0 0 1px var(--hairline); color: var(--ink); margin-bottom: 4px; }
.empty .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

.layout-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 28px 20px; }
.layout-card { display: grid; gap: 4px; }
.layout-open { padding: 0; background: none; border-radius: 10px; }
.layout-open:hover { background: none; }
.layout-open .stage { transition: box-shadow .15s; }
.layout-open:hover .stage { box-shadow: 0 0 0 2px var(--ink); }
.card-caption { display: flex; justify-content: space-between; align-items: center; }
.warning { display: inline-flex; vertical-align: -3px; margin-left: 6px; color: var(--warning); }
button.icon[aria-pressed="true"] { background: transparent; color: var(--ink); }
/* A pressed icon button fills its icon; marks on the filled shape are cut out in the background color. */
button.icon[aria-pressed="true"] .fill { fill: currentColor; }
button.icon[aria-pressed="true"] .cutout { stroke: var(--surface); }
.layout-section { display: grid; gap: 14px; margin-bottom: 40px; }
.layout-section h2 { font-size: 15px; font-weight: 600; }
.layout-section.collapsed { margin-bottom: 8px; }
.group-toggle { display: inline-flex; align-items: center; gap: 6px; margin-left: -8px; padding: 4px 10px 4px 6px; background: transparent; font-weight: 600; }
.group-toggle .hint { font-weight: 400; }

.stage { position: relative; width: 100%; container-type: inline-size; --cm: calc(100cqw / var(--wall-width)); overflow: hidden; background: #888; border-radius: 10px; }
.stage > *, .plane > * { position: absolute; inset: 0; }
.plane { transform-origin: 0 0; pointer-events: none; }
.plane > * { pointer-events: auto; }
.stage .photo { width: 100%; height: 100%; display: block; }
.measurements { pointer-events: none; }
.hide-measurements :is(.measurements, .eye-level) { display: none; }
.eye-level {
  position: absolute; inset: auto 0; height: 0; pointer-events: none;
  border-top: 1px dashed rgb(255 255 255 / .85); filter: drop-shadow(0 0 1px rgb(0 0 0 / .6));
}
.eye-level span { position: absolute; left: 8px; bottom: 3px; font-size: 11px; color: #fff; }
.hanging { position: absolute; pointer-events: none; }
.detail .hanging { outline: 2px dashed rgb(255 255 255 / .85); outline-offset: 3px; }
.occluder { background-size: 100% 100%; mask-size: 100% 100%; -webkit-mask-size: 100% 100%; pointer-events: none; }
.frame {
  position: absolute;
  background:
    linear-gradient(135deg, rgb(255 255 255 / .22), transparent 45%),
    repeating-linear-gradient(90deg, rgb(140 95 45 / .10) 0 1px, transparent 1px 4px, rgb(140 95 45 / .06) 4px 5px, transparent 5px 9px),
    var(--frame-color, #dcc095);
  --frame-edge: color-mix(in srgb, var(--frame-color, #dcc095) 60%, black);
  box-shadow: inset 0 0 0 1px var(--frame-edge);
}
.frame.shadow {
  box-shadow: inset 0 0 0 1px var(--frame-edge),
    0 calc(var(--cm) * .7) calc(var(--cm) * 1.8) rgb(0 0 0 / .32),
    0 calc(var(--cm) * .15) calc(var(--cm) * .35) rgb(0 0 0 / .28);
}
.mat { position: relative; width: 100%; height: 100%; background: #f7f6f1; }
.mat::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 calc(var(--cm) * .35) calc(var(--cm) * .5) rgb(0 0 0 / .22); }
.art { width: 100%; height: 100%; background-size: cover; }
.has-mat .art { box-shadow: 0 0 0 calc(var(--cm) * .2) #fff, 0 0 0 calc(var(--cm) * .25) rgb(0 0 0 / .08); }

/* The photo fills the height left above the hints or frame tools, so switching between them never adds a scrollbar. */
.detail { height: 100%; display: grid; grid-template-rows: minmax(0, 1fr) auto; justify-items: center; gap: 12px; }
.stage-area { container-type: size; width: 100%; min-height: 0; display: grid; justify-items: center; align-items: start; }
.detail .stage { width: min(100cqw, 100cqh * var(--ratio)); cursor: move; touch-action: none; }
.detail .frame { cursor: grab; }
.detail .frame.lifted { z-index: 1; cursor: grabbing; }
.art.dragging { position: relative; opacity: .9; box-shadow: 0 8px 24px rgb(0 0 0 / .35); pointer-events: none; }
.detail .frame.drop-target, .detail .frame.selected { outline: 3px solid var(--focus); outline-offset: 3px; }
.instructions { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 24px; color: var(--muted); font-size: 13px; }
kbd { font: inherit; font-size: 12px; font-weight: 500; color: var(--ink); padding: 1px 6px; border-radius: 5px; background: var(--sidebar); box-shadow: 0 0 0 1px var(--hairline), 0 1px 0 1px var(--hairline); }
.frame-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.frame-tools .hint { margin-right: 6px; }
.frame-tools .rotate { margin-left: 14px; }
/* The hints and the frame tools take the same room, so the photo keeps its size when a picture is selected. */
.instructions, .frame-tools { min-height: 52px; align-content: center; }
.tape {
  position: absolute; inset: auto; width: 10px; transform: translateX(-50%);
  background: repeating-linear-gradient(to bottom, #1c1d1f 0 1px, transparent 1px calc(var(--cm) * 10)), var(--tape);
  border-radius: 2px; pointer-events: none;
}
.tag {
  position: absolute; inset: auto; transform: translate(-50%, -50%); pointer-events: none; white-space: nowrap;
  background: var(--tape); color: #1c1d1f; font-weight: 600; font-size: 12px; padding: 2px 8px; border-radius: 4px;
  box-shadow: 0 1px 4px rgb(0 0 0 / .25);
}

.editor { display: grid; grid-template-columns: 1fr 300px; gap: 24px; align-items: start; }
.photo-wrap { position: relative; width: min(100%, calc((100vh - 180px) * var(--ratio))); width: min(100%, calc((100dvh - 180px) * var(--ratio))); cursor: crosshair; touch-action: none; user-select: none; border-radius: 10px; overflow: hidden; }
.photo-wrap img { width: 100%; display: block; pointer-events: none; }
.photo-wrap.with-margin { aspect-ratio: var(--ratio); background: var(--control); }
.photo-wrap.with-margin img {
  position: absolute; left: calc(100% * var(--margin) / (1 + 2 * var(--margin))); top: calc(100% * var(--margin) / (1 + 2 * var(--margin)));
  width: calc(100% / (1 + 2 * var(--margin))); height: calc(100% / (1 + 2 * var(--margin)));
}
.photo-wrap > svg, .photo-wrap > canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.panel { display: grid; gap: 14px; background: var(--sidebar); padding: 20px; border-radius: 12px; box-shadow: 0 0 0 1px var(--hairline); }
.panel label { display: grid; gap: 6px; }
.panel label.check { display: flex; align-items: start; gap: 8px; }
.panel input[type="number"] { width: 100%; }
.panel .row { display: flex; flex-wrap: wrap; gap: 6px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 2px; border-radius: 10px; background: var(--control); }
.steps button { padding: .45em .4em; background: transparent; color: var(--muted); }
.steps button[aria-pressed="true"] { background: var(--raised); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .12); }
.status { font-weight: 500; }

.title { display: inline-flex; align-items: center; gap: 4px; }
.control-bar { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 6px 6px 6px 12px; background: var(--sidebar); border-radius: 12px; box-shadow: 0 0 0 1px var(--hairline); }
.select-with-icon { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.select-with-icon select { border: none; background: transparent; padding-left: 0; color: var(--ink); font-weight: 500; }
.control-bar .divider { width: 1px; align-self: stretch; background: var(--hairline); margin: 4px; }
.field-label { font-size: 12px; font-weight: 500; color: var(--muted); }
.segmented { display: inline-flex; gap: 2px; padding: 2px; border-radius: 10px; background: var(--control); }
.segmented button { background: transparent; color: var(--muted); padding: .3em .8em; }
.segmented button[aria-pressed="true"] { background: var(--raised); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .12); }
.control-bar .push { margin-left: auto; }
button.icon { display: inline-grid; place-items: center; padding: 6px; background: transparent; color: var(--muted); }
button.icon:hover { background: var(--control); color: var(--ink); }
dialog {
  border: none; border-radius: 14px; padding: 24px; width: min(460px, 92vw);
  box-shadow: 0 20px 60px rgb(0 0 0 / .25); color: var(--ink); background: var(--sidebar);
}
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog h2 { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
dialog h3 { font-size: 14px; font-weight: 600; }
dialog form { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--hairline); }

/* Hanging plan */
.nail {
  position: absolute; inset: auto; transform: translate(-50%, -50%); display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%; background: var(--tape); color: #1c1d1f; font-size: 12px; font-weight: 700;
  box-shadow: 0 0 0 2px #1c1d1f, 0 2px 6px rgb(0 0 0 / .4); pointer-events: none;
}
.plan { height: 100%; display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; }
.plan .stage { width: min(100cqw, 100cqh * var(--ratio)); }
.plan-steps { display: grid; gap: 16px; align-content: start; overflow-y: auto; }
.plan-intro { margin: 0; padding-left: 1.2em; display: grid; gap: 8px; font-size: 15px; }
.plan-table { width: 100%; border-collapse: collapse; }
.plan-table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 0 8px 6px 0; }
.plan-table td { padding: 6px 8px 6px 0; border-top: 1px solid var(--hairline); vertical-align: middle; }
.plan-table td:nth-child(2) { display: flex; align-items: center; gap: 8px; }
.plan-table img { width: 32px; height: 32px; object-fit: cover; border-radius: 4px; }
.nail-number { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--tape); color: #1c1d1f; font-size: 12px; font-weight: 700; }

@media print {
  * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  body { display: block; height: auto; overflow: visible; }
  aside, .walls, .toolbar { display: none; }
  main, .content { display: block; overflow: visible; padding: 0; }
  .plan { display: block; height: auto; }
  .plan .stage-area { container-type: normal; }
  .plan .stage { margin: 0 auto 24px; }
}

/* Phones: one column, the sidebar becomes a drawer. */
button.menu-button { display: none; }
@media (max-width: 760px) {
  body { grid-template-columns: minmax(0, 1fr); }
  aside {
    position: fixed; inset: 0 auto 0 0; z-index: 20; width: min(370px, 88vw);
    transform: translateX(-100%); transition: transform .2s;
  }
  body.sidebar-open aside { transform: none; box-shadow: 0 0 40px rgb(0 0 0 / .25); }
  body.sidebar-open main::after { content: ""; position: fixed; inset: 0; z-index: 10; background: rgb(0 0 0 / .35); }
  button.menu-button { display: inline-grid; }
  .walls { padding: 12px 16px 0; }
  .toolbar { padding: 12px 16px; }
  .content { padding: 4px 16px 24px; }
  .editor, .plan { grid-template-columns: 1fr; }
  .plan { height: auto; }
  .plan .stage-area { container-type: normal; }
  .plan .stage { width: 100%; }
  /* The title and its icons get their own row; the buttons wrap below it. */
  .toolbar .title { flex: 1 1 100%; order: -1; }
  .toolbar .back { margin-right: auto; }
  .detail { height: auto; }
  .detail .stage-area { container-type: normal; }
  .detail .stage { width: 100%; }
  .empty { margin: 8vh auto; }
  .empty h2 { font-size: 26px; }
  .nudge-hint { display: none; }
}

.presets th .unit {
  display: inline-block; margin-left: 4px; padding: 1px 5px; border-radius: 4px;
  background: var(--control); color: var(--ink); font: 600 11px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; vertical-align: 1px;
}

/* Layout toolbar: a menu for the less used actions, and the bookmark's name as an inline field */
.more-button { anchor-name: --more-actions; }
.actions-menu {
  position-anchor: --more-actions; inset: auto; top: anchor(bottom); right: anchor(right); margin: 6px 0 0;
  padding: 6px; border: 1px solid var(--hairline); border-radius: 10px; background: var(--sidebar); color: var(--ink);
  box-shadow: 0 10px 30px rgb(0 0 0 / .18);
}
.actions-menu:popover-open { display: grid; gap: 2px; }
.actions-menu button { background: transparent; text-align: left; }
.actions-menu button:hover { background: var(--control); }
/* The outline takes no space, so the name lays out exactly like a plain title. */
.bookmark-name { border-radius: 4px; outline: 1px solid transparent; outline-offset: 2px; cursor: text; }
.bookmark-name:hover { outline-color: var(--hairline); }
.bookmark-name:focus { outline-color: var(--focus); }

#tooltip {
  position-anchor: --tooltip; position-area: top; position-try-fallbacks: flip-block, top span-right, top span-left;
  inset: auto; margin: 0 0 6px; padding: 4px 8px; border: none; border-radius: 6px; max-width: 260px;
  background: var(--ink); color: var(--on-ink); font-size: 12px; font-weight: 500; line-height: 1.35; pointer-events: none;
}
