/* PhotoLAB — "Comet Night" theme: deep black, cool-tinted surfaces, one violet-to-cyan accent. */
:root {
  --bg: #050508;
  --surface: #0b0b11;
  --surface-2: #111119;
  --surface-3: #181822;
  --surface-4: #20202d;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.12);
  --text: #eef0f7;
  --text-dim: #a4a8bb;
  --text-faint: #6b6f84;
  --accent: #8f7bff;
  --accent-2: #4fd6ff;
  --accent-ink: #0a0a14;
  --grad: linear-gradient(135deg, #8f7bff 0%, #5aa8ff 55%, #4fd6ff 100%);
  --accent-soft: rgba(143, 123, 255, 0.14);
  --danger: #ff6b7a;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.5);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --font: Inter, "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 var(--font);
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: rgba(143, 123, 255, 0.4); }

#app { display: grid; grid-template-rows: 52px minmax(0, 1fr) auto; height: 100%; }

/* ---------- top bar ---------- */
.topbar {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 14px;
  background: linear-gradient(180deg, #0e0e16, var(--surface));
  border-bottom: 1px solid var(--line);
  z-index: 5;
}
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: linear-gradient(90deg, transparent, rgba(143, 123, 255, 0.5), rgba(79, 214, 255, 0.5), transparent); opacity: 0.55; pointer-events: none; }
.brand { display: flex; align-items: center; gap: 11px; }
.logo { flex-shrink: 0; height: 30px; width: auto; filter: drop-shadow(0 0 9px rgba(143, 123, 255, 0.55)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 700; letter-spacing: 0.03em; font-size: 15px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-by { display: flex; align-items: center; gap: 8px; color: var(--text-faint); font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; margin-top: 3px; white-space: nowrap; }
.comet-link {
  display: inline-flex; align-items: center; gap: 4px; height: 17px; padding: 0 7px 0 8px;
  border: 1px solid var(--line-strong); border-radius: 9px; background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim); font-size: 10px; font-weight: 600; letter-spacing: 0.04em; text-transform: none; text-decoration: none;
  transition: color 0.15s, border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.comet-link svg { width: 10px; height: 10px; }
.comet-link:hover { color: #fff; border-color: rgba(143, 123, 255, 0.7); background: var(--accent-soft); box-shadow: 0 0 14px rgba(143, 123, 255, 0.3); }
.toolbar, .top-right { display: flex; align-items: center; gap: 4px; }
.top-right { justify-content: flex-end; gap: 8px; }
.sep { width: 1px; height: 20px; background: var(--line-strong); margin: 0 8px; }

/* ---------- buttons ---------- */
.btn, .icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 32px;
  padding: 0 13px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  font-weight: 500;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease), transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.btn:hover:not(:disabled), .icon-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.09); border-color: var(--line-strong); }
.btn:active:not(:disabled), .icon-btn:active:not(:disabled), .btn.active { background: rgba(255, 255, 255, 0.13); transform: translateY(1px); }
.btn:disabled, .icon-btn:disabled { opacity: 0.32; }
.btn.ghost, .icon-btn { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn.ghost:hover:not(:disabled), .icon-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.07); color: var(--text); border-color: transparent; }
.btn.primary { background: var(--grad); border-color: transparent; color: var(--accent-ink); font-weight: 650; box-shadow: 0 4px 20px rgba(143, 123, 255, 0.32); }
.btn.primary:hover:not(:disabled) { background: var(--grad); filter: brightness(1.1); box-shadow: 0 6px 26px rgba(143, 123, 255, 0.5); }
.btn.primary:active:not(:disabled) { filter: brightness(0.95); }
.btn.big { height: 44px; padding: 0 26px; font-size: 14.5px; border-radius: 10px; }
.btn.tool { background: rgba(255, 255, 255, 0.05); }
.icon-btn { width: 32px; padding: 0; }
.btn.sm, .icon-btn.sm { height: 26px; font-size: 12px; padding: 0 9px; border-radius: 6px; }
.icon-btn.sm { width: 26px; padding: 0; }

/* ---------- layout ---------- */
.workspace { display: grid; grid-template-columns: 252px minmax(0, 1fr) 304px; min-height: 0; }
.panel { background: var(--surface); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.panel.left { border-right: 1px solid var(--line); }
.panel.right { border-left: 1px solid var(--line); overflow-y: auto; }
.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 15px 16px 9px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
}
.panel-title::before { content: ""; width: 3px; height: 11px; border-radius: 2px; background: var(--grad); }
.panel-title.with-action { justify-content: space-between; color: var(--text); text-transform: none; letter-spacing: 0; font-size: 14px; font-weight: 650; padding-right: 12px; }
.panel-title.with-action::before { display: none; }
.title-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title-actions { display: flex; gap: 2px; flex-shrink: 0; }
.empty-note { padding: 10px 16px; color: var(--text-faint); font-size: 12px; }
.hint { margin: 0; padding: 11px 16px; color: var(--text-faint); font-size: 11.5px; border-top: 1px solid var(--line); background: rgba(255, 255, 255, 0.015); }
.tip { margin: 0; padding: 0 16px 8px; color: var(--text-faint); font-size: 11.5px; }

/* ---------- layers ---------- */
.layer-scroll { flex: 1; overflow-y: auto; min-height: 0; padding: 2px 8px 8px; }
.layer-item {
  position: relative; display: flex; align-items: center; gap: 4px; height: 40px; padding: 0 8px 0 4px; margin-bottom: 3px;
  border-radius: 9px; cursor: pointer; user-select: none; border: 1px solid transparent;
  transition: background 0.12s var(--ease), border-color 0.12s var(--ease);
}
.layer-item:hover { background: rgba(255, 255, 255, 0.045); }
.layer-item.selected { background: var(--accent-soft); border-color: rgba(143, 123, 255, 0.4); }
.layer-item.selected::before { content: ""; position: absolute; left: -9px; top: 10px; bottom: 10px; width: 3px; border-radius: 2px; background: var(--grad); }
.layer-item.off .name { color: var(--text-faint); text-decoration: line-through; text-decoration-color: #444; }
.layer-item.dragging { opacity: 0.4; }
.layer-item.drop-before::after, .layer-item.drop-after::after { content: ""; position: absolute; left: 4px; right: 4px; height: 2px; border-radius: 1px; background: var(--grad); }
.layer-item.drop-before::after { top: -3px; }
.layer-item.drop-after::after { bottom: -3px; }
.layer-item .grip { width: 14px; color: var(--text-faint); cursor: grab; display: grid; place-items: center; opacity: 0.5; }
.layer-item .kind { width: 24px; height: 24px; display: grid; place-items: center; color: var(--accent); background: rgba(143, 123, 255, 0.13); border-radius: 7px; flex-shrink: 0; }
.layer-item .kind-text { color: #ffb86b; background: rgba(255, 184, 107, 0.13); }
.layer-item .kind-image { color: #5ee0c1; background: rgba(94, 224, 193, 0.13); }
.layer-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-left: 5px; font-weight: 500; }
.layer-item.base { cursor: default; color: var(--text-dim); margin-top: 10px; border: 1px dashed var(--line-strong); background: transparent; }
.layer-item.base:hover { background: transparent; }
.layer-item.base .kind { color: var(--text-faint); background: var(--surface-3); }
.row-actions { display: none; }
.layer-item:hover .row-actions, .layer-item:focus-within .row-actions { display: flex; }

/* ---------- stage ---------- */
.stage { display: grid; grid-template-rows: 36px minmax(0, 1fr); min-width: 0; min-height: 0; background: var(--bg); }
.infobar { display: flex; align-items: center; justify-content: space-between; padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--line); color: var(--text-dim); font-size: 12px; min-width: 0; }
.status-left { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.status-right { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.gpu { color: var(--text-faint); margin-right: 8px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.zoom { min-width: 48px; text-align: center; font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }

.viewport { position: relative; overflow: hidden; touch-action: none; cursor: default; min-height: 0; }
.has-image .viewport { cursor: grab; }
.viewport.over-layer { cursor: move; }
.viewport.panning { cursor: grabbing; }
.viewport.dragging-layer { cursor: grabbing; }
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- empty state ---------- */
.empty-state { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; overflow: auto; }
.has-image .empty-state { display: none; }
.empty-state::before, .empty-state::after { content: ""; position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.35; pointer-events: none; animation: drift 14s ease-in-out infinite alternate; }
.empty-state::before { width: 46vmin; height: 46vmin; left: 12%; top: 8%; background: #6f5bff; }
.empty-state::after { width: 40vmin; height: 40vmin; right: 10%; bottom: 6%; background: #1fb6ff; animation-delay: -7s; }
@keyframes drift { to { transform: translate(40px, -30px) scale(1.12); } }
.empty-inner { position: relative; z-index: 1; max-width: 520px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.hero-logo { height: 96px; width: auto; margin-bottom: 4px; filter: drop-shadow(0 0 22px rgba(143, 123, 255, 0.55)); }
.empty-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; color: var(--text-faint); font-size: 12px; text-decoration: none; transition: color 0.15s; }
.empty-link:hover { color: var(--accent-2); }
.empty-inner h1 { margin: 0; font-size: 30px; line-height: 1.15; font-weight: 750; letter-spacing: -0.02em; background: linear-gradient(180deg, #fff, #b9bfd8); -webkit-background-clip: text; background-clip: text; color: transparent; }
.empty-inner p { margin: 0; color: var(--text-dim); }
.empty-inner .lead { max-width: 400px; font-size: 14px; }
.empty-inner .hint { color: var(--text-faint); font-size: 12px; border: 0; padding: 0; background: none; }
.steps { list-style: none; margin: 22px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: left; width: 100%; }
.steps li { display: flex; flex-direction: column; gap: 8px; padding: 14px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); border-radius: var(--radius-lg); color: var(--text-dim); font-size: 12.5px; backdrop-filter: blur(6px); }
.steps b { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: var(--grad); color: var(--accent-ink); font-size: 12px; flex-shrink: 0; }
kbd { padding: 1px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--surface-2); font: 11px var(--font); color: var(--text-dim); }

/* ---------- on-photo selection ---------- */
.overlay-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.sel-box { position: absolute; left: 0; top: 0; transform-origin: 50% 50%; pointer-events: none; }
.sel-outline { position: absolute; inset: 0; border: 1.5px solid var(--accent); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), 0 0 18px rgba(143, 123, 255, 0.35), inset 0 0 0 1px rgba(0, 0, 0, 0.3); border-radius: 2px; }
.handle { position: absolute; width: 12px; height: 12px; background: #fff; border: 2px solid var(--accent); border-radius: 3px; pointer-events: auto; transform: translate(-50%, -50%); box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5); }
.handle.nw { left: 0; top: 0; cursor: nwse-resize; }
.handle.ne { left: 100%; top: 0; cursor: nesw-resize; }
.handle.se { left: 100%; top: 100%; cursor: nwse-resize; }
.handle.sw { left: 0; top: 100%; cursor: nesw-resize; }
.handle.rot { left: 50%; top: -32px; width: 15px; height: 15px; border-radius: 50%; cursor: grab; background: var(--accent); border-color: #fff; }
.rot-stem { position: absolute; left: 50%; top: -26px; width: 1.5px; height: 26px; background: var(--accent); }
.edit-box { position: absolute; left: 0; top: 0; transform-origin: 50% 50%; margin: 0; border: 0; outline: 0; resize: none; overflow: hidden; white-space: pre; background: rgba(0, 0, 0, 0.22); caret-color: var(--accent-2); pointer-events: auto; -webkit-user-select: text; user-select: text; }
.sel-box.editing .handle, .sel-box.editing .rot-stem { display: none; }

/* ---------- adjust panel ---------- */
.empty-card { margin: 4px 14px; padding: 18px; border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); color: var(--text-dim); background: rgba(255, 255, 255, 0.02); }
.empty-card p { margin: 0 0 8px; }
.empty-title { color: var(--text); font-weight: 650; font-size: 14px; }
.empty-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.ctl { padding: 7px 16px; }
.ctl-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.ctl-label { color: var(--text-dim); font-size: 12px; user-select: none; font-weight: 500; }
.ctl-inline { display: flex; align-items: center; justify-content: space-between; min-height: 36px; }
.ctl-num {
  width: 58px; height: 22px; padding: 0 6px; text-align: right; background: rgba(255, 255, 255, 0.04); border: 1px solid transparent;
  border-radius: 6px; color: var(--text); font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 600; -moz-appearance: textfield;
}
.ctl-num::-webkit-outer-spin-button, .ctl-num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ctl-num:hover { border-color: var(--line-strong); }
.ctl-num:focus { border-color: var(--accent); outline: 0; background: var(--bg); }
.ctl-textarea { width: 100%; resize: vertical; min-height: 60px; padding: 9px 10px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius); color: var(--text); line-height: 1.4; }
.ctl-textarea:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; margin: 0; background: transparent; cursor: pointer; --p: 50%; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--accent) 0, var(--accent-2) var(--p), rgba(255, 255, 255, 0.1) var(--p)); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 0 0 3px rgba(143, 123, 255, 0.35), 0 2px 6px rgba(0, 0, 0, 0.5); transition: box-shadow 0.15s var(--ease), transform 0.15s var(--ease); }
input[type="range"]:hover::-webkit-slider-thumb { box-shadow: 0 0 0 5px rgba(143, 123, 255, 0.4), 0 2px 8px rgba(0, 0, 0, 0.5); }
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.12); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.1); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 0 0 3px rgba(143, 123, 255, 0.35); }

.ctl-color { display: flex; align-items: center; gap: 8px; }
.ctl-hex { color: var(--text-faint); font-size: 11px; font-variant-numeric: tabular-nums; }
input[type="color"] { -webkit-appearance: none; appearance: none; width: 32px; height: 22px; padding: 0; background: none; border: 1px solid var(--line-strong); border-radius: 6px; cursor: pointer; overflow: hidden; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 0; }
input[type="color"]::-moz-color-swatch { border: 0; }

.switch { -webkit-appearance: none; appearance: none; position: relative; width: 34px; height: 19px; border-radius: 10px; background: rgba(255, 255, 255, 0.13); border: 0; cursor: pointer; transition: background 0.2s var(--ease); flex-shrink: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%; background: #c9cce0; transition: transform 0.2s var(--ease), background 0.2s var(--ease); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); }
.switch:checked { background: var(--grad); }
.switch:checked::after { transform: translateX(15px); background: #fff; }

.ctl-select, .text-input { height: 28px; padding: 0 9px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 7px; color: var(--text); transition: border-color 0.15s; }
.ctl-select:hover, .text-input:hover { border-color: rgba(255, 255, 255, 0.22); }
.ctl-select:focus, .text-input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.text-input { width: 100%; height: 34px; }
.text-input.mono { font-size: 12px; text-overflow: ellipsis; }

/* ---------- dock (effects bar + presets) ---------- */
.dock { background: linear-gradient(180deg, #0d0d14, var(--surface)); border-top: 1px solid var(--line); display: grid; grid-template-rows: 40px 244px; position: relative; }
.dock::before { content: ""; position: absolute; left: 0; right: 0; top: -1px; height: 1px; background: linear-gradient(90deg, transparent, rgba(143, 123, 255, 0.45), rgba(79, 214, 255, 0.45), transparent); opacity: 0.5; pointer-events: none; }
.dock.collapsed { grid-template-rows: 40px 0; }
.dock.collapsed .dock-body { display: none; }
.dock-tabs { display: flex; align-items: stretch; padding: 0 10px; border-bottom: 1px solid var(--line); }
.dock-tab { position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 0 16px; background: none; border: 0; color: var(--text-dim); font-weight: 650; transition: color 0.15s; }
.dock-tab:hover { color: var(--text); }
.dock-tab[aria-selected="true"] { color: var(--text); }
.dock-tab[aria-selected="true"]::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--grad); box-shadow: 0 0 12px rgba(143, 123, 255, 0.7); }
.dock-hint { flex: 1; align-self: center; padding: 0 12px; color: var(--text-faint); font-size: 12px; }
.dock-body { min-height: 0; overflow: hidden; }
.dock-pane { height: 100%; display: flex; flex-direction: column; min-height: 0; }
.dock-bar { display: flex; align-items: center; gap: 14px; padding: 10px 14px 6px; flex-shrink: 0; min-width: 0; }
.dock-bar .search { margin: 0; width: 230px; flex-shrink: 0; }
.dock-note { color: var(--text-faint); font-size: 12px; }
.spacer { flex: 1; }
.search { display: flex; align-items: center; gap: 8px; padding: 0 10px; height: 30px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 15px; color: var(--text-faint); transition: border-color 0.15s, box-shadow 0.15s; }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); color: var(--text-dim); }
.search-input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--text); }
.search-input::-webkit-search-cancel-button { display: none; }
.pills { display: flex; gap: 6px; overflow-x: auto; min-width: 0; padding: 2px 0; scrollbar-width: none; }
.pills::-webkit-scrollbar { display: none; }
.pill { display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 12px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); border-radius: 14px; color: var(--text-dim); white-space: nowrap; font-weight: 500; transition: background 0.15s var(--ease), border-color 0.15s, color 0.15s; flex-shrink: 0; }
.pill:hover { color: var(--text); background: rgba(255, 255, 255, 0.08); }
.pill[aria-pressed="true"] { background: var(--accent-soft); border-color: rgba(143, 123, 255, 0.55); color: #fff; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: hsl(var(--hue, 250) 80% 64%); box-shadow: 0 0 8px hsl(var(--hue, 250) 80% 64% / 0.6); }
.pill-count { color: var(--text-faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.pill[aria-pressed="true"] .pill-count { color: var(--text-dim); }

.card-row { flex: 1; min-width: 0; display: flex; align-items: flex-start; gap: 12px; padding: 6px 14px 6px; overflow-x: auto; overflow-y: hidden; min-height: 0; scroll-behavior: smooth; scrollbar-width: none; cursor: grab; }
.card-row::-webkit-scrollbar { display: none; }
.card-row.dragging { cursor: grabbing; scroll-behavior: auto; user-select: none; }
.card-row.dragging .card { pointer-events: none; }

/* Browse controls: slider underneath, arrows and soft edge fades on the sides. */
.carousel { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.row-wrap { position: relative; flex: 1; min-height: 0; display: flex; }
.row-wrap::before, .row-wrap::after { content: ""; position: absolute; top: 0; bottom: 0; width: 56px; z-index: 2; pointer-events: none; opacity: 0; transition: opacity 0.2s; }
.row-wrap::before { left: 0; background: linear-gradient(90deg, #0b0b11, transparent); }
.row-wrap::after { right: 0; background: linear-gradient(270deg, #0b0b11, transparent); }
.row-wrap.can-left::before, .row-wrap.can-right::after { opacity: 1; }
.row-arrow { position: absolute; top: 34px; z-index: 3; width: 34px; height: 34px; display: grid; place-items: center; padding: 0; border-radius: 50%; background: rgba(18, 18, 28, 0.88); backdrop-filter: blur(8px); border: 1px solid var(--line-strong); color: #fff; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55); opacity: 0; pointer-events: none; transform: scale(0.85); transition: opacity 0.18s, transform 0.18s var(--ease), background 0.15s, border-color 0.15s; }
.row-arrow.prev { left: 8px; }
.row-arrow.prev svg { transform: rotate(-90deg); }
.row-arrow.next { right: 8px; }
.row-arrow.next svg { transform: rotate(90deg); }
.row-wrap.can-left .row-arrow.prev, .row-wrap.can-right .row-arrow.next { opacity: 1; pointer-events: auto; transform: none; }
.row-arrow:hover { background: var(--grad); border-color: transparent; color: var(--accent-ink); }
.scrub { display: none; padding: 0 16px 8px; }
.carousel.scrollable .scrub { display: block; }
.scrub input[type="range"] { height: 16px; }
.scrub input[type="range"]::-webkit-slider-runnable-track { height: 5px; border-radius: 3px; }
.scrub input[type="range"]::-webkit-slider-thumb { width: 38px; height: 12px; margin-top: -3.5px; border-radius: 6px; background: #fff; box-shadow: 0 0 0 2px rgba(143, 123, 255, 0.4), 0 2px 8px rgba(0, 0, 0, 0.5); }
.scrub input[type="range"]::-moz-range-thumb { width: 38px; height: 12px; border-radius: 6px; background: #fff; box-shadow: 0 0 0 2px rgba(143, 123, 255, 0.4); }
@media (hover: none) { .row-arrow { display: none; } } /* touch: swipe, no arrows needed */

/* The category pill row gets the same browse controls, scaled down. */
.carousel.is-pills { flex: 1 1 0; min-width: 0; }
.carousel.is-pills .row-wrap { flex: 0 0 auto; }
.carousel.is-pills .pills { flex: 1; scroll-behavior: smooth; }
.carousel.is-pills .row-wrap::before, .carousel.is-pills .row-wrap::after { width: 40px; }
.carousel.is-pills .row-wrap::before { background: linear-gradient(90deg, #0c0c13, transparent); }
.carousel.is-pills .row-wrap::after { background: linear-gradient(270deg, #0c0c13, transparent); }
.carousel.is-pills .row-arrow { top: 50%; width: 28px; height: 28px; transform: translateY(-50%) scale(0.85); }
.carousel.is-pills .row-arrow.prev { left: 2px; }
.carousel.is-pills .row-arrow.next { right: 2px; }
.carousel.is-pills .row-wrap.can-left .row-arrow.prev, .carousel.is-pills .row-wrap.can-right .row-arrow.next { transform: translateY(-50%); }
.carousel.is-pills .scrub { padding: 3px 4px 0; }
.carousel.is-pills .scrub input[type="range"] { height: 12px; }
.carousel.is-pills .scrub input[type="range"]::-webkit-slider-runnable-track { height: 4px; }
.carousel.is-pills .scrub input[type="range"]::-webkit-slider-thumb { width: 30px; height: 10px; margin-top: -3px; }
.carousel.is-pills .scrub input[type="range"]::-moz-range-thumb { width: 30px; height: 10px; }
.card { position: relative; flex: 0 0 auto; width: 132px; display: flex; flex-direction: column; gap: 7px; padding: 0; background: none; border: 0; text-align: left; cursor: pointer; border-radius: 12px; transition: transform 0.18s var(--ease); animation: card-in 0.28s var(--ease) both; }
@keyframes card-in { from { opacity: 0; transform: translateY(6px); } }
.card:hover { transform: translateY(-3px); }
.card:focus-visible { outline-offset: 4px; }
.thumb { position: relative; width: 132px; height: 92px; border-radius: 11px; overflow: hidden; background: var(--surface-3) linear-gradient(110deg, var(--surface-3) 30%, var(--surface-4) 50%, var(--surface-3) 70%); background-size: 200% 100%; border: 1px solid var(--line-strong); display: grid; place-items: center; color: var(--text-faint); transition: border-color 0.18s, box-shadow 0.18s; }
.card:not(.has-thumb) .thumb { animation: shimmer 1.4s linear infinite; }
.card.has-thumb .thumb { animation: none; background: #000; }
/* Before a photo is open there is nothing to preview: show a quiet category-tinted tile instead. */
body:not(.has-image) .card:not(.has-thumb):not(.card-new) .thumb { animation: none; background: radial-gradient(120% 120% at 20% 10%, hsl(var(--hue, 255) 45% 22%), hsl(var(--hue, 255) 40% 8%)); }
@keyframes shimmer { to { background-position: -200% 0; } }
.card:hover .thumb { border-color: hsl(var(--hue, 255) 85% 66% / 0.8); box-shadow: 0 8px 26px hsl(var(--hue, 255) 85% 60% / 0.32); }
.thumb-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; }
.card.has-thumb .thumb-img { display: block; animation: fade-in 0.3s both; }
@keyframes fade-in { from { opacity: 0; } }
.thumb-add { position: absolute; right: 7px; bottom: 7px; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: var(--grad); color: var(--accent-ink); opacity: 0; transform: scale(0.8); transition: opacity 0.15s, transform 0.15s var(--ease); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5); }
.card:hover .thumb-add, .card:focus-visible .thumb-add { opacity: 1; transform: scale(1); }
.card-name { padding: 0 3px; font-size: 12px; font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-new .thumb { background: transparent; border-style: dashed; animation: none; }
.card-new:hover .thumb { color: var(--text); border-color: var(--accent); }
.card-actions { position: absolute; top: 5px; right: 5px; display: none; gap: 4px; }
.card:hover .card-actions, .card:focus-within .card-actions { display: flex; }
.card-btn { width: 24px; height: 24px; display: grid; place-items: center; padding: 0; background: rgba(8, 8, 14, 0.78); backdrop-filter: blur(6px); border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 7px; color: #fff; transition: background 0.12s, color 0.12s; }
.card-btn:hover { background: #fff; color: #000; }
.row-divider { flex: 0 0 1px; align-self: stretch; margin: 0 6px 24px; background: var(--line-strong); }
.card-row .empty-note { align-self: center; }

/* ---------- dialogs ---------- */
.dialog { width: 420px; max-width: calc(100vw - 32px); padding: 0; background: linear-gradient(180deg, #14141d, #0d0d14); color: var(--text); border: 1px solid var(--line-strong); border-radius: 16px; box-shadow: var(--shadow), 0 0 0 1px rgba(143, 123, 255, 0.1); }
.dialog[open] { animation: dialog-in 0.22s var(--ease); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
.dialog::backdrop { background: rgba(3, 3, 8, 0.72); backdrop-filter: blur(6px); }
.dialog-form { padding: 24px; display: flex; flex-direction: column; gap: 13px; }
.dialog h2 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.dialog-note { margin: 0; color: var(--text-dim); font-size: 12.5px; line-height: 1.5; }
.eyebrow { margin: 0; color: var(--accent-2); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.12em; font-weight: 700; }
.row-gap { display: flex; gap: 8px; }
.row-gap .btn { flex-shrink: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 4px 11px; border: 1px solid var(--line-strong); border-radius: 13px; color: var(--text-dim); font-size: 12px; background: rgba(255, 255, 255, 0.03); }
.field { display: flex; flex-direction: column; gap: 7px; }
.field-label { color: var(--text-dim); font-size: 12px; display: flex; justify-content: space-between; font-weight: 500; }
.muted { color: var(--text-faint); font-size: 12px; }
.segmented { display: inline-flex; padding: 3px; gap: 3px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 10px; width: fit-content; }
.segmented button { height: 28px; padding: 0 18px; background: transparent; border: 0; border-radius: 7px; color: var(--text-dim); font-weight: 600; transition: background 0.15s, color 0.15s; }
.segmented button[aria-pressed="true"] { background: var(--grad); color: var(--accent-ink); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* ---------- overlays ---------- */
.drop-overlay { position: fixed; inset: 0; z-index: 50; display: flex; gap: 16px; padding: 24px; background: rgba(4, 4, 10, 0.86); backdrop-filter: blur(8px); }
.drop-zone { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; border: 2px dashed rgba(255, 255, 255, 0.25); border-radius: 18px; text-align: center; transition: border-color 0.15s, background 0.15s, transform 0.15s var(--ease); }
.drop-zone strong { font-size: 18px; }
.drop-zone span { color: var(--text-dim); }
.drop-zone.hot { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.01); }
.toasts { position: fixed; bottom: 268px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { padding: 10px 16px; background: rgba(22, 22, 32, 0.92); backdrop-filter: blur(10px); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow); font-size: 12.5px; font-weight: 500; animation: toast-in 0.25s var(--ease); }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity 0.2s, transform 0.2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(0.97); } }
.fatal { position: fixed; inset: 0; z-index: 100; display: grid; place-content: center; gap: 8px; padding: 24px; text-align: center; background: var(--bg); }
.fatal h1 { margin: 0; font-size: 20px; }
.fatal p { margin: 0; color: var(--text-dim); }

/* ---------- guided tour ---------- */
.tour { position: fixed; inset: 0; z-index: 90; }
.tour-ring { position: fixed; border-radius: 12px; box-shadow: 0 0 0 9999px rgba(3, 3, 8, 0.8), 0 0 0 2px var(--accent), 0 0 28px rgba(143, 123, 255, 0.55); pointer-events: none; transition: left 0.25s var(--ease), top 0.25s var(--ease), width 0.25s var(--ease), height 0.25s var(--ease); }
.tour-card { position: fixed; padding: 18px; background: linear-gradient(180deg, #181822, #11111a); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: var(--shadow); transition: left 0.25s var(--ease), top 0.25s var(--ease); }
.tour-card h3 { margin: 3px 0 7px; font-size: 16px; font-weight: 700; }
.tour-count { margin: 0; color: var(--accent-2); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.12em; font-weight: 700; }
.tour-body { margin: 0 0 16px; color: var(--text-dim); font-size: 13px; line-height: 1.55; }
.tour-actions { display: flex; align-items: center; gap: 6px; }

/* ---------- scrollbars ---------- */
* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.16) transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 5px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.22); background-clip: padding-box; }

/* ---------- mobile nav (hidden on desktop) ---------- */
.mobile-nav { display: none; }
button, .btn, .icon-btn, .pill, .card { touch-action: manipulation; }

/* Touch screens: bigger targets for handles and buttons. */
@media (pointer: coarse) {
  .handle { width: 24px; height: 24px; border-radius: 5px; }
  .handle.nw { transform: translate(-80%, -80%); }
  .handle.ne { transform: translate(-20%, -80%); }
  .handle.se { transform: translate(-20%, -20%); }
  .handle.sw { transform: translate(-80%, -20%); }
  .handle.rot { width: 28px; height: 28px; top: -52px; }
  .rot-stem { top: -40px; height: 40px; }
  .btn, .icon-btn { height: 38px; }
  .btn.sm, .icon-btn.sm { height: 32px; }
  .icon-btn { width: 38px; }
  .icon-btn.sm { width: 32px; }
  .row-actions, .card-actions { display: flex; }
  .thumb-add { opacity: 1; transform: none; }
  input[type="range"] { height: 30px; }
  input[type="range"]::-webkit-slider-thumb { width: 22px; height: 22px; margin-top: -9px; }
  .ctl-num { height: 30px; }
}

/* ---------- tablets ---------- */
@media (max-width: 1100px) {
  .workspace { grid-template-columns: 210px minmax(0, 1fr) 264px; }
  .gpu, .brand-by > span:first-child { display: none; } /* keep the Comet button, drop the words beside it */
  .btn.tool, .toolbar .btn { padding: 0 10px; }
}

/* ---------- short windows: a more compact dock so the photo keeps room ---------- */
@media (max-height: 700px) and (min-width: 861px) {
  .dock { grid-template-rows: 36px 198px; }
  .dock.collapsed { grid-template-rows: 36px 0; }
  .dock-bar { padding: 6px 14px 2px; }
  .card { width: 104px; }
  .thumb { width: 104px; height: 66px; }
  .card-row { padding: 4px 14px 4px; gap: 10px; }
  .row-arrow { top: 22px; }
  .scrub { padding-bottom: 6px; }
  .toasts { bottom: 220px; }
}

/* ---------- phone-only pieces: hidden on desktop ---------- */
.mobile-only, .sheet-head, .ctx-bar { display: none; }
@supports (height: 100dvh) { #app { height: 100dvh; } } /* iOS/Android: ignore the collapsing browser bar */
* { -webkit-tap-highlight-color: transparent; }

/* The "more" menu (opened from the top bar on phones). */
.menu-sheet { position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column; justify-content: flex-end; }
.menu-backdrop { position: absolute; inset: 0; background: rgba(3, 3, 8, 0.62); backdrop-filter: blur(5px); animation: fade-in 0.2s both; }
.menu-panel { position: relative; background: linear-gradient(180deg, #181823, #0f0f17); border: 1px solid var(--line-strong); border-bottom: 0; border-radius: 24px 24px 0 0; padding: 8px 12px calc(16px + env(safe-area-inset-bottom, 0px)); box-shadow: var(--shadow); animation: sheet-up 0.24s var(--ease); }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
.menu-grab { display: grid; place-items: center; height: 20px; }
.menu-grab i { width: 40px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.22); }
.menu-item { display: flex; align-items: center; gap: 15px; width: 100%; height: 56px; padding: 0 14px; background: none; border: 0; border-radius: 14px; color: var(--text); font-size: 15.5px; font-weight: 550; text-decoration: none; text-align: left; }
.menu-item:active { background: rgba(255, 255, 255, 0.09); }
.menu-item svg { width: 21px; height: 21px; color: var(--accent); flex-shrink: 0; }

/* ---------- phones and small tablets: Adobe Express-style layout ---------- */
@media (max-width: 860px) {
  :root { --nav-h: calc(64px + env(safe-area-inset-bottom, 0px)); }
  #app { grid-template-rows: 54px minmax(0, 1fr) auto var(--nav-h); }
  .mobile-only { display: inline-flex; }

  /* Top bar: logo, undo / redo, menu, Export. Everything else lives in the tool bar or the menu. */
  .topbar { grid-template-columns: auto 1fr auto; padding: 0 8px 0 12px; gap: 4px; overflow: visible; }
  .brand { padding: 0; }
  .brand-text, .sep, .lbl { display: none; }
  .logo { height: 30px; }
  #btnOpen, #btnAddText, #btnAddImage, #btnReset, #btnHelp, #btnSupport { display: none !important; }
  .toolbar { justify-content: center; gap: 2px; }
  .top-right { gap: 4px; }
  .icon-btn { width: 44px; height: 44px; }
  .icon-btn svg { width: 22px; height: 22px; }
  .btn.primary { height: 40px; padding: 0 18px; border-radius: 20px; font-size: 14px; }
  .btn.primary .lbl { display: inline; }

  /* Photo area: the whole stage, with two floating buttons instead of an info strip. */
  .stage { position: relative; grid-template-rows: minmax(0, 1fr); flex: 1 1 auto; min-height: 0; order: 1; }
  .infobar { position: absolute; top: 10px; right: 10px; z-index: 6; padding: 0; background: none; border: 0; }
  .status-left, .gpu, #btnZoomIn, #btnZoomOut, #zoomLabel, #btnActual { display: none !important; }
  .status-right { gap: 8px; }
  #btnCompare, #btnFit { width: 44px; height: 44px; padding: 0; border-radius: 50%; background: rgba(14, 14, 22, 0.74); backdrop-filter: blur(12px); border: 1px solid var(--line-strong); color: #fff; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45); }
  #btnCompare svg, #btnFit svg { width: 20px; height: 20px; }
  body:not(.has-image) .infobar { display: none; }

  /* Floating action bar for the selected text / image layer. */
  body.has-image .ctx-bar:not([hidden]) { display: flex; }
  .ctx-bar { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 6; gap: 2px; padding: 6px; background: rgba(16, 16, 26, 0.92); backdrop-filter: blur(16px); border: 1px solid var(--line-strong); border-radius: 20px; box-shadow: var(--shadow); animation: sheet-up 0.2s var(--ease); }
  .ctx-bar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 62px; height: 56px; padding: 0 6px; background: none; border: 0; border-radius: 14px; color: var(--text); font-size: 11px; font-weight: 600; }
  .ctx-bar button svg { width: 21px; height: 21px; }
  .ctx-bar button:active { background: rgba(255, 255, 255, 0.12); }
  .ctx-bar [data-ctx="delete"] { color: var(--danger); }
  .ctx-bar [hidden] { display: none; }
  body:not([data-sheet="none"]) .ctx-bar { display: none !important; } /* a sheet is open: don't cover the photo */

  /* Bottom sheets: always under the photo, drag the handle to resize or dismiss. */
  .workspace { grid-row: 2; display: flex; flex-direction: column; }
  .panel { display: none; order: 2; flex: 0 0 var(--sheet-h, 320px); height: var(--sheet-h, 320px); border: 0; border-top: 1px solid var(--line-strong); border-radius: 22px 22px 0 0; box-shadow: 0 -14px 44px rgba(0, 0, 0, 0.55); overflow: hidden; }
  .panel.right { overflow-y: hidden; display: none; }
  body[data-sheet="layers"] #layers, body[data-sheet="adjust"] #params { display: flex; flex-direction: column; }
  #params .params-body { flex: 1; overflow-y: auto; min-height: 0; padding-bottom: 20px; -webkit-overflow-scrolling: touch; }
  #layers .layer-scroll { flex: 1; min-height: 0; }
  #layers .panel-title, #layers .hint { display: none; }
  .dock { display: none; grid-row: 3; height: var(--sheet-h, 306px); grid-template-rows: auto minmax(0, 1fr); border-radius: 22px 22px 0 0; box-shadow: 0 -14px 44px rgba(0, 0, 0, 0.55); overflow: hidden; }
  .dock::before { display: none; }
  body[data-sheet="dock"] .dock { display: grid; }
  .dock .dock-tabs { display: none; }
  .dock .dock-body { min-height: 0; }
  .panel.dismissing, .dock.dismissing { opacity: 0.6; }

  .sheet-head { display: block; flex: 0 0 auto; }
  .sheet-handle { display: grid; place-items: center; height: 26px; cursor: grab; touch-action: none; }
  .sheet-handle i { width: 42px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.24); }
  .sheet-row { display: flex; align-items: center; gap: 4px; padding: 0 8px 8px 20px; min-height: 40px; }
  .sheet-title { font-size: 18px; font-weight: 750; letter-spacing: -0.01em; }
  .sheet-action { min-width: 44px; height: 44px; display: grid; place-items: center; padding: 0 12px; background: transparent; border: 0; border-radius: 22px; color: var(--text-dim); font-weight: 650; font-size: 14px; }
  .sheet-action:active { background: rgba(255, 255, 255, 0.1); }
  .sheet-action.done { background: var(--grad); color: var(--accent-ink); padding: 0 20px; height: 38px; box-shadow: 0 4px 16px rgba(143, 123, 255, 0.35); }
  .dock .sheet-search { display: inline-flex; }
  .dock[data-tab="presets"] .sheet-search { display: none; }

  /* Effects / Looks content. */
  .dock-bar { flex-wrap: nowrap; gap: 8px; padding: 0 14px 4px; }
  .dock.search-open .dock-bar { flex-wrap: wrap; }
  .dock-bar .pills { flex: 1; min-width: 0; }
  .dock-bar .btn { flex-shrink: 0; width: 44px; height: 44px; padding: 0; border-radius: 22px; }
  .dock .dock-bar .search { display: none; width: 100%; height: 42px; border-radius: 21px; }
  .dock.search-open .dock-bar .search { display: flex; }
  .dock-note { display: none; }
  .pill { height: 38px; padding: 0 16px; font-size: 13.5px; border-radius: 19px; }
  .card-row { padding: 6px 14px 8px; gap: 12px; }
  .card { width: 128px; }
  .thumb { width: 128px; height: 96px; }
  .card-name { font-size: 12.5px; }
  .row-arrow { display: none; }
  #btnShare, .dock-bar .btn .lbl { display: none; }

  /* Adjust + layers: roomy, thumb-friendly rows. */
  .ctl { padding: 11px 20px; }
  .ctl-label { font-size: 13.5px; }
  .ctl-num { height: 32px; width: 64px; font-size: 13px; }
  .ctl-inline { min-height: 46px; }
  #params .panel-title.with-action { padding: 4px 12px 8px 20px; font-size: 15px; }
  .empty-card { margin: 4px 16px; }
  .layer-scroll { padding: 2px 10px 12px; }
  .layer-item { height: 52px; border-radius: 12px; }
  .layer-item .kind { width: 30px; height: 30px; }
  .layer-item .name { font-size: 14px; }

  /* Tool bar. */
  .mobile-nav { display: flex; grid-row: 4; align-items: stretch; gap: 2px; padding: 4px 6px env(safe-area-inset-bottom, 0px); overflow-x: auto; scrollbar-width: none; background: linear-gradient(180deg, #0f0f17, var(--surface)); border-top: 1px solid var(--line); }
  .mobile-nav::-webkit-scrollbar { display: none; }
  .mobile-nav button { position: relative; flex: 1 0 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; margin: 4px 0; background: none; border: 0; border-radius: 14px; color: var(--text-dim); font-size: 11.5px; font-weight: 650; transition: background 0.15s, color 0.15s, transform 0.12s; }
  .mobile-nav button svg { width: 24px; height: 24px; }
  .mobile-nav button:active { transform: scale(0.94); background: rgba(255, 255, 255, 0.08); }
  .mobile-nav button[aria-pressed="true"] { color: #fff; background: var(--accent-soft); }
  .mobile-nav button[aria-pressed="true"] svg { color: var(--accent-2); }

  .toasts { top: 62px; bottom: auto; max-width: calc(100vw - 24px); }
  .empty-state { place-items: start center; padding: 26px 18px; }
  .empty-inner { gap: 12px; }
  .empty-inner h1 { font-size: 24px; }
  .hero-logo { height: 76px; }
  .btn.big { height: 50px; width: 100%; max-width: 320px; font-size: 16px; border-radius: 25px; }
  .steps { margin-top: 8px; grid-template-columns: 1fr; }
  .steps li { flex-direction: row; align-items: center; padding: 11px 14px; }
  .dialog-form { padding: 20px; }
  .drop-overlay { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* =====================================================================================
   Layout hardening: fixes for everything the automated layout audit (14 screen sizes x
   every UI state) found. Keep these at the end of the file so they win the cascade.
   ===================================================================================== */

/* Nothing may widen the page: a long file name or label must truncate, not push controls off the edge. */
#app { grid-template-columns: minmax(0, 1fr); }
.workspace, .stage, .panel, .viewport, .dock, .dock-body, .dock-pane, .dock-bar, .carousel, .row-wrap, .toolbar, .top-right, .brand { min-width: 0; }
.layer-item .name, .card-name, .status-left, .title-text, .brand-text, .sheet-title { min-width: 0; }
.dialog { max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; }

/* The welcome screen: centre when it fits, scroll from the top when it doesn't (never cut off the top). */
.empty-state { display: flex; }
.empty-inner { margin: auto; }
@media (max-height: 640px) { .hero-logo { height: 64px; } }
@media (max-height: 520px) { .steps { display: none; } }

/* Narrow desktop windows (just above the phone breakpoint): icon-only top bar so Export never leaves the screen. */
@media (min-width: 861px) and (max-width: 1000px) {
  #btnAddText .lbl, #btnAddImage .lbl, #btnReset .lbl, #btnSupport .lbl { display: none; }
  .toolbar .btn { padding: 0 10px; }
  .sep { margin: 0 4px; }
}

/* No photo yet on desktop: fold the effects bar away so the welcome screen has the room. */
@media (min-width: 861px) {
  body:not(.has-image) .dock { grid-template-rows: 40px 0; }
  body:not(.has-image) .dock .dock-body { display: none; }
  body:not(.has-image) .dock-hint::after { content: "Open a photo to preview 100+ effects and 96 looks on it"; }
}

/* ---------- phones / small tablets (<= 860px) ---------- */
@media (max-width: 860px) {
  /* Floating action bar: centre with auto margins (not transform) so it can never be shifted off-screen. */
  .ctx-bar { left: 0; right: 0; margin-inline: auto; width: max-content; max-width: calc(100% - 16px); transform: none; }
  .ctx-bar button { flex: 1 1 0; min-width: 54px; }

  /* Comfortable touch targets everywhere, even when the browser reports a mouse. */
  .icon-btn.sm { width: 40px; height: 40px; }
  .btn.sm { height: 38px; }
  .ctl-select, .text-input { height: 42px; }
  .ctl-select { min-width: 120px; }
  .segmented button { height: 40px; padding: 0 22px; }
  .dialog .btn { height: 42px; }
  .empty-link { padding: 13px 10px; margin-top: 0; }
  .card-btn { width: 30px; height: 30px; }
  .layer-item > .icon-btn, .layer-item .row-actions .icon-btn { width: 36px; height: 36px; }
}

/* Very narrow phones (320-360px): the six tools share the bar equally instead of scrolling off the edge. */
@media (max-width: 360px) {
  .mobile-nav { padding-left: 2px; padding-right: 2px; gap: 0; }
  .mobile-nav button { flex: 1 1 0; min-width: 0; font-size: 10.5px; }
  .mobile-nav button svg { width: 22px; height: 22px; }
}

/* Short phones (portrait): tighter sheet content so cards and sliders still fit, and the photo keeps room. */
@media (max-width: 860px) and (max-height: 700px) {
  .sheet-handle { height: 20px; }
  .sheet-row { min-height: 34px; padding-bottom: 4px; }
  .sheet-title { font-size: 16px; }
  .sheet-action { height: 38px; }
  .pill { height: 34px; padding: 0 13px; font-size: 12.5px; }
  .card { width: 104px; }
  .thumb { width: 104px; height: 72px; }
  .card-name { font-size: 11.5px; }
  .dock-bar { padding-bottom: 2px; }
  .ctl { padding: 8px 18px; }
  .layer-item { height: 46px; }
  .mobile-nav button { margin: 3px 0; gap: 3px; }
}

/* Phones in landscape: sheets become a side panel next to the photo (there is no vertical room for a bottom sheet). */
@media (max-width: 860px) and (max-height: 540px) {
  :root { --nav-h: calc(50px + env(safe-area-inset-bottom, 0px)); --side-w: min(46vw, 340px); }
  #app { grid-template-rows: 46px minmax(0, 1fr) auto var(--nav-h); }
  .icon-btn { width: 40px; height: 40px; }
  .btn.primary { height: 36px; padding: 0 16px; }
  .logo { height: 26px; }
  .workspace { flex-direction: row; }
  .panel { flex: 0 0 var(--side-w); height: auto !important; border: 0; border-left: 1px solid var(--line-strong); border-radius: 0; box-shadow: -12px 0 36px rgba(0, 0, 0, 0.45); }
  .dock { position: fixed; z-index: 20; right: 0; top: 46px; bottom: var(--nav-h); width: var(--side-w); height: auto !important; border: 0; border-left: 1px solid var(--line-strong); border-radius: 0; box-shadow: -12px 0 36px rgba(0, 0, 0, 0.45); }
  body[data-sheet="dock"] .stage { margin-right: var(--side-w); }
  .sheet-handle { display: none; }
  .sheet-row { padding-top: 6px; }
  .mobile-nav button { margin: 3px 0; gap: 2px; font-size: 10.5px; }
  .mobile-nav button svg { width: 20px; height: 20px; }
  .ctx-bar { bottom: 8px; }
  .toasts { top: 52px; }
  .empty-state { padding: 12px 18px; }
  .hero-logo { height: 48px; }
}

/* Dialogs: when the window is short the form scrolls, but its buttons stay pinned and reachable. */
.dialog-form { --dpad: 24px; padding: var(--dpad); }
.dialog-actions { position: sticky; bottom: calc(var(--dpad) * -1); z-index: 2; margin: 6px calc(var(--dpad) * -1) calc(var(--dpad) * -1); padding: 14px var(--dpad) var(--dpad); background: linear-gradient(180deg, rgba(15, 15, 23, 0), #0f0f17 38%); }
@media (max-width: 860px) { .dialog-form { --dpad: 20px; } }
.menu-panel { max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); overflow-y: auto; }
@media (max-height: 540px) { .menu-item { height: 46px; } .menu-grab { height: 14px; } }

/* Landscape phones: keep every top-bar button at least 5px away from the screen edge. */
@media (max-width: 860px) and (max-height: 540px) {
  .icon-btn { width: 38px; height: 36px; }
  .btn.primary { height: 34px; }
}
