:root {
  --ink: #1C1B19;
  --ink-2: #3D3A35;
  --muted: #5E5A52;
  --faint: #8A857B;
  --line: #DDD8CE;
  --line-2: #ECE8E0;
  --paper: #FFFFFF;
  --soft: #F8F7F3;
  --soft-2: #F3F1EC;
  --stage: #E6E3DC;
  --rail: #1C1B19;
  --rail-active: #3A3833;
  --rail-fg: #C9C4B8;
  --accent: #2E4BC6;
  --accent-ink: #1F3595;
  --accent-tint: #E8ECFB;
  --danger: #A1321F;
  --danger-line: #E5C3BC;
  --radius: 10px;
  --display: 'Bricolage Grotesque', 'Figtree', system-ui, sans-serif;
  --body: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--body); color: var(--ink); background: var(--stage); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: default; opacity: 0.4; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; line-height: 1.5; margin: 0; }
.spacer { flex: 1; }
hr { border: 0; height: 1px; background: var(--line-2); margin: 4px 0; width: 100%; }
h2 { margin: 0; font-family: var(--display); font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
h3 { margin: 4px 0 0; font-size: 15px; font-weight: 700; }

.app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }

/* ---------- top bar ---------- */
.topbar { height: 64px; flex-shrink: 0; display: flex; align-items: center; gap: 12px; padding: 0 16px 0 20px; background: var(--paper); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); margin-right: 8px; }
.brand svg { width: 28px; height: 28px; stroke: none; }
.brand span { font-family: var(--display); font-weight: 700; font-size: 22px; letter-spacing: -0.02em; }
.tb-group { display: flex; gap: 2px; }
.tb-divider { width: 1px; height: 28px; background: var(--line); }
.icon-btn { width: 40px; height: 40px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; color: var(--ink); }
.icon-btn:hover:not(:disabled) { background: var(--soft-2); }
.icon-btn.sm { width: 36px; height: 36px; }
.title-field input { width: 220px; height: 36px; border: 1px solid transparent; border-radius: 8px; padding: 0 10px; font-weight: 600; font-size: 15px; background: var(--soft-2); }
.title-field input:hover { border-color: var(--line); }
.title-field input:focus { outline: none; border-color: var(--accent); background: var(--paper); }
.meta { font-size: 13px; color: var(--muted); white-space: nowrap; }
.zoom { display: flex; align-items: center; background: var(--soft-2); border-radius: 10px; padding: 2px; }
.zoom-val { min-width: 56px; height: 36px; border-radius: 8px; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.zoom-val:hover { background: var(--paper); }

.btn { height: 44px; padding: 0 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--paper); font-size: 15px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; color: var(--ink); }
.btn svg { width: 18px; height: 18px; }
.btn:hover:not(:disabled) { background: var(--soft); border-color: #C9C4B8; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.btn.primary:hover:not(:disabled) { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 700; }
.btn.dark:hover:not(:disabled) { background: #000; }
.btn.plain { border-color: transparent; background: transparent; }
.btn.ghost-danger { color: var(--danger); border-color: var(--danger-line); }
.btn.ghost-danger:hover { background: #FBF1EE; border-color: var(--danger); }
.btn.on-dark { background: transparent; border-color: #4A4740; color: #F3F1EC; }
.btn.on-dark:hover { background: #34322E; border-color: #6A665D; }
.btn.grow { flex: 1; }
.btn-row { display: flex; gap: 8px; }

/* ---------- workspace ---------- */
.workspace { flex: 1; display: flex; min-height: 0; }

.rail { width: 80px; flex-shrink: 0; background: var(--rail); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 0; overflow-y: auto; scrollbar-width: none; }
.rail button { flex-shrink: 0; }
.rail button { width: 68px; height: 64px; border-radius: 10px; color: var(--rail-fg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; font-size: 12px; font-weight: 600; }
.rail button svg { width: 22px; height: 22px; }
.rail button:hover { color: #fff; }
.rail button[aria-selected="true"] { background: var(--rail-active); color: #fff; }

.panel { width: 344px; flex-shrink: 0; background: var(--paper); border-right: 1px solid var(--line); overflow-y: auto; padding: 20px; }
.pane { display: flex; flex-direction: column; gap: 16px; }
.sheet-grip { display: none; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); font-size: 13px; font-weight: 600; }
.chip:hover { border-color: #B9B3A6; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

/* layouts pane */
.layouts-pane { gap: 14px; }
.kind-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; padding: 3px; background: var(--soft-2); border-radius: 12px; }
.kind-tabs button { height: 40px; border-radius: 9px; font-size: 14px; font-weight: 700; color: var(--muted); }
.kind-tabs button:hover { color: var(--ink); }
.kind-tabs button[aria-selected="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px rgba(28,27,25,0.15); }
.count-bar { position: sticky; top: -20px; z-index: 2; background: var(--paper); margin: 0 -20px; padding: 8px 20px 10px; border-bottom: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 8px; }
.count-label { font-size: 13px; font-weight: 700; color: var(--muted); }
.count-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; padding-bottom: 2px; }
.count-chip { flex-shrink: 0; min-width: 40px; height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; position: relative; }
.count-chip:hover { border-color: #9E978A; }
.count-chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.count-chip.mine::after { content: ''; position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--paper); }
.suggest { margin: 0; font-size: 13px; line-height: 1.5; color: var(--ink-2); background: var(--accent-tint); border-radius: 10px; padding: 10px 12px; }
.link { color: var(--accent); font-weight: 700; font-size: 13px; text-decoration: underline; text-underline-offset: 2px; padding: 4px 0; }
.link:hover { color: var(--accent-ink); }
.adjust { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--soft); }
.slider-row { display: grid; grid-template-columns: 58px 1fr 58px; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; min-height: 36px; }
.num { height: 32px; width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 0 6px; font-size: 13px; text-align: center; background: var(--paper); font-variant-numeric: tabular-nums; }
.num:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.adjust .toggle { min-height: 36px; font-size: 13px; font-weight: 600; }
.adjust .tile-hint { padding-top: 4px; border-top: 1px solid var(--line-2); }
.adjust #resetTiles { height: 36px; margin-top: 6px; font-size: 13px; }
.layout-list { display: flex; flex-direction: column; gap: 20px; }
.lgroup { display: flex; flex-direction: column; gap: 10px; }
.lgroup-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.lgroup-head h3 { margin: 0; font-size: 14px; }
.layout-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.layout-thumb { aspect-ratio: 1; padding: 6px; border-radius: 10px; border: 2px solid var(--line-2); background: var(--soft); }
.layout-thumb:hover { border-color: #B9B3A6; }
.layout-thumb canvas { width: 100%; height: 100%; display: block; }
.layout-thumb[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-tint); }

.range { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; }
.range > span { display: flex; justify-content: space-between; }
.range output { color: var(--muted); font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; accent-color: var(--accent); height: 24px; margin: 0; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; font-size: 14px; font-weight: 500; cursor: pointer; }
.toggle > span { display: flex; flex-direction: column; }
.toggle small { color: var(--muted); font-size: 12px; font-weight: 400; }
.toggle input { width: 20px; height: 20px; accent-color: var(--accent); flex-shrink: 0; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
.field input, .field textarea { height: 44px; border: 1px solid var(--line); border-radius: var(--radius); padding: 0 12px; font-weight: 400; font-size: 15px; background: var(--paper); width: 100%; }
.field textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.4; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }

/* photos */
.dropzone { min-height: 132px; border: 2px dashed #B9B3A6; border-radius: 12px; background: var(--soft); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 16px; text-align: center; }
.dropzone:hover { border-color: var(--accent); background: var(--accent-tint); }
.dropzone svg { width: 28px; height: 28px; color: var(--accent); }
.dropzone strong { font-size: 15px; }
.dropzone span { font-size: 13px; color: var(--muted); }
.src-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.src { height: 48px; border: 1px solid var(--line); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; font-weight: 600; }
.src:hover { background: var(--soft); }
.src svg { width: 18px; height: 18px; }
.row-head { display: flex; align-items: baseline; justify-content: space-between; }
.row-head h3 { margin: 0; }
.row-head .muted { font-size: 13px; }
.photo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.photo-grid:empty { display: none; }
.pthumb { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--soft-2); }
.pthumb > .pick { position: absolute; inset: 0; cursor: pointer; border-radius: 8px; }
.pthumb > .pick:focus-visible { outline-offset: -2px; }
.pthumb img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.pthumb .del { z-index: 1; }
.pthumb .used { position: absolute; top: 6px; left: 6px; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.pthumb .used svg { width: 12px; height: 12px; stroke-width: 3; }
.pthumb .del { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; background: rgba(28,27,25,0.72); color: #fff; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.15s; }
.pthumb .del svg { width: 14px; height: 14px; stroke-width: 2.2; }
.pthumb:hover .del, .pthumb .del:focus-visible { opacity: 1; }
@media (hover: none) { .pthumb .del { opacity: 1; } }

/* text */
.add-text { border: 1px solid var(--line); border-radius: var(--radius); text-align: left; padding: 0 16px; color: var(--ink); }
.add-text:hover { background: var(--soft); border-color: #C9C4B8; }
.add-text.h { height: 56px; font-family: var(--display); font-size: 22px; font-weight: 700; }
.add-text.s { height: 48px; font-size: 17px; font-weight: 600; }
.add-text.b { height: 44px; font-size: 14px; }
#textEditor { display: flex; flex-direction: column; gap: 14px; }
.font-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.font-grid button { height: 64px; border: 2px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.font-grid button .aa { font-size: 22px; line-height: 1.1; }
.font-grid button .nm { font-size: 11px; color: var(--muted); }
.font-grid button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-tint); }
.swatch-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 1px solid #C9C4B8; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--accent); }
.swatch-row input[type=color], .color-field input[type=color] { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 3px; background: var(--paper); cursor: pointer; }
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); background: var(--soft-2); border-radius: 10px; padding: 3px; gap: 3px; }
.seg.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.seg button { height: 38px; border-radius: 8px; font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.seg button svg { width: 18px; height: 18px; }
.seg button[aria-pressed="true"] { background: var(--paper); box-shadow: 0 1px 3px rgba(28,27,25,0.15); }

/* stickers */
.search { display: flex; align-items: center; gap: 8px; height: 44px; border: 1px solid var(--line); border-radius: var(--radius); padding: 0 12px; color: var(--muted); }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.search input { border: 0; outline: 0; flex: 1; background: transparent; font-size: 14px; color: var(--ink); min-width: 0; }
.sticker-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.sticker-grid button { aspect-ratio: 1; border: 1px solid var(--line-2); border-radius: 12px; background: var(--soft); display: flex; align-items: center; justify-content: center; }
.sticker-grid button:hover { border-color: #C9C4B8; background: var(--paper); }
.sticker-grid canvas { width: 56px; height: 56px; }
#stickerEditor { display: flex; flex-direction: column; gap: 14px; }

/* backdrop */
.swatch-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; }
.swatch-grid .swatch { width: auto; aspect-ratio: 1; height: auto; }
.color-field { display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 500; cursor: pointer; }
.pattern-grid, .grad-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 8px; }
.pattern-grid button, .grad-grid button { display: flex; flex-direction: column; gap: 5px; align-items: center; font-size: 11px; font-weight: 600; color: var(--ink-2); text-align: center; line-height: 1.2; }
.pattern-grid .pv, .grad-grid .pv { width: 100%; aspect-ratio: 1; border-radius: 10px; border: 2px solid var(--line); overflow: hidden; display: block; }
.pattern-grid .pv canvas { width: 100%; height: 100%; display: block; }
.pattern-grid button[aria-pressed="true"] .pv, .grad-grid button[aria-pressed="true"] .pv { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-tint); }
.bgpane { display: flex; flex-direction: column; gap: 14px; }
.kind-tabs.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kind-tabs.four button { font-size: 13px; }
.kind-tabs.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kind-tabs.five button { font-size: 11px; padding: 0 1px; letter-spacing: -0.01em; }
.theme-cats { flex-wrap: nowrap; overflow-x: auto; margin: 0 -20px 4px; padding: 2px 20px 8px; scrollbar-width: thin; }
.theme-cats .count-chip { flex-shrink: 0; }
.theme-list { display: flex; flex-direction: column; gap: 18px; margin-top: 8px; }
.theme-list .pattern-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grad-custom { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.swatch-none { background: linear-gradient(135deg, transparent 46%, #D9482B 46%, #D9482B 54%, transparent 54%), #FFFFFF; }
.small-drop { min-height: 104px; }
.pthumb.on { box-shadow: 0 0 0 3px var(--accent); }
.slider-row output { font-size: 13px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.item-editor { display: flex; flex-direction: column; gap: 12px; }
.shape-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.shape-grid button { aspect-ratio: 1; border: 1px solid var(--line-2); border-radius: 12px; background: var(--soft); display: flex; align-items: center; justify-content: center; }
.shape-grid button:hover { border-color: #B9B3A6; background: var(--paper); }
.shape-grid canvas { width: 48px; height: 48px; }
.doodle-on { margin: 0; font-size: 13px; line-height: 1.5; color: var(--ink-2); background: var(--accent-tint); border-radius: 10px; padding: 10px 12px; }
.tool-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.tool-grid button { height: 40px; border: 1px solid var(--line); border-radius: 10px; font-size: 13px; font-weight: 600; }
.tool-grid button:hover { border-color: #9E978A; }
.tool-grid button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.brush-preview { border: 1px solid var(--line-2); border-radius: 12px; background: var(--paper); overflow: hidden; }
.brush-preview canvas { width: 100%; display: block; }
#collage.drawing { cursor: crosshair; }

/* size */
.size-list { display: flex; flex-direction: column; gap: 6px; }
.size-opt { min-height: 54px; display: flex; align-items: center; gap: 12px; padding: 0 12px; border-radius: 10px; border: 2px solid transparent; background: var(--soft); text-align: left; }
.size-opt:hover { border-color: var(--line); }
.size-opt[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-tint); }
.size-opt .shape { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.size-opt .shape i { border: 2px solid var(--ink); border-radius: 3px; display: block; }
.size-opt .txt { flex: 1; display: flex; flex-direction: column; }
.size-opt .txt strong { font-size: 14px; }
.size-opt .txt span, .size-opt .dims { font-size: 12px; color: var(--muted); }
.size-opt .dims { font-variant-numeric: tabular-nums; }
.wh { display: flex; align-items: flex-end; gap: 8px; }
.wh .field { flex: 1; }
.wh .x { height: 44px; display: flex; align-items: center; color: var(--muted); }

/* ---------- stage ---------- */
.stage { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.canvas-wrap { flex: 1; min-height: 0; overflow: auto; display: flex; padding: 72px 40px 40px; }
#collage { margin: auto; display: block; box-shadow: 0 12px 40px rgba(28,27,25,0.18); touch-action: none; background: #fff; }
#collage:focus { outline: none; }
#collage:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.photo-toolbar { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 2px; padding: 4px; background: var(--paper); border-radius: 12px; box-shadow: 0 4px 16px rgba(28,27,25,0.16); z-index: 5; max-width: calc(100% - 24px); overflow-x: auto; }
.photo-toolbar button { height: 44px; padding: 0 11px; border-radius: 8px; display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.photo-toolbar button:hover { background: var(--soft-2); }
.photo-toolbar button.danger { color: var(--danger); }
.photo-toolbar svg { width: 18px; height: 18px; }
.tb-sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; flex-shrink: 0; }
.swap-hint { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 6; background: var(--ink); color: #fff; padding: 10px 10px 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.swap-hint button { color: #fff; background: #3A3833; padding: 6px 12px; border-radius: 8px; font-weight: 600; }
.drop-overlay { position: absolute; inset: 8px; border: 3px dashed var(--accent); border-radius: 16px; background: rgba(232,236,251,0.82); display: flex; align-items: center; justify-content: center; z-index: 8; pointer-events: none; }
.drop-overlay div { font-family: var(--display); font-size: 26px; font-weight: 700; color: var(--accent-ink); }

.tray { height: 108px; flex-shrink: 0; display: flex; align-items: center; gap: 12px; padding: 0 20px; background: var(--soft); border-top: 1px solid var(--line); }
.tray-label { display: flex; flex-direction: column; gap: 2px; width: 108px; flex-shrink: 0; }
.tray-label strong { font-size: 14px; }
.tray-label span { font-size: 12px; color: var(--muted); }
.tray-list { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px; min-width: 0; }
.tray-list:empty::before { content: 'No photos yet — add some to start.'; color: var(--muted); font-size: 14px; align-self: center; }
.tray-item { width: 72px; height: 72px; flex-shrink: 0; border-radius: 8px; overflow: hidden; position: relative; cursor: grab; background: var(--soft-2); }
.tray-item img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.tray-item.is-used img { opacity: 0.45; }
.tray-item:focus-visible { outline-offset: 1px; }
.tray-add { width: 72px; height: 72px; flex-shrink: 0; border: 2px dashed #B9B3A6; border-radius: 8px; color: var(--accent); display: flex; align-items: center; justify-content: center; }
.tray-add:hover { border-color: var(--accent); background: var(--accent-tint); }
.tray-add svg { width: 24px; height: 24px; stroke-width: 2; }

/* ---------- dialogs ---------- */
.modal { border: 0; padding: 0; border-radius: 18px; box-shadow: 0 24px 60px rgba(28,27,25,0.35); color: var(--ink); max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); }
.modal::backdrop { background: rgba(28,27,25,0.55); }
.dl { width: 640px; max-width: 100%; display: flex; flex-direction: column; background: var(--paper); }
.small-modal .dl { width: 520px; }
.dl-head { display: flex; align-items: center; gap: 12px; padding: 20px 20px 0 24px; }
.dl-head h2 { flex: 1; font-size: 24px; }
.dl-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 18px; overflow-y: auto; }
.dl-foot { display: flex; align-items: center; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line-2); flex-wrap: wrap; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { font-size: 14px; font-weight: 600; padding: 0; margin-bottom: 8px; }
.with-suffix { display: flex; align-items: center; height: 44px; border: 1px solid var(--line); border-radius: var(--radius); padding: 0 12px; font-weight: 400; }
.with-suffix:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.with-suffix input { border: 0; outline: 0; flex: 1; height: 100%; padding: 0; min-width: 0; font-size: 15px; }
.with-suffix span { color: var(--muted); }
.fmt-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.fmt-grid button { min-height: 72px; border: 2px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; padding: 8px 14px; text-align: left; }
.fmt-grid button strong { font-size: 16px; }
.fmt-grid button span { font-size: 12px; color: var(--muted); }
.fmt-grid button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-tint); }
.exp-sizes { display: flex; flex-direction: column; gap: 6px; }
.exp-sizes label { min-height: 48px; display: flex; align-items: center; gap: 12px; padding: 0 14px; border: 2px solid var(--line-2); border-radius: 10px; cursor: pointer; font-size: 15px; font-weight: 600; }
.exp-sizes label:has(input:checked) { border-color: var(--accent); background: var(--accent-tint); }
.exp-sizes input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.exp-sizes .name { flex: 1; }
.exp-sizes .hd-badge { margin-left: 8px; padding: 2px 8px; border-radius: 999px; background: #FFF1C1; color: #7A5A00; font-size: 11px; font-weight: 700; vertical-align: 1px; white-space: nowrap; }
.exp-sizes .hd-badge.on { background: #E3F1E7; color: #2F7A4A; }
#doDownload .i-play, #doDownload.unlock .i-dl { display: none; }
#doDownload.unlock .i-play { display: block; }
.hd-note { margin: -8px 0 0; padding: 10px 12px; border-radius: 10px; background: #FFF8E1; color: #5C4A12; font-size: 13px; line-height: 1.5; }
.exp-sizes .dims { font-size: 13px; color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }

/* photo editor */
.edit-modal { width: 1200px; height: 820px; background: #252420; }
.edit-shell { height: 100%; display: flex; flex-direction: column; }
.edit-head { height: 64px; flex-shrink: 0; display: flex; align-items: center; gap: 10px; padding: 0 16px 0 24px; background: var(--ink); color: #fff; }
.edit-head h2 { font-size: 20px; }
.edit-head .muted { color: #B5AFA3; font-size: 13px; }
.edit-body { flex: 1; display: flex; min-height: 0; }
.edit-stage { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 24px; }
.edit-canvas-wrap { flex: 1; width: 100%; min-height: 0; display: flex; align-items: center; justify-content: center; }
#editCanvas { display: block; cursor: grab; touch-action: none; box-shadow: 0 0 0 1px rgba(255,255,255,0.25); }
#editCanvas:active { cursor: grabbing; }
.edit-tools { display: flex; gap: 4px; padding: 4px; background: var(--ink); border-radius: 12px; }
.edit-tools button { height: 44px; padding: 0 14px; border-radius: 8px; color: #F3F1EC; display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.edit-tools button:hover { background: #34322E; }
.edit-tools svg { width: 18px; height: 18px; }
.edit-side { width: 380px; flex-shrink: 0; background: var(--paper); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 12px; border-bottom: 1px solid var(--line-2); }
.tabs button { height: 44px; border-radius: 10px; background: var(--soft-2); font-size: 15px; font-weight: 700; }
.tabs button[aria-selected="true"] { background: var(--ink); color: #fff; }
.etab { flex: 1; overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 18px; }
#adjustList { display: flex; flex-direction: column; gap: 18px; }
.filter-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.filter-grid button { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
.filter-grid canvas { width: 100%; aspect-ratio: 1; border-radius: 10px; border: 3px solid transparent; display: block; }
.filter-grid button[aria-pressed="true"] canvas { border-color: var(--accent); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 600; z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,0.25); max-width: calc(100vw - 32px); }

/* ---------- small screens ---------- */
/* ---------- admin-managed banner ---------- */
.preview-bar { flex-shrink: 0; padding: 8px 16px; background: #FFF1C1; color: #5C4A12; font-size: 13px; font-weight: 600; text-align: center; }
.preview-bar a { color: inherit; margin-left: 6px; }
.site-banner { flex-shrink: 0; display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 40px; padding: 6px 12px 6px 20px; background: var(--ink); color: #fff; font-size: 14px; font-weight: 500; }
.site-banner[data-tone="accent"] { background: var(--accent); }
.site-banner[data-tone="warm"] { background: #F6D58E; color: var(--ink); }
.site-banner a { color: inherit; font-weight: 700; }
.site-banner button { width: 32px; height: 32px; border-radius: 8px; color: inherit; display: flex; align-items: center; justify-content: center; margin-left: 4px; flex-shrink: 0; }
.site-banner button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.site-banner button:hover { background: rgba(255,255,255,0.14); }

/* ---------- after a download ---------- */
.ready-head { display: flex; gap: 12px; align-items: flex-start; }
.ready-head h2 { font-size: 22px; line-height: 1.25; margin: 0 0 2px; outline: none; }
.ready-head p { overflow-wrap: anywhere; }
.ready-check { width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%; background: #E3F1E7; color: #2F7A4A; display: flex; align-items: center; justify-content: center; }
.ready-check svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.ready-preview { width: 100%; max-height: 300px; object-fit: contain; background: var(--soft-2); border-radius: 12px; border: 1px solid var(--line-2); }
.ready-pane .btn svg { width: 18px; height: 18px; }
.ad-ready { padding-top: 14px; border-top: 1px solid var(--line-2); }
.ad-ready .ad-box { min-height: 250px; }
.panel.showing-ready .ad-panel { display: none; }

/* ---------- ads ---------- */
.ad-label { margin: 0 0 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.ad-label a { color: inherit; }
.ad-panel { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--line-2); }
.ad-panel .ad-box { min-height: 100px; }
.ad-rail { width: 184px; flex-shrink: 0; padding: 14px 12px; background: var(--paper); border-left: 1px solid var(--line); overflow: hidden; text-align: center; }
.ad-rail .ad-box { width: 160px; min-height: 600px; margin: 0 auto; }
@media (max-width: 1279px), (max-height: 699px) { .ad-rail { display: none; } }

@media (max-width: 1100px) {
  .meta { display: none; }
  .title-field input { width: 160px; }
}

@media (max-width: 860px) {
  .topbar { height: 56px; gap: 6px; padding: 0 8px 0 12px; }
  .brand span, .title-field, .tb-divider, .zoom, #newBtn { display: none; }
  .btn { padding: 0 12px; }
  #shareBtn span { display: none; }
  #shareBtn { width: 44px; padding: 0; }
  .workspace { flex-direction: column; }
  .stage { order: 1; flex: 1; min-height: 0; }
  .canvas-wrap { padding: 64px 12px 16px; }
  .tray { display: none; }
  .panel { order: 2; width: auto; border-right: 0; border-top: 1px solid var(--line); max-height: 44dvh; padding: 0 16px 16px; border-radius: 18px 18px 0 0; box-shadow: 0 -4px 20px rgba(28,27,25,0.08); margin-top: -12px; position: relative; z-index: 4; }
  .panel.collapsed { max-height: 32px; overflow: hidden; }
  .panel.collapsed .pane { display: none; }
  .count-bar { top: 32px; margin: 0 -16px; padding: 8px 16px 10px; }
  .layout-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .sheet-grip { display: flex; justify-content: center; align-items: center; width: 100%; height: 32px; position: sticky; top: 0; background: var(--paper); z-index: 1; }
  .sheet-grip span { width: 40px; height: 4px; border-radius: 2px; background: #D3CEC4; }
  .rail { order: 3; width: auto; flex-direction: row; justify-content: flex-start; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); gap: 0; overflow-x: auto; overflow-y: hidden; }
  .rail button { width: auto; flex: 1 0 60px; height: 56px; font-size: 11px; gap: 3px; }
  .rail button svg { width: 20px; height: 20px; }
  .photo-toolbar { top: 8px; }
  .photo-toolbar button span { display: none; }
  .photo-toolbar button { padding: 0 10px; }
  .edit-modal { width: 100vw; height: 100dvh; max-width: 100vw; max-height: 100dvh; border-radius: 0; }
  .edit-body { flex-direction: column; }
  .edit-stage { padding: 12px; gap: 10px; }
  .edit-tools button span { display: none; }
  .edit-side { width: auto; height: 46%; }
  .edit-head { padding: 0 8px 0 16px; }
  #editMeta { display: none; }
  .dl-foot .btn span { display: inline; }
  .ready-preview { max-height: 150px; }
  .ready-head h2 { font-size: 19px; }
}

@media (max-width: 420px) {
  .fmt-grid button span { display: none; }
  #copyImg span, #printImg span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Right-click menu on the canvas */
.ctx-menu { position: fixed; z-index: 60; min-width: 200px; padding: 6px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(28, 27, 25, 0.18), 0 2px 6px rgba(28, 27, 25, 0.08); }
.menu-item { width: 100%; height: 34px; display: flex; align-items: center; gap: 10px; padding: 0 10px; border: 0; border-radius: 8px; background: none; font-size: 14px; font-weight: 500; color: var(--ink); text-align: left; }
.menu-item svg { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.menu-item:hover, .menu-item:focus-visible { background: var(--soft-2); outline: none; }
.menu-item:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.menu-item.danger { color: var(--danger); }
.menu-item[aria-disabled="true"] { color: #B3AEA4; cursor: default; background: none; }
.menu-sep { height: 1px; margin: 5px 4px; background: var(--line-2); }
.zoom-pop { display: flex; flex-direction: column; gap: 8px; width: 260px; padding: 12px 14px; }
.zoom-pop .slider-row output { font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; }
.zoom-pop .btn { height: 34px; font-size: 13px; }
@media (hover: none) { .menu-item { height: 42px; } }
