/* TinkScreen — editor.
   An Apple-style workspace (translucent toolbar, library · stage ·
   inspector, macOS-like controls, light and dark) with TinkScreen's own
   violet-to-pink accent for selection and the primary action. */

:root { color-scheme: light dark; }

body.editor-body {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "Inter", "Segoe UI", Roboto, sans-serif;
  --app: #f5f5f7;
  --stage: #e8e8ed;
  --panel: #fbfbfd;
  --panel-raised: #ffffff;
  --control: rgba(118, 118, 128, 0.12);
  --control-hover: rgba(118, 118, 128, 0.2);
  --control-active: #ffffff;
  --sep: rgba(60, 60, 67, 0.12);
  --sep-strong: rgba(60, 60, 67, 0.2);
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #a1a1a6;
  --accent: #7c5cff;
  --accent-strong: #6746f5;
  --accent-soft: rgba(124, 92, 255, 0.12);
  --accent-grad: linear-gradient(135deg, #7c5cff 0%, #a95cff 48%, #ff5fa2 100%);
  --toolbar: rgba(247, 247, 249, 0.78);
  --popover: rgba(252, 252, 253, 0.94);
  --shadow-card: 0 1px 1px rgba(0, 0, 0, 0.04), 0 12px 32px -10px rgba(22, 18, 52, 0.26);
  --shadow-pop: 0 12px 40px -8px rgba(0, 0, 0, 0.28), 0 0 0 0.5px rgba(0, 0, 0, 0.12);
  --focus: 0 0 0 3px rgba(124, 92, 255, 0.32);
  --danger: #ff3b30;
  --r: 10px;
  --r-sm: 7px;
}

@media (prefers-color-scheme: dark) {
  body.editor-body {
    --app: #161618;
    --stage: #1b1b1e;
    --panel: #202023;
    --panel-raised: #2a2a2e;
    --control: rgba(118, 118, 128, 0.24);
    --control-hover: rgba(118, 118, 128, 0.34);
    --control-active: #636366;
    --sep: rgba(255, 255, 255, 0.08);
    --sep-strong: rgba(255, 255, 255, 0.16);
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --text-3: #6e6e73;
    --accent: #9a82ff;
    --accent-strong: #ad99ff;
    --accent-soft: rgba(154, 130, 255, 0.18);
    --toolbar: rgba(32, 32, 35, 0.78);
    --popover: rgba(40, 40, 44, 0.94);
    --shadow-card: 0 1px 1px rgba(0, 0, 0, 0.3), 0 16px 40px -12px rgba(0, 0, 0, 0.7);
    --shadow-pop: 0 16px 48px -8px rgba(0, 0, 0, 0.6), 0 0 0 0.5px rgba(255, 255, 255, 0.12);
  }
}

* { box-sizing: border-box; }
/* The `hidden` attribute must win over any display set below. */
[hidden] { display: none !important; }

html, body.editor-body { height: 100%; }
body.editor-body {
  margin: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  background: var(--app);
  color: var(--text);
  font: 13px/1.4 var(--font);
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: none; box-shadow: var(--focus); }

/* ---------- toolbar ---------- */

.toolbar {
  position: relative;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 12px;
  background: var(--toolbar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--sep-strong);
}
.tb-left, .tb-right { display: flex; align-items: center; gap: 6px; min-width: 0; }
.tb-right { justify-content: flex-end; }
.tb-center { display: flex; align-items: center; gap: 2px; }
.tb-group { display: flex; gap: 2px; margin-left: 6px; }

.brand { display: flex; align-items: center; gap: 8px; margin: 0 2px 0 6px; padding: 3px; border: none; border-radius: 9px; background: transparent; color: var(--text); text-decoration: none; font-weight: 700; font-size: 14px; letter-spacing: -0.02em; white-space: nowrap; }
button.brand:hover { background: var(--control); }

/* project name + save state, like a document title */
.project-title {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
  min-width: 0; max-width: 240px;
  height: 38px;
  padding: 0 10px;
  border: none; border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
}
.project-title:hover { background: var(--control); }
.pt-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; letter-spacing: -0.01em; }
.pt-name::after { content: "⌄"; margin-left: 5px; color: var(--text-3); font-weight: 500; position: relative; top: -2px; }
.pt-status { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10.5px; color: var(--text-2); }
.pt-status:empty { display: none; }
.pt-status[data-kind="error"] { color: var(--danger); }
.pt-status[data-kind="saved"]::before { content: "✓ "; color: #30b158; }

.avatar-btn {
  display: grid; place-items: center;
  flex: none;
  width: 30px; height: 30px;
  margin-left: 2px;
  padding: 0;
  overflow: hidden;
  border: none; border-radius: 999px;
  background: var(--control);
  color: var(--text-2);
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.02em;
}
.avatar-btn:hover { background: var(--control-hover); color: var(--text); }
.avatar-btn.signed-in { background: var(--accent-grad); color: #fff; }
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; }
.avatar-btn svg { width: 18px; height: 18px; }
.brand-mark {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: url("../assets/logo.svg") center / cover no-repeat;
  box-shadow: 0 2px 6px -2px rgba(124, 92, 255, 0.6);
}

.tb-icon {
  display: grid; place-items: center;
  width: 34px; height: 30px;
  border: none; border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  transition: background .12s ease, color .12s ease;
}
.tb-icon:hover { background: var(--control); color: var(--text); }
.tb-icon:disabled { opacity: .35; cursor: default; background: transparent; }
.tb-icon svg { width: 19px; height: 19px; }
.tb-icon.on { color: var(--accent); }

.tb-tool {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 58px;
  padding: 4px 8px 3px;
  border: none; border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 10.5px;
  font-weight: 500;
  transition: background .12s ease, color .12s ease;
}
.tb-tool span { color: var(--text-2); }
.tb-tool svg { width: 20px; height: 20px; }
.tb-tool:hover { background: var(--control); }
.tb-tool[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.tb-tool[aria-pressed="true"] span { color: var(--accent); }
.tb-divider { width: 0.5px; height: 28px; margin: 0 8px; background: var(--sep-strong); }

.tb-size select {
  height: 28px;
  max-width: 190px;
  padding: 0 26px 0 10px;
  border: none; border-radius: 7px;
  background: var(--control) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 8px center / 12px;
  -webkit-appearance: none; appearance: none;
  font-size: 12px;
  cursor: pointer;
}
.tb-size select:hover { background-color: var(--control-hover); }

.tb-export {
  display: flex; align-items: center; gap: 6px;
  height: 30px;
  padding: 0 14px 0 11px;
  border: none; border-radius: 8px;
  background: var(--accent-grad);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15), inset 0 0 0 0.5px rgba(255, 255, 255, 0.25);
  transition: filter .12s ease, transform .12s ease;
}
.tb-export svg { width: 16px; height: 16px; stroke-width: 2; }
.tb-export:hover { filter: brightness(1.06); }
.tb-export:active { transform: scale(.98); }

/* ---------- workspace ---------- */

.workspace {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr) 300px;
  min-height: 0;
}
.workspace.no-library { grid-template-columns: 0 minmax(0, 1fr) 300px; }
.workspace.no-inspector { grid-template-columns: 264px minmax(0, 1fr) 0; }
.workspace.no-library.no-inspector { grid-template-columns: 0 minmax(0, 1fr) 0; }
.workspace.no-library .library, .workspace.no-inspector .inspector { visibility: hidden; }

.library, .inspector {
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--panel);
  scrollbar-width: thin;
}
.library { border-right: 0.5px solid var(--sep-strong); padding: 12px 12px 20px; }
.inspector { border-left: 0.5px solid var(--sep-strong); display: flex; flex-direction: column; }

/* ---------- segmented control ---------- */

.seg {
  display: flex;
  padding: 2px;
  gap: 2px;
  border-radius: 8px;
  background: var(--control);
}
.seg button {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  min-height: 24px;
  padding: 3px 8px;
  border: none; border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  transition: background .12s ease, box-shadow .12s ease;
}
.seg button svg { width: 15px; height: 15px; }
.seg button:hover:not(.on) { background: var(--control); }
.seg button.on {
  background: var(--control-active);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
}

/* ---------- library ---------- */

.lib-tabs { margin-bottom: 12px; }
.lib-hint { margin: 0 2px 10px; color: var(--text-2); font-size: 12px; }
.template-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tpl-card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 0;
  border: none;
  background: none;
  text-align: center;
}
.tpl-card canvas {
  width: 100%;
  aspect-ratio: 170 / 368;
  border-radius: 9px;
  box-shadow: 0 0 0 0.5px var(--sep-strong), 0 4px 12px -6px rgba(0, 0, 0, 0.35);
  transition: transform .16s ease, box-shadow .16s ease;
}
.tpl-card span { font-size: 11.5px; color: var(--text-2); }
.tpl-card:hover canvas { transform: translateY(-2px); box-shadow: 0 0 0 2px var(--accent), 0 10px 22px -10px rgba(0, 0, 0, 0.45); }
.tpl-card.current span { color: var(--accent); font-weight: 600; }

.shot-drop {
  width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 18px 14px;
  margin-bottom: 12px;
  border: 1.5px dashed var(--sep-strong);
  border-radius: var(--r);
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  text-align: center;
  transition: border-color .15s ease, background .15s ease;
}
.shot-drop svg { width: 26px; height: 26px; color: var(--accent); margin-bottom: 2px; }
.shot-drop strong { color: var(--text); font-size: 13px; }
.shot-drop:hover, .shot-drop.drag { border-color: var(--accent); background: var(--accent-soft); }
.shot-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.shot-thumb {
  position: relative;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: var(--control);
  aspect-ratio: 9 / 19.5;
  overflow: hidden;
  cursor: grab;
  box-shadow: 0 0 0 0.5px var(--sep-strong);
}
.shot-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.shot-thumb:hover { box-shadow: 0 0 0 2px var(--accent); }
.shot-thumb .shot-x {
  position: absolute; top: 4px; right: 4px;
  width: 18px; height: 18px;
  display: none; place-items: center;
  border: none; border-radius: 999px;
  background: rgba(0, 0, 0, 0.55); color: #fff;
  font-size: 12px; line-height: 1;
}
.shot-thumb:hover .shot-x { display: grid; }

/* ---------- stage ---------- */

.stage {
  position: relative;
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(124, 92, 255, 0.07), transparent 70%),
    var(--stage);
}
.screen-gallery {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 26px 40px 10px;
  scrollbar-width: thin;
}
.screen-card {
  position: relative;
  flex: 0 0 auto;
  display: flex; flex-direction: column;
  gap: 8px;
}
.screen-card-canvas-wrap {
  position: relative;
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  cursor: default;
  outline: 2.5px solid transparent;
  outline-offset: 3px;
  transition: outline-color .15s ease;
}
.screen-card-canvas-wrap canvas { width: 100%; height: 100%; border-radius: 14px; display: block; }
.screen-card.active .screen-card-canvas-wrap { outline-color: var(--accent); }
.screen-card.drop-target .screen-card-canvas-wrap { outline-color: var(--accent); outline-style: dashed; }
.screen-card-footer {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  height: 18px;
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 500;
}
.screen-card.active .screen-card-footer { color: var(--accent); }

.gallery-add {
  flex: 0 0 auto;
  display: grid; place-items: center;
  align-self: stretch;
  width: 64px;
  margin: 40px 0 52px;
  border: 1.5px dashed var(--sep-strong);
  border-radius: 14px;
  background: transparent;
  color: var(--text-3);
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.gallery-add svg { width: 22px; height: 22px; }
.gallery-add:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* Banner mode: slides join edge to edge and read as one strip. */
.stage.banner .screen-gallery { gap: 0; }
.stage.banner .screen-card-canvas-wrap { border-radius: 0; box-shadow: 0 12px 32px -18px rgba(22, 18, 52, 0.4); outline-offset: -2.5px; }
.stage.banner .screen-card-canvas-wrap canvas { border-radius: 0; }
.stage.banner .screen-card:first-of-type .screen-card-canvas-wrap,
.stage.banner .screen-card:first-of-type .screen-card-canvas-wrap canvas { border-radius: 14px 0 0 14px; }
.stage.banner .screen-card.last .screen-card-canvas-wrap,
.stage.banner .screen-card.last .screen-card-canvas-wrap canvas { border-radius: 0 14px 14px 0; }
.stage.banner .screen-card:not(.last) .screen-card-canvas-wrap::after {
  content: "";
  position: absolute;
  top: -8px; bottom: -8px; right: -0.5px;
  border-right: 1px dashed rgba(124, 92, 255, 0.6);
  pointer-events: none;
  z-index: 3;
}
.stage.banner .gallery-add { margin-left: 14px; }

.stage-bar {
  display: flex; align-items: center; gap: 14px;
  height: 36px;
  padding: 0 14px;
  color: var(--text-2);
  font-size: 11.5px;
}
.stage-info { font-weight: 600; color: var(--text); white-space: nowrap; }
.stage-tip { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zoom { display: flex; align-items: center; gap: 4px; }
.zoom input { width: 110px; }
.zoom-btn { display: grid; place-items: center; width: 22px; height: 22px; border: none; border-radius: 6px; background: transparent; color: var(--text-2); }
.zoom-btn:hover { background: var(--control); color: var(--text); }
.zoom-btn svg { width: 14px; height: 14px; }

/* ---------- canvas overlay: handles & selection ---------- */

.card-overlay { position: absolute; top: 0; left: 0; z-index: 2; pointer-events: none; }
.phone-handle, .text-drag-handle {
  position: absolute;
  box-sizing: border-box;
  pointer-events: auto;
  touch-action: none;
  border: 1.5px solid transparent;
  transition: border-color .12s ease, background .12s ease;
}
.phone-handle { border-radius: 12%; cursor: grab; }
.phone-handle:hover { border-color: rgba(124, 92, 255, 0.55); border-style: dashed; }
.phone-handle.dragging { cursor: grabbing; }
.text-drag-handle { border-radius: 6px; cursor: default; }
.text-drag-handle:hover { border-color: rgba(124, 92, 255, 0.55); border-style: dashed; background: rgba(124, 92, 255, 0.05); }
.phone-handle.selected, .text-drag-handle.selected {
  border-color: var(--accent);
  border-style: solid;
  background: rgba(124, 92, 255, 0.05);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.55);
}
.phone-handle.drop-target { border-color: var(--accent); border-style: dashed; background: rgba(124, 92, 255, 0.16); }

.phone-rotate-handle, .phone-orbit-handle {
  position: absolute;
  left: 50%;
  pointer-events: auto;
  opacity: 0;
  cursor: grab;
  transition: opacity .15s ease, transform .1s ease;
}
.phone-rotate-handle {
  top: -30px;
  width: 14px; height: 14px;
  margin-left: -7px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 0 0 2px var(--accent), 0 2px 6px rgba(0, 0, 0, 0.35);
}
.phone-rotate-handle::after {
  content: "";
  position: absolute;
  left: 50%; top: 100%;
  width: 1.5px; height: 16px;
  background: var(--accent);
  transform: translateX(-50%);
}
.phone-orbit-handle {
  bottom: -28px;
  height: 20px;
  margin-left: -17px;
  width: 34px;
  display: grid; place-items: center;
  border-radius: 999px;
  background: var(--accent-grad);
  color: #fff;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .02em;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  user-select: none;
  touch-action: none;
}
.phone-handle:hover .phone-rotate-handle, .phone-handle:hover .phone-orbit-handle,
.phone-handle.selected .phone-rotate-handle, .phone-handle.selected .phone-orbit-handle,
.phone-rotate-handle.dragging, .phone-orbit-handle.dragging { opacity: 1; }
.phone-rotate-handle.dragging, .phone-orbit-handle.dragging { cursor: grabbing; transform: scale(1.12); }

/* ---------- inspector ---------- */

.insp-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 8px;
  min-height: 48px;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 0.5px solid var(--sep);
}
.insp-head .crumb-back {
  display: grid; place-items: center;
  width: 24px; height: 24px;
  border: none; border-radius: 6px;
  background: transparent; color: var(--text-2);
}
.insp-head .crumb-back:hover { background: var(--control); color: var(--text); }
.insp-head .crumb-back svg { width: 16px; height: 16px; }
.insp-title { display: flex; flex-direction: column; min-width: 0; }
.insp-title small { color: var(--text-2); font-size: 11px; font-weight: 500; }
.insp-title strong { font-size: 14px; font-weight: 700; letter-spacing: -0.015em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.insp-head .head-actions { margin-left: auto; display: flex; gap: 2px; }

.insp-body { padding: 4px 0 24px; }
.sec { padding: 12px 14px 14px; border-bottom: 0.5px solid var(--sep); }
.sec:last-child { border-bottom: none; }
.sec-title {
  display: flex; align-items: center; justify-content: space-between;
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}
.sec-title .sec-aside { font-weight: 500; color: var(--text-2); font-size: 11px; }

.row { display: grid; grid-template-columns: 66px minmax(0, 1fr); align-items: center; gap: 8px; margin-bottom: 8px; }
.row:last-child { margin-bottom: 0; }
.row > label, .row > .lbl { color: var(--text-2); font-size: 12px; }
.row.full { grid-template-columns: 1fr; }
.row .ctl { display: flex; align-items: center; gap: 6px; min-width: 0; }

.field-input, .field-area, .field-select {
  width: 100%;
  min-width: 0;
  border: none;
  border-radius: var(--r-sm);
  background: var(--control);
  color: var(--text);
  font-size: 12.5px;
  transition: box-shadow .12s ease, background .12s ease;
}
.field-input { height: 26px; padding: 0 8px; }
.field-area { padding: 7px 9px; resize: vertical; min-height: 58px; line-height: 1.35; }
.field-input:focus, .field-area:focus, .field-select:focus { outline: none; box-shadow: var(--focus); background: var(--panel-raised); }
.field-select { height: 26px; padding: 0 24px 0 8px; -webkit-appearance: none; appearance: none; background: var(--control) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 7px center / 11px; }
.hint { color: var(--text-2); font-size: 11.5px; line-height: 1.45; margin: 6px 0 0; }

/* slider with numeric readout */
.slider { display: flex; align-items: center; gap: 8px; width: 100%; }
.slider input[type="range"] { flex: 1; min-width: 0; }
.slider .num {
  width: 50px; height: 22px;
  padding: 0 6px;
  border: none; border-radius: 6px;
  background: var(--control);
  font-size: 11.5px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.slider .num:focus { outline: none; box-shadow: var(--focus); }
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  height: 18px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--control-hover); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--control-hover); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  margin-top: -6px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 0.5px 2px rgba(0, 0, 0, 0.3), 0 0 0 0.5px rgba(0, 0, 0, 0.12);
}
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border: none; border-radius: 999px; background: #fff; box-shadow: 0 0.5px 2px rgba(0, 0, 0, 0.3); }
input[type="range"]:disabled { opacity: .35; cursor: default; }

/* color well + hex + presets */
.color-ctl { display: flex; align-items: center; gap: 6px; width: 100%; }
.well {
  position: relative;
  width: 26px; height: 26px;
  flex: none;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12), 0 0 0 2px var(--panel), 0 0 0 2.5px var(--sep-strong);
  overflow: hidden;
}
.well input[type="color"] { position: absolute; inset: -8px; width: 42px; height: 42px; opacity: 0; cursor: pointer; border: none; padding: 0; }
.hex { width: 66px; flex: none; height: 24px; padding: 0 7px; border: none; border-radius: 6px; background: var(--control); font: 11.5px ui-monospace, "SF Mono", Menlo, monospace; text-transform: uppercase; }
.hex:focus { outline: none; box-shadow: var(--focus); }
.swatches { display: flex; gap: 3px; margin-left: auto; flex: none; }
.swatch { width: 13px; height: 13px; padding: 0; border: none; border-radius: 999px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15), 0 0 0 1px var(--sep-strong); }
.swatch:hover { transform: scale(1.18); }
.ctl-reset { display: grid; place-items: center; width: 22px; height: 22px; border: none; border-radius: 6px; background: transparent; color: var(--text-3); flex: none; }
.ctl-reset:hover { background: var(--control); color: var(--text); }
.ctl-reset svg { width: 14px; height: 14px; }

/* toggle switch */
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span {
  position: absolute; inset: 0;
  border-radius: 999px;
  background: var(--control-hover);
  transition: background .18s ease;
  pointer-events: none;
}
.switch span::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform .18s ease;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { box-shadow: var(--focus); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.toggle-row:last-child { margin-bottom: 0; }
.toggle-row .lbl { display: flex; flex-direction: column; font-size: 12.5px; }
.toggle-row .lbl small { color: var(--text-2); font-size: 11px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 28px;
  padding: 0 12px;
  border: none; border-radius: var(--r-sm);
  background: var(--control);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: background .12s ease;
}
.btn:hover { background: var(--control-hover); }
.btn svg { width: 15px; height: 15px; }
.btn.danger { color: var(--danger); }
.btn.accent { background: var(--accent); color: #fff; }
.btn.accent:hover { background: var(--accent-strong); }
.btn:disabled { opacity: .4; cursor: default; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }
.icon-btn { display: grid; place-items: center; width: 28px; height: 26px; border: none; border-radius: 6px; background: transparent; color: var(--text-2); }
.icon-btn:hover { background: var(--control); color: var(--text); }
.icon-btn.on { background: var(--accent-soft); color: var(--accent); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn.txt { width: auto; padding: 0 8px; font-size: 13px; }

/* font picker button */
.picker-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  width: 100%; height: 26px;
  padding: 0 8px;
  border: none; border-radius: var(--r-sm);
  background: var(--control);
  font-size: 13px;
  text-align: left;
}
.picker-btn:hover { background: var(--control-hover); }
.picker-btn .caret { color: var(--text-3); }
.picker-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* layers */
.layers { display: flex; flex-direction: column; gap: 1px; }
.layer {
  display: flex; align-items: center; gap: 8px;
  height: 28px;
  padding: 0 8px;
  border: none; border-radius: 6px;
  background: transparent;
  text-align: left;
  font-size: 12.5px;
}
.layer:hover { background: var(--control); }
.layer.on { background: var(--accent); color: #fff; }
.layer.on .layer-kind { color: rgba(255, 255, 255, 0.8); }
.layer svg { width: 15px; height: 15px; }
.layer-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-kind { color: var(--text-3); font-size: 11px; }
.layer.empty .layer-name { color: var(--text-3); font-style: italic; }

/* phone model tiles */
.tile-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.tile {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 2px 5px;
  border: none; border-radius: 8px;
  background: var(--control);
  color: var(--text-2);
  font-size: 10.5px;
  line-height: 1.15;
  text-align: center;
  box-shadow: inset 0 0 0 1.5px transparent;
}
.tile canvas { width: 100%; max-width: 56px; aspect-ratio: 120 / 150; display: block; }
.tile:hover { background: var(--control-hover); }
.tile.on { box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--text); background: var(--accent-soft); }

.finish-row { display: flex; gap: 10px; }
.finish-dot { width: 22px; height: 22px; padding: 0; border: none; border-radius: 999px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18); }
.finish-dot.on { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18), 0 0 0 2px var(--panel), 0 0 0 3.5px var(--accent); }

.shot-well {
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
  border-radius: var(--r);
  background: var(--control);
  border: 1.5px dashed transparent;
}
.shot-well.drag { border-color: var(--accent); background: var(--accent-soft); }
.shot-well .thumb {
  width: 38px; height: 76px;
  flex: none;
  border-radius: 7px;
  background: var(--panel-raised) center / cover no-repeat;
  box-shadow: 0 0 0 0.5px var(--sep-strong);
}
.shot-well .info { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.shot-well .info small { color: var(--text-2); font-size: 11px; }
.mini-shots { display: flex; gap: 6px; overflow-x: auto; margin-top: 8px; padding-bottom: 2px; }
.mini-shots button { flex: none; width: 30px; height: 60px; padding: 0; border: none; border-radius: 5px; background: center / cover no-repeat; box-shadow: 0 0 0 0.5px var(--sep-strong); }
.mini-shots button:hover { box-shadow: 0 0 0 2px var(--accent); }

.empty-state { padding: 22px 16px; color: var(--text-2); text-align: center; }

/* ---------- popovers & menus ---------- */

.popover-layer { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.popover {
  position: fixed;
  pointer-events: auto;
  min-width: 200px;
  max-height: min(520px, calc(100vh - 80px));
  overflow-y: auto;
  padding: 5px;
  border-radius: 12px;
  background: var(--popover);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  box-shadow: var(--shadow-pop);
  animation: pop-in .14s ease;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.menu-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 6px 10px;
  border: none; border-radius: 6px;
  background: transparent;
  text-align: left;
  font-size: 13px;
  white-space: nowrap;
}
.menu-item:hover, .menu-item.hot { background: var(--accent); color: #fff; }
.menu-item small { margin-left: auto; color: var(--text-2); font-size: 11.5px; }
.menu-item:hover small { color: rgba(255, 255, 255, 0.8); }
.menu-item.checked::before { content: "✓"; width: 12px; }
.menu-item:not(.checked).checkable::before { content: ""; width: 12px; }
.menu-sep { height: 0.5px; margin: 4px 8px; background: var(--sep-strong); }
.menu-label { padding: 6px 10px 2px; color: var(--text-2); font-size: 11px; font-weight: 600; }

.icon-pop { width: 296px; padding: 10px; }
.icon-pop-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.icon-pop-grid button {
  display: grid; place-items: center;
  aspect-ratio: 1;
  border: none; border-radius: 8px;
  background: transparent;
  color: var(--text);
}
.icon-pop-grid button:hover, .icon-pop-grid button.on { background: var(--accent-soft); color: var(--accent); }
.icon-pop-grid canvas { width: 26px; height: 26px; }
.icon-pop .btn { width: 100%; margin-top: 8px; }
.icon-pop .pop-tabs { margin-bottom: 10px; }
.badge-pop-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; max-height: min(420px, calc(100vh - 160px)); overflow-y: auto; }
.badge-pop-grid button {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px;
  border: none; border-radius: 10px;
  background: transparent;
  color: var(--text-2);
  font-size: 11px;
}
.badge-pop-grid button:hover { background: var(--accent-soft); color: var(--accent); }
.badge-pop-grid canvas { border-radius: 8px; }

.badge-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.badge-tile {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-width: 0;
  padding: 4px 4px 5px;
  border: none; border-radius: 9px;
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--sep);
  color: var(--text-2);
  font-size: 10.5px;
}
.badge-tile:hover { background: var(--control); }
.badge-tile.on { box-shadow: inset 0 0 0 2px var(--accent); color: var(--accent); font-weight: 600; }
.badge-tile canvas { display: block; width: 100% !important; height: auto !important; border-radius: 6px; }
.badge-template { display: grid; place-items: center; width: 100%; aspect-ratio: 76 / 46; border-radius: 6px; background: var(--control); color: var(--text-2); }
.badge-template svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }

.text-pop { width: 320px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.text-pop textarea { min-height: 70px; }
.text-pop .pop-tools { display: flex; align-items: center; gap: 4px; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%; bottom: 56px;
  z-index: 60;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(30, 30, 34, 0.92);
  color: #fff;
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  transform: translate(-50%, 12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- projects browser ---------- */

.projects-view {
  position: fixed; inset: 0; z-index: 35;
  display: grid; grid-template-rows: auto 1fr;
  background: var(--app);
  animation: pv-in .18s ease;
}
@keyframes pv-in { from { opacity: 0; transform: scale(.985); } to { opacity: 1; transform: none; } }
.pv-bar {
  display: flex; align-items: center; gap: 14px;
  height: 56px;
  padding: 0 14px 0 16px;
  background: var(--toolbar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--sep-strong);
}
.pv-brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 14px; letter-spacing: -0.02em; }
.pv-bar h1 { margin: 0 0 0 6px; padding-left: 14px; border-left: 0.5px solid var(--sep-strong); font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.pv-search {
  display: flex; align-items: center; gap: 6px;
  width: min(260px, 30vw);
  height: 30px;
  margin-left: auto;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--control);
  color: var(--text-3);
}
.pv-search svg { width: 15px; height: 15px; }
.pv-search input { flex: 1; min-width: 0; border: none; background: transparent; outline: none; color: var(--text); font: inherit; font-size: 13px; }
.pv-actions { display: flex; align-items: center; gap: 8px; }
.pv-actions .btn { height: 30px; }
.pv-main { overflow-y: auto; padding: 26px clamp(16px, 4vw, 48px) 60px; }

.pv-promo {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  max-width: 1180px;
  margin: 0 auto 28px;
  padding: 16px 18px;
  border-radius: 14px;
  background: linear-gradient(120deg, rgba(124, 92, 255, 0.14), rgba(255, 95, 162, 0.12));
  box-shadow: inset 0 0 0 0.5px var(--sep-strong);
}
.pv-promo strong { font-size: 14px; }
.pv-promo p { margin: 3px 0 0; color: var(--text-2); font-size: 12.5px; }
.pv-promo .btn-row .btn { flex: none; height: 30px; padding: 0 16px; }

.pv-section { max-width: 1180px; margin: 0 auto 34px; }
.pv-section-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.pv-section-head h2 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.pv-section-head span { color: var(--text-2); font-size: 12.5px; }
.pv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 22px 18px; }
.pv-empty { color: var(--text-2); font-size: 13px; }

.pv-card { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 0; border: none; background: transparent; color: var(--text); text-align: left; }
.pv-thumb {
  position: relative;
  display: grid; place-items: center;
  aspect-ratio: 16 / 11;
  padding: 0;
  overflow: hidden;
  border: none; border-radius: 12px;
  background: var(--stage);
  box-shadow: 0 0 0 0.5px var(--sep-strong), 0 6px 18px -10px rgba(0, 0, 0, 0.35);
  transition: transform .15s ease, box-shadow .15s ease;
}
.pv-thumb img { position: absolute; inset: 10px; width: calc(100% - 20px); height: calc(100% - 20px); object-fit: contain; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.25)); }
.pv-card:hover .pv-thumb { transform: translateY(-2px); box-shadow: 0 0 0 0.5px var(--sep-strong), 0 14px 28px -12px rgba(0, 0, 0, 0.45); }
.pv-card.current .pv-thumb { box-shadow: 0 0 0 2.5px var(--accent), 0 14px 28px -12px rgba(0, 0, 0, 0.45); }
.pv-noimg { color: var(--text-3); font-size: 12px; }
.pv-meta { display: flex; align-items: flex-start; gap: 6px; padding: 0 2px; }
.pv-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.pv-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; }
.pv-text small { color: var(--text-2); font-size: 11.5px; }
.pv-card.current .pv-text small { color: var(--accent); font-weight: 600; }
.pv-new .pv-thumb { background: transparent; border: 1.5px dashed var(--sep-strong); box-shadow: none; color: var(--text-2); }
.pv-new:hover .pv-thumb { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); }
.pv-new .pv-thumb svg { width: 34px; height: 34px; stroke-width: 1.5; }
.pv-new .pv-meta strong { font-size: 13px; font-weight: 600; }

/* ---------- sheets (dialogs) ---------- */

body.modal-open .card-overlay { pointer-events: none; }
.sheet-layer {
  position: fixed; inset: 0; z-index: 45;
  display: grid; place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.32);
  animation: fade-in .15s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 22px;
  border-radius: 16px;
  background: var(--panel-raised);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.55), 0 0 0 0.5px var(--sep-strong);
  animation: pop-in .18s ease;
}
.sheet-small { width: min(400px, 100%); }
.sheet-wide { width: min(880px, 100%); }
.sheet-auth { width: min(380px, 100%); padding: 28px 28px 22px; }
.sheet-head h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.sheet-head p { margin: 6px 0 0; color: var(--text-2); font-size: 13px; line-height: 1.45; }
.sheet-field { width: 100%; height: 32px; margin-top: 14px; font-size: 14px; }
.sheet-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.sheet-buttons .btn { min-width: 84px; height: 30px; }
.btn.danger-fill { background: var(--danger); }
.btn.danger-fill:hover { background: #e0342a; }

.sheet-templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 14px; margin-top: 18px; }
.sheet-template { display: flex; flex-direction: column; gap: 6px; padding: 0; border: none; background: transparent; color: var(--text-2); font-size: 12px; font-weight: 500; }
.sheet-template canvas { width: 100%; height: auto; border-radius: 10px; box-shadow: 0 0 0 0.5px var(--sep-strong), 0 6px 16px -10px rgba(0, 0, 0, 0.4); transition: transform .15s ease, box-shadow .15s ease; }
.sheet-template:hover canvas { transform: translateY(-2px); box-shadow: 0 0 0 2px var(--accent), 0 12px 24px -12px rgba(0, 0, 0, 0.45); }
.sheet-template:hover { color: var(--accent); }

.auth { display: flex; flex-direction: column; align-items: stretch; text-align: center; }
.auth-mark { width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 12px; background: url("../assets/logo.svg") center / cover no-repeat; box-shadow: 0 6px 16px -6px rgba(124, 92, 255, 0.7); }
.auth .sheet-head { margin-bottom: 18px; }
.google-slot { display: flex; justify-content: center; min-height: 44px; }
.auth-or { display: flex; align-items: center; gap: 10px; margin: 14px 0; color: var(--text-3); font-size: 12px; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 0.5px; background: var(--sep-strong); }
.auth-form { display: flex; flex-direction: column; gap: 8px; }
.auth-form .field-input { height: 36px; padding: 0 12px; border-radius: 9px; font-size: 14px; }
.auth-submit { height: 36px !important; margin-top: 6px; border-radius: 9px !important; font-size: 14px !important; }
.auth-error { margin: 2px 0 0; color: var(--danger); font-size: 12.5px; text-align: left; }
.auth-switch { margin: 16px 0 0; color: var(--text-2); font-size: 12.5px; }
.link-btn { padding: 0; border: none; background: none; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.auth-steps { margin: 0 0 4px; padding-left: 20px; text-align: left; color: var(--text); font-size: 13px; line-height: 1.5; }
.auth-steps li + li { margin-top: 6px; }

/* ---------- narrow windows ---------- */

@media (max-width: 1080px) {
  .tb-tool { min-width: 48px; }
  .tb-tool span { display: none; }
  .brand-name { display: none; }
  .project-title { max-width: 150px; }
  .pv-bar h1, .pv-actions .btn span { display: none; }
}
/* Narrower: the tool row gets whatever room is left (and scrolls if it
   must) instead of overlapping the title and the buttons around it. */
@media (max-width: 960px) {
  .toolbar { grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; }
  .tb-center { min-width: 0; justify-content: safe center; overflow-x: auto; scrollbar-width: none; }
  .tb-center::-webkit-scrollbar { display: none; }
  .tb-tool { min-width: 40px; padding: 4px 6px 3px; }
  .tb-divider { margin: 0 4px; }
  .pt-status { display: none; }
  .project-title { max-width: 130px; height: 32px; }
  .tb-export span { display: none; }
  .tb-export { padding: 0 10px; }
}
@media (max-width: 640px) {
  .tb-group, #shotsBtn, #toggleInspectorBtn { display: none; }
  .project-title { max-width: 96px; }
}
@media (max-width: 860px) {
  .workspace, .workspace.no-library, .workspace.no-inspector { grid-template-columns: minmax(0, 1fr); }
  .library, .inspector {
    position: fixed; top: 56px; bottom: 0; z-index: 25;
    width: min(320px, 88vw);
    box-shadow: var(--shadow-pop);
  }
  .library { left: 0; }
  .inspector { right: 0; }
  .workspace.no-library .library, .workspace.no-inspector .inspector { display: none; }
  .tb-size { display: none; }
}
