:root {
  --red-950: #6f0905;
  --red-900: #97120b;
  --red-800: #bd1d12;
  --red-700: #e1261c;
  --red-600: #f33828;
  --gold: #ffd369;
  --gold-strong: #f5ad35;
  --cream: #fff4df;
  --cream-2: #fff9ef;
  --ink: #32150c;
  --muted: #9a6f5d;
  --line: rgba(143, 50, 22, .15);
  --glass-fill: rgba(255, 250, 241, .62);
  --glass-fill-strong: rgba(255, 248, 236, .82);
  --glass-stroke: rgba(255, 255, 255, .64);
  --glass-shadow: 0 18px 45px rgba(116, 24, 10, .22);
  --glass-inner: inset 0 1px 0 rgba(255, 255, 255, .78), inset 0 -1px 0 rgba(160, 54, 22, .08);
  --radius-xs: 10px;
  --radius-sm: 14px;
  --radius-md: 18px;
  --radius-lg: 28px;
  --radius-xl: 34px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(.2, .8, .2, 1);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: #3a0704;
}

body {
  min-height: 100svh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 0, rgba(255, 208, 102, .22), transparent 30%),
    linear-gradient(180deg, #460805, #120101 88%);
  display: flex;
  justify-content: center;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

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

a {
  color: inherit;
  text-decoration: none;
}

svg {
  display: block;
}

button svg,
.glass-icon-button svg,
.stage-action svg,
.sheet-action-tile svg,
.primary-action svg,
.bottom-tabbar svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.liquid-filter-defs {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
}

.app-shell {
  width: min(100vw, 430px);
  min-height: 100svh;
  position: relative;
  isolation: isolate;
  padding: calc(var(--safe-top) + 16px) 14px calc(var(--safe-bottom) + 114px);
  overflow-x: hidden;
  background: #d8190f;
  box-shadow: 0 0 0 1px rgba(255,255,255,.06), 0 34px 80px rgba(0,0,0,.34);
}

.app-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(180deg, rgba(202, 8, 0, .08) 0 28%, rgba(255, 244, 223, .1) 58%),
    url("assets/mobile-2027/backgrounds/festival-page-bg.png") top center / cover no-repeat;
}

.app-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at 14% 18%, rgba(255, 226, 129, .25) 0 1px, transparent 2px),
    radial-gradient(circle at 84% 13%, rgba(255, 255, 255, .2) 0 1px, transparent 2px),
    linear-gradient(180deg, rgba(116, 7, 2, .05), rgba(255, 245, 227, .82) 67%, #fff5e6 100%);
  background-size: 74px 74px, 96px 96px, auto;
}

.is-hidden,
.fallback-photo-actions {
  display: none !important;
}

.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;
}

.glass-panel,
.glass-button,
.glass-icon-button,
.glass-drawer,
.glass-sheet {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(255,255,255,.72), rgba(255,244,226,.34)),
    var(--glass-fill);
  border: 1px solid var(--glass-stroke);
  box-shadow: var(--glass-shadow), var(--glass-inner);
}

.glass-panel::before,
.glass-button::before,
.glass-icon-button::before,
.glass-drawer::before,
.glass-sheet::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(120deg, rgba(255,255,255,.72), rgba(255,255,255,0) 32%),
    radial-gradient(circle at 16% 0, rgba(255, 255, 255, .42), transparent 30%);
  opacity: .7;
}

.aave-glass::after {
  content: "";
  position: absolute;
  inset: 1px;
  pointer-events: none;
  border-radius: inherit;
  z-index: 1;
  background:
    radial-gradient(circle at 24% 12%, rgba(255,255,255,.82), transparent 20%),
    linear-gradient(135deg, rgba(255,255,255,.7), transparent 34% 66%, rgba(255, 201, 91, .18));
  mix-blend-mode: screen;
  opacity: .26;
}

.glass-refraction {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 10%, rgba(255,255,255,.62), transparent 24%),
    linear-gradient(135deg, rgba(255,255,255,.44), rgba(255,255,255,0) 42%, rgba(255, 215, 128, .22) 76%, rgba(255,255,255,.38));
  opacity: .45;
}

.glass-icon-button {
  width: 48px;
  height: 48px;
  border-radius: 17px;
  display: grid;
  place-items: center;
  color: #fff8df;
  background: rgba(255, 255, 255, .12);
}

.glass-icon-button > *,
.glass-button > *,
.glass-panel > *,
.glass-drawer > *,
.glass-sheet > *,
.glass-tabbar > * {
  position: relative;
  z-index: 2;
}

.glass-refraction {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
}

.mobile-topbar {
  position: relative;
  display: block;
  min-height: 88px;
}

.mobile-title {
  text-align: center;
  color: #fff7d7;
  text-shadow: 0 4px 18px rgba(80, 7, 2, .34);
  min-width: 0;
  padding: 8px 54px 0;
}

.top-gallery-button,
.top-export-button {
  position: absolute;
  top: 7px;
}

.top-gallery-button {
  left: 0;
}

.top-export-button {
  right: 0;
}

.mobile-title h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.06;
  font-weight: 900;
  letter-spacing: 0;
  white-space: nowrap;
}

.mobile-title p {
  margin: 7px 0 0;
  font-size: 15px;
  line-height: 1.1;
  font-weight: 700;
  color: rgba(255, 245, 202, .94);
}

.history-strip {
  display: none;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  align-items: center;
  padding: 6px;
  border-radius: 18px;
  margin: 0 auto 12px;
  color: rgba(255, 252, 235, .95);
  background: rgba(108, 13, 5, .18);
}

.history-button,
.history-toggle {
  min-height: 30px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff5d1;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  font-size: 12px;
  font-weight: 800;
}

.history-toggle {
  gap: 5px;
}

.history-toggle input {
  width: 13px;
  height: 13px;
  margin: 0;
  accent-color: var(--red-700);
}

.mobile-editor {
  display: grid;
  gap: 12px;
}

.hero-stage {
  display: grid;
  gap: 12px;
  order: 1;
}

.canvas-card {
  padding: 0;
  border-radius: 30px;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.canvas-toolbar {
  display: none;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 8px;
}

.canvas-toolbar strong {
  color: var(--red-900);
  font-size: 13px;
  line-height: 1;
  font-weight: 900;
}

.canvas-toolbar span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.canvas-wrap {
  border-radius: 25px;
  padding: 5px;
  background:
    linear-gradient(145deg, rgba(255, 228, 154, .96), rgba(180, 38, 19, .62)),
    rgba(255, 255, 255, .3);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.52), 0 14px 32px rgba(130, 28, 10, .18);
  touch-action: none;
}

.canvas-wrap.is-circle-output {
  border-radius: 50%;
}

.canvas-wrap.has-movable-layer #avatarCanvas {
  cursor: grab;
}

.canvas-wrap.is-dragging-layer #avatarCanvas {
  cursor: grabbing;
}

.canvas-wrap.show-grid {
  background-image:
    linear-gradient(145deg, rgba(255, 228, 154, .96), rgba(180, 38, 19, .62)),
    linear-gradient(rgba(255,255,255,.3) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.3) 1px, transparent 1px);
  background-size: auto, 25% 25%, 25% 25%;
}

#avatarCanvas {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  border-radius: 21px;
  background: #fff2d4;
  box-shadow: 0 8px 22px rgba(82, 18, 8, .16);
}

.canvas-wrap.is-circle-output #avatarCanvas,
.export-preview-row img.is-circle-output {
  border-radius: 50%;
}

.preview-meta {
  display: none;
  justify-content: center;
  gap: 12px;
  padding: 8px 4px 2px;
  color: rgba(126, 82, 60, .78);
  font-size: 12px;
  font-weight: 700;
}

.stage-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.stage-actions.primary-stage-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stage-action {
  min-height: 74px;
  border-radius: 19px;
  color: #5a2918;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 5px;
}

.stage-action strong {
  font-size: 12px;
  line-height: 1.1;
  font-weight: 900;
}

.mobile-primary {
  text-align: center;
}

.primary-action {
  width: 100%;
  min-height: 62px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: white;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.2), rgba(255,255,255,0) 32%),
    linear-gradient(135deg, #ff392e, #c90d07);
  box-shadow: 0 19px 34px rgba(162, 20, 10, .31), inset 0 1px 0 rgba(255,255,255,.28);
  font-size: 23px;
  font-weight: 900;
}

.mobile-primary p {
  margin: 8px 0 0;
  color: rgba(130, 83, 58, .76);
  font-size: 13px;
  font-weight: 700;
}

.crop-dock {
  display: none;
}

.section-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.section-title span {
  color: var(--ink);
  font-size: 16px;
  font-weight: 900;
}

.section-title small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.section-title.compact {
  margin-bottom: 9px;
}

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 16px;
  background: rgba(255, 255, 255, .54);
  border: 1px solid rgba(139, 55, 27, .11);
}

.segmented button {
  min-height: 34px;
  border-radius: 12px;
  color: #7e513f;
  background: transparent;
  font-size: 13px;
  font-weight: 900;
}

.segmented button.is-active {
  color: var(--red-800);
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 7px 14px rgba(143, 50, 22, .12), inset 0 0 0 1px rgba(227, 58, 46, .3);
}

.range-stack {
  display: grid;
  gap: 9px;
  margin-top: 11px;
}

.range-stack label {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--red-700);
}

.bottom-tabbar {
  --active-tab-index: 0;
  position: fixed;
  z-index: 64;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 12px);
  width: min(calc(100vw - 22px), 408px);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  padding: 6px;
  border-radius: 29px;
  transform: translateX(-50%);
  color: #73503f;
  background:
    linear-gradient(180deg, rgba(255,255,255,.72), rgba(255,248,232,.34)),
    rgba(255, 247, 232, .66);
  border: 1px solid rgba(255,255,255,.66);
  box-shadow:
    0 18px 44px rgba(87, 17, 7, .24),
    inset 0 1px 0 rgba(255,255,255,.86),
    inset 0 -1px 0 rgba(142, 48, 22, .08);
}

.tabbar-lens {
  position: absolute;
  z-index: 0;
  top: 6px;
  bottom: 6px;
  left: 6px;
  width: calc((100% - 12px) / 5);
  border-radius: 23px;
  transform: translateX(calc(var(--active-tab-index) * 100%));
  transition: transform .34s cubic-bezier(.18, .9, .2, 1.08);
  background:
    linear-gradient(160deg, rgba(255,255,255,.62), rgba(255,227,169,.2)),
    rgba(255,255,255,.36);
  border: 1px solid rgba(255,255,255,.72);
  box-shadow:
    0 10px 22px rgba(160, 34, 16, .2),
    inset 0 1px 0 rgba(255,255,255,.92),
    inset 0 -1px 0 rgba(180, 55, 24, .12);
}

.bottom-tabbar button {
  min-height: 57px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  color: #8d6c5b;
  background: transparent;
  font-size: 11px;
  font-weight: 900;
  position: relative;
  z-index: 1;
  transition: color .2s var(--ease), transform .2s var(--ease);
}

.bottom-tabbar button svg {
  width: 21px;
  height: 21px;
}

.bottom-tabbar button.is-active {
  color: var(--red-800);
  transform: translateY(-1px);
}

.tool-surface {
  position: fixed;
  z-index: 63;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 92px);
  width: min(calc(100vw - 22px), 408px);
  max-height: min(39svh, 348px);
  transform: translate(-50%, 18px) scale(.985);
  opacity: 0;
  pointer-events: none;
  border-radius: 30px;
  padding: 7px 12px 14px;
  overflow-y: auto;
  background:
    linear-gradient(180deg, rgba(255,255,255,.72), rgba(255, 246, 230, .46)),
    rgba(255, 248, 237, .72);
  transition: opacity .22s var(--ease), transform .24s var(--ease);
}

.tool-surface.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0) scale(1);
}

.sheet-compact-header {
  min-height: 43px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.sheet-compact-header strong {
  display: block;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.1;
  font-weight: 900;
}

.sheet-compact-header span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.sheet-close-button {
  width: 38px;
  height: 38px;
  color: var(--red-800);
  background: rgba(255,255,255,.44);
}

.tool-panel {
  display: none;
  padding: 0 0 2px;
}

.tool-panel.is-active {
  display: block;
}

.option-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 86px;
  gap: 10px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding: 2px 2px 8px;
  scrollbar-width: none;
}

.option-grid::-webkit-scrollbar,
.gallery-rail::-webkit-scrollbar {
  display: none;
}

.option-tile {
  min-height: 104px;
  padding: 7px;
  border-radius: 15px;
  display: grid;
  gap: 6px;
  align-content: start;
  text-align: center;
  color: #68402f;
  background: rgba(255, 255, 255, .58);
  border: 1px solid rgba(139, 55, 27, .1);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.68);
  position: relative;
}

.option-tile.is-active {
  color: var(--red-800);
  border-color: rgba(230, 45, 35, .82);
  box-shadow: 0 10px 18px rgba(196, 35, 22, .16), inset 0 0 0 1px rgba(230, 45, 35, .32);
}

.option-tile.is-muted {
  opacity: .62;
}

.option-tile .check {
  position: absolute;
  right: 5px;
  bottom: 27px;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(135deg, #ff4635, #c70e07);
  box-shadow: 0 6px 12px rgba(184, 25, 14, .22);
  font-size: 14px;
  font-weight: 900;
  opacity: 0;
  transform: scale(.82);
  transition: opacity .16s var(--ease), transform .16s var(--ease);
}

.option-tile.is-active .check {
  opacity: 1;
  transform: scale(1);
}

.option-preview {
  width: 72px;
  height: 72px;
  margin: 0 auto;
  border-radius: 13px;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: rgba(126, 67, 39, .42);
  background: rgba(255, 244, 225, .85) center / contain no-repeat;
  border: 1px solid rgba(139, 55, 27, .1);
  font-size: 22px;
  font-weight: 900;
}

.frame-grid .option-preview {
  background-size: cover;
}

.border-adjust-card {
  margin-top: 12px;
  padding: 12px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.72), rgba(255,246,235,.5)),
    rgba(255,255,255,.56);
  border: 1px solid rgba(139, 55, 27, .1);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.74);
}

.border-preset-grid {
  margin-top: 8px;
}

.border-preset-grid button.is-active {
  color: var(--red-800);
  border-color: rgba(230, 45, 35, .62);
  background: rgba(255,255,255,.9);
  box-shadow: 0 8px 18px rgba(184, 25, 14, .12), inset 0 0 0 1px rgba(230, 45, 35, .16);
}

.compact-range-stack {
  padding: 10px 2px 0;
}

.compact-range-stack label {
  grid-template-columns: 40px 1fr;
  font-size: 12px;
}

.sticker-grid .option-preview {
  background-size: contain;
}

.filter-grid .option-preview,
.background-grid .option-preview {
  background-size: cover;
}

.option-tile strong {
  min-height: 26px;
  color: inherit;
  font-size: 11px;
  line-height: 1.15;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.field input[type="text"] {
  min-height: 44px;
  width: 100%;
  border: 1px solid rgba(139, 55, 27, .14);
  border-radius: 14px;
  padding: 0 13px;
  color: var(--ink);
  background: rgba(255,255,255,.74);
  outline: none;
  font-weight: 800;
}

.field input[type="text"]:focus {
  border-color: rgba(227, 58, 46, .68);
  box-shadow: 0 0 0 3px rgba(227, 58, 46, .12);
}

.control-row {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 10px;
  margin: 10px 0;
}

.color-field input {
  width: 100%;
  height: 42px;
  border: 0;
  padding: 0;
  background: transparent;
}

.toggle-line {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 10px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.toggle-line input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--red-700);
}

.layer-details {
  margin-top: 10px;
  border-top: 1px solid rgba(139, 55, 27, .1);
  padding-top: 10px;
}

.layer-details summary {
  color: var(--red-800);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.layer-list {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.layer-row {
  display: grid;
  gap: 10px;
  padding: 11px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.74), rgba(255,246,235,.52)),
    rgba(255,255,255,.56);
  border: 1px solid rgba(139, 55, 27, .11);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7);
}

.layer-row.is-selected {
  border-color: rgba(227, 58, 46, .64);
  box-shadow: inset 0 0 0 1px rgba(227, 58, 46, .18);
}

.layer-main {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: start;
  gap: 10px;
}

.layer-main > div {
  min-width: 0;
  padding-top: 1px;
}

.layer-badge {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  align-self: start;
  color: var(--red-800);
  background: rgba(255, 239, 202, .92);
  font-size: 11px;
  line-height: 1;
  font-weight: 900;
}

.layer-row strong {
  display: block;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.2;
}

.layer-main div span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.layer-position-actions,
.layer-actions {
  display: grid;
  gap: 6px;
}

.layer-controls {
  display: grid;
  gap: 9px;
}

.layer-control-block {
  display: grid;
  gap: 6px;
}

.layer-control-block > span {
  color: rgba(126, 82, 60, .78);
  font-size: 10px;
  line-height: 1;
  font-weight: 900;
}

.layer-position-actions {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.layer-actions {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.layer-position-actions button,
.layer-actions button {
  min-height: 34px;
  border-radius: 12px;
  color: #7a4a37;
  background: rgba(255,255,255,.7);
  border: 1px solid rgba(139, 55, 27, .12);
  font-size: 12px;
  font-weight: 900;
}

.layer-actions .layer-delete {
  color: var(--red-800);
}

.layer-blend-field {
  display: grid;
  grid-template-columns: 64px 1fr;
  align-items: center;
  gap: 8px;
}

.layer-blend-field span {
  color: rgba(126, 82, 60, .78);
  font-size: 10px;
  line-height: 1;
  font-weight: 900;
}

.layer-blend-field select {
  min-height: 36px;
  width: 100%;
  border-radius: 12px;
  padding: 0 28px 0 11px;
  color: #7a4a37;
  background:
    linear-gradient(45deg, transparent 50%, rgba(122, 74, 55, .78) 50%) calc(100% - 15px) 15px / 6px 6px no-repeat,
    linear-gradient(135deg, rgba(255,255,255,.86), rgba(255,246,235,.68));
  border: 1px solid rgba(139, 55, 27, .12);
  outline: none;
  font-size: 12px;
  font-weight: 900;
  appearance: none;
}

.empty-layer-state {
  padding: 14px;
  border-radius: 14px;
  background: rgba(255,255,255,.52);
  color: var(--muted);
  font-size: 12px;
}

.doc-links {
  display: none;
}

.drawer-backdrop,
.sheet-backdrop,
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(42, 6, 2, .42);
}

.drawer-backdrop {
  z-index: 70;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s var(--ease);
}

.drawer-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.gallery-drawer {
  position: fixed;
  z-index: 80;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(88vw, 366px);
  padding: calc(var(--safe-top) + 16px) 14px calc(var(--safe-bottom) + 16px);
  border-radius: 0 28px 28px 0;
  transform: translateX(-104%);
  transition: transform .28s var(--ease);
  overflow-y: auto;
  background: rgba(255, 249, 238, .82);
}

.gallery-drawer.is-open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.drawer-header strong {
  display: block;
  color: var(--ink);
  font-size: 22px;
  font-weight: 900;
}

.drawer-header span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.drawer-header .glass-icon-button,
.sheet-header .glass-icon-button {
  width: 40px;
  height: 40px;
  color: var(--red-800);
  background: rgba(255,255,255,.5);
}

.gallery-rail {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.work-card {
  min-width: 0;
  padding: 8px;
  border-radius: 16px;
  background: rgba(255,255,255,.6);
  border: 1px solid rgba(139, 55, 27, .1);
}

.work-card img,
.empty-work-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  display: grid;
  place-items: center;
  object-fit: cover;
  border: 1px solid rgba(139, 55, 27, .1);
  background: rgba(255, 246, 231, .7);
}

.empty-work-thumb {
  color: var(--red-800);
  font-size: 34px;
  font-weight: 300;
}

.work-thumb-wrap {
  position: relative;
}

.work-badge {
  position: absolute;
  left: 6px;
  bottom: 6px;
  padding: 3px 6px;
  border-radius: 999px;
  color: white;
  background: rgba(198, 28, 16, .9);
  font-size: 9px;
  font-weight: 900;
}

.work-card time {
  display: block;
  margin: 6px 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  font-weight: 800;
}

.work-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}

.work-actions button {
  min-height: 29px;
  border-radius: 9px;
  color: #7a4a37;
  background: rgba(255,255,255,.72);
  border: 1px solid rgba(139, 55, 27, .1);
  font-size: 11px;
  font-weight: 900;
}

.sheet-modal,
.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
}

.sheet-modal.is-open,
.modal.is-open {
  display: block;
}

.sheet-backdrop,
.modal-backdrop {
  z-index: 0;
}

.glass-sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 1;
  width: min(100vw, 430px);
  max-height: min(82svh, 720px);
  transform: translateX(-50%);
  padding: 8px 14px calc(var(--safe-bottom) + 16px);
  border-radius: 30px 30px 0 0;
  overflow-y: auto;
  background: rgba(255, 249, 239, .84);
}

.action-sheet {
  max-height: min(84svh, 740px);
  padding: 8px 16px calc(var(--safe-bottom) + 18px);
}

.photo-action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.sheet-action-tile {
  min-height: 128px;
  position: relative;
  overflow: hidden;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  padding: 14px 10px;
  border-radius: 22px;
  color: #5a2918;
  background:
    linear-gradient(145deg, rgba(255,255,255,.72), rgba(255,244,226,.42)),
    rgba(255, 250, 241, .62);
  border: 1px solid rgba(255,255,255,.68);
  box-shadow: var(--glass-shadow), var(--glass-inner);
  text-align: center;
}

.sheet-action-tile svg {
  width: 30px;
  height: 30px;
}

.sheet-action-tile strong,
.sheet-action-tile span {
  position: relative;
  z-index: 2;
}

.sheet-action-tile strong {
  font-size: 16px;
  font-weight: 900;
}

.sheet-action-tile span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  font-weight: 800;
}

.sheet-tip-card,
.crop-sync-card,
.layer-toolbar-card {
  margin-top: 10px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255,255,255,.58);
  border: 1px solid rgba(139, 55, 27, .1);
}

.sheet-tip-card strong,
.sheet-tip-card span,
.crop-sync-card strong,
.crop-sync-card span {
  display: block;
}

.sheet-tip-card strong,
.crop-sync-card strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
}

.sheet-tip-card span,
.crop-sync-card span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  font-weight: 800;
}

.crop-sync-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
}

.switch-line {
  width: 52px;
  height: 32px;
  position: relative;
  display: block;
}

.switch-line input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.switch-line span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(139, 55, 27, .16);
  border: 1px solid rgba(139, 55, 27, .12);
  transition: background .18s var(--ease), border-color .18s var(--ease);
}

.switch-line span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 5px 12px rgba(116, 24, 10, .18);
  transition: transform .18s var(--ease);
}

.switch-line input:checked + span {
  background: linear-gradient(135deg, #ff392e, #c90d07);
  border-color: transparent;
}

.switch-line input:checked + span::after {
  transform: translateX(20px);
}

.strong-segmented {
  min-height: 48px;
}

.strong-segmented button {
  min-height: 40px;
  font-size: 14px;
}

.shape-dual-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.mini-title {
  margin: 0 0 6px;
}

.mini-title span {
  font-size: 12px;
}

.crop-preset-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.crop-preset-grid button {
  min-height: 38px;
  border-radius: 13px;
  color: #7a4a37;
  background: rgba(255,255,255,.68);
  border: 1px solid rgba(139, 55, 27, .12);
  font-size: 12px;
  font-weight: 900;
}

.sheet-range-stack {
  padding: 12px;
  border-radius: 18px;
  background: rgba(255,255,255,.48);
  border: 1px solid rgba(139, 55, 27, .1);
}

.layer-toolbar-card {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) 1.2fr;
  gap: 7px;
  align-items: center;
  flex: 0 0 auto;
}

.layer-toolbar-card button,
.layer-toolbar-card label {
  min-height: 36px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #7a4a37;
  background: rgba(255,255,255,.68);
  border: 1px solid rgba(139, 55, 27, .12);
  font-size: 12px;
  font-weight: 900;
}

.layer-toolbar-card input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--red-700);
}

.layer-sheet {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.layer-sheet .sheet-grabber,
.layer-sheet .sheet-header {
  flex: 0 0 auto;
}

.layer-sheet .layer-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  margin-top: 12px;
  padding: 2px 2px calc(var(--safe-bottom) + 16px);
  scroll-padding-top: 10px;
  overscroll-behavior: contain;
}

.sheet-grabber {
  width: 44px;
  height: 5px;
  border-radius: 999px;
  margin: 4px auto 12px;
  background: rgba(117, 72, 51, .22);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.sheet-header h2,
.modal-card h2 {
  margin: 0;
  color: var(--ink);
  font-size: 22px;
  font-weight: 900;
}

.sheet-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.export-preview-row {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border-radius: 18px;
  background: rgba(255,255,255,.55);
  border: 1px solid rgba(139, 55, 27, .1);
  margin-bottom: 10px;
}

.export-preview-row img {
  width: 76px;
  height: 76px;
  object-fit: cover;
  border-radius: 17px;
  background: #fff0d7;
  border: 1px solid rgba(139, 55, 27, .12);
}

.export-preview-row strong {
  display: block;
  color: var(--ink);
  font-size: 16px;
  font-weight: 900;
}

.export-preview-row span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.sheet-title {
  margin: 12px 0 8px;
}

.style-preset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.style-preset {
  min-height: 78px;
  display: grid;
  grid-template-columns: 52px 1fr;
  align-items: center;
  gap: 9px;
  padding: 8px;
  border-radius: 16px;
  text-align: left;
  color: #69402f;
  background: rgba(255,255,255,.56);
  border: 1px solid rgba(139, 55, 27, .1);
}

.style-preset.is-active {
  color: var(--red-800);
  border-color: rgba(230, 45, 35, .74);
  box-shadow: inset 0 0 0 1px rgba(230,45,35,.2);
}

.style-preset-preview {
  width: 52px;
  height: 52px;
  border-radius: 13px;
  background: center / cover no-repeat;
}

.style-preset strong,
.style-preset span {
  display: block;
}

.style-preset strong {
  font-size: 12px;
  font-weight: 900;
}

.style-preset span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.generation-status {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.modal-actions {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.style-actions {
  grid-template-columns: 1fr;
}

.modal-actions button,
.modal-actions a {
  min-height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: var(--red-800);
  background: rgba(255,255,255,.72);
  border: 1px solid rgba(139, 55, 27, .12);
  font-size: 13px;
  font-weight: 900;
}

.modal-actions .danger,
.style-actions .danger {
  color: white;
  background: linear-gradient(135deg, #ff392e, #c90d07);
  border-color: transparent;
}

.modal-card {
  position: fixed;
  z-index: 1;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(calc(100vw - 28px), 390px);
  max-height: 84svh;
  overflow-y: auto;
  padding: 18px;
  border-radius: 24px;
  background: rgba(255, 250, 241, .96);
  box-shadow: 0 28px 70px rgba(40, 5, 2, .36);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--red-800);
  background: rgba(255,255,255,.72);
  font-size: 24px;
}

.modal-body img {
  width: 100%;
  border-radius: 18px;
  background: #fff0d7;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 104px);
  z-index: 120;
  width: max-content;
  max-width: min(360px, calc(100vw - 36px));
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  padding: 10px 14px;
  border-radius: 999px;
  color: #fff7d7;
  background: rgba(72, 12, 6, .84);
  border: 1px solid rgba(255,255,255,.18);
  box-shadow: 0 18px 32px rgba(45, 6, 3, .28);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  font-size: 13px;
  font-weight: 800;
  transition: opacity .18s var(--ease), transform .18s var(--ease);
}

.toast.is-show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass-panel,
  .glass-button,
  .glass-icon-button,
  .glass-drawer,
  .glass-sheet {
    background: rgba(255, 248, 236, .94);
  }
}

@media (min-width: 431px) {
  .app-shell {
    margin: 0 auto;
  }
}

@media (max-width: 380px) {
  .app-shell {
    padding-left: 10px;
    padding-right: 10px;
  }

  .mobile-title h1 {
    font-size: 25px;
  }

  .mobile-title p {
    font-size: 13px;
  }

  .stage-actions {
    gap: 7px;
  }

  .stage-action {
    min-height: 66px;
  }

  .option-grid {
    grid-auto-columns: 80px;
  }

  .option-preview {
    width: 66px;
    height: 66px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
