/* Hugo Ballot — quiet, fixed-height Rate → Create → Share shell. */

:root {
  --app-bg: #0b0b10;
  --app-surface: #17171d;
  --app-raised: #1e1e25;
  --app-line: #2b2b33;
  --app-text: #f4f1ea;
  --app-muted: #aaa7b2;
  --app-faint: #77747f;
  --app-accent: #f5724a;
  --app-accent-ink: #25100a;
  --app-success: #55cda1;
  --app-focus: #8d83ff;
  --app-radius: 16px;
  --row-gap: 6px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  background: var(--app-bg);
}

body {
  display: grid;
  place-items: center;
  color: var(--app-text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
    system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.35;
}

.starfield,
.sitefoot { display: none; }

.app-shell {
  width: 100%;
  height: 100dvh;
  max-width: 1180px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  background: var(--app-bg);
}

.app-bar {
  min-height: 58px;
  padding:
    max(10px, env(safe-area-inset-top))
    max(16px, calc(env(safe-area-inset-right) + 12px))
    8px
    max(16px, calc(env(safe-area-inset-left) + 12px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--app-line);
}

.app-bar-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mode-selector {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--app-line);
  border-radius: 12px;
  background: var(--app-surface);
  border-color: #f5724a66;
  box-shadow: 0 0 0 2px #f5724a14;
}

.mode-button {
  min-height: 30px;
  padding: 0 9px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--app-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
}

.mode-button.is-active {
  background: var(--app-accent);
  color: var(--app-accent-ink);
}

/* First-visit guide keeps the actual Creator/Gallery switch visible so people
   know where to return after the tour. */

body.onboarding-open { overflow: hidden; }

body.onboarding-open .app-bar {
  position: relative;
  z-index: 112;
  pointer-events: none;
}

body.onboarding-open .mode-selector {
  z-index: 113;
  border-color: #ff8b65;
  box-shadow: 0 0 0 4px #f5724a42, 0 0 28px #f5724a88;
}

.welcome-guide {
  position: fixed;
  z-index: 110;
  inset: 0;
  padding: max(82px, calc(env(safe-area-inset-top) + 76px))
    max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  display: grid;
  place-items: start center;
  overflow-y: auto;
  background: #05050be8;
  backdrop-filter: blur(10px);
}

.welcome-guide[hidden] { display: none; }

.welcome-card {
  width: min(100%, 480px);
  padding: 22px;
  border: 1px solid #f5724a66;
  border-radius: 20px;
  background: #17171ef5;
  box-shadow: 0 24px 80px #000d;
}

.welcome-card h2 { margin: 4px 0 6px; font-size: clamp(28px, 8vw, 38px); }
.welcome-card > p { color: var(--app-muted); }

.welcome-steps {
  margin: 20px 0;
  padding: 0;
  display: grid;
  gap: 12px;
  list-style: none;
}

.welcome-steps li { display: grid; grid-template-columns: 38px 1fr; gap: 12px; align-items: center; }
.welcome-steps li > span {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--app-accent);
  color: var(--app-accent-ink);
  font-weight: 800;
}
.welcome-steps strong { color: var(--app-text); }
.welcome-steps p { margin: 2px 0 0; color: var(--app-muted); font-size: 13px; }

.welcome-modes {
  width: fit-content;
  margin: 18px 0 10px;
  padding: 3px;
  display: flex;
  border: 1px solid #ff8b65;
  border-radius: 12px;
  box-shadow: 0 0 0 3px #f5724a24;
}

.welcome-modes span { padding: 8px 12px; border-radius: 9px; color: var(--app-muted); font-weight: 750; }
.welcome-modes .is-active { background: var(--app-accent); color: var(--app-accent-ink); }
.welcome-gallery-copy { margin: 0 0 18px; font-size: 13px; }
.welcome-awards {
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px solid var(--app-line);
  border-radius: 12px;
  background: #101016;
  font-size: 13px;
}
.welcome-awards > strong { color: var(--app-text); }
.welcome-awards p { margin: 5px 0 8px; color: var(--app-muted); }
.welcome-awards a,
.award-context a { color: #ff9a78; font-weight: 750; text-underline-offset: 3px; }
.welcome-done { width: 100%; }

/* Gallery is a separate top-level mode. Creator's grid and child state are
   untouched; only its three top-level rows are hidden while Gallery is open. */

.app-shell.gallery-mode {
  grid-template-rows: auto minmax(0, 1fr);
}

.app-shell.gallery-mode > .flow-progress,
.app-shell.gallery-mode > .flow-viewport,
.app-shell.gallery-mode > .flow-actions {
  display: none !important;
}

.gallery-view {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding:
    20px max(16px, calc(env(safe-area-inset-right) + 12px))
    max(32px, calc(env(safe-area-inset-bottom) + 20px))
    max(16px, calc(env(safe-area-inset-left) + 12px));
}

.gallery-inner {
  width: min(100%, 980px);
  margin-inline: auto;
}

.gallery-pull {
  height: 0;
  overflow: visible;
  position: relative;
  z-index: 2;
  transform: translateY(calc(-34px + var(--gallery-pull, 0px)));
  color: var(--app-success);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  opacity: 0;
  pointer-events: none;
}

.gallery-view.is-pulling .gallery-pull { opacity: 1; }

.gallery-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.gallery-toolbar h2 { margin: 2px 0 0; }

.gallery-tools {
  display: flex;
  align-items: end;
  gap: 8px;
}

.gallery-refresh {
  min-height: 42px;
  padding-inline: 11px;
  white-space: nowrap;
}

.gallery-year-label {
  display: grid;
  gap: 4px;
  color: var(--app-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.gallery-year-label select {
  min-width: 104px;
  min-height: 42px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--app-line);
  border-radius: 12px;
  background: var(--app-raised);
  color: var(--app-text);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
}

.public-upload-control {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: space-between;
  width: min(100%, 620px);
  margin: 0 auto;
  padding: 11px 13px;
  border: 1px solid #654132;
  border-radius: var(--app-radius);
  background: #211711;
}

.public-upload-control strong { display: block; margin-bottom: 2px; font-size: 13px; }
.public-upload-control p {
  max-width: 680px;
  margin: 0;
  color: #cabcb3;
  font-size: 11px;
}

.gallery-switch {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 42px;
  justify-items: center;
  gap: 3px;
  color: var(--app-muted);
  font-size: 10px;
}

.gallery-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.gallery-switch span {
  width: 42px;
  height: 24px;
  padding: 3px;
  border-radius: 999px;
  background: var(--app-faint);
  transition: background .18s ease;
}

.gallery-switch span::after {
  content: "";
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  transition: transform .18s ease;
}

.gallery-switch input:checked + span { background: var(--app-accent); }
.gallery-switch input:checked + span::after { transform: translateX(18px); }
.gallery-switch input:focus-visible + span { outline: 2px solid var(--app-focus); outline-offset: 3px; }

.gallery-status {
  min-height: 19px;
  margin: 6px 2px 12px;
  color: var(--app-muted);
  font-size: 12px;
}

.gallery-status[data-kind="error"] { color: #ffad98; }
.gallery-status[data-kind="success"] { color: var(--app-success); }

.gallery-board {
  columns: 2;
  column-gap: 10px;
}

.gallery-card {
  width: 100%;
  margin: 0 0 10px;
  padding: 0;
  overflow: hidden;
  break-inside: avoid;
  border: 1px solid var(--app-line);
  border-radius: 15px;
  background: var(--app-surface);
  color: var(--app-text);
  text-align: left;
}

.gallery-card img {
  display: block;
  width: 100%;
  height: auto;
  background: var(--app-raised);
}

.gallery-card span {
  display: block;
  padding: 8px 10px 9px;
  color: var(--app-muted);
  font-size: 11px;
}

.gallery-empty {
  padding: 52px 20px;
  border: 1px dashed var(--app-line);
  border-radius: var(--app-radius);
  color: var(--app-muted);
  text-align: center;
}

.gallery-empty .primary-btn { margin-top: 8px; }

.gallery-detail {
  width: min(100%, 720px);
  margin-inline: auto;
}

.gallery-back { margin-bottom: 12px; }
.gallery-detail img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--app-line);
  border-radius: 18px;
  background: var(--app-surface);
}

.gallery-detail p {
  margin: 10px 2px;
  color: var(--app-muted);
  text-align: center;
}

@media (min-width: 700px) {
  .gallery-board { columns: 3; column-gap: 14px; }
  .gallery-card { margin-bottom: 14px; }
}

@media (min-width: 1000px) {
  .gallery-board { columns: 4; }
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  box-shadow: none;
}

h1 {
  margin: 0;
  color: var(--app-text);
  background: none;
  font-size: 17px;
  line-height: 1.1;
  letter-spacing: -.01em;
  -webkit-text-fill-color: currentColor;
}

.tagline {
  margin: 2px 0 0;
  color: var(--app-faint);
  font-size: 12px;
}

.offline-notice {
  position: fixed;
  z-index: 70;
  top: max(8px, env(safe-area-inset-top));
  left: 50%;
  width: min(440px, calc(100% - 24px));
  margin: 0;
  transform: translateX(-50%);
  padding: 10px 14px;
  border: 1px solid #8d6e37;
  border-radius: 12px;
  background: #2a2117;
  color: #f2d397;
  font-size: 13px;
  text-align: center;
}

.flow-progress {
  min-height: 50px;
  padding: 7px max(16px, calc(env(safe-area-inset-right) + 12px))
    7px max(16px, calc(env(safe-area-inset-left) + 12px));
  display: grid;
  grid-template-columns: auto 1fr auto 1fr auto;
  align-items: center;
  gap: 9px;
  border-bottom: 1px solid var(--app-line);
  background: #101015;
}

.flow-progress > i {
  height: 1px;
  background: var(--app-line);
}

.flow-progress-step {
  min-height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  background: transparent;
  color: var(--app-faint);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
}

.flow-progress-step span {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid var(--app-line);
  border-radius: 50%;
  color: var(--app-muted);
  font-size: 12px;
}

.flow-progress-step[aria-current="step"] {
  padding: 0 9px;
  border-radius: 999px;
  background: #3b1d17;
  color: #fff;
  box-shadow: inset 0 0 0 1px #a9472c;
}

.flow-progress-step[aria-current="step"] span {
  border-color: var(--app-accent);
  background: var(--app-accent);
  color: var(--app-accent-ink);
}

.flow-progress-step.is-complete { color: var(--app-muted); cursor: pointer; }
.flow-progress-step.is-complete span {
  border-color: #356f5c;
  background: #183a30;
  color: var(--app-success);
}

.flow-progress-step:disabled { opacity: 1; cursor: default; }

.flow-viewport {
  position: static;
  z-index: auto;
  width: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.flow-step {
  width: 100%;
  min-width: 0;
  height: 100%;
  min-height: 0;
  padding: 14px max(16px, calc(env(safe-area-inset-right) + 12px))
    12px max(16px, calc(env(safe-area-inset-left) + 12px));
  overflow: hidden;
}

.step-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.step-head h2 {
  margin: 0;
  color: var(--app-text);
  font-size: clamp(23px, 6vw, 29px);
  line-height: 1.08;
  letter-spacing: -.025em;
}

.step-kicker {
  margin: 0 0 4px;
  color: var(--app-accent);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.stack-sub,
.share-mode {
  margin: 4px 0 0;
  color: var(--app-muted);
  font-size: 13px;
}

.primary-btn,
.quiet-btn,
.ghost-btn,
.edit-btn {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease,
    color .16s ease, transform .12s ease;
}

.primary-btn {
  border: 1px solid #ff8d6b;
  background: var(--app-accent);
  color: var(--app-accent-ink);
  box-shadow: none;
}

.quiet-btn,
.ghost-btn {
  border: 1px solid var(--app-line);
  background: var(--app-raised);
  color: var(--app-text);
}

.edit-btn {
  min-height: 40px;
  border: 1px solid #ffffff40;
  background: #0b0b10d9;
  color: #fff;
  backdrop-filter: blur(12px);
}

.primary-btn:hover,
.quiet-btn:hover,
.ghost-btn:hover,
.edit-btn:hover { transform: none; filter: brightness(1.08); }

.primary-btn:active,
.quiet-btn:active,
.ghost-btn:active,
.edit-btn:active { transform: scale(.98); }

:where(a, button, input, select, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--app-focus);
  outline-offset: 2px;
}

button[disabled] { opacity: .42; cursor: not-allowed; }

/* Rate */

.rate-step {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 9px;
}

.rate-step > *,
.create-step > *,
.studio > * { min-width: 0; }

.rate-head {
  gap: 8px;
}

.rate-head > :first-child {
  min-width: 0;
}

.rate-head h2 {
  font-size: clamp(21px, 5.5vw, 29px);
}

.award-context {
  margin: 3px 0 0;
  color: var(--app-faint);
  font-size: 11px;
  line-height: 1.35;
}

.award-context a { white-space: nowrap; }

.rate-head-actions {
  flex: 0 0 auto;
  display: grid;
  justify-items: end;
  gap: 6px;
}

.rate-menu { position: relative; }

.rate-menu > summary {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--app-line);
  border-radius: 12px;
  background: var(--app-surface);
  color: var(--app-muted);
  font-size: 18px;
  letter-spacing: 2px;
  list-style: none;
  cursor: pointer;
}

.rate-menu > summary::-webkit-details-marker { display: none; }

.rate-menu-popover {
  position: absolute;
  z-index: 20;
  top: 50px;
  right: 0;
  width: min(300px, calc(100vw - 32px));
  padding: 12px;
  display: grid;
  gap: 8px;
  border: 1px solid var(--app-line);
  border-radius: 14px;
  background: #1b1b22f7;
  box-shadow: 0 20px 50px #000b;
}

.rate-menu-popover .quiet-btn { width: 100%; text-align: left; }
.rate-menu-popover .menu-link {
  width: 100%;
  display: flex;
  align-items: center;
  text-align: left;
  text-decoration: none;
}
.rate-menu-popover p,
.rate-menu-popover small {
  margin: 2px;
  color: var(--app-muted);
  font-size: 12px;
  line-height: 1.45;
}
.rate-menu-popover small { color: var(--app-faint); }

.rate-year-control {
  display: block;
}

.rate-year-control select {
  width: 118px;
  min-height: 44px;
  margin: 0;
  padding: 0 26px 0 9px;
  border: 1px solid #a9472c;
  border-radius: 10px;
  background: #3b1d17;
  color: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
}

.stack {
  width: min(100%, 720px);
  height: 100% !important;
  min-height: 0;
  margin: 0 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  touch-action: pan-y;
}

.book {
  height: 56px;
  grid-template-columns: 34px 32px minmax(0, 1fr) 50px;
  gap: 9px;
  padding: 5px 4px 5px 7px;
  border: 1px solid var(--app-line);
  border-radius: 12px;
  background: var(--app-surface);
  box-shadow: none;
}

.book:hover,
.book:focus-visible { background: var(--app-raised); border-color: #42424c; }

.book.rank-1 {
  border-color: #8a4431;
  background: #211714;
}

.book-cover {
  width: 32px;
  height: 46px;
  border-radius: 4px;
  box-shadow: none;
}

.rank {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #25252c;
  color: var(--app-muted);
  font-size: 13px;
}

.rank-1 .rank {
  background: var(--app-accent);
  color: var(--app-accent-ink);
  box-shadow: none;
}

.book-meta { min-width: 0; align-self: center; }
.book-title {
  margin: 0;
  overflow: hidden;
  color: var(--app-text);
  font-size: 14px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-author {
  margin: 2px 0 0;
  overflow: hidden;
  color: var(--app-muted);
  font-size: 12px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-tags { display: none; }

.grip {
  align-self: stretch;
  min-width: 50px;
  border-radius: 9px;
  background: transparent;
  color: var(--app-faint);
  font-size: 22px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.grip::before {
  content: '⠿';
  pointer-events: none;
}

.grip:hover { background: #ffffff0a; color: var(--app-text); }

/* Create */

.create-step {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
}

.studio {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
}

.studio-tabs {
  width: 100%;
  margin: 0;
  padding: 3px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 3px;
  border: 1px solid var(--app-line);
  border-radius: 12px;
  background: var(--app-surface);
}

.studio-tab {
  min-width: 0;
  min-height: 44px;
  padding: 0 5px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--app-muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.1;
}

.studio-tab[aria-selected="true"] {
  background: #34343d;
  color: #fff;
  box-shadow: none;
}

.studio-tab[aria-selected="true"]::after { display: none; }

.create-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  align-items: end;
  gap: 8px;
  padding: 8px 0;
}

.field {
  min-width: 0;
  margin: 0;
}

.field span,
.seg-field legend {
  display: block;
  margin: 0 0 4px;
  color: var(--app-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: none;
}

.field input,
.field select {
  width: 100%;
  min-height: 42px;
  padding: 0 34px 0 11px;
  border: 1px solid var(--app-line);
  border-radius: 10px;
  background-color: var(--app-surface);
  color: var(--app-text);
  font: inherit;
  font-size: 14px;
}

.field input { padding-right: 11px; }
.field input::placeholder { color: var(--app-faint); }

.studio-panel {
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

.studio-panel[hidden] { display: none !important; }

.body-mode {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 6px;
}

.body-workspace {
  display: contents;
}

.poster {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 6px;
}

.card-mode {
  position: relative;
  display: grid;
  min-height: 0;
}

.render-out,
.body-out {
  min-height: 0;
  margin: 0;
}

.layer-stage {
  position: relative;
  width: min(100%, 620px);
  max-width: none;
  height: 100%;
  max-height: 100%;
  aspect-ratio: 3 / 2;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--app-line);
  border-radius: var(--app-radius);
  background: #08080c;
  box-shadow: none;
  isolation: isolate;
}

.layer-stage > canvas,
.render-out canvas {
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  display: block;
  object-fit: contain;
  border: 0;
  border-radius: var(--app-radius);
  background: #08080c;
  box-shadow: none;
}

.layer-stage.is-editing {
  border-color: #b54d31;
  box-shadow: 0 0 0 2px #f5724a33;
}

.layer-editor-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
}

.editor-toolbar {
  position: absolute;
  z-index: 4;
  top: 9px;
  right: 9px;
  width: auto;
  max-width: none;
  margin: 0;
  display: block;
}

.editor-actions {
  display: flex;
  gap: 6px;
}

.editor-actions .quiet-btn { min-height: 40px; background: #0b0b10d9; }

.editor-help,
.drag-hint {
  margin: 5px 0 0;
  color: var(--app-faint);
  font-size: 11px;
  text-align: center;
}

.body-out {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

.body-controls {
  width: min(100%, 620px);
  margin: 0 auto;
}

.body-upload-card {
  min-height: 58px;
  padding: 7px 8px 7px 11px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--app-line);
  border-radius: 12px;
  background: var(--app-surface);
}

.body-upload-card > div:first-child {
  min-width: 0;
  flex: 1;
}

.body-upload-title {
  margin: 0;
  color: var(--app-text);
  font-size: 13px;
  font-weight: 700;
}

.field-note {
  margin: 2px 0 0;
  color: var(--app-muted);
  font-size: 11px;
  line-height: 1.3;
}

.body-file-button {
  grid-column: 2;
  grid-row: 1;
  min-height: 42px;
  margin: 0;
  padding: 0 13px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.body-file-actions {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex: 0 0 auto;
  gap: 5px;
}

.body-file-actions .quiet-btn {
  min-height: 40px;
  padding: 0 10px;
  font-size: 12px;
}

.body-status {
  min-height: 0;
  margin: 4px 2px 0;
  color: var(--app-muted);
  font-size: 11px;
}

.body-status:empty { display: none; }
.body-status[data-tone="ok"] { color: var(--app-success); }
.body-status[data-tone="error"] { color: #ffae97; }

.privacy-note {
  margin: 2px;
  padding: 0;
  border: 0;
  color: var(--app-faint);
  font-size: 10px;
}

.mode-controls {
  min-width: 0;
  min-height: 42px;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 6px;
}

.seg-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.seg {
  height: 40px;
  padding: 3px;
  display: inline-flex;
  gap: 2px;
  border: 1px solid var(--app-line);
  border-radius: 10px;
  background: var(--app-surface);
}

.seg-btn {
  min-width: 48px;
  padding: 0 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--app-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
}

.seg-btn[aria-checked="true"] {
  background: #34343d;
  color: #fff;
  box-shadow: none;
}

.mode-controls > .quiet-btn {
  min-height: 40px;
  padding-inline: 11px;
}

.poster .render-out {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

.poster .layer-stage {
  height: auto;
  align-self: center;
}

.face-block {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.face-block > summary {
  min-height: 42px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--app-line);
  border-radius: 11px;
  background: var(--app-surface);
  color: var(--app-text);
  font-size: 13px;
  font-weight: 700;
  list-style: none;
}

.face-block > summary::before { display: none; }
.face-block > summary::-webkit-details-marker { display: none; }

.face-block .opt {
  padding: 2px 7px;
  border: 0;
  border-radius: 999px;
  background: #2b2b33;
  color: var(--app-muted);
  font-size: 9px;
}

.face-block[open] {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  align-items: end;
  padding: 0;
  background: #000b;
  backdrop-filter: blur(8px);
}

.face-block[open] > summary { display: none; }

.face-sheet-inner {
  width: min(100%, 520px);
  max-height: 92dvh;
  margin: 0 auto;
  padding: 20px 20px max(20px, calc(env(safe-area-inset-bottom) + 14px));
  overflow-y: auto;
  border: 1px solid var(--app-line);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  background: var(--app-surface);
  box-shadow: 0 -20px 60px #000c;
}

.face-sheet-inner h3 {
  margin: 0;
  font-size: 24px;
}

.face-stage {
  margin: 18px 0;
  display: grid;
  justify-items: center;
  gap: 14px;
}

.face-frame {
  width: min(240px, 64vw);
  height: min(240px, 64vw);
  border: 2px solid var(--app-line);
  background: #08080c;
}

.face-frame.live { border-color: var(--app-success); box-shadow: none; }
.face-frame.shot { border-color: var(--app-accent); box-shadow: none; }

.face-frame video,
.face-frame canvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
}

.face-buttons {
  width: 100%;
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.upload-btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.face-adjust {
  margin: 0;
  padding: 0;
  border: 0;
  text-align: center;
}

.face-done {
  width: 100%;
  margin-top: 6px;
}

.backdrop-field {
  position: static;
  width: auto;
}

.backdrop-field select {
  min-height: 42px;
  background-color: var(--app-surface);
}

.card-mode .render-out {
  height: 100%;
  display: grid;
  place-items: center;
}

.card-mode .render-out canvas {
  width: auto;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  aspect-ratio: 4 / 5;
}

.warn {
  margin: 4px 0 0;
  padding: 7px 10px;
  border: 1px solid #8a4b38;
  border-radius: 9px;
  background: #321b18;
  color: #ffbfaa;
  font-size: 11px;
}

/* Share */

.share-step {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  gap: 8px;
}

.final-preview {
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.final-preview canvas {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 100%;
  border: 1px solid var(--app-line);
  border-radius: var(--app-radius);
  background: #08080c;
  box-shadow: 0 18px 48px #0008;
}

.share-actions {
  width: min(100%, 620px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.share-actions .primary-btn { width: 100%; }

.save-help {
  margin: 0;
  color: var(--app-muted);
  font-size: 12px;
  text-align: center;
}

/* Persistent bottom action */

.flow-actions {
  min-height: 68px;
  padding: 9px max(16px, calc(env(safe-area-inset-right) + 12px))
    max(9px, env(safe-area-inset-bottom))
    max(16px, calc(env(safe-area-inset-left) + 12px));
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--app-line);
  background: #101015f2;
  backdrop-filter: blur(16px);
}

.flow-actions .primary-btn { min-width: min(100%, 250px); }
.flow-actions .quiet-btn { margin-right: auto; }
.flow-actions.share-footer { justify-content: flex-start; }

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Existing book/install sheets stay modal inside the fixed shell. */

.sheet,
.install-sheet {
  color: var(--app-text);
  background: var(--app-surface);
  border-color: var(--app-line);
}

@media (min-width: 760px) {
  body { padding: 18px; }

  .app-shell {
    height: min(920px, calc(100dvh - 36px));
    border: 1px solid var(--app-line);
    border-radius: 22px;
    box-shadow: 0 30px 90px #000a;
  }

  .flow-step { padding-inline: 28px; }
  .flow-progress { padding-inline: 28px; }
  .rate-step { padding-inline: max(28px, calc((100% - 780px) / 2)); }

  .create-step {
    grid-template-columns: 190px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 28px;
  }

  .create-head {
    padding-top: 4px;
    border-right: 1px solid var(--app-line);
  }

  .studio { padding-block: 2px; }
  .studio-panel { max-width: 800px; margin-inline: auto; width: 100%; }

  .face-sheet-inner { max-width: 520px; }
}

@media (max-height: 700px) {
  .app-bar { min-height: 50px; }
  .tagline { display: none; }
  .flow-progress { min-height: 44px; padding-block: 4px; }
  .flow-step { padding-block: 8px; }
  .step-kicker { display: none; }
  .flow-actions { min-height: 60px; }
  .privacy-note { display: none; }
  .face-frame { width: 150px; height: 150px; }
}

@media (max-width: 430px) {
  .flow-progress { gap: 5px; }
  .flow-progress-step { gap: 5px; font-size: 12px; }
  .flow-progress-step[aria-current="step"] { padding-inline: 7px; }
  .flow-progress-step span { width: 22px; height: 22px; }
  .create-fields { grid-template-columns: .82fr 1.18fr; }
  .book { grid-template-columns: 31px 31px minmax(0, 1fr) 50px; gap: 7px; }
}

/* Keep the complete first-run tour above mobile browser chrome. The dialog is
   deliberately denser than the rest of the app so Start rating never requires
   a scroll on a phone-sized viewport. */
@media (max-width: 600px) {
  .welcome-guide {
    padding: var(--welcome-top, max(68px, calc(env(safe-area-inset-top) + 62px)))
      max(12px, env(safe-area-inset-right))
      max(8px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
    place-items: start center;
    overflow: hidden;
  }

  .welcome-card {
    padding: 13px 16px;
    border-radius: 16px;
  }

  .welcome-card .step-kicker { margin-bottom: 2px; }
  .welcome-card h2 { margin: 0 0 3px; font-size: 29px; line-height: 1.05; }
  #welcomeSummary { margin: 0; font-size: 13px; line-height: 1.3; }

  .welcome-steps {
    margin: 9px 0;
    gap: 4px;
  }

  .welcome-steps li {
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 9px;
  }

  .welcome-steps li > span {
    width: 30px;
    height: 30px;
    font-size: 14px;
  }

  .welcome-steps strong { font-size: 14px; }
  .welcome-steps p { margin-top: 0; font-size: 11px; line-height: 1.25; }

  .welcome-modes {
    margin: 7px 0 6px;
    padding: 2px;
    border-radius: 10px;
  }

  .welcome-modes span { padding: 5px 9px; border-radius: 8px; font-size: 13px; }
  .welcome-gallery-copy { margin: 0 0 7px; font-size: 11px; line-height: 1.3; }

  .welcome-awards {
    margin: 0 0 7px;
    padding: 7px 10px;
    border-radius: 10px;
    font-size: 11px;
    line-height: 1.28;
  }

  .welcome-awards p { margin: 2px 0 4px; }
  .welcome-done { min-height: 38px; }
}

@media (max-width: 600px) and (max-height: 680px) {
  .welcome-card { padding-block: 9px; }
  .welcome-card .step-kicker { display: none; }
  .welcome-card h2 { font-size: 25px; }
  .welcome-steps { margin-block: 6px; gap: 2px; }
  .welcome-modes { margin-top: 4px; }
  .welcome-awards { padding-block: 5px; }
}

/* The shared editor powers Star Yourself, Take Photo, and Mars Depot. On phone
   screens it becomes a true full-screen workspace while preserving 3:2 art. */
@media (max-width: 759px) {
  body.layer-editor-open {
    overflow: hidden;
    overscroll-behavior: none;
  }

  .layer-stage.is-editing,
  .poster .layer-stage.is-editing {
    position: fixed;
    z-index: 120;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    aspect-ratio: auto;
    border: 0;
    border-radius: 0;
    background: #05050a;
    box-shadow: none;
  }

  .layer-stage.is-editing > canvas,
  .layer-stage.is-editing > .layer-editor-overlay {
    position: absolute;
    z-index: 1;
    top: 50%;
    left: 50%;
    inset: auto;
    width: min(100vw, 150dvh);
    height: auto;
    aspect-ratio: 3 / 2;
    transform: translate(-50%, -50%);
    border-radius: 0;
  }

  .layer-stage.is-editing > .layer-editor-overlay { z-index: 2; }

  .layer-stage.is-editing .editor-toolbar {
    position: fixed;
    z-index: 4;
    top: max(10px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
  }

  .layer-stage.is-editing .editor-actions .quiet-btn,
  .layer-stage.is-editing .editor-actions .edit-btn {
    min-height: 44px;
    padding-inline: 16px;
    background: #0b0b10e8;
    box-shadow: 0 4px 18px #0009;
  }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
