/* =========================================================================
   Splet — "viewing booth".
   Color on screen belongs to the room photo and to the marker strokes.
   The interface around them is true neutral grey (no tint), the way colour
   proofing booths and image tools keep their surroundings, so it never
   shifts how a paint or fabric reads. Versions and projects are paint chips.
   ========================================================================= */

:root {
  --booth: #D4D4D4;   /* page: light neutral grey */
  --plane: #E6E6E6;   /* side panels */
  --field: #F7F7F7;   /* inputs */
  --chip: #FFFFFF;    /* paint-chip paper */
  --stage: #707070;   /* mid grey around photos */
  --ink: #000000;
  --ink-2: #474747;   /* secondary text, 7:1 on --plane */
  --line: #8C8C8C;    /* control borders, 3:1 on --field */
  --rule: #BDBDBD;    /* quiet dividers */
  --danger: #A3001B;

  --font: Jost, "Futura", "Century Gothic", system-ui, sans-serif;
  --topbar-h: 56px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--booth);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }
a { color: inherit; }
h1, h2, p { margin: 0; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.section-title { font-size: 21px; font-weight: 500; line-height: 1.2; letter-spacing: -0.005em; margin-bottom: 16px; }
.hint { font-size: 14px; line-height: 1.45; color: var(--ink-2); }
.error {
  padding-left: 10px; border-left: 3px solid var(--danger);
  font-size: 14px; line-height: 1.45; color: var(--danger);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px;
  border: 1px solid var(--ink); border-radius: 3px;
  background: transparent; color: var(--ink);
  font: 500 15px/1 var(--font);
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: rgba(0, 0, 0, 0.07); }
.btn[aria-pressed="true"] { background: var(--ink); color: #fff; }
.btn[aria-disabled="true"], .btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:disabled:hover { background: transparent; }
.btn--primary { background: var(--ink); color: #fff; }
.btn--primary:hover { background: #333; }
.btn--primary:disabled:hover { background: var(--ink); }
.btn--light { background: #fff; border-color: #fff; color: var(--ink); }
.btn--light:hover { background: var(--field); }
.btn--quiet { border-color: transparent; padding: 0 10px; }
.btn--quiet:hover { background: transparent; text-decoration: underline; text-underline-offset: 4px; }
.btn--danger { color: var(--danger); }
.btn--block { width: 100%; min-height: 52px; font-size: 17px; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 8px 24px; min-height: var(--topbar-h); padding: 8px 24px;
  border-bottom: 1px solid var(--rule);
}
.topbar__left, .topbar__right { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; min-width: 0; }
.topbar__right { gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 24px; font-weight: 600; letter-spacing: -0.02em; text-decoration: none; line-height: 1; }
/* Logo: a plain weave (splet = weave) in the interface's own ink and stage grey. */
.brand__mark { display: block; flex-shrink: 0; }
.brand__warp { fill: var(--ink); }
.brand__weft { fill: var(--stage); }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--ink-2); min-width: 0; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 4px; }
.crumbs__current { color: var(--ink); max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Account menu: spend and sign-out live here, out of the way of the work */
.account { position: relative; }
.account__toggle { list-style: none; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.account__toggle::-webkit-details-marker { display: none; }
.account__caret { font-size: 12px; color: var(--ink-2); }
.account[open] .account__caret { transform: rotate(180deg); }
.account__panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 260px; padding: 14px 16px 16px;
  background: var(--chip); border: 1px solid var(--rule); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  display: flex; flex-direction: column; gap: 14px;
}
.account__stats { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.account__stats div { display: flex; justify-content: space-between; gap: 16px; font-size: 14px; }
.account__stats dt { color: var(--ink-2); }
.account__stats dd { margin: 0; font-weight: 500; white-space: nowrap; }
.badge { padding: 3px 8px; border: 1px solid var(--ink); border-radius: 2px; font-size: 13px; font-weight: 500; cursor: help; }
.account__email { font-size: 14px; color: var(--ink-2); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Sign in ---------- */
.auth {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 400px); gap: 48px 64px; align-items: start;
  width: 100%; max-width: 1080px; margin: 0 auto; padding: 96px 24px;
}
.auth__intro { display: flex; flex-direction: column; gap: 20px; padding-top: 8px; }
.auth__intro h1 { font-size: clamp(40px, 6vw, 60px); font-weight: 500; line-height: 1.02; letter-spacing: -0.025em; max-width: 9em; }
.auth__intro p { font-size: 18px; line-height: 1.5; color: var(--ink-2); max-width: 28em; }
.auth__card { background: var(--plane); padding: 24px; border-radius: 4px; display: flex; flex-direction: column; gap: 24px; }
.auth__form { display: flex; flex-direction: column; gap: 18px; }

/* ---------- Form controls ---------- */
.field { display: flex; flex-direction: column; gap: 8px; }
.field__label { font-size: 15px; font-weight: 600; }
.field__aside { font-weight: 400; color: var(--ink-2); margin-left: 6px; }
.input, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 3px; background: var(--field);
  font: inherit; font-size: 16px; color: var(--ink);
}
.input { min-height: 44px; padding: 0 12px; }
textarea { resize: vertical; min-height: 112px; padding: 12px; line-height: 1.5; }
.input:hover, textarea:hover { border-color: var(--ink-2); }
.input:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); background: #fff; }
textarea::placeholder { color: #6E6E6E; }

/* Segmented switch: one bordered strip, the chosen part filled black */
.segmented { display: grid; border: 1px solid var(--ink); border-radius: 3px; overflow: hidden; }
.segmented--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.segmented--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.seg {
  min-height: 44px; padding: 8px 12px; border: 0; border-left: 1px solid var(--ink); border-radius: 0;
  background: transparent; font: inherit; color: var(--ink); cursor: pointer;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; text-align: left;
}
.seg:first-child { border-left: 0; }
.seg:hover { background: rgba(0, 0, 0, 0.07); }
.seg[aria-pressed="true"] { background: var(--ink); color: #fff; }
.seg:focus-visible { outline-offset: -4px; outline-color: currentColor; }
.seg__label { font-weight: 500; font-size: 15px; }
.seg__hint { font-size: 13px; color: var(--ink-2); }
.seg[aria-pressed="true"] .seg__hint { color: #C8C8C8; }
.seg--tab, .segmented--3 .seg { align-items: center; }
.segmented--3 .seg { font-size: 15px; font-weight: 500; }

/* ---------- Upload screen ---------- */
.upload {
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 48px 56px; align-items: start;
  width: 100%; max-width: 1280px; margin: 0 auto; padding: 72px 24px 96px;
}
.upload__intro { display: flex; flex-direction: column; gap: 20px; }
.upload__intro h1 { font-size: clamp(40px, 5.6vw, 72px); font-weight: 500; line-height: 1; letter-spacing: -0.03em; max-width: 7em; }
.upload__intro > p { font-size: 18px; line-height: 1.5; color: var(--ink-2); max-width: 26em; }

.howto { margin-top: 28px; }
.howto .section-title { margin-bottom: 10px; cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; }
.howto .section-title::-webkit-details-marker { display: none; }
.howto .section-title::after { content: "▾"; font-size: 14px; color: var(--ink-2); }
.howto:not([open]) .section-title::after { transform: rotate(-90deg); }
.howto:not([open]) .section-title { font-size: 15px; font-weight: 500; color: var(--ink-2); margin-bottom: 0; }
.howto__list { margin: 0; display: flex; flex-direction: column; }
.howto__list > div { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 12px; padding: 10px 0; border-top: 1px solid var(--rule); }
.howto__list dt { font-weight: 600; font-size: 15px; }
.howto__list dd { margin: 0; font-size: 15px; line-height: 1.45; color: var(--ink-2); max-width: 34em; }

/* The drop area is a photo-shaped frame in the same mid grey photos are shown on */
.dropzone {
  aspect-ratio: 3 / 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  padding: 24px; text-align: center;
  background: var(--stage); color: #fff; border-radius: 2px;
  outline: 2px dashed transparent; outline-offset: -14px;
}
.dropzone.is-over { background: #5C5C5C; outline-color: #fff; }
.dropzone.is-busy { opacity: 0.75; pointer-events: none; }
.dropzone__title { font-size: 28px; font-weight: 500; letter-spacing: -0.01em; }
.dropzone__hint { font-size: 14px; color: #F0F0F0; }
.dropzone .btn--light { min-height: 46px; padding: 0 22px; font-size: 16px; }
.dropzone .error { color: #fff; border-color: #fff; text-align: left; }

.recent { grid-column: 1 / -1; padding-top: 8px; }

/* Paint chip: colour on top, a white paper strip with the name underneath */
.projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 24px 16px; }
.project {
  display: flex; flex-direction: column; background: var(--chip); text-decoration: none; color: var(--ink);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
}
.project:hover { outline: 2px solid var(--ink); outline-offset: 2px; }
.project img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--stage); }
.project__meta { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px 16px; min-width: 0; }
.project__meta strong { font-weight: 500; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project__meta span { font-size: 13px; color: var(--ink-2); }

/* ---------- Editor: chips | photo on grey | form ---------- */
.editor {
  display: grid; grid-template-columns: 216px minmax(0, 1fr) 384px;
  height: calc(100vh - var(--topbar-h)); min-height: 560px;
}
.versions { overflow-y: auto; padding: 20px 16px; display: flex; flex-direction: column; }
.versions .section-title { font-size: 18px; margin-bottom: 14px; }
.versions .hint { font-size: 13px; padding-top: 4px; }
.versions__list { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 14px; }

.version {
  width: 100%; display: flex; flex-direction: column; padding: 0; border: 0; border-radius: 0;
  background: var(--chip); color: var(--ink); text-align: left; font: inherit; cursor: pointer;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
}
.version:hover { outline: 1px solid var(--ink-2); outline-offset: 2px; }
.version[aria-current="true"] { outline: 2px solid var(--ink); outline-offset: 2px; }
.version__thumb {
  display: flex; align-items: center; justify-content: center; width: 100%; aspect-ratio: 3 / 2;
  object-fit: cover; background: var(--stage); color: #fff;
}
.version__text { display: flex; flex-direction: column; gap: 3px; padding: 8px 10px 12px; min-width: 0; }
.version__title {
  font-size: 14px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.version__code { font-weight: 600; }
.version__sub { font-size: 12px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.version__sub--failed { color: var(--danger); }

.result { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--stage); }
.stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 32px; overflow: auto; }
.compare { position: relative; width: fit-content; max-width: 100%; line-height: 0; }
.compare img { display: block; user-select: none; -webkit-user-drag: none; }
.compare__before {
  max-width: 100%; max-height: calc(100vh - var(--topbar-h) - 64px - 72px);
  width: auto; height: auto; min-width: 240px; min-height: 160px; background: #666;
}
.compare__after { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; clip-path: inset(0 0 0 var(--split, 50%)); }
.compare.is-single .compare__after { clip-path: none; }
.compare.is-single .compare__divider,
.compare.is-single .compare__range,
.compare.is-single .compare__label--left { display: none; }
.compare__divider {
  position: absolute; top: 0; bottom: 0; left: var(--split, 50%); width: 2px; margin-left: -1px;
  background: #fff; pointer-events: none;
}
.compare__divider::after {
  content: ""; position: absolute; top: 50%; left: 50%; width: 36px; height: 36px; margin: -18px 0 0 -18px;
  border-radius: 50%; border: 1px solid rgba(0, 0, 0, 0.25);
  background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'><path d='M7 5l-5 5 5 5zM13 5l5 5-5 5z' fill='black'/></svg>") center / 20px no-repeat;
}
.compare__tool {
  position: absolute; right: 12px; bottom: 12px; z-index: 2; width: 40px; height: 40px; border: 0; border-radius: 2px;
  background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 20px; line-height: 1; cursor: pointer;
}
.compare__tool:hover { background: rgba(0, 0, 0, 0.8); }
.compare__tool--mark { right: 60px; }
.compare.is-single .compare__tool--mark { right: 60px; }
.compare__range { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: ew-resize; }
.compare__label {
  position: absolute; top: 12px; padding: 5px 9px; border-radius: 2px;
  background: rgba(0, 0, 0, 0.62); color: #fff; font-size: 13px; line-height: 1.2; pointer-events: none;
}
.compare__label--left { left: 12px; }
.compare__label--right { right: 12px; }
.compare__overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(112, 112, 112, 0.82); color: #fff; font-size: 16px; line-height: 1.4; text-align: center; padding: 24px;
}

.spinner {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.35); border-top-color: #fff;
  animation: spin 0.9s linear infinite;
}
.spinner--sm { width: 20px; height: 20px; }
@keyframes spin { to { transform: rotate(360deg); } }

.toolbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 16px;
  padding: 12px 16px 12px 20px; background: var(--booth); border-top: 1px solid var(--rule);
}
.toolbar__info { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.toolbar__meta { font-size: 14px; color: var(--ink-2); }
.toolbar__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.used-refs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 14px; color: var(--ink-2); }
.used-refs img { width: 28px; height: 28px; object-fit: cover; display: block; }
.used-refs__item {
  position: relative; padding: 0; border: 1px solid var(--line); background: var(--stage); cursor: zoom-in; line-height: 0;
}
.used-refs__item img { width: 40px; height: 40px; }
.used-refs__item:hover { border-color: var(--ink); }
.used-refs__item:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.used-refs__num {
  position: absolute; left: 2px; bottom: 2px; min-width: 16px; padding: 2px 3px; border-radius: 8px;
  color: #fff; font-size: 11px; font-weight: 600; line-height: 1; text-align: center;
}
.link-btn {
  border: 0; background: none; padding: 2px 4px; margin-left: 4px;
  font: inherit; font-size: 14px; font-weight: 500; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}

.panel { overflow-y: auto; background: var(--plane); padding: 24px; display: flex; flex-direction: column; gap: 26px; }
.panel__title { font-size: 24px; font-weight: 500; letter-spacing: -0.01em; line-height: 1.15; }
.panel .field { gap: 10px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips--presets { padding-top: 4px; }
.chips--presets .chip { border-style: dashed; }
.chip {
  min-height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 3px;
  background: transparent; font: inherit; font-size: 14px; color: var(--ink); cursor: pointer;
}
.chip:hover { border-color: var(--ink); background: rgba(0, 0, 0, 0.05); }

.keep { margin: 0; padding: 0; border: 0; min-width: 0; }
.keep legend { padding: 0; margin-bottom: 8px; }
.keep__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 16px; }
.keep__grid label { display: flex; align-items: center; gap: 10px; min-height: 34px; font-size: 15px; cursor: pointer; }
.keep__grid input { width: 18px; height: 18px; margin: 0; flex-shrink: 0; accent-color: var(--ink); }

.cost { display: flex; flex-direction: column; gap: 14px; padding-top: 18px; border-top: 1px solid var(--rule); }
.generate { display: flex; align-items: center; justify-content: center; gap: 10px; }
.generate__cost { font-weight: 400; opacity: 0.75; font-size: 15px; }
.generate__cost:empty { display: none; }

/* Settings: everything that is not the instruction itself, folded under one line */
.settings__toggle {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; min-height: 36px;
  font-size: 15px; color: var(--ink-2);
}
.settings__toggle::-webkit-details-marker { display: none; }
.settings__toggle > span:first-child { font-weight: 500; color: var(--ink); text-decoration: underline; text-underline-offset: 4px; }
.settings__summary { font-size: 14px; }
.settings[open] .settings__summary { display: none; }
.settings__body { display: flex; flex-direction: column; gap: 22px; padding-top: 14px; }

/* ---------- References (marker colours carry meaning here) ---------- */
.refs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.refs.is-over { outline: 2px dashed var(--ink); outline-offset: 6px; }
.ref {
  position: relative; aspect-ratio: 1; overflow: hidden; background: var(--chip);
  box-shadow: 0 0 0 3px var(--ref, transparent);
}
.ref img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ref__label { position: absolute; left: 0; top: 0; padding: 3px 7px; background: var(--ink); color: #fff; font-size: 12px; font-weight: 600; }
/* Markers outlined on this reference */
.ref__marks { position: absolute; left: 6px; bottom: 6px; display: flex; flex-wrap: wrap; gap: 3px; max-width: calc(100% - 12px); pointer-events: none; }
.ref__dot { width: 14px; height: 14px; border-radius: 50%; box-shadow: 0 0 0 1.5px #fff; font-size: 9px; font-weight: 600; line-height: 14px; text-align: center; color: #fff; }
.ref__remove {
  position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, 0.62); color: #fff; cursor: pointer; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
}
.ref__remove:hover { background: var(--ink); }
.ref__open { position: absolute; inset: 0; border: 0; padding: 0; background: none; cursor: pointer; }
.ref__open:focus-visible { outline-offset: -4px; outline-color: #fff; }
.ref__marked {
  position: absolute; left: 0; bottom: 0; right: 0; padding: 3px 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: rgba(255, 255, 255, 0.92); font-size: 12px; font-weight: 500; pointer-events: none;
}
.ref--busy { display: flex; align-items: center; justify-content: center; background: var(--stage); }
.ref--add {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 1px dashed var(--line); background: transparent; box-shadow: none;
  font-size: 14px; color: var(--ink-2); cursor: pointer;
}
.ref__plus { font-size: 26px; font-weight: 400; line-height: 1; color: var(--ink); }
.ref--add:hover { border-color: var(--ink); border-style: solid; color: var(--ink); }
.ref--add:focus-within { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---------- Renaming ---------- */
.crumbs__rename { border: 0; background: none; padding: 4px 6px; margin: -4px -6px; font: inherit; cursor: text; border-radius: 3px; }
.crumbs__rename:hover { background: rgba(0, 0, 0, 0.07); }
.crumbs__rename::after { content: "✎"; margin-left: 8px; color: var(--ink-2); font-size: 14px; }
.input--inline { min-height: 34px; width: min(320px, 50vw); font-size: 15px; }
.project-card { position: relative; display: flex; }
.project-card > .project { flex: 1; min-width: 0; }
.project__rename {
  position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; border: 1px solid var(--line);
  background: var(--chip); color: var(--ink); font-size: 16px; cursor: pointer; opacity: 0;
}
.project-card:hover .project__rename, .project__rename:focus-visible { opacity: 1; }
.project__rename:hover { border-color: var(--ink); }
@media (hover: none) { .project__rename { opacity: 1; } }

/* ---------- Viewer dialog ---------- */
.viewer {
  width: min(1240px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0;
  border: 0; border-radius: 4px; background: var(--plane); color: var(--ink);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35); overflow: hidden;
}
.viewer[open] { display: flex; flex-direction: column; }
.viewer::backdrop { background: rgba(60, 60, 60, 0.6); }
.viewer__head { display: flex; align-items: center; gap: 12px 16px; padding: 12px 16px 12px 20px; }
.viewer__title { font-size: 21px; font-weight: 500; }
.viewer__count { flex: 1; font-size: 15px; color: var(--ink-2); }
.viewer__stage {
  position: relative; flex: 1; min-height: 0; background: var(--stage);
  display: flex; align-items: center; justify-content: center; padding: 20px 64px;
}
.viewer__stage img { display: block; max-width: 100%; max-height: calc(100vh - 220px); object-fit: contain; }
.viewer__nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 64px;
  border: 0; background: rgba(0, 0, 0, 0.45); color: #fff; font: 400 34px/1 var(--font); cursor: pointer;
}
.viewer__nav:hover { background: rgba(0, 0, 0, 0.7); }
.viewer__nav:focus-visible { outline: 2px solid #fff; outline-offset: -4px; }
.viewer__nav--prev { left: 10px; }
.viewer__nav--next { right: 10px; }
.viewer__caption { padding: 12px 20px 16px; font-size: 15px; color: var(--ink-2); }
@media (max-width: 760px) {
  .viewer { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  .viewer__stage { padding: 12px 8px; }
  .viewer__stage img { max-height: calc(100dvh - 200px); }
  .viewer__nav { width: 36px; height: 52px; }
}

/* ---------- Markup dialog ---------- */
.markup {
  width: min(1240px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0;
  border: 0; border-radius: 4px; background: var(--plane); color: var(--ink);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35); overflow: hidden;
}
.markup[open] { display: flex; flex-direction: column; }
.markup::backdrop { background: rgba(60, 60, 60, 0.6); }
.markup__head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 16px; padding: 12px 16px 12px 20px; }
.markup__title { font-size: 21px; font-weight: 500; }
.markup__tabs { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.mtab {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 3px; background: transparent;
  font: inherit; font-size: 15px; color: var(--ink); cursor: pointer;
}
.mtab:hover { border-color: var(--ink); }
.mtab[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.mtab__dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.6); }
.mtab__check { font-weight: 600; }
.markup__hint { padding: 0 20px 12px; font-size: 15px; color: var(--ink-2); }
.markup__stage { flex: 1; min-height: 0; overflow: auto; background: var(--stage); display: flex; align-items: center; justify-content: center; padding: 20px; }
.markup__wrap { position: relative; line-height: 0; touch-action: none; cursor: crosshair; }
.markup__wrap img { display: block; max-width: 100%; max-height: calc(100vh - 280px); user-select: none; -webkit-user-drag: none; pointer-events: none; }
.markup__layer { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.55; pointer-events: none; }
.markup__tools { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; padding: 12px 16px; }
.markup__colors { display: flex; gap: 8px; }
.mcolor {
  width: 40px; height: 40px; border-radius: 50%; border: 0;
  color: #fff; font: 600 16px/1 var(--font); cursor: pointer;
}
.mcolor[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--plane), 0 0 0 5px var(--ink); }
.mcolor { position: relative; }
.mcolor--light { color: #000; }
/* A marker already used somewhere in the markup */
.mcolor--more { background: transparent; border: 1.5px dashed var(--line); color: var(--ink-2); font-size: 20px; }
.mcolor--more:hover { border-color: var(--ink); color: var(--ink); }
.mcolor.is-used::after {
  content: ""; position: absolute; right: -2px; top: -2px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--ink); box-shadow: 0 0 0 2px var(--plane);
}
.markup__colors { flex-wrap: wrap; }
.markup__size { display: inline-flex; align-items: center; gap: 10px; font-size: 15px; }
.markup__size input { width: 150px; accent-color: var(--ink); }

/* ---------- Narrower screens: stack the editor ---------- */
@media (max-width: 1100px) {
  .editor { display: flex; flex-direction: column; height: auto; min-height: 0; }
  .versions { order: 2; padding: 16px; overflow-x: auto; overflow-y: visible; }
  .versions__list { flex-direction: row; gap: 12px; margin-bottom: 10px; }
  .versions__list li { flex: 0 0 160px; }
  .result { order: 1; }
  .stage { padding: 16px; }
  .compare__before { max-height: 70vh; }
  .panel { order: 3; overflow: visible; }
}

@media (max-width: 760px) {
  .topbar { padding: 8px 16px; }
  .account__email { display: none; }
  .account__toggle::before { content: "Аккаунт"; font-size: 14px; }
  .account__panel { position: fixed; left: 16px; right: 16px; top: var(--topbar-h); min-width: 0; }
  .auth, .upload { grid-template-columns: minmax(0, 1fr); padding: 40px 16px 64px; gap: 24px; }
  /* On phones the drop area goes right under the headline, tips after it */
  .upload__intro { display: contents; }
  .upload__intro h1 { order: 1; }
  .upload__intro > p { order: 2; }
  .dropzone { order: 3; }
  .howto { order: 4; }
  .recent { order: 5; }
  .dropzone { aspect-ratio: 4 / 3; }
  .howto { margin-top: 16px; }
  .projects { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 12px; }
  .stage { padding: 8px; }
  .compare__before { min-width: 0; }
  .panel { padding: 20px 16px; }
  .markup { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  .markup__wrap img { max-height: calc(100dvh - 330px); }
  .markup__size input { width: 100px; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
}
