:root {
  --bg: #1b1d22;
  --workspace: #14161a;
  --panel: #232730;
  --panel-2: #2b3038;
  --rail: #1e2228;
  --border: #353b45;
  --text: #e6e8ec;
  --muted: #9aa1ad;
  --accent: #ec4899; /* the single brand accent (matches the Pictools gradient) */
  --danger: #ff5a52;
  --sheet-h: 54dvh; /* height of the mobile bottom sheet (photo fits above it) */
  --panel-glass: #232730db;    /* translucent dock — the photo shows through */
  --checker: #101216;          /* transparency checkerboard tile */
  --workspace-social: #191426; /* purple-tinted workspace in social mode */
  --scroll-thumb: rgba(255, 255, 255, 0.2);
  --scroll-thumb-hover: rgba(255, 255, 255, 0.34);
  --shadow-strong: rgba(0, 0, 0, 0.55); /* dock/sheet/stage drop shadows */
  color-scheme: dark;
}
/* Light theme: html[data-theme] is set before the stylesheet loads (index.html)
   and switched at runtime — explicit user choice wins, installed PWAs follow the
   phone's scheme, plain browser tabs default to dark. */
html[data-theme="light"] {
  --bg: #f4f5f7;
  --workspace: #e9ebee;
  --panel: #ffffff;
  --panel-2: #eef0f3;
  --rail: #fafbfc;
  --border: #d9dde3;
  --text: #1c1f26;
  --muted: #667085;
  --panel-glass: #ffffffdb;
  --checker: #dde0e6;
  --workspace-social: #e9e6f2; /* as subtle vs --workspace as the dark pair */
  --scroll-thumb: rgba(0, 0, 0, 0.22);
  --scroll-thumb-hover: rgba(0, 0, 0, 0.38);
  --shadow-strong: rgba(15, 20, 30, 0.18);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.hidden { display: none !important; }
/* 100dvh (dynamic viewport height) so the bottom dock/status bar aren't hidden behind the
   mobile browser's address bar; 100vh is the fallback for older browsers. */
.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

/* ---- Scrollbars: thin, floating, transparent track (no ugly white gutters) ---- */
* { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track,
::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border: 3px solid transparent;     /* padding around the thumb -> floating look */
  border-radius: 8px;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); background-clip: padding-box; }

/* ---- Top bar ---- */
/* Installed PWAs draw edge-to-edge (Android 15+/iOS standalone): the top/bottom
   system-bar areas come from env(safe-area-inset-*) and must pad our own bars,
   or the bottom menu hides behind the gesture bar. Zero on regular browsers. */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  height: calc(46px + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 12px 0;
  background: var(--rail);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.brand { font-weight: 700; letter-spacing: 0.3px; }
.brand span { color: var(--accent); margin: 0 2px; }
.topbar-group { display: flex; align-items: center; gap: 6px; }

/* Topbar ⋯ dropdown */
.topmenu {
  position: fixed; top: calc(50px + env(safe-area-inset-top, 0px)); right: 8px; z-index: 95;
  min-width: 168px; padding: 6px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 14px 36px var(--shadow-strong);
  display: flex; flex-direction: column; gap: 2px;
}
.topmenu button {
  display: flex; align-items: center; gap: 10px; text-align: left; cursor: pointer;
  background: none; border: none; color: var(--text); font: inherit; font-size: 13.5px; font-weight: 600;
  padding: 10px 12px; border-radius: 8px;
}
.topmenu button:hover { background: var(--panel-2); }
.topmenu .tm-ic { width: 18px; text-align: center; color: var(--muted); }

/* Light theme: ghost buttons (undo/redo etc.) need real contrast on the pale rail */
html[data-theme="light"] .btn.ghost { border-color: #c2c9d3; color: #2a2f38; }
html[data-theme="light"] .btn:disabled { opacity: 0.55; }
.opt-label { color: var(--muted); font-size: 12px; }
.spacer { flex: 1; }
.topselect { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 5px 6px; font-size: 12px; }
.status { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- Body layout ---- */
.body { flex: 1; display: flex; min-height: 0; position: relative; }

/* ---- Center column: image area + docked controls below it ---- */
.center { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }

/* ---- Snapseed-style Tools grid sheet ---- */
.toolsheet {
  position: absolute; inset: 0;
  z-index: 25;
  background: transparent; /* keep the image visible above the grid */
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.toolgrid {
  width: 100%;
  max-height: 82%;
  overflow-y: auto;
  background: var(--panel-glass); /* translucent — the photo shows through */
  backdrop-filter: blur(16px) saturate(120%);
  -webkit-backdrop-filter: blur(16px) saturate(120%);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 6px 6px calc(16px + env(safe-area-inset-bottom, 0px));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px 2px;
  box-shadow: 0 -10px 40px var(--shadow-strong);
}
@media (min-width: 760px) {
  .toolgrid { grid-template-columns: repeat(6, 1fr); max-width: 760px; border-radius: 16px; margin-bottom: 10px; }
}
.toolgroup { grid-column: 1 / -1; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); padding: 12px 6px 2px; }
.toolitem {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 11px 2px;
  background: transparent; border: none; color: var(--text);
  cursor: pointer; border-radius: 10px;
}
.toolitem:hover { background: var(--panel-2); }
.toolitem .ic { font-size: 28px; line-height: 1; height: 30px; display: grid; place-items: center; }
.toolitem .lb { font-size: 12.5px; color: var(--text); text-align: center; line-height: 1.2; white-space: normal; }

/* The dock sits below the image (not over it): active control, pill strip, main tab menu —
   each a centered, horizontally-scrollable row, like the Android photo editor. */
.dock {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 10px;
  background: var(--rail);
  border-top: 1px solid var(--border);
}
.tabbar { display: flex; align-items: center; justify-content: safe center; gap: 4px; align-self: stretch; max-width: 100%; overflow-x: auto; padding: 2px 4px; scrollbar-width: none; }
.tabbar::-webkit-scrollbar { display: none; }
.tab {
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: 16px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex: 0 0 auto;
}
.tab:hover { color: var(--text); background: var(--panel-2); }
.tab.active { color: #fff; background: var(--accent); }
/* The AI tab is the conversion driver — always dressed in the brand gradient. */
.tab[data-nav="ai"] {
  background: linear-gradient(90deg, #8b3dff, #ec4899);
  color: #fff;
  font-weight: 700;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(160, 60, 220, 0.35);
}
.tab[data-nav="ai"]:hover { filter: brightness(1.1); }
.tab[data-nav="ai"].active { filter: brightness(1.15); box-shadow: 0 4px 18px rgba(160, 60, 220, 0.55); }
.workspace { position: relative; }
.mode-label { position: absolute; top: 10px; left: 14px; z-index: 30; font-size: 13px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 7px; }
.mode-label::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--accent); }
/* Busy: a filter frame is rendering in the fx worker. */
.mode-label.busy::after {
  content: "";
  width: 12px; height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  display: inline-block;
  margin-left: 4px;
  animation: fxspin 0.7s linear infinite;
}
@keyframes fxspin { to { transform: rotate(360deg); } }
.modal-actions { justify-content: space-between; align-items: center; padding: 4px 14px; }
.modal-actions .modal-mid { display: flex; align-items: center; gap: 18px; }
/* Bigger undo/redo/compare in the middle */
.modal-actions .modal-mid .btn { flex: 0 0 auto; width: 46px; height: 44px; font-size: 23px; padding: 0; background: transparent; border-color: transparent; }
/* Filled circular cancel/apply pinned to the far edges — instantly readable */
.modal-actions .btn.lg {
  flex: 0 0 auto; width: 48px; height: 48px; padding: 0; border: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; color: #fff;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
}
#modalApply { background: #22a55c; }
#modalCancel { background: #e5484d; }
#modalApply:hover { background: #27b866; filter: none; }
#modalCancel:hover { background: #ef5a5f; filter: none; }
#modalApply:active, #modalCancel:active { transform: scale(0.94); }
/* No global toolbar while inside a tool session (Social, Healing, …) */
.app.social-mode .topbar { display: none; }
.optrow { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: 92vw; }
.optbtn { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 52px; padding: 6px 8px; background: var(--panel-2); border: 2px solid var(--border); border-radius: 10px; color: var(--text); cursor: pointer; }
.optbtn .opt-ic { font-size: 18px; line-height: 1; }
.optbtn .opt-lb { font-size: 10px; color: var(--muted); white-space: nowrap; }
.optbtn.sel { border-color: #ec4899; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--border); cursor: pointer; padding: 0; }
.swatch.sel { border-color: #ec4899; box-shadow: 0 0 0 2px rgba(236,72,153,0.35); }
/* safe center: when the strip overflows, fall back to flex-start so the left end
   stays scroll-reachable (plain `center` strands half the chips off-screen left). */
.optrow.txtrow { flex-wrap: nowrap; overflow-x: auto; max-width: 96vw; scrollbar-width: none; padding-bottom: 2px; justify-content: safe center; }
.optrow.txtrow::-webkit-scrollbar { display: none; }
.txtpreset { flex: 0 0 auto; min-width: 54px; height: 52px; padding: 2px 10px 4px; background: #40454e; border: 2px solid transparent; border-radius: 8px; color: #fff; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.txtpreset .ag { font-size: 19px; line-height: 1.15; }
.txtpreset .nm { font-family: system-ui, sans-serif; font-size: 8.5px; line-height: 1; color: var(--muted); letter-spacing: 0; white-space: nowrap; }
.txtpreset.sel { border-color: #ec4899; }
.txtpreset[data-frame] { box-shadow: inset 0 0 0 1.5px rgba(255,255,255,0.45); }
.txtpreset[data-frame="circle"], .txtpreset[data-frame="hex"] { border-radius: 50%; }
.optbtn.sel .opt-lb { color: var(--text); }
/* Preset picker tiles: pink border on the current preset + a small dimensions line. */
#presetgrid .toolitem { border: 2px solid transparent; border-radius: 12px; }
#presetgrid .toolitem.sel { border-color: #ec4899; }
#presetgrid .toolitem .dim { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
#presetgrid .toolitem.sel .lb { color: var(--text); }
/* Subtle purple tint on the canvas area while in the Social preset editor. */
.workspace { transition: background-color 0.25s ease; }
.app.social-mode .workspace { background-color: var(--workspace-social); }
.app.social-mode .dock { background: linear-gradient(0deg, rgba(139, 61, 255, 0.06), transparent); }

.contextbar {
  display: flex;
  align-items: center;
  justify-content: safe center;
  gap: 8px;
  align-self: stretch;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 16px;
  scrollbar-width: none;
  /* edge fade = "there's more, scroll" affordance on narrow screens */
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
}
.contextbar::-webkit-scrollbar { display: none; }
.chip {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 7px 14px;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
  flex: 0 0 auto;
}
.chip:hover { border-color: var(--accent); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip.go { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.chip.danger { color: #ff6b6b; border-color: rgba(255, 107, 107, 0.4); }
.ctx-mini {
  display: flex; flex-direction: column; gap: 3px; min-width: 138px; flex: 0 0 auto;
  font-size: 11px; color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px 12px;
}
.ctx-mini > span { display: flex; justify-content: space-between; }
.ctx-mini output { font-variant-numeric: tabular-nums; color: var(--muted); }
.ctx-mini input[type="range"] { width: 100%; accent-color: var(--accent); margin: 0; }

/* The active single-control block (e.g. an Adjust slider), centered above the pill strip. */
.ctxcontrol { display: flex; justify-content: safe center; align-self: stretch; max-width: 100%; overflow-x: auto; padding: 0 8px; scrollbar-width: none; }
.ctxcontrol::-webkit-scrollbar { display: none; }
.ctxcontrol .ctrl {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 7px 12px;
  font-size: 12px;
  color: var(--text);
}
.ctxcontrol .ctrl > span { white-space: nowrap; }
.ctxcontrol .ctrl input[type="range"] { width: min(240px, 38vw); min-width: 96px; accent-color: var(--accent); }
.ctxcontrol .ctrl output { min-width: 34px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.ctxcontrol .ctrl .chip { padding: 5px 11px; }
.ctxcontrol .ctrl.propctrl { flex-wrap: wrap; max-width: 94vw; row-gap: 8px; column-gap: 14px; justify-content: center; }
.ctxcontrol .ctrl.propctrl .field, .ctxcontrol .ctrl.propctrl .check { gap: 6px; font-size: 12px; }
.ctxcontrol .ctrl.propctrl .field > span { white-space: nowrap; }
.ctxcontrol .ctrl.propctrl input[type="color"] { width: 34px; height: 26px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); }
.ctxcontrol .ctrl.propctrl input[type="number"] { width: 60px; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; color: var(--text); padding: 4px 6px; font: inherit; }
.ctxcontrol .ctrl.propctrl select { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 4px 6px; font-size: 12px; }
.ctxcontrol .ctrl input[type="number"] { width: 64px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; color: var(--text); padding: 4px 6px; font: inherit; }
.ctxcontrol .ctrl .lockchk { display: flex; align-items: center; gap: 4px; cursor: pointer; color: var(--muted); }

/* Curves session: the tone block moves into the dynamic control area. */
.ctxcontrol .tone {
  width: min(440px, 92vw);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
}

/* Layers sheet: the layer stack as a bottom overlay (same surface as the Tools sheet). */
.layersheet-body {
  width: 100%;
  background: var(--panel-glass);
  backdrop-filter: blur(16px) saturate(120%);
  -webkit-backdrop-filter: blur(16px) saturate(120%);
  border-top: 1px solid var(--border);
  border-radius: 14px 14px 0 0;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  max-height: 55dvh;
  overflow-y: auto;
  box-shadow: 0 -10px 40px var(--shadow-strong);
}
.layersheet-body .toolgroup { margin-bottom: 8px; }
@media (min-width: 760px) {
  .layersheet-body { max-width: 480px; border-radius: 14px; margin-bottom: 10px; }
}

/* ---- Bottom status / zoom bar ---- */
.statusbar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: calc(28px + env(safe-area-inset-bottom, 0px));
  padding: 0 12px env(safe-area-inset-bottom, 0px);
  background: var(--rail);
  border-top: 1px solid var(--border);
  flex: 0 0 auto;
}
.statusbar .status { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.zoombar { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.zbtn {
  background: transparent;
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 5px;
  height: 22px;
  min-width: 24px;
  padding: 0 6px;
  font-size: 13px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.zbtn:hover { background: var(--panel-2); }
.zbtn.zlevel { min-width: 54px; font-size: 12px; }
.zbtn.ztext { font-size: 11px; color: var(--muted); }
.zbtn.ztext:hover { color: var(--text); }

.toolrail {
  width: 48px;
  flex: 0 0 auto;
  background: var(--rail);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
}
.tool {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: transparent;
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 17px;
  cursor: pointer;
}
.tool:hover { background: var(--panel-2); }
.tool.tool-on { background: var(--accent); color: #fff; }
.tool-sep { width: 24px; height: 1px; background: var(--border); margin: 4px 0; }

.workspace {
  flex: 1;
  min-width: 0;
  background:
    linear-gradient(45deg, var(--checker) 25%, transparent 25%) -10px 0 / 20px 20px,
    linear-gradient(-45deg, var(--checker) 25%, transparent 25%) -10px 0 / 20px 20px,
    linear-gradient(45deg, transparent 75%, var(--checker) 75%) -10px 0 / 20px 20px,
    linear-gradient(-45deg, transparent 75%, var(--checker) 75%) -10px 0 / 20px 20px,
    var(--workspace);
  display: flex;
  overflow: auto;
  padding: 24px;
  touch-action: none; /* we handle pinch-zoom/pan ourselves */
}
/* margin:auto centers the stage in the flex container without clipping when it overflows (zoom). */
.stage { position: relative; margin: auto; width: min(100%, 860px); flex: 0 0 auto; box-shadow: 0 8px 40px var(--shadow-strong); }
.stage #canvas { width: 100%; height: auto; display: block; }
.stage #overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; touch-action: none; }
.stage.cropping #overlay { pointer-events: auto; cursor: crosshair; }
.stage.moving:not(.cropping) #overlay { pointer-events: auto; }

/* On-canvas text editor */
.text-edit {
  position: absolute;
  background: rgba(20, 22, 28, 0.4);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: 3px;
  outline: none;
  padding: 0;
  margin: 0;
  resize: none;
  line-height: 1.2;
  font-family: inherit;
  overflow: hidden;
}

/* ---- Panels (right) ---- */
/* Retired: the desktop accordion panels. The DOM stays as the state store for the dock's
   proxied controls (sliders, curve data, export fields), but it is never shown — the dock
   is the single UI on every viewport. */
.panels { display: none !important; }
.panel { border-bottom: 1px solid var(--border); }
.panel > summary {
  list-style: none;
  cursor: pointer;
  padding: 9px 12px;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary::before { content: "▸"; font-size: 10px; transition: transform 0.12s; }
.panel[open] > summary::before { transform: rotate(90deg); }
.panel > summary:hover { color: var(--text); }
.panel-body { padding: 10px 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.subhead { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); margin-top: 4px; }

/* ---- Controls ---- */
.row { display: flex; gap: 6px; }
.row.buttons { display: flex; gap: 6px; }
.row.wrap { flex-wrap: wrap; }
.iconbar { display: flex; flex-wrap: wrap; gap: 4px; }

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex: 1;
  text-align: center;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
.btn.ghost.tool-on { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.sm { padding: 6px 10px; font-size: 12px; flex: 0 0 auto; }
.btn.xs { padding: 5px 8px; font-size: 12px; flex: 0 0 auto; min-width: 30px; }
.btn.icon { width: 30px; padding: 6px 0; }
.btn.icon svg { display: block; margin: 0 auto; }

/* Inline SVG icon set: inline by default, centered block inside icon-only buttons. */
svg.ic { display: inline-block; vertical-align: -3px; pointer-events: none; flex: none; }
.toolitem .ic svg.ic, .opt-ic svg.ic, .tm-ic svg.ic, .fx-fav svg.ic, .play-slot .ph svg.ic, .fx-action-ic svg.ic, .gal-del svg.ic, .gal-dl svg.ic, .ai-slot-add svg.ic { display: block; margin: 0 auto; }
.chip svg.ic, .tab svg.ic, .fx-cat svg.ic, .account-chip svg.ic { vertical-align: -2px; }
.fx-costchip svg.ic { vertical-align: -1px; }
.fx-fav.on svg.ic path { fill: currentColor; }
.gal-tile-add svg.ic { display: block; }
.btn.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.slider { display: flex; flex-direction: column; gap: 5px; font-size: 12px; }
.slider span { display: flex; justify-content: space-between; }
.slider output { color: var(--muted); font-variant-numeric: tabular-nums; }
.slider input[type="range"] { width: 100%; accent-color: var(--accent); }

.field { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; }
.field > span { color: var(--muted); }
.field input[type="number"] { width: 72px; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 5px 6px; font-size: 12px; }
.slider textarea { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 6px; font: inherit; font-size: 12px; resize: vertical; min-height: 40px; }

.fmt-row { border: 1px solid var(--border); border-radius: 8px; padding: 4px 10px; margin: 4px 0; }
.fmt-row > summary { cursor: pointer; padding: 6px 0; font-size: 12px; font-weight: 600; }
.fmt-rowbody { display: flex; flex-direction: column; gap: 8px; padding: 4px 0 10px; }
.fmt-rowbody input[type="text"] { width: 100%; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 6px; font: inherit; font-size: 12px; }
#formatBody select { max-width: 190px; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 4px 6px; font-size: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }
.histmode { margin-left: auto; }

.dims { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.dims label { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.dims input[type="number"], .field select, .dims select {
  width: 64px; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 5px 6px; font-size: 12px;
}
.field select { width: auto; flex: 1; }

.seg { display: flex; gap: 2px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 7px; padding: 2px; }
.seg button { flex: 1; background: transparent; color: var(--muted); border: none; border-radius: 5px; padding: 5px 0; font-size: 12px; font-weight: 600; cursor: pointer; }
.seg button.active { background: var(--accent); color: #fff; }

.tone #curve { width: 100%; height: auto; aspect-ratio: 280 / 170; background: #0f1115; border: 1px solid var(--border); border-radius: 7px; touch-action: none; cursor: crosshair; }

.hint { margin: 2px 0 0; font-size: 11px; color: var(--muted); line-height: 1.5; }

/* ---- Layers list ---- */
.layer-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow-y: auto; }
.layer-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid transparent; border-radius: 6px; background: var(--panel-2); cursor: pointer; font-size: 12px; }
.layer-row:hover { border-color: var(--border); }
.layer-row.active { border-color: var(--accent); background: rgba(236, 72, 153, 0.12); }
.layer-row.photo { opacity: 0.85; font-style: italic; }
.layer-row input[type="checkbox"] { accent-color: var(--accent); }
.layer-row .layer-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-row .layer-kind { color: var(--muted); font-size: 10px; }
.layer-row.child { background: transparent; border-style: dashed; opacity: 0.92; }

#layerProps { display: flex; flex-direction: column; gap: 9px; }
#layerProps input[type="color"] { width: 34px; height: 24px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: var(--panel-2); cursor: pointer; }
#layerProps textarea { width: 100%; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 6px; font: inherit; font-size: 12px; resize: vertical; min-height: 40px; }

/* ---- Responsive: phones/tablets — panels become a slide-up bottom sheet ---- */
.panels-toggle { display: none; }
.panels-header { display: none; } /* shown only on mobile (below) */
@media (max-width: 900px) {
  .panels-toggle { display: inline-flex; }
  .topbar { gap: 8px; padding: 0 8px; }
  .topbar-group { gap: 4px; }
  .toolrail { width: 44px; overflow-y: auto; }

  /* Right panels dock to the bottom as a swipe-up sheet, off-flow so the image fills width. */
  .panels {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    width: auto;
    height: var(--sheet-h);
    z-index: 30;
    border-left: none;
    border-top: 1px solid var(--border);
    border-top-left-radius: 14px;
    border-top-right-radius: 14px;
    transform: translateY(100%);
    transition: transform 0.22s ease;
    box-shadow: 0 -8px 34px var(--shadow-strong);
  }
  .panels.open { transform: translateY(0); }
  /* When the sheet is open, shrink the photo to fit ABOVE it (so you can see edits live),
     and drop the bottom bar (the sheet's Done handles navigation). */
  .app.sheet-open .dock { display: none; }
  .app.sheet-open .workspace { flex: 0 0 auto; height: calc(100dvh - 46px - var(--sheet-h)); }
  /* Header with the tool name + a Done button so you can always get out. */
  .panels-header {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 3;
    padding: 10px 12px 10px 16px;
    background: var(--panel); border-bottom: 1px solid var(--border);
    font-weight: 600; letter-spacing: 0.3px;
  }
  /* When a single tool is focused, show only that panel (not the whole stack). */
  .panels.solo-mode .panel { display: none; }
  .panels.solo-mode .panel.solo { display: block; }
  .panels.solo-mode .panel.solo > summary { display: none; } /* title is in the header already */
}
@media (max-width: 520px) {
  .brand { display: none; }
}

/* ---- Pictools branding ---- */
.brand-pictools {
  font-weight: 800; font-size: 17px; letter-spacing: -0.4px; white-space: nowrap;
  background: linear-gradient(90deg, #8b3dff, #ec4899);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-pictools span { -webkit-text-fill-color: var(--muted); color: var(--muted); font-weight: 700; }
/* The SVG logo (mosaic mark + wordmark); tapping it goes home. */
.brand-logo { background: none; border: 0; padding: 0; display: flex; align-items: center; cursor: pointer; }
.brand-logo svg { display: block; height: 24px; width: auto; }
/* Official pictools.ai logo: white wordmark on dark (footer variant), purple
   wordmark + pink .ai on light (main variant). The grid keeps literal fills. */
.brand-logo .lw { fill: #ffffff; }
.brand-logo .la { fill: #ffffff; }
:root[data-theme="light"] .brand-logo .lw { fill: #602d91; }
:root[data-theme="light"] .brand-logo .la { fill: #ed3193; }

/* ---- Pricing sheet (top-ups + Pro) ---- */
.pricing-card { max-width: 460px; }
.pricing-sec { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); margin: 16px 0 8px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pricing-warn { background: rgba(236, 72, 153, 0.12); border: 1px solid rgba(236, 72, 153, 0.4); color: var(--text); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin-top: 4px; }
.pricing-packs, .pricing-pro { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pack-card, .pro-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 14px 6px 12px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); cursor: pointer; font: inherit;
}
.pack-card.popular, .pro-card.popular { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.pc-badge { position: absolute; top: -8px; left: 50%; transform: translateX(-50%); background: var(--accent); color: #fff; font-size: 9.5px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.pk-credits { font-weight: 800; font-size: 17px; display: flex; align-items: center; gap: 3px; }
.pk-usd { font-size: 14px; color: var(--muted); font-weight: 600; }
.pk-per { font-size: 10.5px; color: var(--muted); font-weight: 600; }
.pk-sub { font-size: 10.5px; color: var(--muted); }
.pk-cta { margin-top: 6px; background: var(--accent); color: #fff; font-weight: 700; font-size: 12.5px; border-radius: 999px; padding: 5px 16px; }
.pack-card:disabled, .pro-card:disabled { opacity: 0.6; cursor: default; }
.pricing-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.pricing-toggle button { background: transparent; border: none; color: var(--muted); font: inherit; font-size: 11.5px; font-weight: 700; padding: 4px 10px; cursor: pointer; }
.pricing-toggle button.on { background: var(--accent); color: #fff; }
.pricing-feats { font-size: 12px; color: var(--muted); margin-top: 10px; line-height: 1.5; }
.pricing-note { font-size: 11.5px; color: var(--muted); margin: 14px 0 0; line-height: 1.5; }
.pricing-err { margin-top: 10px; color: #ff7a7f; font-size: 13px; }
.flash-banner {
  position: fixed; left: 50%; top: 18px; transform: translate(-50%, -30px); z-index: 300;
  background: #22a55c; color: #fff; font-weight: 600; font-size: 13.5px;
  border-radius: 999px; padding: 10px 18px; box-shadow: 0 6px 24px rgba(0,0,0,0.35);
  opacity: 0; transition: opacity 0.3s, transform 0.3s; pointer-events: none;
}
.flash-banner.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- My Images gallery ---- */
.gallery { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: flex; flex-direction: column; }
.gallery.hidden { display: none; }
.gallery-top {
  display: flex; align-items: center; gap: 12px;
  height: calc(56px + env(safe-area-inset-top, 0px)); flex: 0 0 auto;
  padding: env(safe-area-inset-top, 0px) 16px 0;
  border-bottom: 1px solid var(--border); background: var(--rail);
}
.gallery-toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 16px 2px; color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; }
.gallery-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; padding-bottom: 12px; }

/* My Images: one horizontal strip — action tiles first, then the photo cards */
.gallery-strip {
  display: flex; gap: 10px; align-items: stretch;
  overflow-x: auto; padding: 12px 16px 8px; flex: 0 0 auto;
  scroll-snap-type: x proximity; scroll-padding: 0 16px; -webkit-overflow-scrolling: touch;
}
.gallery-grid { display: contents; }
.gal-tile {
  flex: 0 0 auto; width: 84px; aspect-ratio: 1; scroll-snap-align: start;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: var(--panel-2); color: var(--text); font-weight: 600; font-size: 11px;
  border: 1px solid var(--border); border-radius: 14px; cursor: pointer;
}
.gal-tile:hover { border-color: var(--accent); }
.gal-tile-add {
  border: none; color: #fff; font-size: 22px; line-height: 1;
  background: linear-gradient(135deg, #8b3dff, #ec4899);
  box-shadow: 0 6px 18px rgba(160, 60, 220, 0.35);
}
.gal-tile-add span { font-size: 11px; font-weight: 700; letter-spacing: 0.2px; }
.gal-tile-sample { padding: 0; overflow: hidden; position: relative; }
.gal-tile-sample img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.55; }
.gal-tile-sample span { position: relative; z-index: 1; text-shadow: 0 1px 4px rgba(0,0,0,0.6); color: #fff; }
.gal-card {
  position: relative; flex: 0 0 auto; width: 128px; aspect-ratio: 1; scroll-snap-align: start;
  border-radius: 14px; overflow: hidden; background: var(--panel);
  border: 1px solid var(--border); cursor: pointer;
}
.gal-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gal-card:hover { border-color: var(--accent); }
.gal-card.sel { outline: 3px solid var(--accent); outline-offset: -3px; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent), 0 6px 18px rgba(0,0,0,0.3); }
.gal-card .gal-name { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 8px 6px; font-size: 11px; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,0.7)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gal-card .gal-edit {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  padding: 5px 10px; border-radius: 999px; font-size: 11px; font-weight: 700;
  background: rgba(0,0,0,0.62); color: #fff; white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity 0.15s;
}
.gal-card.sel .gal-edit { opacity: 1; }
.gal-card.sel .gal-name { opacity: 0; }
.gal-card .gal-del, .gal-card .gal-dl { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 8px; border: none; background: rgba(0,0,0,0.55); color: #fff; cursor: pointer; display: grid; place-items: center; font-size: 13px; opacity: 0; transition: opacity 0.15s; }
.gal-card .gal-dl { right: 38px; font-size: 15px; }
.gal-card:hover .gal-del, .gal-card:hover .gal-dl { opacity: 1; }
/* Adopt-into-account on device-pool cards — always visible (mobile has no hover). */
.gal-card .gal-adopt {
  position: absolute; left: 6px; bottom: 26px; z-index: 2;
  border: none; border-radius: 999px; padding: 4px 10px;
  background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 700;
  cursor: pointer; display: inline-flex; align-items: center; gap: 3px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}
/* Cloud-generation cards: same tile feel, image + tiny label */
.gen-card {
  position: relative; flex: 0 0 auto; width: 96px; height: 120px;
  border-radius: 14px; overflow: hidden; border: 1px solid var(--border);
  background: var(--panel); cursor: pointer; padding: 0;
}
.gen-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gen-card .gen-lb {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 6px;
  font-size: 10.5px; font-weight: 600; color: #fff; text-align: left;
  background: linear-gradient(transparent, rgba(0,0,0,0.65));
  text-transform: capitalize; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gen-card:disabled { opacity: 0.5; }
/* Explicit unselect on the picked card — always visible (mobile has no hover). */
.gal-card .gal-unsel {
  position: absolute; top: 6px; left: 6px; width: 26px; height: 26px; border-radius: 50%;
  border: none; background: var(--accent); color: #fff; cursor: pointer;
  display: grid; place-items: center; z-index: 2; box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}
.gal-card .gal-unsel svg.ic { display: block; margin: 0 auto; }
/* touch devices have no hover — keep the actions visible */
@media (hover: none) { .gal-card .gal-del, .gal-card .gal-dl { opacity: 1; } }
.gallery-empty { text-align: center; color: var(--muted); padding: 4px 24px 10px; font-size: 13px; }
.gallery-empty .big { font-size: 14px; color: var(--text); }
.gal-cloud { font-size: 12px; color: var(--muted); padding: 2px 16px 0; }

/* AI filter shelf: the stars of the home screen */
.fx-head { padding-top: 18px; }
.fx-head .fx-sub { text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 12px; opacity: 0.8; }
.fx-cats { display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px 2px; scrollbar-width: none; }
.fx-cats::-webkit-scrollbar { display: none; }
.fx-cat {
  flex: 0 0 auto; padding: 7px 14px; border-radius: 999px; cursor: pointer;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.fx-cat:hover { border-color: var(--accent); }
.fx-cat.sel {
  background: linear-gradient(90deg, #8b3dff, #ec4899); color: #fff; border-color: transparent;
  box-shadow: 0 4px 12px rgba(160, 60, 220, 0.35);
}
/* Pack pills (events/experiences) stand out even unselected */
.fx-cat-pack { border-color: var(--accent); }
.fx-shelf {
  display: flex; gap: 12px; align-items: stretch; flex: 1 0 auto;
  overflow-x: auto; padding: 12px 16px 16px;
  scroll-snap-type: x proximity; scroll-padding: 0 16px; -webkit-overflow-scrolling: touch;
}
.fx-loading { color: var(--muted); font-size: 13px; padding: 18px 4px; }
.fx-card {
  position: relative; flex: 0 0 auto; scroll-snap-align: start;
  width: clamp(150px, 38vw, 200px); aspect-ratio: 3 / 4; max-height: 46vh;
  border-radius: 18px; overflow: hidden; cursor: pointer; padding: 0;
  background: var(--panel); border: 1px solid var(--border);
  transition: transform 0.15s;
}
/* hover-capable devices only — tap must not leave a sticky highlight on mobile */
@media (hover: hover) {
  .fx-card:hover { border-color: var(--accent); transform: translateY(-2px); }
}
.fx-card.sel {
  outline: 3px solid var(--accent); outline-offset: -3px;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent), 0 8px 24px rgba(0,0,0,0.35);
  transform: translateY(-2px);
}
.fx-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fx-card .fx-lb {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 10px 10px;
  font-size: 14px; font-weight: 700; color: #fff; text-align: left;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Pinned action cards: free-prompt AI + manual editor */
/* First shelf column: the two fixed action cards stacked, half height each. */
.fx-action-col {
  flex: 0 0 auto; scroll-snap-align: start;
  display: flex; flex-direction: column; gap: 12px;
  width: clamp(150px, 38vw, 200px); aspect-ratio: 3 / 4; max-height: 46vh;
}
.fx-action-col .fx-card { width: 100%; flex: 1 1 0; min-height: 0; aspect-ratio: auto; max-height: none; }
.fx-action-col .fx-action-sub { font-size: 11px; }
.fx-action {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background:
    radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%),
    var(--panel-2);
}
.fx-action .fx-action-ic { font-size: 44px; line-height: 1; }
.fx-action .fx-action-sub { font-size: 12px; color: var(--muted); text-align: center; padding: 0 14px; }
.fx-action .fx-lb { background: linear-gradient(transparent, rgba(0,0,0,0.55)); }
html[data-theme="light"] .fx-action .fx-lb { color: var(--text); background: none; }
@keyframes slot-nudge {
  0%, 100% { transform: none; box-shadow: none; }
  25%, 75% { transform: translateY(-3px); }
  50% { transform: translateY(0); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 45%, transparent); }
}
.play-slot.nudge { animation: slot-nudge 0.9s ease-in-out 2; }

/* Favorite heart (top-right) + price chip (only when ≠ 1 credit) */
.fx-card .fx-fav {
  position: absolute; top: 6px; right: 6px; width: 30px; height: 30px;
  display: grid; place-items: center; border-radius: 50%; cursor: pointer;
  background: rgba(0,0,0,0.45); color: #fff; font-size: 17px; line-height: 1;
}
.fx-card .fx-fav.on { color: #ff5c8a; }
.fx-card .fx-costchip {
  position: absolute; right: 8px; bottom: 42px; padding: 3px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 800; letter-spacing: 0.4px;
  background: rgba(0,0,0,0.6); color: #ffd166;
}
.fx-card .fx-costchip.free { background: #17402c; color: #5fd39a; }
.fx-card .fx-new {
  position: absolute; top: 8px; left: 8px; padding: 3px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 800; letter-spacing: 0.6px; color: #fff;
  background: linear-gradient(90deg, #8b3dff, #ec4899);
  box-shadow: 0 2px 8px rgba(160, 60, 220, 0.5);
}

/* Instagram-style floating size slider (left edge, social text widgets) */
.size-slider {
  position: absolute; left: 6px; top: 50%; transform: translateY(-50%);
  height: 44%; width: 34px; z-index: 30;
  display: flex; align-items: stretch; justify-content: center;
  touch-action: none; cursor: grab;
}
.size-slider .ss-track {
  width: 3px; border-radius: 2px; margin: 0 auto;
  background: rgba(255,255,255,0.8); box-shadow: 0 0 6px rgba(0,0,0,0.45);
}
html[data-theme="light"] .size-slider .ss-track { background: rgba(30,34,40,0.55); box-shadow: none; }
.size-slider .ss-thumb {
  position: absolute; left: 50%; transform: translate(-50%, -50%);
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
html[data-theme="light"] .size-slider .ss-thumb { border: 1px solid #c2c9d3; }
.size-slider.dragging .ss-thumb { transform: translate(-50%, -50%) scale(1.25); }

/* Social style carousel (Instagram): horizontal chips previewing their font */
.social-styles { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; }
.social-styles::-webkit-scrollbar { display: none; }
.social-styles .sstyle {
  flex: 0 0 auto; padding: 8px 14px; border-radius: 10px; cursor: pointer; font-size: 14px;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border); white-space: nowrap;
}
.social-styles .sstyle.sel { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }

/* Play bar: [photo] + [filter] → Apply */
.play-bar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border); background: var(--rail);
}
.play-slot {
  flex: 0 0 auto; width: 46px; height: 46px; border-radius: 12px; overflow: hidden;
  display: grid; place-items: center; cursor: pointer; padding: 0;
  background: var(--panel-2); border: 1px dashed var(--border); color: var(--muted); font-size: 18px;
}
.play-slot.filled { border: 1px solid var(--accent); }
.play-slot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.play-plus { color: var(--muted); font-weight: 700; }
.play-apply {
  flex: 1; min-width: 0; border: none; cursor: pointer; border-radius: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 9px 12px; font-weight: 800; font-size: 15px; letter-spacing: 0.2px;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--border);
}
.play-apply .play-apply-lb { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.play-apply .play-cost { font-size: 10px; font-weight: 600; opacity: 0.75; }
.play-apply:disabled { cursor: default; }
.play-apply.armed {
  border: none; color: #fff;
  background: linear-gradient(90deg, #8b3dff, #ec4899);
  box-shadow: 0 8px 22px rgba(160, 60, 220, 0.35);
  animation: play-pulse 1.6s ease-in-out infinite;
}
.play-apply.armed:active { transform: translateY(1px); }
@keyframes play-pulse {
  0%, 100% { box-shadow: 0 8px 22px rgba(160, 60, 220, 0.35); }
  50% { box-shadow: 0 8px 30px rgba(200, 70, 235, 0.6); }
}

/* ---- Account chip + sheet (light card, pictools.ai V2 design) ---- */
.account-chip { font-weight: 600; white-space: nowrap; }
.account-chip.signed { border-color: var(--accent); color: var(--text); }
.acctsheet {
  position: fixed; inset: 0; z-index: 130;
  background: rgba(10, 11, 14, 0.62);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
}
.acct-card {
  /* The sheet INHERITS the app theme (team crossing-finding, 26 ago): dark
     card on the dark editor, the original light "V2" palette on light. */
  --ink: var(--text);
  --ink-muted: var(--muted);
  --sheet-bg: var(--panel);
  --sheet-field: var(--bg);
  --sheet-flat: var(--panel-2);
  --sheet-hover: #333947;
  --line: #e2e8f0;
  position: relative;
  width: min(430px, 94vw);
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--sheet-bg);
  color: var(--ink);
  border-radius: 20px;
  padding: 30px 28px 22px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  display: flex; flex-direction: column; gap: 12px;
}
.acct-close {
  position: absolute; top: 12px; right: 12px;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--sheet-flat); border: none; color: var(--ink-muted);
  font-size: 14px; cursor: pointer;
}
.acct-close:hover { background: var(--sheet-hover); color: var(--ink); }
#acctAuth, #acctProfile { display: flex; flex-direction: column; gap: 12px; }
#acctAuth > button, #acctProfile > button { width: 100%; }
.acct-title { margin: 0 0 6px; font-size: 30px; font-weight: 800; text-align: center; letter-spacing: -0.4px; }
.acct-label { font-size: 16px; font-weight: 600; color: var(--ink); margin-top: 2px; }
.acct-card input[type="email"], .acct-card input[type="password"], .acct-card input[type="text"] {
  width: 100%;
  background: var(--sheet-field); border: 1px solid var(--border); border-radius: 12px;
  color: var(--ink); padding: 13px 14px; font: inherit; font-size: 15px;
}
.acct-card input::placeholder { color: var(--ink-muted); }
.acct-card input:focus { outline: none; border-color: var(--ink); }
.acct-passwrap { position: relative; }
.acct-passwrap input { padding-right: 44px; }
.acct-passwrap #acctEye {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--ink); cursor: pointer; padding: 6px;
}
#acctEye .eye-slash { opacity: 1; }
#acctEye.showing .eye-slash { opacity: 0; }
.acct-error { color: #dc2626; font-size: 13px; line-height: 1.45; }
.acct-error.ok { color: #16a34a; }
.acct-google {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  cursor: pointer; border-radius: 12px; padding: 14px;
  background: var(--sheet-field); border: 1px solid var(--border); color: var(--ink); font-weight: 700; font-size: 16px;
}
.acct-google:hover { background: var(--sheet-hover); }
.acct-or { display: flex; align-items: center; gap: 12px; color: #94a3b8; font-size: 13px; letter-spacing: 1px; margin: 4px 0; justify-content: center; }
.acct-primary {
  border: none; cursor: pointer; border-radius: 14px; padding: 15px;
  background: linear-gradient(90deg, #8b3dff, #ec4899); color: #fff; font-weight: 700; font-size: 16px;
  margin-top: 6px;
}
.acct-primary:hover { filter: brightness(1.25); }
.acct-primary:disabled { opacity: 0.6; }
.acct-outline {
  cursor: pointer; border-radius: 14px; padding: 14px;
  background: var(--sheet-field); border: 1px solid var(--border); color: var(--ink); font-weight: 700; font-size: 15px;
}
.acct-outline:hover { background: var(--sheet-hover); }
.acct-link { background: none; border: none; color: var(--ink-muted); font-size: 14.5px; cursor: pointer; padding: 6px; }
.acct-link:hover { color: var(--ink); }
/* App theme picker (Auto follows the phone when installed; browser default is dark) */
.acct-theme { display: flex; align-items: center; gap: 8px; padding-top: 6px; }
.acct-theme-lb { color: var(--ink-muted); font-size: 13px; margin-right: auto; }
.acct-theme button {
  padding: 8px 14px; border-radius: 999px; border: 1.5px solid var(--line);
  background: #fff; color: var(--ink); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.acct-theme button.sel { border-color: var(--accent); color: var(--accent); }
.acct-legal { display: flex; justify-content: center; gap: 26px; padding-top: 8px; }
.acct-legal a { color: var(--ink-muted); font-size: 13px; text-decoration: none; }
.acct-legal a:hover { color: var(--ink); text-decoration: underline; }
/* Signed-in profile: avatar initial, quiet truncated email, credits as a card */
.acct-ava {
  width: 56px; height: 56px; border-radius: 50%; margin: 2px auto 8px;
  background: linear-gradient(135deg, #8b3dff, #ec4899); color: #fff;
  font-size: 24px; font-weight: 800; display: grid; place-items: center;
  text-transform: uppercase; user-select: none;
}
.acct-who {
  text-align: center; font-size: 14.5px; font-weight: 600; color: var(--ink-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 8px; margin-bottom: 12px;
}
.acct-credits-card {
  background: #f4f1fb; border: 1px solid var(--line); border-radius: 16px;
  padding: 14px 16px 12px; text-align: center; margin-bottom: 12px;
}
.acct-balance { font-size: 34px; font-weight: 800; color: var(--ink); line-height: 1.1; }
.acct-balance svg.ic { color: #eab308; vertical-align: 1px; margin-right: 2px; }
.acct-balance-lb { font-size: 13px; color: var(--ink-muted); margin-left: 6px; font-weight: 600; }
.acct-break { color: var(--ink-muted); font-size: 12.5px; margin-top: 2px; }

/* ---- AI filter grid ---- */
/* AI filter grid: thumbnails fill their cells (tight padding, bigger art + labels). */
#aigrid { padding: 6px 6px 16px; gap: 6px 4px; }
#aigrid .toolitem.aifx { height: auto; padding: 4px 2px 8px; gap: 5px; }
#aigrid .toolitem.aifx .lb { font-size: 12.5px; color: var(--text); white-space: normal; }
.aifx-thumb {
  width: min(100%, 96px); aspect-ratio: 1 / 1; height: auto;
  border-radius: 50%; overflow: hidden; background: var(--panel-2);
  display: block; margin: 0 auto; border: 2px solid transparent;
}
.aifx-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.toolitem.aifx.sel .aifx-thumb { border-color: var(--accent); }
.ai-promptbox { position: relative; width: 100%; }
.ai-prompt {
  display: block; width: 100%; resize: none;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  color: var(--text); padding: 11px 62px 11px 13px; font: inherit; font-size: 13.5px; line-height: 1.45;
}
.ai-prompt:focus { outline: none; border-color: var(--accent); }
.ai-fab {
  position: absolute; right: 10px; bottom: 10px;
  width: 46px; height: 46px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, #8b3dff, #ec4899); color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(160, 60, 220, 0.45);
  transition: transform 0.1s, filter 0.15s;
}
.ai-fab:hover { filter: brightness(1.08); }
.ai-fab:active { transform: scale(0.94); }
.ai-fab:disabled { filter: saturate(0.4) brightness(0.8); cursor: default; }
.ai-fab-spin {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.35); border-top-color: #fff;
  animation: fxspin 0.7s linear infinite;
}

/* ---- AI Studio (the AI tab session) ---- */
.ai-studio {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 16px;
  padding: 10px 12px; width: min(560px, 94vw);
}
.ai-slots { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.ai-slots::-webkit-scrollbar { display: none; }
.ai-slot {
  position: relative; flex: 0 0 auto; width: 58px; height: 58px;
  border-radius: 10px; overflow: hidden; background: var(--panel);
  border: 1px solid var(--border);
}
.ai-slot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ai-slot-lb {
  position: absolute; left: 0; right: 0; bottom: 0;
  font-size: 8px; text-align: center; padding: 1px 2px;
  background: rgba(0, 0, 0, 0.55); color: #fff; white-space: nowrap; overflow: hidden;
}
.ai-slot-x {
  position: absolute; top: 2px; right: 2px; width: 16px; height: 16px;
  border: none; border-radius: 50%; background: rgba(0, 0, 0, 0.65); color: #fff;
  font-size: 9px; line-height: 1; cursor: pointer; display: grid; place-items: center;
}
.ai-slot-add {
  display: grid; place-items: center; cursor: pointer;
  color: var(--muted); font-size: 22px; background: transparent;
  border-style: dashed;
}
.ai-slot-add:hover { border-color: var(--accent); color: var(--accent); }
.ai-promptrow { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.ai-filterbtn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 10px 18px; border-radius: 999px; font-weight: 700; font-size: 13.5px;
  background: var(--panel); color: var(--text);
  border: 1.5px solid var(--accent);
}
.ai-filterbtn:hover { background: rgba(236, 72, 153, 0.12); }
.ai-filterbtn.sel { background: var(--accent); color: #fff; }
.ai-filterbtn-ic { font-size: 15px; }
.ai-filterbtn-thumb { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; margin: -6px 0; border: 1.5px solid rgba(255, 255, 255, 0.85); }
.ai-filterbtn-x { opacity: 0.85; font-size: 13px; margin-left: 4px; padding: 4px; }
.ai-filterbtn-x:hover { opacity: 1; }
.ai-cost { color: var(--muted); font-size: 11.5px; white-space: nowrap; }

/* ---- In-app camera ---- */
.camsheet { position: fixed; inset: 0; z-index: 120; background: #000; display: flex; flex-direction: column; }
.camsheet video { flex: 1; min-height: 0; width: 100%; object-fit: contain; background: #000; }
.camsheet video.mirror { transform: scaleX(-1); }
.cam-controls {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 30px calc(16px + env(safe-area-inset-bottom, 0px));
  background: #000;
}
.cam-controls .btn { color: #fff; }
#camShutter {
  width: 66px; height: 66px; border-radius: 50%; cursor: pointer;
  border: 4px solid #fff; background: rgba(255, 255, 255, 0.28);
  transition: background 0.1s;
}
#camShutter:active { background: #fff; }

/* Bundled fonts (also used by the core text renderer) so previews/editor match. */
@font-face { font-family: ff-sans; src: url("assets/fonts/sans.ttf"); }
@font-face { font-family: ff-sans; font-weight: 700; src: url("assets/fonts/sans-bold.ttf"); }
@font-face { font-family: ff-serif; src: url("assets/fonts/serif.ttf"); }
@font-face { font-family: ff-serif; font-weight: 700; src: url("assets/fonts/serif-bold.ttf"); }
@font-face { font-family: ff-mono; src: url("assets/fonts/mono.ttf"); }
@font-face { font-family: ff-mono; font-weight: 700; src: url("assets/fonts/mono-bold.ttf"); }
@font-face { font-family: ff-gothic; src: url("assets/fonts/gothic.ttf"); }
@font-face { font-family: ff-gothic; font-weight: 700; src: url("assets/fonts/gothic-bold.ttf"); }
@font-face { font-family: ff-bookman; src: url("assets/fonts/bookman.ttf"); }
@font-face { font-family: ff-bookman; font-weight: 700; src: url("assets/fonts/bookman-bold.ttf"); }
@font-face { font-family: ff-palatino; src: url("assets/fonts/palatino.ttf"); }
@font-face { font-family: ff-palatino; font-weight: 700; src: url("assets/fonts/palatino-bold.ttf"); }
@font-face { font-family: ff-script; src: url("assets/fonts/script.ttf"); }
/* Google Fonts (OFL/Apache — assets/fonts/LICENSES.md). DOM previews must match
   what the Rust core renders, so these load the exact same TTFs. */
@font-face { font-family: ff-montserrat; src: url("assets/fonts/montserrat.ttf"); }
@font-face { font-family: ff-oswald; src: url("assets/fonts/oswald.ttf"); }
@font-face { font-family: ff-bebas; src: url("assets/fonts/bebas.ttf"); }
@font-face { font-family: ff-anton; src: url("assets/fonts/anton.ttf"); }
@font-face { font-family: ff-archivo; src: url("assets/fonts/archivo.ttf"); }
@font-face { font-family: ff-playfair; src: url("assets/fonts/playfair.ttf"); }
@font-face { font-family: ff-pacifico; src: url("assets/fonts/pacifico.ttf"); }
@font-face { font-family: ff-lobster; src: url("assets/fonts/lobster.ttf"); }
@font-face { font-family: ff-dancing; src: url("assets/fonts/dancing.ttf"); }
@font-face { font-family: ff-caveat; src: url("assets/fonts/caveat.ttf"); }
@font-face { font-family: ff-marker; src: url("assets/fonts/marker.ttf"); }
@font-face { font-family: ff-amatic; src: url("assets/fonts/amatic.ttf"); }
@font-face { font-family: ff-amatic; font-weight: 700; src: url("assets/fonts/amatic-bold.ttf"); }
@font-face { font-family: ff-righteous; src: url("assets/fonts/righteous.ttf"); }
@font-face { font-family: ff-bangers; src: url("assets/fonts/bangers.ttf"); }
@font-face { font-family: ff-vibes; src: url("assets/fonts/vibes.ttf"); }

/* Section hints stay lowercase and quiet (the toolbar default is uppercase). */
#deviceSection .fx-sub, #genSection .fx-sub { text-transform: none; letter-spacing: 0; }

/* Multi-pick count badge on the play-bar photo slot */
.play-slot .play-count {
  position: absolute; right: -4px; top: -4px; z-index: 2;
  background: var(--accent); color: #fff; font-size: 10.5px; font-weight: 800;
  border-radius: 999px; padding: 2px 6px; box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}

/* Cloud generations inline in the My Images strip: match the gallery card size */
#galleryGrid .gen-card { width: 128px; height: auto; aspect-ratio: 1; border-radius: 14px; scroll-snap-align: start; }
.gen-card .gen-del {
  position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 8px;
  background: rgba(0,0,0,0.55); color: #fff; display: grid; place-items: center; cursor: pointer;
}
.gen-card .gen-cloud {
  position: absolute; top: 6px; left: 6px; width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,0.55); color: #fff; display: grid; place-items: center;
}

/* ---- AI generation cover: dancing brand mosaic ----
   FULL-PAGE modal: while a generation runs nothing else is tappable (the only
   affordance is its own Cancel). */
.gen-cover {
  position: fixed; inset: 0; z-index: 260;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(7px) saturate(115%); -webkit-backdrop-filter: blur(7px) saturate(115%);
}
.gc-cancel {
  margin-top: 6px; border: 1px solid var(--border); background: var(--panel-2);
  color: var(--muted); font: inherit; font-size: 13px; font-weight: 600;
  border-radius: 999px; padding: 8px 22px; cursor: pointer;
}
.gc-cancel:hover { color: var(--text); }
.gen-cover.hidden { display: none; }
.gc-grid { display: grid; grid-template-columns: repeat(4, 18px); gap: 5px; }
.gc-sq {
  width: 18px; height: 18px; border-radius: 4px;
  animation: gcDance 1.15s ease-in-out infinite;
}
@keyframes gcDance {
  0%, 100% { transform: scale(0.65) rotate(0deg); opacity: 0.45; }
  45% { transform: scale(1.15) rotate(90deg); opacity: 1; }
}
.gc-line { font-size: 14px; font-weight: 600; color: var(--text); text-align: center; padding: 0 24px; min-height: 20px; }

/* ---- Digital Identity sheet ---- */
.id-explain { font-size: 14px; color: var(--ink-muted); line-height: 1.55; margin: 6px 0 14px; text-align: center; }
.id-guide { font-size: 12.5px; color: var(--ink-muted); text-align: center; margin-bottom: 12px; }
.id-qcard { background: #f4f1fb; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; }
.id-qtop { display: flex; align-items: baseline; justify-content: space-between; font-weight: 700; color: var(--ink); }
.id-qbar { height: 8px; border-radius: 999px; background: #e4def2; margin: 8px 0; overflow: hidden; }
.id-qfill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #8b3dff, #ec4899); transition: width 0.4s; }
.id-qfact { font-size: 12px; color: var(--ink-muted); }
.id-qsug { font-size: 12px; color: #7e22ce; margin-top: 4px; font-weight: 600; }
.id-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.id-ref { position: relative; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.id-ref img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.id-ref select { width: 100%; border: none; border-top: 1px solid var(--line); font-size: 10.5px; padding: 4px 2px; background: #fff; color: var(--ink); }
.id-ref .id-refx { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: none; background: rgba(0,0,0,0.55); color: #fff; display: grid; place-items: center; cursor: pointer; }
.id-ref .id-refzoom { position: absolute; top: 4px; left: 4px; width: 22px; height: 22px; border-radius: 50%; border: none; background: rgba(0,0,0,0.55); color: #fff; display: grid; place-items: center; cursor: pointer; }
.id-status { display: inline-block; font-size: 10.5px; font-weight: 800; letter-spacing: 0.4px; border-radius: 999px; padding: 2px 10px; margin-left: 8px; vertical-align: 2px; }
.id-status.ready { background: #d8f5e4; color: #1a7f4b; }
.id-status.draft { background: #f2ecc9; color: #8a6d1a; }
.id-status.enh { background: #ede4fb; color: #6d28d9; }
.id-head { text-align: center; font-weight: 800; font-size: 17px; color: var(--ink); margin-bottom: 8px; }
.id-del { background: none; border: none; color: #d33; font-size: 13px; cursor: pointer; padding: 8px; display: block; margin: 4px auto 0; }
.id-busy { text-align: center; color: var(--ink-muted); font-size: 13px; padding: 8px; }
/* Studio "Me" tile */
.ai-slot-me { border: 1.5px dashed var(--border); background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 700; cursor: pointer; }
.ai-slot-me.on { border: 2px solid var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }

/* Identity wizard: switcher chips, slot tiles */
.id-chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-bottom: 12px; }
.id-chip {
  border: 1.5px solid var(--line); background: #fff; color: var(--ink);
  font: inherit; font-size: 12.5px; font-weight: 700; border-radius: 999px;
  padding: 6px 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
}
.id-chip.on { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, #fff); }
.id-ref.empty {
  aspect-ratio: 1; display: grid; place-items: center; cursor: pointer;
  border: 1.5px dashed #c9c2dd; background: #faf8ff; color: #8b81a8;
}
.id-ref.empty:hover { border-color: var(--accent); color: var(--accent); }
.id-slot-add { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; text-align: center; padding: 4px; }
.id-ref { cursor: pointer; }
.id-reflb { font-size: 10.5px; font-weight: 700; padding: 4px 2px; text-align: center; background: #fff; border-top: 1px solid var(--line); color: var(--ink-muted); }
.id-reflb.done { color: #1a7f4b; }
.id-reflb.warn { color: #b3261e; background: #fdecea; }
.id-avaset { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin: 12px 0; background: linear-gradient(135deg, #faf7ff, #fdf9f4); }
.gc-prog { color: #fff; font-weight: 800; font-size: 16px; margin-top: 14px; letter-spacing: 0.2px; }

/* ---- full-screen image viewer -------------------------------------------- */
.viewer { position: fixed; inset: 0; z-index: 260; background: rgba(8, 8, 12, 0.97); display: flex; align-items: center; justify-content: center; }
.vw-stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: none; }
.vw-stage img { max-width: 100%; max-height: 100%; user-select: none; -webkit-user-drag: none; transform-origin: center center; will-change: transform; }
.vw-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 14px 10px; background: linear-gradient(rgba(0,0,0,0.55), transparent); }
.vw-name { color: #fff; font-weight: 700; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.vw-count { color: rgba(255,255,255,0.75); font-weight: 700; font-size: 12.5px; }
.vw-btn { width: 38px; height: 38px; border-radius: 50%; border: none; background: rgba(255,255,255,0.14); color: #fff; display: grid; place-items: center; cursor: pointer; }
.vw-btn:active { background: rgba(255,255,255,0.28); }
.vw-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 60px; border: none; background: transparent; color: rgba(255,255,255,0.65); font-size: 44px; line-height: 1; cursor: pointer; padding: 0; }
.vw-nav.prev { left: 2px; } .vw-nav.next { right: 2px; }
.vw-nav:disabled { opacity: 0.18; }
@media (hover: none) { .vw-nav { display: none; } } /* touch: swipe instead */
/* Bottom-right, clear of gal-unsel (top-left) and del/dl (top-right). */
.gal-zoom { position: absolute; bottom: 26px; right: 6px; width: 30px; height: 30px; border-radius: 50%; border: none; background: rgba(15,17,21,0.55); color: #fff; display: grid; place-items: center; cursor: pointer; z-index: 2; }
.gen-card .gal-zoom { bottom: 26px; right: 6px; }
.id-ava-head { font-weight: 800; font-size: 13.5px; color: #6d28d9; }
.id-ava-note { font-weight: 600; font-size: 11px; color: var(--ink-muted); margin-left: 6px; }
.id-ava-row { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 4px; }
.id-ava { width: 76px; height: 100px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); flex: 0 0 auto; display: block; }
.id-ava-wrap { position: relative; flex: 0 0 auto; }
.id-ava-x {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%;
  border: none; background: rgba(15,17,21,0.6); color: #fff; display: grid; place-items: center; cursor: pointer;
}
.id-ava-actions { display: flex; gap: 10px; align-items: center; margin-top: 6px; }
.id-ava-actions .acct-outline { flex: 1; }

/* ---- My Identities: full page (route /identities) ---- */
.idpage { position: fixed; inset: 0; z-index: 60; background: var(--bg); display: flex; flex-direction: column; }
.idpage.hidden { display: none; }
.idpage-title { font-weight: 800; font-size: 17px; letter-spacing: -0.3px; }
.idpage-scroll { flex: 1; overflow-y: auto; padding: 12px 14px calc(24px + env(safe-area-inset-bottom, 0px)); }
.idpage-card {
  max-width: 520px; margin: 0 auto; background: #fff; color: var(--ink, #12151c);
  border-radius: 22px; padding: 20px 18px;
}
@media (min-width: 700px) { .idpage-card .id-grid { grid-template-columns: repeat(4, 1fr); } }

/* ---- Identity photo cropper ---- */
.crop-modal {
  position: fixed; inset: 0; z-index: 280; background: rgba(8, 8, 14, 0.92);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 18px;
}
.crop-modal.hidden { display: none; }
.crop-stage { position: relative; touch-action: none; }
#cropCanvas { display: block; max-width: 92vw; max-height: 58vh; border-radius: 8px; }
.crop-box {
  position: absolute; border: 2px solid #ec4899; border-radius: 4px; cursor: move;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
}
.crop-h {
  position: absolute; width: 22px; height: 22px; background: #ec4899; border-radius: 50%;
  border: 3px solid #fff; box-sizing: border-box;
}
.crop-h.tl { left: -11px; top: -11px; cursor: nwse-resize; }
.crop-h.tr { right: -11px; top: -11px; cursor: nesw-resize; }
.crop-h.bl { left: -11px; bottom: -11px; cursor: nesw-resize; }
.crop-h.br { right: -11px; bottom: -11px; cursor: nwse-resize; }
.crop-hint { color: #cfc9dd; font-size: 13px; }
.crop-actions { display: flex; gap: 10px; }
.crop-actions .btn { flex: 0 0 auto; padding: 10px 18px; }

/* Identity tiles in the My Images strip */
.gal-tile.id-tile { position: relative; }
.gal-tile.id-tile.sel { outline: 3px solid var(--accent); outline-offset: -3px; }
.id-tile-ava { width: 44px; height: 44px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: var(--panel-2); }
.id-tile-ava img { width: 100%; height: 100%; object-fit: cover; display: block; }
.id-tile-badge {
  position: absolute; top: 6px; right: 6px; background: #f2ecc9; color: #8a6d1a;
  font-size: 9px; font-weight: 800; letter-spacing: 0.3px; border-radius: 999px; padding: 2px 7px; text-transform: uppercase;
}
.id-tile-badge.enh { background: #ede4fb; color: #6d28d9; }
.play-count.play-id { right: auto; left: -4px; background: #7e22ce; display: grid; place-items: center; width: 18px; height: 18px; padding: 0; }

.fx-search {
  width: calc(100% - 28px); margin: 6px 14px 2px; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); font-size: 14px; outline: none;
}
.fx-search:focus { border-color: var(--accent); }
#fxSearchBtn.on { color: var(--accent); }

.play-quality {
  flex: 0 0 auto; min-width: 52px; height: 44px; border-radius: 12px; border: 1px solid var(--line);
  font-weight: 800; font-size: 12.5px; letter-spacing: 0.4px; cursor: pointer; background: var(--panel); color: var(--ink);
}
.play-quality.q-standard { background: var(--panel); }
.play-quality.q-high { background: #ede4fb; color: #6d28d9; border-color: #d8c6f5; }
.play-quality.q-pro { background: #fdf3d7; color: #92600a; border-color: #f2dfa7; }

.studio-quality { height: 38px; min-width: 48px; margin-left: 2px; }

.gal-sync { position: absolute; bottom: 26px; left: 6px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; background: rgba(15,17,21,0.55); color: #9be8b7; }
.gal-sync.pend { color: #ffd479; }

.pick-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 10px 14px 0; padding: 12px 14px; border-radius: 14px;
  background: linear-gradient(135deg, #7c3aed, #ec4899); color: #fff; font-size: 13.5px; font-weight: 600;
}
.pick-banner .acct-primary { flex: 0 0 auto; width: auto; padding: 8px 14px; background: #fff; color: #7c3aed; border-radius: 10px; border: none; font-weight: 800; cursor: pointer; }

/* Empty library: compact strip so filters start above the mobile fold. */
.gallery.slim .gallery-strip .gal-tile { height: 76px; }
.gallery.slim .gallery-strip .gal-tile span { font-size: 11px; }
.gallery.slim .gallery-empty { display: none !important; }
.gallery.slim .gallery-sub { display: none; }

/* Light theme: the account sheet returns to the original light V2 palette. */
:root[data-theme="light"] .acct-card {
  --ink: #0b1524;
  --ink-muted: #64748b;
  --sheet-bg: #fff;
  --sheet-field: #fff;
  --sheet-flat: #f1f5f9;
  --sheet-hover: #e2e8f0;
}

/* Bridge arrival strip: brand continuity for the pictools.ai → app crossing. */
.arrive-banner {
  position: fixed; top: 10px; left: 50%; transform: translate(-50%, -140%);
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  border-radius: 999px; padding: 9px 18px 9px 12px; font-size: 13.5px; font-weight: 600;
  box-shadow: 0 10px 34px rgba(0,0,0,0.45); z-index: 300;
  transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.1);
  white-space: nowrap;
}
.arrive-banner.show { transform: translate(-50%, 0); }
.arrive-banner svg { display: block; }

/* Help & legal inside My Account: tighter than the settings variant */
.acct-help { gap: 18px; flex-wrap: wrap; margin-top: 4px; }

/* #17 fase 1: Plan & Credits card in My Account */
.acct-plan { border: 1px solid var(--line, rgba(128,128,128,.25)); border-radius: 12px; padding: 12px 14px; margin: 10px 0 4px; text-align: left; font-size: 13.5px; }
.acct-plan .ap-row { display: flex; justify-content: space-between; align-items: center; padding: 3px 0; }
.acct-plan .ap-label { color: var(--ink-muted); }
.acct-plan .ap-status { text-transform: capitalize; }
.acct-plan .ap-status.ok { color: #2e9e5b; }
.acct-plan .ap-status.warn { color: #c77b12; }
.acct-plan .ap-actions { display: flex; gap: 10px; margin-top: 8px; }
.acct-plan .ap-actions button { flex: 1; font-size: 13px; padding: 7px 6px; border-radius: 9px; border: 1px solid var(--line, rgba(128,128,128,.35)); background: transparent; color: inherit; cursor: pointer; }
.acct-plan .ap-invoices { margin-top: 8px; max-height: 140px; overflow-y: auto; font-size: 12.5px; }
.acct-plan .ap-invoices a { color: inherit; }
.acct-plan .ap-inv-row { display: flex; justify-content: space-between; padding: 2px 0; border-top: 1px dashed var(--line, rgba(128,128,128,.2)); }

/* #17 fase 2: edit profile */
.acct-provider { font-size: 12px; color: var(--ink-muted); margin: -2px 0 2px; }
.acct-edit { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 2px; text-align: left; }
.acct-edit input { font-size: 14px; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--line, rgba(128,128,128,.35)); background: transparent; color: inherit; }
.acct-edit .pe-row { display: flex; gap: 8px; }
.acct-edit .pe-row button { flex: 1; }
.pe-danger { color: #d64545 !important; }
.pe-warn { font-size: 12.5px; color: var(--ink-muted); margin: 2px 0 6px; }
#pePw, #peDelete { display: flex; flex-direction: column; gap: 8px; }
#pePw.hidden, #peDelete.hidden { display: none; }
.acct-ava img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
