/* Inkling. Material 3 / Google Workspace craft: crisp hierarchy, immediate utility, tactile studio. */
:root {
  color-scheme: light;
  --ink: #18221e;
  --muted: #52605a;
  --subtle: #6e7d76;
  --line: #e0e5e1;
  --line-strong: #c7d1ca;
  --paper: #f7f9f7;
  --surface-tonal: #eef3ef;
  --card: #ffffff;
  --green: #0f766e;
  --green-hover: #0d665f;
  --green-soft: #e6f4f1;
  --green-line: #b4ded6;
  --lime: #c3f192;
  --violet: #6d28d9;
  --violet-hover: #5b21b6;
  --violet-soft: #f3effe;
  --violet-line: #ddd6fe;
  --amber: #b45309;
  --amber-soft: #fef7e6;
  --danger: #c5221f;
  --danger-soft: #fce8e6;
  --blue-pencil: #4f8fe6;
  --radius: 16px;
  --radius-lg: 24px;
  --radius-sm: 10px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 20, 0.05);
  --shadow-sm: 0 1px 2px rgba(15, 23, 20, 0.06), 0 2px 6px rgba(15, 23, 20, 0.04);
  --shadow: 0 4px 12px -2px rgba(15, 23, 20, 0.08), 0 1px 3px rgba(15, 23, 20, 0.06);
  --shadow-hover: 0 12px 28px -6px rgba(15, 23, 20, 0.14), 0 4px 10px -2px rgba(15, 23, 20, 0.06);
  --shadow-lg: 0 22px 56px -12px rgba(15, 23, 20, 0.22), 0 4px 14px rgba(15, 23, 20, 0.08);
  --shadow-ai: 0 8px 24px -4px rgba(109, 40, 217, 0.18), 0 2px 6px rgba(109, 40, 217, 0.08);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --pad: clamp(16px, 4vw, 32px);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body {
  margin: 0;
  overflow-x: clip;
  color: var(--ink);
  background: var(--paper);
  font: 400 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .42; cursor: not-allowed; }
a { color: inherit; }
:focus-visible { outline: 2.5px solid #0f766e; outline-offset: 2px; border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); margin: 4px 0 0; font-size: 13.5px; line-height: 1.45; }
.eyebrow { margin: 0 0 4px; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--green); }
.btn-svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }

button:not(:disabled) { transition: transform .18s var(--spring), background-color .18s var(--ease), color .18s var(--ease), box-shadow .22s var(--ease), border-color .18s var(--ease), opacity .18s var(--ease); }
button:not(:disabled):active { transform: scale(.965); }

/* ---------- Top App Bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  min-height: 60px;
  padding: 8px var(--pad);
  padding-top: max(8px, env(safe-area-inset-top));
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(1.6) blur(18px);
  border-bottom: 1px solid rgba(224, 229, 225, 0.85);
  color: var(--ink);
  transition: box-shadow .28s var(--ease), border-color .28s var(--ease), background-color .28s var(--ease);
}
.topbar.scrolled { background: rgba(255, 255, 255, 0.94); box-shadow: var(--shadow); }
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; margin-right: 0; padding: 4px 8px 4px 4px; border-radius: 10px; transition: background-color .18s var(--ease), transform .18s var(--spring); }
.brand:hover { background: var(--surface-tonal); }
.brand:hover .brand-mark { transform: scale(1.06) rotate(-3deg); }
.brand-mark { width: 26px; height: 26px; fill: var(--ink); flex: none; transition: transform .25s var(--spring); }
.brand-spark { fill: var(--violet); transform-origin: 25px 7.5px; animation: twinkle 5s var(--ease) infinite; }
@keyframes twinkle { 0%, 88%, 100% { transform: scale(1) rotate(0); } 94% { transform: scale(1.25) rotate(45deg); } }
.wordmark { font: 700 20px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; letter-spacing: -.04em; color: var(--ink); }
.connection { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 999px; background: var(--surface-tonal); font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; cursor: pointer; }
.connection:hover { background: #e5ece6; color: var(--ink); }
@media (max-width: 359px) { .ink-dot { width: 24px; height: 24px; } #connection { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); } }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #d4a237; flex: none; }
.dot.online { background: #10b981; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); animation: ping 2.6s infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); } 70%, 100% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); } }
.help-button { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--muted); font-weight: 600; font-size: 14px; }
.help-button:hover { background: var(--surface-tonal); color: var(--ink); border-color: var(--line-strong); }

main { max-width: 1360px; margin: 0 auto; padding: 0 var(--pad) 56px; }
.hero { width: 100%; max-width: 1120px; margin: 0 auto; padding: 8px 0 4px; text-align: left; }
.hero h1 { margin: 0; font: 700 clamp(22px, 2.8vw, 30px)/1.14 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; letter-spacing: -.03em; color: var(--ink); animation: rise .5s var(--ease) both; }
.hero h1 span {
  display: inline;
  color: transparent;
  background: linear-gradient(100deg, #0f766e, #6d28d9 60%, #0f766e) 0 0 / 200% 100%;
  -webkit-background-clip: text; background-clip: text;
  animation: shimmer 7s ease-in-out infinite;
}
@keyframes shimmer { 50% { background-position: 100% 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(.6); } 100% { transform: scale(1); } }
.hero-sub { margin: 4px 0 0; max-width: 66ch; color: var(--muted); font-size: 14px; line-height: 1.4; animation: rise .5s .06s var(--ease) both; }

/* No transform or opacity animation on .studio so position:fixed drawers and sheets always sit above .topbar. */
.studio, .library { width: 100%; max-width: 1120px; margin-inline: auto; }
.studio { display: grid; gap: 12px; }
.canvas-card, .save-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.canvas-card { overflow: hidden; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: #ffffff; }
.tools { display: flex; align-items: center; gap: 2px; padding: 3px; border-radius: 11px; background: var(--surface-tonal); overflow-x: auto; scrollbar-width: none; }
.tool { position: relative; display: grid; place-items: center; min-width: 36px; height: 34px; padding: 0 7px; border: 0; border-radius: 8px; background: none; color: var(--muted); font-size: 14px; font-weight: 600; }
.tool:hover:not(:disabled) { color: var(--ink); background: rgba(255, 255, 255, 0.72); box-shadow: var(--shadow-xs); }
.tool svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.85; stroke-linecap: round; stroke-linejoin: round; flex: none; transition: transform .2s var(--spring); }
.tool:hover:not(:disabled) svg { transform: scale(1.08); }
.tool[aria-pressed="true"] { background: #ffffff; color: var(--green); box-shadow: var(--shadow-sm); }
.tool[aria-pressed="true"] svg { transform: scale(1.06); }

@keyframes shine { 0%, 70% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
.toolbar-row { flex: 1 1 100%; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 6px; border-top: 1px solid #f0f3f0; }
.toolbar-spacer { flex: 1; }
.swatch input[type="color"], .fill-control input[type="color"] { width: 28px; height: 28px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 8px; background: white; cursor: pointer; }
.fill-control { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 9px; background: var(--surface-tonal); font-size: 12.5px; font-weight: 500; color: var(--muted); }
.fill-control input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--green); margin: 0; }
.size-control { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
input[type="range"] { width: 88px; accent-color: var(--green); }
.icon-button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-width: 34px; height: 34px; padding: 0 9px; border: 1px solid transparent; border-radius: 9px; background: none; color: var(--ink); font-size: 14px; font-weight: 600; }
.icon-button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.85; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon-button:hover:not(:disabled) { background: var(--surface-tonal); }
.layers-toggle { border-color: var(--line); background: var(--card); font-size: 13px; padding: 0 11px; }
.layers-toggle[aria-expanded="true"] { background: var(--green-soft); border-color: var(--green-line); color: var(--green); }
.history { display: flex; gap: 2px; }
@media (max-width: 639px) {
  .toolbar { gap: 6px; padding: 8px; flex-wrap: wrap; }
  .tools { flex: 1 1 0; min-width: 0; }
  .tool { min-width: 34px; flex: 1 0 34px; padding: 0 4px; }
  .history .icon-button { min-width: 34px; padding: 0 5px; }
  .focus-button { flex: none; padding: 0 10px; }
  .focus-button span, .fill-control span { display: none; }
  .toolbar-row { flex: 1 1 100%; min-width: 0; flex-wrap: nowrap; gap: 6px; }
  .toolbar-spacer { display: none; }
  .swatches { flex: 1 1 auto; min-width: 0; gap: 7px; padding: 4px 18px 4px 3px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
  .swatches::-webkit-scrollbar { display: none; }
  .swatches > * { flex: none; scroll-snap-align: start; }
  .size-control { flex: 0 0 64px; min-width: 0; }
  .size-control input { flex: 1; width: auto; min-width: 0; }
  .size-control output { display: none; }
  .toolbar-row .icon-button { min-width: 34px; padding: 0 6px; }
}

.canvas-body { display: grid; }
.canvas-frame { position: relative; margin: 12px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: white; box-shadow: 0 2px 6px rgba(15, 23, 20, 0.05), 0 14px 36px -10px rgba(15, 23, 20, 0.14); transition: box-shadow .28s var(--ease), border-color .22s var(--ease); }
.canvas-frame:hover { box-shadow: 0 4px 10px rgba(15, 23, 20, 0.07), 0 18px 42px -10px rgba(15, 23, 20, 0.16); }
canvas { display: block; width: 100%; height: auto; aspect-ratio: 1000 / 650; touch-action: none; cursor: crosshair; }
#overlay { position: absolute; inset: 0; pointer-events: none; }
canvas.eraser-mode { cursor: cell; }
canvas.place-mode { cursor: copy; }
.canvas-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--line); background: #fbfcfb; font-size: 12.5px; color: var(--muted); }
.foot-actions { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.foot-action { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--ink); font-size: 12.5px; font-weight: 600; }
.foot-action:hover { background: var(--surface-tonal); border-color: var(--line-strong); }
.foot-export { border-color: var(--green-line); background: var(--green-soft); color: var(--green); }
.foot-export:hover { background: #d6efe9; border-color: var(--green); }

@keyframes popIn { from { opacity: 0; transform: translateY(6px) scale(.97); } to { opacity: 1; transform: none; } }
.examples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.example { padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--muted); font-size: 12.5px; font-weight: 500; }
.example:hover { background: var(--violet-soft); border-color: var(--violet-line); color: var(--violet-hover); }
.pill { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: white; font-size: 13px; font-weight: 600; color: var(--ink); }
.pill:hover:not(:disabled) { background: var(--surface-tonal); border-color: var(--line-strong); }
.pill.primary { background: var(--violet); border-color: var(--violet); color: white; }
.pill.primary:hover:not(:disabled) { background: var(--violet-hover); border-color: var(--violet-hover); }
.pill.ghost { margin-left: auto; border-color: transparent; background: transparent; color: var(--muted); }
.pill.ghost:hover { background: var(--surface-tonal); color: var(--ink); }
.wu-group .pill.primary, .help-foot .pill.primary { background: var(--green); border-color: var(--green); }
.wu-group .pill.primary:hover:not(:disabled), .help-foot .pill.primary:hover:not(:disabled) { background: var(--green-hover); border-color: var(--green-hover); }
kbd { font: 600 10.5px/1 ui-monospace, SFMono-Regular, Menlo, monospace; opacity: .75; }

.tray { position: absolute; z-index: 4; left: 10px; right: 10px; bottom: 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 9px 10px 9px 14px; border-radius: 14px; background: rgba(24, 24, 46, 0.94); backdrop-filter: blur(10px); color: #ede9fe; font-size: 13px; box-shadow: 0 12px 32px rgba(15, 23, 20, 0.28); animation: slideUp .26s var(--spring) both; }
.tray[hidden] { display: none; }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.tray.error { background: rgba(127, 29, 29, 0.95); color: #fee2e2; }
.tray button { min-height: 32px; padding: 0 12px; border: 0; border-radius: 999px; background: rgba(255, 255, 255, 0.14); color: white; font-size: 12.5px; font-weight: 600; }
.tray button:hover { background: rgba(255, 255, 255, 0.22); }
.tray button:first-of-type { background: var(--lime); color: #162a06; font-weight: 700; }
.tray button:first-of-type:hover { background: #d4f7aa; }
.tray-note { flex: 1 1 160px; font-weight: 500; overflow-wrap: anywhere; }
.tray-note.pending { animation: breathe 1.4s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .5; } }
.tray-more { opacity: .75; font-size: 12px; }
.tray .short { display: none; }

/* Layers */
.layers { display: none; padding: 12px; border-top: 1px solid var(--line); background: #fafcfa; }
.layers.open { display: block; animation: rise .22s var(--ease) both; }
.layers-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.layers-head h3 { margin: 0 auto 0 0; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.layer-list { list-style: none; margin: 10px 0; padding: 0; display: grid; gap: 4px; }
.layer { display: grid; grid-template-columns: 28px 44px minmax(0, 1fr); align-items: center; gap: 8px; padding: 5px 6px; border: 1px solid transparent; border-radius: 10px; animation: rise .2s var(--ease) both; }
.layer:hover { background: #f1f5f2; }
.layer.active { background: white; border-color: var(--green-line); box-shadow: var(--shadow-xs); }
.layer.hidden-layer .layer-thumb, .layer.hidden-layer .layer-name { opacity: .42; }
.layer-eye { width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 7px; background: none; color: var(--muted); }
.layer-eye:hover { background: var(--surface-tonal); color: var(--ink); }
.layer-eye svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.85; stroke-linecap: round; }
.layer-thumb { width: 44px; height: 29px; border: 1px solid var(--line); border-radius: 5px; background: white; }
.layer-name { min-height: 28px; border: 0; background: none; text-align: left; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layer.active .layer-name { font-weight: 650; color: var(--green); }
.layer.linked .layer-name { color: var(--green); }
.layer-rename { min-width: 0; padding: 4px 6px; border: 1px solid var(--green); border-radius: 6px; font-size: 13px; outline: none; }
.asset-badge { display: inline-block; margin-right: 5px; padding: 1px 6px; border-radius: 999px; background: var(--green-soft); color: var(--green); font-size: 10px; font-weight: 700; }
.layer-props { display: grid; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.layer-props label { display: flex; justify-content: space-between; font-size: 12px; font-weight: 600; color: var(--muted); }
.layer-props input[type="range"] { width: 100%; }
.layer-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.layer-actions button { flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center; min-height: 30px; padding: 0 7px; border: 1px solid var(--line); border-radius: 8px; background: white; font-size: 12px; font-weight: 600; color: var(--ink); }
.layer-actions button:hover:not(:disabled) { background: var(--surface-tonal); border-color: var(--line-strong); }
.layer-actions svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Save card */
.save-card { width: min(100%, 760px); margin-inline: auto; padding: 0 20px; box-shadow: none; transition: box-shadow .25s var(--ease); }
.save-card[open] { padding-bottom: 18px; box-shadow: var(--shadow-sm); }
.save-card > summary { margin: 0 -20px; padding: 13px 20px; color: var(--ink); font-size: 14px; font-weight: 650; text-align: left; cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; }
.save-card > summary::after { content: "▾"; color: var(--muted); font-size: 13px; transition: transform .2s var(--ease); }
.save-card[open] > summary::after { transform: rotate(180deg); }
.save-card > summary::-webkit-details-marker { display: none; }
.save-card > summary:hover { background: #fbfcfb; }
.save-card[open] > summary { margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.save-card[open] > :not(summary) { animation: rise .28s var(--ease) both; }
.kind-hint { margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.save-row { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .save-row { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); } }
.save-card label { display: block; margin-bottom: 5px; font-size: 12.5px; font-weight: 600; color: var(--ink); }
.save-card label span { color: var(--muted); font-weight: 400; }
.save-card input:not([type]), .save-card input[type="text"], .save-card select, .save-card textarea, #title, #description {
  display: block; width: 100%; margin-bottom: 12px; padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: 10px; background: #ffffff;
  font-size: 14.5px; transition: border-color .18s, box-shadow .18s;
}
.save-card input:focus, .save-card select:focus, .save-card textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14); outline: none; }
.type-field[hidden] { display: none; }
.placed-note { margin: -2px 0 12px; font-size: 12.5px; color: var(--green); overflow-wrap: anywhere; }
.more-fields { margin: 2px 0 14px; }
.more-fields summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); padding: 4px 0; list-style-position: inside; }
.more-fields[open] summary { margin-bottom: 8px; }
textarea { resize: vertical; min-height: 64px; }
.tag-label { display: flex; justify-content: space-between; align-items: baseline; }
.tag-editor { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin-bottom: 4px; padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: 10px; background: #ffffff; }
.chips { display: contents; }
.chip { display: inline-flex; align-items: center; gap: 3px; padding: 3px 6px 3px 10px; border-radius: 999px; background: var(--surface-tonal); font-size: 12.5px; font-weight: 500; animation: pop .2s var(--spring); }
.chip button { border: 0; background: none; color: var(--muted); font-size: 14px; line-height: 1; padding: 0 3px; }
#tag-input { flex: 1; min-width: 90px; border: 0; margin: 0; padding: 4px; background: transparent; font-size: 14px; outline: none; }
.save-actions { display: grid; gap: 8px; }
.save-button { width: 100%; min-height: 46px; border: 0; border-radius: 12px; background: linear-gradient(180deg, #118279 0%, #0f766e 100%); color: white; font-weight: 650; font-size: 15px; box-shadow: 0 2px 6px rgba(15, 118, 110, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.18); }
.save-button:hover:not(:disabled) { background: linear-gradient(180deg, #0f766e 0%, #0b5d56 100%); box-shadow: 0 6px 18px -2px rgba(15, 118, 110, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.22); transform: translateY(-1px); }
.save-button.saved { animation: saved .9s var(--ease); }
@keyframes saved { 0% { box-shadow: 0 0 0 0 #34d39988; } 100% { box-shadow: 0 0 0 16px #34d39900; } }
.save-new { display: block; margin: 2px auto 0; }
.save-new[hidden] { display: none; }
.link-button { border: 0; background: none; padding: 4px 8px; border-radius: 8px; color: var(--green); font-size: 13px; font-weight: 600; text-decoration: none; }
.link-button:hover { background: var(--green-soft); }
.status { min-height: 20px; margin: 10px 0 0; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.status:not(:empty) { animation: rise .22s var(--ease) both; }
.status.error { color: var(--danger); }
.next-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.next-action { min-height: 32px; padding: 0 12px; border: 1px solid var(--green-line); border-radius: 999px; background: var(--green-soft); color: var(--green); font-size: 12.5px; font-weight: 600; }
.next-action:hover { background: #d6efe9; border-color: var(--green); }
.fine-print { margin: 12px 0 0; font-size: 11.5px; color: var(--subtle); cursor: help; }

/* ---------- Library ---------- */
.library { margin-top: 10px; animation: rise .5s .1s var(--ease) both; }
.library-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.library-head h2 { margin: 0; font: 700 clamp(20px, 2.6vw, 24px)/1.2 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; letter-spacing: -.02em; }
.library-sub { margin: 2px 0 0; font-size: 13.5px; color: var(--muted); }
.library-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.search-bar {
  display: flex; align-items: center; gap: 6px;
  margin-top: 8px; padding: 4px 6px 4px 16px;
  border: 1px solid var(--line); border-radius: 28px;
  background: white; box-shadow: var(--shadow-sm);
  transition: border-color .22s var(--ease), box-shadow .25s var(--ease), transform .22s var(--ease);
}
.search-bar:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.search-bar:focus-within { border-color: var(--green); box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12), var(--shadow); transform: translateY(-1px); }
.search-leading { width: 18px; height: 18px; fill: none; stroke: var(--subtle); stroke-width: 2; stroke-linecap: round; flex: none; transition: stroke .2s; }
.search-bar:focus-within .search-leading { stroke: var(--green); }
.search-bar input { flex: 1; min-width: 0; height: 38px; border: 0; background: none; font-size: 15px; outline: none; }
.search-bar input::placeholder { color: var(--subtle); }
.search-go { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--green); color: white; flex: none; box-shadow: 0 2px 6px rgba(15, 118, 110, 0.25); }
.search-go:hover { background: var(--green-hover); box-shadow: 0 4px 12px rgba(15, 118, 110, 0.32); }
.search-go svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s var(--spring); }
.search-go:hover svg { transform: translateX(2px); }

.library-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-top: 7px; }
.search-hints { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.search-hints small { color: var(--subtle); font-size: 12px; font-weight: 600; margin-right: 2px; }
.filters { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0; scrollbar-width: none; }
.filters[hidden] { display: none; }
.filter-chip { flex: 0 0 auto; min-height: 30px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: white; font-size: 12.5px; font-weight: 500; color: var(--ink); }
.filter-chip:hover { background: var(--surface-tonal); }
.filter-chip[aria-pressed="true"] { background: var(--green-soft); border-color: var(--green); color: var(--green); font-weight: 650; }
.color-chip { flex: none; width: 24px; height: 24px; padding: 0; border: 2px solid white; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.14); }
.color-chip:hover { transform: scale(1.12); }
.color-chip[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); transform: scale(1.14); }

.results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 8px; }
.card {
  --i: 0; display: flex; flex-direction: column; text-align: left; overflow: hidden; padding: 0;
  border: 1px solid var(--line); border-radius: 18px; background: white; color: var(--ink);
  box-shadow: var(--shadow-sm);
  animation: cardIn .38s var(--ease) both; animation-delay: calc(var(--i) * 34ms);
  transition: transform .24s var(--ease), box-shadow .24s var(--ease), border-color .22s var(--ease);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
@media (hover: hover) { .card:hover { transform: translateY(-4px); border-color: var(--line-strong); box-shadow: var(--shadow-hover); } }
.thumb-button { position: relative; display: block; width: 100%; padding: 0; border: 0; background: #fafbfa; border-bottom: 1px solid var(--line); overflow: hidden; }
.card img { display: block; width: 100%; aspect-ratio: 1000 / 650; object-fit: contain; background: transparent; transition: transform .32s var(--ease); }
@media (hover: hover) { .card:hover .thumb-button img { transform: scale(1.035); } .card:hover .card-title { color: var(--green); } }
.card-text { display: grid; gap: 4px; padding: 12px 14px 6px; }
.card strong { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 14.5px; font-weight: 650; line-height: 1.3; }
.card-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: color .2s var(--ease); }
.card-meta-pill { flex: none; font-size: 11px; font-weight: 600; color: var(--muted); background: var(--surface-tonal); padding: 2px 7px; border-radius: 999px; white-space: nowrap; }
.card small { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.asset-card .asset-card-about { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--muted); }
.asset-card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.asset-card-tag { padding: 1px 7px; border-radius: 6px; background: var(--surface-tonal); color: var(--muted); font-size: 11px; font-weight: 500; }

.card-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 14px 12px; margin-top: auto; border-top: 1px solid #f2f5f2; }
.mini { min-height: 30px; padding: 0 11px; border: 1px solid var(--line); border-radius: 999px; background: white; font-size: 12px; font-weight: 600; color: var(--ink); }
.mini:hover { background: var(--surface-tonal); border-color: var(--line-strong); }
.mini.primary-mini { background: var(--green-soft); border-color: var(--green-line); color: var(--green); }
.mini.primary-mini:hover { background: #d6efe9; border-color: var(--green); }

.empty { grid-column: 1 / -1; padding: 36px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 16px; background: rgba(255, 255, 255, 0.6); font-size: 14px; }

/* ---------- Sheets (asset page, export, help): bottom sheet on phones, centered modal on desktop ---------- */
.sheet {
  width: 100%; max-width: 100%; max-height: 92vh; margin: auto 0 0;
  padding: 20px var(--pad) calc(22px + env(safe-area-inset-bottom));
  border: 0; border-radius: 24px 24px 0 0;
  background: var(--card); color: var(--ink);
  box-shadow: var(--shadow-lg); overflow-y: auto;
}
.sheet[open] { animation: sheetUp .34s var(--ease) both; }
@keyframes sheetUp { from { transform: translateY(36px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet::backdrop { background: rgba(15, 23, 20, 0.45); backdrop-filter: blur(4px); animation: fade .25s both; }
@keyframes fade { from { opacity: 0; } }
.sheet-head { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: start; }
.sheet-head:has(img) { grid-template-columns: 76px 1fr auto; }
.sheet-head img { width: 76px; aspect-ratio: 1000 / 650; object-fit: contain; border: 1px solid var(--line); border-radius: 12px; background: #fafbfa; }
.sheet-head h2 { margin: 0; font: 700 clamp(21px, 4vw, 28px)/1.15 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; letter-spacing: -.025em; }
.close { width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--surface-tonal); color: var(--muted); font-size: 20px; line-height: 1; }
.close:hover { background: #e3eae5; color: var(--ink); }

.wu-group { margin-top: 24px; }
.wu-group-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.wu-group h3 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.wu-group h3 span { color: var(--muted); font-weight: 500; }
.wu-explain { margin: 4px 0 12px; font-size: 13px; color: var(--muted); line-height: 1.45; }
.wu-explain b { color: var(--ink); }
.wu-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.wu-card { --i: 0; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: white; box-shadow: var(--shadow-xs); animation: cardIn .35s var(--ease) both; animation-delay: calc(var(--i) * 40ms); transition: transform .2s var(--ease), box-shadow .2s var(--ease); }
.wu-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.wu-card.outdated { border-color: #fcd34d; }
.wu-figure { position: relative; display: block; overflow: hidden; width: 100%; padding: 0; border: 0; border-bottom: 1px solid var(--line); background: #fafbfa; }
.wu-figure img { display: block; width: 100%; aspect-ratio: 1000 / 650; object-fit: contain; }

.wu-card .card-text { padding: 12px 14px 4px; }
.wu-card strong { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14px; font-weight: 650; }
.wu-card small { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
.why { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }
.why.outdated { color: var(--amber); font-weight: 600; }
.why.current { color: var(--green); font-weight: 600; }
.meter { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; font-weight: 600; cursor: help; }
.meter-bar { flex: 1; height: 6px; border-radius: 999px; background: var(--violet-soft); overflow: hidden; }
.meter-fill { display: block; height: 100%; border-radius: inherit; background: #a78bfa; transform-origin: left; animation: grow .8s .2s var(--ease) both; }
@keyframes grow { from { transform: scaleX(0); } }
.meter.strong .meter-fill { background: var(--violet); }
.meter.strong .meter-label, .meter.possible .meter-label { color: var(--violet); }
.wu-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 14px 12px; margin-top: auto; }
.wu-empty { display: grid; gap: 3px; padding: 18px; text-align: center; font-size: 13px; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 14px; background: #fafbfa; }
.wu-empty b { color: var(--ink); }

.help-flow { list-style: none; display: grid; gap: 10px; margin: 16px 0; padding: 0; counter-reset: step; }
.help-flow li { counter-increment: step; display: grid; gap: 3px; padding: 14px 14px 14px 46px; position: relative; border: 1px solid var(--line); border-radius: 14px; background: #fafbfa; font-size: 13.5px; animation: rise .35s var(--ease) both; }
.help-flow li:nth-child(2) { animation-delay: .04s; } .help-flow li:nth-child(3) { animation-delay: .08s; } .help-flow li:nth-child(4) { animation-delay: .12s; }
.help-flow li::before { content: counter(step); position: absolute; left: 14px; top: 14px; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--green); color: white; font-size: 11px; font-weight: 700; }
.help-flow span { color: var(--muted); line-height: 1.45; }
.help-flow i { color: var(--violet); font-size: 12.5px; }
.glossary { display: grid; grid-template-columns: 1fr; margin: 0; }
.glossary div { padding: 10px 0; border-top: 1px solid var(--line); }
.glossary dt { font-weight: 650; font-size: 14px; }
.glossary dd { margin: 2px 0 0; font-size: 13px; color: var(--muted); line-height: 1.45; }
.help-foot { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

/* Tooltip */
.tooltip { position: fixed; z-index: 1000; max-width: min(280px, calc(100vw - 16px)); padding: 9px 12px; border-radius: 10px; background: #18221e; color: #f2f5f3; font-size: 12px; line-height: 1.45; box-shadow: 0 10px 30px rgba(15, 23, 20, 0.28); pointer-events: none; animation: popIn .14s var(--ease) both; }
.tooltip[hidden] { display: none; }
.tooltip strong { display: block; color: var(--lime); font-size: 12px; margin-bottom: 1px; }
.tooltip.single strong { color: #f2f5f3; margin-bottom: 0; }

@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 #0f766e00; } 40% { box-shadow: 0 0 0 7px #0f766e44; } }
.pulse { animation: pulse 1s ease-in-out 3; }

footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; max-width: 1360px; margin: 0 auto; padding: 20px var(--pad) calc(24px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
footer b { font-weight: 700; color: var(--ink); font-size: 13.5px; letter-spacing: -.02em; }

/* ---------- Focus + swatches ---------- */
.focus-button { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; background: white; color: var(--ink); font-weight: 600; font-size: 13px; }
.focus-button:hover { background: var(--surface-tonal); border-color: var(--line-strong); }
.focus-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.focus-button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: white; }
.swatches { display: flex; align-items: center; gap: 7px; }
.ink-dot { width: 24px; height: 24px; padding: 0; border: 2px solid white; border-radius: 50%; background: var(--c); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.14), 0 0 0 1px rgba(0, 0, 0, 0.1); transition: transform .2s var(--spring), box-shadow .18s var(--ease); }
.ink-dot:hover { transform: scale(1.16); box-shadow: 0 3px 8px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.15); }
.ink-dot[aria-pressed="true"] { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--green), 0 3px 8px rgba(15, 118, 110, 0.25); transform: scale(1.16); }
.swatches .swatch input[type="color"] { width: 26px; height: 26px; border-radius: 50%; padding: 1px; }
body.focus-mode { overflow: hidden; overscroll-behavior: none; }
.focus-mode .canvas-card { position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column; border: 0; border-radius: 0; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); background: #eaeeea; animation: fade .22s both; }
.focus-mode .toolbar { flex: none; }
.focus-mode .canvas-body { flex: 1 1 auto; min-height: 0; display: grid; place-items: center; overflow: hidden; }
.focus-mode .canvas-frame { margin: 12px; box-shadow: var(--shadow-lg); animation: popIn .28s var(--spring) both; }
.focus-mode .canvas-foot { display: none; }
.focus-mode .layers.open { position: fixed; top: 0; right: 0; bottom: 0; z-index: 75; width: min(300px, 84vw); overflow-y: auto; box-shadow: -20px 0 50px rgba(15, 23, 20, 0.18); animation: slideIn .25s var(--ease) both; }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } }

/* ---------- Starters: never face a blank page ---------- */
.starter-strip { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; padding: 10px 0 12px; background: linear-gradient(transparent, rgba(255, 255, 255, 0.96) 28%); opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .25s var(--ease), transform .3s var(--ease); }
.starter-strip.show { opacity: 1; transform: none; }
.starter-strip.show .starter-list, .starter-strip.show .starter-skip { pointer-events: auto; }
.starter-strip-head { display: flex; align-items: center; justify-content: space-between; padding: 0 12px 6px; font-size: 12px; color: var(--muted); }
.starter-skip { width: 26px; height: 26px; border: 0; border-radius: 50%; background: var(--surface-tonal); color: var(--muted); font-size: 16px; line-height: 1; }
.starter-list { display: flex; gap: 8px; padding: 2px 12px 4px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; }
.starter-list::-webkit-scrollbar { display: none; }
.starter { --i: 0; flex: none; display: grid; gap: 4px; padding: 5px; border: 1px solid var(--line); border-radius: 12px; background: white; text-align: left; scroll-snap-align: start; box-shadow: var(--shadow-sm); }
.starter:hover { border-color: var(--green); transform: translateY(-1px); }
.starter-strip.show .starter { animation: cardIn .35s var(--ease) both; }
.starter-strip.show .starter:nth-child(2) { animation-delay: .04s; } .starter-strip.show .starter:nth-child(3) { animation-delay: .08s; }
.starter-strip.show .starter:nth-child(4) { animation-delay: .12s; } .starter-strip.show .starter:nth-child(5) { animation-delay: .16s; }
.starter-thumb img { display: block; width: 96px; aspect-ratio: 1000 / 650; border-radius: 8px; border: 1px solid var(--line); }
.starter-name { font-size: 12px; font-weight: 600; white-space: nowrap; padding: 0 2px; }
.starters-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.starter.big { padding: 8px; box-shadow: var(--shadow-xs); }
.starter.big .starter-thumb img { width: 100%; }
.starter.big .starter-name { font-size: 14px; white-space: normal; }
.starter-hint { font-size: 12px; color: var(--muted); padding: 0 2px 2px; }
@media (min-width: 640px) { .starters-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } .starter-thumb img { width: 120px; } }

/* ---------- Search controls ---------- */
.search-sketch { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid transparent; border-radius: 50%; background: var(--violet-soft); color: var(--violet); }
.search-sketch:hover { background: #e8e0fe; border-color: var(--violet-line); }
.search-sketch svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.85; stroke-linecap: round; stroke-linejoin: round; }
.asset-filters { align-items: center; }
.asset-filters[hidden] { display: none; }
.made-line { display: flex !important; align-items: center; gap: 3px; cursor: help; }
@media (max-width: 639px) { .canvas-foot { flex-wrap: wrap; } }

/* ---------- Lineage + AI marks on cards ---------- */
.mini.ai-mini { border-color: var(--violet-line); background: var(--violet-soft); color: var(--violet-hover); }
.mini.ai-mini:hover { background: #e8e0fe; border-color: var(--violet); }
.lineage { color: var(--violet) !important; }
.wu-head-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.wu-card.kin { border-color: #bbf7d0; }

/* ---------- Variations sheet ---------- */
.var-step { margin-top: 16px; animation: rise .35s var(--ease) both; }
.var-step[hidden] { display: none; }
.var-step-title { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-weight: 700; }
.step-dot { width: 22px; height: 22px; display: inline-grid; place-items: center; border-radius: 50%; background: var(--violet); color: white; font-size: 11px; }
.var-goal-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.var-goal-row input, .var-goal-row select { min-height: 44px; padding: 0 12px; border: 1px solid #ddd6fe; border-radius: 10px; background: white; font-size: 15px; }
.var-goal-row input { grid-column: 1 / -1; }
.var-goal-row .pill { min-height: 44px; }
.var-plan-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; counter-reset: plan; }
.var-plan-row { --i: 0; counter-increment: plan; display: grid; grid-template-columns: minmax(0, 1fr) 36px; gap: 6px; padding: 10px; border: 1px solid #e4dcff; border-radius: 12px; background: #fcfbff; animation: cardIn .35s var(--ease) both; animation-delay: calc(var(--i) * 45ms); }
.var-plan-row input, .var-plan-row textarea { min-width: 0; min-height: 38px; padding: 0 10px; border: 1px solid #e4dcff; border-radius: 8px; background: white; font-size: 14px; }
.var-plan-row textarea { min-height: 0; padding: 8px 10px; resize: vertical; line-height: 1.35; }
.var-name { font-weight: 700; }
.var-brief { grid-column: 1 / 2; }
.var-remove { grid-row: 1; grid-column: 2; padding: 0; font-size: 18px; }
.var-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.var-results-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.var-results-head .var-actions { margin-top: 0; }
.var-results-head .pill[hidden] { display: none; }
.var-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.var-card { --i: 0; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: white; animation: cardIn .4s var(--ease) both; animation-delay: calc(var(--i) * 50ms); }
.var-card.kept { border-color: var(--green); box-shadow: 0 0 0 2px #0f766e22; }
.var-card.error { border-color: #fca5a5; }
.var-figure { position: relative; display: grid; place-items: center; aspect-ratio: 1000 / 650; border-bottom: 1px solid var(--line); background: white; }
.var-figure canvas { display: block; width: 100%; height: auto; animation: fade .5s both; }
.var-card.pending .var-figure { background: linear-gradient(100deg, #f5f3ff 30%, #ede9fe 50%, #f5f3ff 70%) 0 0 / 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.var-wait { color: var(--violet); font-weight: 700; font-size: 13px; animation: breathe 1.4s ease-in-out infinite; }
.var-card small { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
.var-stats { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 6px 0 0; font-size: 11.5px; cursor: help; }
.var-stats .hand { color: var(--green); }
.var-stats .ai { color: var(--violet); }
.kept-note { align-self: center; color: var(--green); font-weight: 700; font-size: 13px; }

/* ---------- Breakdown sheet ---------- */
.bd-top { display: grid; gap: 14px; margin-top: 14px; }
.bd-player { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: white; }
.bd-player canvas { display: block; width: 100%; height: auto; }

.bd-made h3 { margin: 0 0 8px; font-size: 15px; }
.made-bar { display: flex; height: 14px; overflow: hidden; border-radius: 999px; background: #eef3ec; }
.made-bar span { width: var(--share); transform-origin: left; animation: grow .9s .1s var(--ease) both; }
.made-hand, .made-legend .made-hand::before { background: var(--green); }
.made-ai, .made-legend .made-ai::before { background: var(--violet); }
.made-placed, .made-legend .made-placed::before { background: #38bdf8; }
.made-legend { display: grid; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; font-size: 13px; }
.made-legend li { display: flex; align-items: baseline; gap: 8px; background: none; }
.made-legend li::before { content: ""; width: 10px; height: 10px; border-radius: 3px; flex: none; transform: translateY(1px); }
.made-legend b { min-width: 38px; font-variant-numeric: tabular-nums; }
.made-legend span { color: var(--muted); }
.bd-replay-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 8px 10px 10px; background: #fbfcf8; }
.bd-caption { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

.art-math { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.math-tile { display: grid; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: white; cursor: help; animation: pop .35s var(--spring) both; }
.math-tile b { font-size: 18px; font-variant-numeric: tabular-nums; }
.math-tile span { font-size: 11.5px; color: var(--muted); }
.math-palette { grid-column: 1 / -1; display: flex; gap: 6px; padding: 6px 2px; cursor: help; }
.swatch-dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid white; box-shadow: 0 0 0 1px #cfdccf; }
.made-kit, .made-legend .made-kit::before { background: #fbbf24; }
.evolution { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scroll-snap-type: x proximity; }
.evo-card { --i: 0; flex: none; display: grid; gap: 2px; width: 150px; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: white; text-align: left; scroll-snap-align: start; animation: cardIn .4s var(--ease) both; animation-delay: calc(var(--i) * 60ms); }
.evo-card img { width: 100%; aspect-ratio: 1000 / 650; object-fit: contain; border-radius: 8px; border: 1px solid #eef3ec; background: white; }
.evo-card b { font-size: 13px; }
.evo-card small { font-size: 11.5px; color: var(--muted); }
.bd-origin { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0 0; padding: 10px 12px; border-radius: 12px; background: var(--violet-soft); color: #4c1d95; font-size: 13px; }
.bd-origin[hidden] { display: none; }

.badges { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.badge { padding: 1px 6px; border-radius: 999px; font-size: 10px; font-weight: 700; }
.badge.asset { background: #ccfbf1; color: var(--green); }
.badge.ai { background: var(--violet-soft); color: var(--violet); }
.badge.hidden { background: #eef3ec; color: var(--muted); }

.timeline { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.event { --i: 0; display: grid; grid-template-columns: 30px 1fr; gap: 10px; padding: 8px 0; border-top: 1px solid #eef3ec; animation: rise .3s var(--ease) both; animation-delay: calc(var(--i) * 30ms); }
.event-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: #eef3ec; font-size: 13px; }
.by-ai .event-icon { background: var(--violet-soft); color: var(--violet); }
.by-artist .event-icon { background: var(--green-soft); color: var(--green); }
.event-body p { margin: 0; font-size: 13px; overflow-wrap: anywhere; }
.event-body small { color: var(--muted); font-size: 11.5px; }
.event.pending small { color: var(--amber); font-weight: 650; }

/* ---------- Phones: get to the paper fast ---------- */
@media (max-width: 639px) {
  .hero { padding: 14px 0 10px; }
  .hero h1 { font-size: clamp(26px, 7.6vw, 34px); }
  .canvas-frame { margin: 8px; }
  .library { margin-top: 20px; }
}
/* Fingers need bigger targets than mice. */
@media (pointer: coarse) {
  .tool { height: 42px; }
  .toolbar-row .icon-button, .history .icon-button, .layers-toggle { height: 40px; }
  .scene-go { min-height: 46px; }
  
  .layer-eye, .layer-name { min-height: 38px; }
  .mini { min-height: 38px; }
}

/* ---------- Bigger screens ---------- */
@media (min-width: 640px) {
  body { font-size: 16px; }
  .muted { font-size: 14px; }
  .eyebrow { font-size: 12px; }
  .var-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .var-goal-row { grid-template-columns: minmax(0, 1fr) auto auto; }
  .var-goal-row input { grid-column: auto; }
  .var-plan-row { grid-template-columns: minmax(0, 200px) minmax(0, 1fr) 36px; }
  .var-brief { grid-column: auto; }
  .var-remove { grid-column: auto; }
  .bd-top { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }
  .results { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .wu-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .glossary { grid-template-columns: 1fr 1fr; column-gap: 24px; }
  .help-flow { grid-template-columns: 1fr 1fr; }
  .toolbar-row { flex: 1 1 auto; padding-top: 0; border-top: 0; }
  .sheet { width: min(980px, calc(100vw - 48px)); max-height: calc(100vh - 64px); margin: auto; border-radius: 24px; padding: 28px 32px; }
  .sheet[open] { animation-name: sheetIn; }
  @keyframes sheetIn { from { transform: translateY(12px) scale(.985); opacity: 0; } to { transform: none; opacity: 1; } }
  .sheet-head:has(img) { grid-template-columns: 108px 1fr auto; }
  .sheet-head img { width: 108px; }
}
@media (min-width: 1024px) {
  :root { --pad: clamp(24px, 3vw, 44px); }
  main, footer { max-width: 1480px; }
  .layers.open { border-top: 0; border-left: 1px solid var(--line); animation: none; }
  .focus-mode .layers.open { position: static; width: auto; align-self: stretch; overflow-y: auto; box-shadow: none; animation: none; }
  .results { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .wu-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .help-flow { grid-template-columns: repeat(3, 1fr); }
  .library-sub { font-size: 14px; }
  .canvas-foot { font-size: 13px; }
}
@media (min-width: 1440px) { .results { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .pulse { outline: 3px solid var(--green); }
}

/* ---------- Accounts: the gate, the account menu, the welcome sheet ---------- */
.account-button { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--violet); color: white; font: 700 14px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; text-transform: uppercase; box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px rgba(109, 40, 217, 0.22); }
.account-button:hover { box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(109, 40, 217, 0.4); }
.account-button[aria-expanded="true"] { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--violet); }
.account-menu { position: absolute; top: calc(100% + 8px); right: var(--pad); width: min(290px, calc(100vw - 2 * var(--pad))); padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); color: var(--ink); box-shadow: var(--shadow-lg); animation: popIn .2s var(--ease) both; }
.account-menu p { margin: 0 0 4px; }
.account-email { font-weight: 700; font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; }
.account-counts { font-size: 13px; color: var(--muted); }
.account-budget { font-size: 12.5px; color: var(--violet); font-weight: 500; }
.account-note { font-size: 12px; color: var(--green); margin-bottom: 12px !important; }
.account-menu .pill { width: 100%; justify-content: center; }

.gate { width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; padding: 0; border: 0; background: radial-gradient(120% 90% at 85% 5%, #164e47 0%, #0b2422 52%, #071918 100%); color: #edf4ef; overflow-y: auto; }
.gate[open] { display: grid; place-items: center; animation: fade .3s both; }
.gate::backdrop { background: #071918; }
.gate-art { position: fixed; inset: auto 0 0 0; height: 34vh; pointer-events: none; opacity: .16; }
.gate-art svg { width: 100%; height: 100%; }
.gate-line { fill: none; stroke: var(--lime); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; animation: drawIn 3s .2s var(--ease) forwards; }
.gate-line.two { stroke: #7dd3c0; stroke-width: 2; animation-delay: 1.4s; animation-duration: 1.4s; }
.gate-dot { fill: #fbbf24; transform-origin: 300px 64px; transform: scale(0); animation: pop .5s 3s var(--spring) forwards; }
@keyframes drawIn { to { stroke-dashoffset: 0; } }

.gate-layout { position: relative; display: grid; gap: 28px; width: min(460px, 100%); margin: auto; padding: max(28px, env(safe-area-inset-top)) var(--pad) calc(28px + env(safe-area-inset-bottom)); }
.gate-story { min-width: 0; }
.gate-brand { display: flex; align-items: center; gap: 9px; margin-bottom: 18px; }
.gate-brand .brand-mark { fill: #ffffff; }
.gate-brand .brand-spark { fill: var(--lime); }
.gate-brand .wordmark { color: #ffffff; font-size: 22px; }
.gate-story h2 { margin: 0; font: 700 clamp(28px, 6.2vw, 38px)/1.1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; letter-spacing: -.03em; color: #ffffff; overflow-wrap: break-word; }
.gate-story h2 span { display: block; margin-top: 6px; color: #a7d7c5; font-weight: 600; }
.gate-promise { margin: 12px 0 20px; color: var(--lime); font-weight: 600; font-size: 15px; }
.gate-perks { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; font-size: 13.5px; color: #d5e5dd; }
.gate-perks li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; align-items: start; opacity: 0; animation: rise .45s var(--ease) forwards; }
.gate-perks li:nth-child(2) { animation-delay: .1s; }
.gate-perks li:nth-child(3) { animation-delay: .2s; }
.gate-perk-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: rgba(195, 241, 146, 0.14); color: var(--lime); }
.gate-perk-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.gate-fine { margin: 18px 0 0; font-size: 12px; color: #8fb3a8; }

.gate-card { position: relative; min-width: 0; width: 100%; margin: 0; padding: 22px; border-radius: 22px; background: #ffffff; color: var(--ink); box-shadow: 0 24px 64px rgba(0, 0, 0, 0.32); }
.gate-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-tonal); }
.gate-tabs button { min-height: 38px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 13.5px; font-weight: 600; }
.gate-tabs button[aria-selected="true"] { background: #ffffff; color: var(--ink); box-shadow: var(--shadow-xs); }
.gate-form { display: grid; gap: 6px; margin-top: 16px; }
.gate-form label { margin-top: 8px; font-size: 12.5px; font-weight: 600; color: var(--ink); }
.gate-form label small { font-weight: 400; color: var(--muted); margin-left: 4px; }
.gate-form input { width: 100%; min-height: 46px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 11px; background: #ffffff; color: var(--ink); font-size: 15px; transition: border-color .18s, box-shadow .18s; }
.gate-form input::placeholder { color: #9aa8a1; }
.gate-form input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14); }
.gate-pw { position: relative; }
.gate-pw input { padding-right: 64px; }
.gate-reveal { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); min-height: 32px; padding: 0 10px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.gate-reveal:hover { background: var(--surface-tonal); color: var(--ink); }
.gate-submit { position: relative; overflow: hidden; margin-top: 14px; min-height: 48px; border: 0; border-radius: 12px; background: var(--green); color: #ffffff; font-weight: 650; font-size: 15px; box-shadow: 0 2px 10px rgba(15, 118, 110, 0.25); }
.gate-submit:hover:not(:disabled) { background: var(--green-hover); }
.gate-submit[aria-busy="true"]::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent); animation: shine 1.1s linear infinite; }
.gate-status { min-height: 1.4em; margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.gate-status.error { color: var(--danger); }
.gate-form.shake { animation: shake .4s var(--ease); }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

@media (min-width: 640px) {
  .gate-layout { width: min(560px, calc(100vw - 48px)); padding: 36px 0; }
  .gate-story h2 { font-size: clamp(34px, 5vw, 44px); }
  .gate-perks { font-size: 14px; }
  .gate-card { padding: 28px 32px; border-radius: 24px; }
}
@media (min-width: 960px) {
  .gate[open] { padding: clamp(32px, 5vw, 64px); }
  .gate-art { inset: auto auto 0 0; width: 54vw; height: 50vh; max-height: 480px; opacity: .14; }
  .gate-layout { grid-template-columns: minmax(0, 1.1fr) minmax(380px, 440px); align-items: center; gap: clamp(40px, 6vw, 96px); width: min(1180px, 100%); padding: 0; }
  .gate-story h2 { font-size: clamp(38px, 3.8vw, 52px); }
  .gate-promise { font-size: 17px; margin: 14px 0 24px; }
  .gate-perks { gap: 14px; font-size: 15px; }
  .gate-card { padding: 32px; border-radius: 24px; }
}

.welcome-choices { display: grid; gap: 12px; margin-top: 16px; }
@media (min-width: 640px) { .welcome-choices { grid-template-columns: 1fr 1fr; } }
.welcome-choice { display: grid; gap: 6px; justify-items: start; text-align: left; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); transition: border-color .18s, box-shadow .18s, transform .18s var(--ease); }
.welcome-choice:hover { border-color: var(--line-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.welcome-choice.primary { border-color: var(--green-line); background: var(--green-soft); }
.welcome-choice.primary:hover { border-color: var(--green); }
.welcome-choice b { font-size: 15.5px; font-weight: 700; }
.welcome-choice span:last-child { font-size: 13px; color: var(--muted); line-height: 1.45; }
.welcome-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; background: white; color: var(--green); box-shadow: var(--shadow-xs); margin-bottom: 2px; }
.welcome-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.welcome-choice[aria-busy="true"] { opacity: .7; }
@media (prefers-reduced-motion: reduce) {
  .gate-line { stroke-dashoffset: 0; animation: none; }
  .gate-dot { transform: none; animation: none; }
  .gate-perks li { opacity: 1; animation: none; }
}

/* ---------- Direct manipulation ---------- */
.layer-hud { position: absolute; z-index: 2; top: 10px; left: 10px; max-width: calc(100% - 20px); padding: 5px 12px; border: 0; border-radius: 999px; background: rgba(24, 34, 30, 0.82); color: #f2f5f3; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; backdrop-filter: blur(8px); animation: popIn .22s var(--ease) both; }
.layer-hud.asset { background: rgba(15, 118, 110, 0.9); }
.layer-hud[hidden] { display: none; }
#drawing.move-mode { cursor: grab; }
#drawing.move-mode:active { cursor: grabbing; }
.canvas-frame.drop-ok { outline: 3px dashed var(--green); outline-offset: -3px; }
.thumb-button[draggable="true"] { cursor: grab; }

@media (max-width: 639px) {
  .tray .long, .tray kbd { display: none; }
  .tray .short { display: inline; }
}

/* Breakdown */
.bd-behind { margin-top: 14px; border: 1px solid var(--line); border-radius: 14px; background: #fafcfa; }
.bd-behind summary { cursor: pointer; padding: 11px 14px; font-weight: 650; font-size: 13.5px; }
.bd-behind summary small { font-weight: 500; color: var(--muted); margin-left: 6px; }
.bd-behind .bd-replay-bar { padding: 0 14px 10px; background: none; }
.bd-behind .art-math { padding: 0 14px 14px; }
.bd-player .bd-caption { margin: 6px 12px; min-height: 1em; }
.bd-player .bd-caption:empty { display: none; }

@keyframes flow { to { background-position: 0 0, -200% 0; } }

/* Material 3 / Google-style action buttons */
.scene-go { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 15px; border: 1px solid var(--line); border-radius: 999px; background: #ffffff; color: var(--ink); font-size: 13.5px; font-weight: 600; white-space: nowrap; box-shadow: var(--shadow-xs); }
.scene-go:hover:not(:disabled) { background: var(--surface-tonal); border-color: var(--line-strong); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.scene-go[hidden] { display: none; }
.scene-go.primary { border-color: transparent; background: linear-gradient(180deg, #7c3aed 0%, #6d28d9 100%); color: white; box-shadow: 0 2px 8px rgba(109, 40, 217, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.2); }
.scene-go.primary:hover:not(:disabled) { background: linear-gradient(180deg, #6d28d9 0%, #5b21b6 100%); color: white; box-shadow: var(--shadow-ai); }
.scene-go:disabled { opacity: .55; cursor: progress; }

@keyframes reveal { from { opacity: 0; transform: scale(.985); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }
@media (max-width: 639px) {
  .scene-go { flex: 1 1 auto; padding: 0 12px; font-size: 13px; }
  .starter-strip .starter-thumb img { width: 74px; }
  .starter-strip .starter-name { font-size: 11px; }
  .starter-strip-head { padding-bottom: 2px; }
}
.voice-button { flex: none; display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 1px solid transparent; border-radius: 50%; background: var(--violet-soft); color: var(--violet); }
.voice-button:hover { background: #e8e0fe; }
.voice-button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.voice-button[hidden] { display: none; }
.voice-button[aria-pressed="true"] { background: var(--violet); color: white; }
.voice-input { display: flex; gap: 6px; align-items: center; }
.voice-input input { min-width: 0; flex: 1; }
.voice-status { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.voice-status.error { color: var(--danger); }
@media (min-width: 640px) { .var-goal-row { grid-template-columns: minmax(0, 1fr) auto auto auto; } }
@media (max-width: 639px) { .var-goal-row input:has(+ .voice-button:not([hidden])) { grid-column: auto; } }

.example.pending { border-style: dashed; background: white; animation: breathe 1.4s ease-in-out infinite; }
.results-count { padding: 1px 8px; border-radius: 999px; background: var(--green-soft); color: var(--green); font-size: 12px; font-weight: 600; line-height: 20px; }
.score-line { font: 500 11.5px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--subtle); }

/* ---------- Menu drawer ---------- */
.menu-button { display: grid; place-content: center; gap: 4px; width: 38px; height: 38px; margin-right: -4px; border: 0; border-radius: 50%; background: none; }
.menu-button span { display: block; width: 18px; height: 1.8px; border-radius: 2px; background: var(--ink); transition: transform .3s var(--spring), opacity .2s; }
.menu-button:hover { background: var(--surface-tonal); }
.menu-button[aria-expanded="true"] span:nth-child(1) { transform: translateY(5.8px) rotate(45deg); }
.menu-button[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.menu-button[aria-expanded="true"] span:nth-child(3) { transform: translateY(-5.8px) rotate(-45deg); }
@media (max-width: 639px) {
  .topbar .connection, .help-button, .account-button { display: none; }
  .hero { padding: 14px 0 10px; }
}

.menu { position: fixed; inset: 0 0 0 auto; width: min(350px, 88vw); height: 100dvh; max-height: none; margin: 0; padding: max(14px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
  border: 0; border-radius: 24px 0 0 24px; background: #ffffff; color: var(--ink); box-shadow: -20px 0 60px rgba(15, 23, 20, 0.18); overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; }
.menu[open] { display: flex; flex-direction: column; animation: drawerIn .42s var(--spring) both; }
.menu.closing { animation: drawerOut .24s var(--ease) forwards; }
.menu::backdrop { background: rgba(15, 23, 20, 0.32); backdrop-filter: blur(4px); animation: fade .25s both; }
.menu.closing::backdrop { animation: fadeOut .24s forwards; }
@keyframes drawerIn { from { transform: translateX(105%); } to { transform: none; } }
@keyframes drawerOut { to { transform: translateX(105%); } }
@keyframes fadeOut { to { opacity: 0; } }
.menu-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 14px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.menu-brand { display: inline-flex; align-items: center; gap: 8px; }
.menu-close { width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--surface-tonal); color: var(--muted); font-size: 20px; line-height: 1; }
.menu-close:hover { background: #e3eae5; color: var(--ink); }
.menu-list { display: grid; gap: 2px; }
.menu-list button { position: relative; overflow: hidden; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 8px 10px; border: 0; border-radius: 12px; background: none; text-align: left; }
.menu-list button:hover, .menu-list button:focus-visible { background: var(--surface-tonal); transform: translateX(2px); }
.menu-list button:hover .menu-icon { transform: scale(1.06); background: #d6efe9; }
.menu[open] .menu-list button, .menu[open] .menu-foot { animation: itemIn .4s calc(.04s + var(--i) * .03s) var(--ease) both; }
@keyframes itemIn { from { opacity: 0; transform: translateX(18px); } }
.menu-icon { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--green-soft); color: var(--green); transition: transform .22s var(--spring), background-color .18s var(--ease); }
.menu-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.85; stroke-linecap: round; stroke-linejoin: round; }
.menu-list b { display: block; font-size: 14.5px; font-weight: 600; }
.menu-list small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.3; }
.menu-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--line); }
.menu-account { margin: 0; font-weight: 650; font-size: 14px; overflow-wrap: anywhere; }
.menu-status { margin: 2px 0 12px; color: var(--muted); font-size: 12.5px; }
.menu-foot .pill { width: 100%; justify-content: center; }

.scene-go, .tool, .starter, .primary-mini, .save-button, .next-action { position: relative; overflow: hidden; }
.ripple { position: absolute; z-index: 0; border-radius: 50%; background: currentColor; opacity: .16; transform: scale(0); pointer-events: none; animation: ripple .55s var(--ease) forwards; }
@keyframes ripple { to { transform: scale(1); opacity: 0; } }
.library, .save-card, .canvas-card { scroll-margin-top: 76px; }

/* ---------- Authorship pill ---------- */
.authorship { position: absolute; z-index: 2; top: 10px; right: 10px; max-width: calc(100% - 20px); padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: rgba(255, 255, 255, 0.92); color: var(--ink); font-size: 12px; font-weight: 600; white-space: nowrap; box-shadow: var(--shadow-sm); backdrop-filter: blur(6px);
  animation: popIn .25s var(--spring) both; }
.authorship[hidden] { display: none; }
.authorship.pure { color: var(--green); }
.focus-mode .authorship { top: 14px; right: 14px; }

/* ---------- Stamp brush ---------- */
.stamp-tool canvas { width: 22px; height: 22px; pointer-events: none; }
.stamp-tool[hidden] { display: none; }
.stamp-tool.fresh { animation: brushIn .55s var(--spring); }
@keyframes brushIn { 0% { transform: scale(.2) rotate(-40deg); } 60% { transform: scale(1.2) rotate(8deg); } 100% { transform: none; } }
#drawing.stamp-mode { cursor: copy; }
#layer-brush:disabled { opacity: .4; }

/* ---------- Help shortcuts ---------- */
.help-sub { margin: 20px 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.shortcuts { display: grid; gap: 8px 20px; margin: 0; }
.shortcuts div { display: flex; align-items: center; gap: 10px; }
.shortcuts dt { flex: 0 0 auto; min-width: 124px; }
.shortcuts dd { margin: 0; color: var(--muted); font-size: 13.5px; }
.shortcuts kbd { display: inline-block; min-width: 24px; opacity: 1; padding: 2px 7px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 6px; background: #fafbfa; font: 600 11.5px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; text-align: center; }
@media (min-width: 640px) { .shortcuts { grid-template-columns: 1fr 1fr; } }
@media (pointer: coarse) { .shortcuts, .flow-keys { display: none; } }

/* ---------- Canvas paper stage ---------- */
.canvas-body { background: radial-gradient(#d5ddd6 1px, transparent 1.2px) 0 0 / 18px 18px, #eef1ee; }
.canvas-frame { border-color: var(--line); border-radius: 12px; box-shadow: var(--shadow); transition: box-shadow .25s var(--ease); }
.brush-cursor { position: absolute; left: 0; top: 0; z-index: 3; width: var(--size); height: var(--size); border: 1.5px solid var(--ink); border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.85), inset 0 0 0 1px rgba(255, 255, 255, 0.6); pointer-events: none; will-change: transform; transition: width .1s var(--ease), height .1s var(--ease); }
.brush-cursor::after { content: ""; position: absolute; left: 50%; top: 50%; width: 3px; height: 3px; margin: -1.5px; border-radius: 50%; background: var(--ink); }
.brush-cursor.erasing { border-style: dashed; }
.brush-cursor.erasing::after { display: none; }
.brush-cursor.preview { background: color-mix(in srgb, var(--ink) 22%, transparent); animation: popIn .2s var(--spring); }
.brush-cursor[hidden] { display: none; }
@media (pointer: fine) { .canvas-frame.brushing #drawing { cursor: none; } }

/* ---------- Under the hood ---------- */
.connection { cursor: pointer; }
.hood-flow { list-style: none; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin: 18px 0 6px; padding: 0; counter-reset: none; }
.hood-flow li { position: relative; display: grid; justify-items: center; gap: 3px; padding: 12px 8px; border: 1px solid var(--line); border-radius: 14px; background: #fafcfa; text-align: center; animation: rise .45s calc(.06s * var(--i)) var(--ease) both; }
.hood-flow li span { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--violet-soft); font-size: 13px; font-weight: 700; color: var(--violet); }
.hood-flow li b { font-size: 13.5px; font-weight: 650; }
.hood-flow li small { color: var(--muted); font-size: 11.5px; line-height: 1.3; }
.hood-flow li:not(:last-child)::after { content: ""; position: absolute; top: 50%; right: -8px; width: 8px; height: 2px; background: repeating-linear-gradient(90deg, var(--violet) 0 3px, transparent 3px 6px) 0 0 / 12px 2px; animation: flowLine 0.8s linear infinite; }
@keyframes flowLine { to { background-position: 12px 0; } }
.hood-card { display: grid; gap: 14px 24px; margin-top: 14px; padding: 20px; border: 1px solid var(--line); border-radius: 18px; background: #fff; animation: rise .45s .15s var(--ease) both; }
.hood-card h3 { margin: 0 0 6px; font: 700 18px/1.25 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: -.015em; }
.hood-card p { margin: 0 0 8px; line-height: 1.55; font-size: 14px; }
.hood-card code { padding: 2px 6px; border-radius: 6px; background: var(--surface-tonal); font-size: 12px; }
.hood-fine { color: var(--muted); font-size: 12.5px; }
.hood-live { padding: 14px; border-radius: 14px; background: #14221e; color: #d7e6df; }
.hood-live-head { margin: 0 0 8px; color: var(--lime); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.hood-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: 0 0 10px; }
.hood-stats div { padding: 7px 8px; border-radius: 10px; background: rgba(255, 255, 255, 0.08); }
.hood-stats dt { color: #9fc3b6; font-size: 11px; }
.hood-stats dd { margin: 0; color: white; font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hood-json { margin: 0; max-height: 130px; overflow: auto; color: #c3f192; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-word; }
.hood-map { width: 100%; max-width: 320px; justify-self: center; }
.hood-map .ring { fill: #f3efff; stroke: #c4b5fd; stroke-dasharray: 4 5; animation: breathe 3s ease-in-out infinite; }
.hood-map .dot circle { fill: var(--violet); }
.hood-map .dot.far circle { fill: var(--green); }
.hood-map .dot text { fill: var(--ink); font: 600 10.5px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.hood[open] .hood-map .dot { animation: settle 1s calc(.35s + .16s * var(--i)) var(--spring) both; }
@keyframes settle { from { opacity: 0; transform: translate(60px, 40px); } }
.hood-points, .hood-jobs { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.hood-points li, .hood-jobs li { padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fafcfa; font-size: 13.5px; line-height: 1.45; }
.hood-yours { background: linear-gradient(135deg, #f3faf7, #f8f6ff); }
@media (min-width: 760px) { .hood-card { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: center; } .hood-yours, .hood-card:has(> :only-child) { grid-template-columns: 1fr; } }
@media (max-width: 639px) {
  .hood-flow { grid-template-columns: repeat(5, minmax(84px, 1fr)); overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
  .hood-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Floating cards (AI Spark, the kit) and the pinned spark ---------- */
.nudge { position: fixed; z-index: 85; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); width: min(440px, calc(100vw - 24px)); padding: 18px; border-radius: 22px;
  background: rgba(255, 255, 255, 0.97); box-shadow: var(--shadow-lg), 0 0 0 1px var(--violet-line); backdrop-filter: blur(12px); transform: translateX(-50%); }
.nudge[hidden] { display: none; }
.nudge.dealt { animation: dealIn .45s var(--spring) both; }
@keyframes dealIn { from { opacity: 0; transform: translate(-50%, 24px) scale(.97); } to { opacity: 1; transform: translate(-50%, 0); } }
.nudge-head { display: flex; align-items: center; justify-content: space-between; }
.nudge-head .eyebrow { margin: 0; color: var(--violet); }
.nudge-head .close { width: 32px; height: 32px; font-size: 18px; }
.nudge-prompt { margin: 8px 0 6px; font: 700 clamp(19px, 2.2vw, 23px)/1.22 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: -.02em; }
.nudge-rule { margin: 0 0 10px; display: inline-block; padding: 4px 10px; border-radius: 999px; background: var(--amber-soft); color: var(--amber); font-size: 12.5px; font-weight: 600; }
.nudge-rule[hidden] { display: none; }
.nudge-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.nudge-actions .scene-go { flex: 1 1 auto; }
.nudge-fine { margin: 10px 0 0; color: var(--muted); font-size: 12px; text-align: center; }

.flow-banner { position: absolute; z-index: 3; left: 50%; top: 10px; display: flex; align-items: center; gap: 8px; max-width: min(560px, calc(100% - 24px)); padding: 6px 8px 6px 14px; border-radius: 999px;
  background: rgba(24, 24, 46, 0.92); color: #ede9fe; font-size: 13px; font-weight: 500; transform: translateX(-50%); overflow: hidden; backdrop-filter: blur(8px); animation: slideDown .35s var(--spring) both; }
.flow-banner[hidden] { display: none; }
@keyframes slideDown { from { opacity: 0; transform: translate(-50%, -10px); } }
#flow-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#flow-stop { flex: none; width: 24px; height: 24px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, 0.16); color: white; line-height: 1; }
.canvas-frame:has(.flow-banner:not([hidden])) .layer-hud, .canvas-frame:has(.flow-banner:not([hidden])) .authorship { visibility: hidden; }

.rotate-hint { display: none; }
@media (max-width: 639px) and (orientation: portrait) {
  .focus-mode .rotate-hint { display: block; position: absolute; z-index: 3; left: 50%; bottom: 10px; margin: 0; padding: 6px 12px; border-radius: 999px; background: rgba(24, 34, 30, 0.85); color: white;
    font-size: 12px; white-space: nowrap; pointer-events: none; transform: translateX(-50%); animation: hintOut 5s 1s forwards; }
}
@keyframes hintOut { 0%, 80% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }

/* ---------- Full screen Focus mode ---------- */
.focus-mode .canvas-card { background: radial-gradient(#d5ddd6 1px, transparent 1.2px) 0 0 / 20px 20px, #eef1ee; }
.focus-mode .toolbar { margin: 10px auto 0; width: min(calc(100% - 20px), 1120px); border: 1px solid var(--line); border-radius: 16px; background: rgba(255, 255, 255, 0.92); box-shadow: var(--shadow); backdrop-filter: blur(12px); }
.focus-mode .canvas-body { background: none; }
.focus-mode .toolbar, .focus-mode .authorship, .focus-mode .layer-hud { transition: opacity .3s var(--ease), transform .3s var(--ease); }
.focus-mode.inking .toolbar { opacity: .12; pointer-events: none; transition-delay: .12s; transform: translateY(-6px); }
.focus-mode.inking .authorship, .focus-mode.inking .layer-hud { visibility: hidden; }
@media (max-height: 520px) and (orientation: landscape) {
  .focus-mode .toolbar { flex-wrap: nowrap; gap: 6px; margin-top: 4px; padding: 4px 6px; }
  .focus-mode .tools { flex: 0 1 auto; min-width: 0; overflow-x: auto; }
  .focus-mode .tool { min-width: 32px; height: 32px; }
  .focus-mode .history .icon-button, .focus-mode .toolbar-row .icon-button, .focus-mode .layers-toggle { min-width: 32px; height: 32px; padding: 0 5px; }
  .focus-mode .focus-button { height: 32px; padding: 0 10px; }
  .focus-mode .focus-button span, .focus-mode .fill-control span, .focus-mode .size-control output, .focus-mode .toolbar-spacer { display: none; }
  .focus-mode .toolbar-row { flex: 1 1 0; min-width: 0; flex-wrap: nowrap; gap: 4px; }
  .focus-mode .swatches { flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; padding: 2px 14px 2px 2px;
    -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
  .focus-mode .swatches > * { flex: none; }
  .focus-mode .ink-dot { width: 22px; height: 22px; }
  .focus-mode .size-control { flex: 0 0 64px; }
  .focus-mode .size-control input { width: 100%; }
  .focus-mode .canvas-frame { margin: 6px; }
  .nudge { padding: 12px 14px; }
  .nudge-prompt { font-size: 18px; }
  .nudge-fine { display: none; }
}

/* ---------- The kit: shapes, figures, brushes ---------- */
.kit { width: min(520px, calc(100vw - 24px)); max-height: min(78vh, 640px); overflow-y: auto; overscroll-behavior: contain; }
.kit-group + .kit-group { margin-top: 12px; }
.kit-label { margin: 8px 0 6px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.kit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.kit-item { display: grid; justify-items: center; gap: 3px; padding: 8px 4px 6px; border: 1px solid var(--line); border-radius: 12px; background: white; font-size: 12px; font-weight: 600; }
.kit-item canvas { width: 38px; height: 38px; }
.kit-item:hover { border-color: var(--violet-line); background: #fcfbff; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.kit-item[aria-pressed="true"] { border-color: var(--violet); background: var(--violet-soft); color: var(--violet-hover); }
.kit.dealt .kit-item { animation: popIn .3s var(--spring) both; }
.kit-hint { margin: 6px 0 0; color: var(--muted); font-size: 12.5px; }
.stamp-tool[aria-expanded="true"] { background: var(--violet-soft); color: var(--violet); }

/* ---------- The finder: Google-spotlight search from anywhere ---------- */
.finder-trigger {
  display: flex; align-items: center; gap: 10px;
  flex: 0 1 460px; min-width: 0; height: 40px;
  margin: 0 auto 0 12px; padding: 0 10px 0 14px;
  border: 1px solid rgba(224, 229, 225, 0.7); border-radius: 999px;
  background: var(--surface-tonal); color: var(--muted); font-size: 14px; text-align: left;
  box-shadow: inset 0 1px 2px rgba(15, 23, 20, 0.03);
}
.finder-trigger:hover { background: #ffffff; border-color: var(--line-strong); color: var(--ink); box-shadow: var(--shadow-sm); }
.finder-trigger:hover svg { transform: scale(1.08); color: var(--green); }
.finder-trigger svg, .finder-bar > svg { flex: none; width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; transition: transform .2s var(--spring), color .18s var(--ease); }
.finder-trigger span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.finder-trigger kbd { padding: 2px 7px; border: 1px solid var(--line-strong); border-radius: 6px; background: white; font: 600 11px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--muted); opacity: 1; }
@media (max-width: 639px) {
  .finder-trigger { flex: 0 0 38px; width: 38px; height: 38px; margin-left: auto; padding: 0; justify-content: center; background: transparent; color: var(--ink); }
  .finder-trigger span, .finder-trigger kbd { display: none; }
}
@media (pointer: coarse) { .finder-trigger kbd { display: none; } }

.finder {
  width: min(720px, calc(100vw - 24px)); max-width: none; max-height: min(82vh, 720px);
  margin: 8vh auto auto; padding: 0; border: 1px solid var(--line); border-radius: 22px;
  background: #fff; color: var(--ink); box-shadow: var(--shadow-lg); overflow: hidden;
}
.finder[open] { display: flex; flex-direction: column; animation: finderIn .26s var(--ease) both; }
.finder::backdrop { background: rgba(15, 23, 20, 0.36); backdrop-filter: blur(4px); animation: fade .2s both; }
@keyframes finderIn { from { opacity: 0; transform: translateY(-10px) scale(.985); } }
.finder-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px 8px 18px; border-bottom: 1px solid var(--line); color: var(--muted); }
.finder-bar input { flex: 1; min-width: 0; height: 42px; border: 0; outline: 0; background: none; color: var(--ink); font-size: 16px; }
.finder-bar input::-webkit-search-cancel-button { cursor: pointer; }
.finder-bar .voice-button { border: 0; background: none; border-radius: 50%; }
.finder-sketch, .finder-close { flex: none; height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-tonal); color: var(--ink); font-size: 12.5px; font-weight: 600; }
.finder-sketch:hover, .finder-close:hover { background: #e4eae5; }
.finder-close { color: var(--muted); background: white; }
.finder.searching .finder-bar > svg { color: var(--violet); animation: breathe 1s ease-in-out infinite; }
.finder-status { margin: 0; padding: 8px 18px 0; color: var(--muted); font-size: 12.5px; }
.finder-status:empty { display: none; }
.finder-body { flex: 1; min-height: 120px; padding: 8px 14px 16px; overflow-y: auto; overscroll-behavior: contain; }
.finder-ideas { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 4px 4px; }
.finder-ideas small { color: var(--subtle); font-size: 12px; font-weight: 600; margin-right: 2px; }
.finder-head { display: flex; align-items: center; gap: 8px; margin: 14px 4px 8px; font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.finder-grid { display: grid; gap: 4px; }
.finder-item { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 7px 10px; border-radius: 12px; cursor: pointer; animation: rise .25s var(--ease) both; transition: background-color .14s var(--ease), box-shadow .16s var(--ease), transform .16s var(--ease); }
.finder-item:hover, .finder-item.active { background: var(--surface-tonal); transform: translateX(2px); }
.finder-item.active { box-shadow: inset 0 0 0 1.5px var(--green); }
.finder-thumb { position: relative; display: block; width: 72px; aspect-ratio: 1000 / 650; border: 1px solid var(--line); border-radius: 8px; background: #fff; overflow: hidden; }
.finder-thumb img { display: block; width: 100%; height: 100%; object-fit: contain; }
.finder-badge { position: absolute; right: 3px; bottom: 3px; padding: 0 5px; border-radius: 5px; background: rgba(24, 34, 30, 0.84); color: #fff; font-size: 10px; font-weight: 700; }
.finder-text { display: grid; min-width: 0; gap: 2px; }
.finder-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 650; }
.finder-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12.5px; }
.finder-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.finder-go { min-height: 30px; padding: 0 11px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: 12px; font-weight: 600; white-space: nowrap; }
.finder-go:hover { border-color: var(--line-strong); background: #fafbfa; }
.finder-go.primary { border-color: transparent; background: var(--green); color: #fff; }
.finder-go.primary:hover { background: var(--green-hover); }
.finder-empty { margin: 24px 4px; color: var(--muted); text-align: center; font-size: 14px; }
.finder-pack { display: block; width: 100%; margin-top: 14px; padding: 14px; border: 1px dashed var(--violet); border-radius: 14px; background: var(--violet-soft); color: var(--violet-hover); font-weight: 650; font-size: 13.5px; }
.finder-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; margin: 0; padding: 10px 18px; border-top: 1px solid var(--line); background: #fafbfa; color: var(--muted); font-size: 12px; }
@media (max-width: 639px) {
  .finder { width: 100vw; max-height: none; height: 100dvh; margin: 0; border-radius: 0; border: 0; }
  .finder-bar { padding: max(8px, env(safe-area-inset-top)) 10px 8px 14px; }
  .finder-bar input { font-size: 16px; }
  .finder-sketch span { display: none; }
  .finder-item { grid-template-columns: 60px minmax(0, 1fr); }
  .finder-thumb { width: 60px; }
  .finder-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .finder-foot span:first-child { display: none; }
}
@media (pointer: coarse) { .finder-foot span:first-child { display: none; } }

/* ---------- The AI tray ---------- */
.tray-note b { color: var(--lime); font-weight: 700; }
.tray button.held { background: #fff; color: #1e1b4b; }
.tray button { touch-action: none; }
@media (pointer: coarse) { .tray kbd { display: none; } }

/* Under the hood rules */
.hood-rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; margin: 14px 0 16px; padding: 0; list-style: none; }
.hood-rules li { display: grid; align-content: start; gap: 5px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.hood-rules b { font-size: 14.5px; font-weight: 650; }
.hood-rules span { color: var(--muted); font-size: 13.5px; line-height: 1.45; }

.nb { font-style: inherit; }

/* Offline */
[data-offline] { display: none; }
body.offline [data-online], body.offline .voice-button { display: none !important; }
body.offline [data-offline] { display: block; }
body.offline .connection .dot { background: #f59e0b; box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.16); }
.offline-save { margin: 12px 0 0; padding: 14px 18px; border: 1px dashed #f59e0b88; border-radius: 16px; background: #fffbeb; color: #78350f; font-size: 13.5px; line-height: 1.5; animation: rise .35s var(--ease) both; }
.menu-list button[hidden] { display: none; }
body.offline .topbar .connection { display: inline-flex !important; margin-left: auto; padding: 5px 12px; border-radius: 999px; background: #fffbeb; color: #92400e; font-weight: 600; }
body.offline .topbar .connection #connection { position: static; width: auto; height: auto; clip-path: none; }

@media (max-width: 639px) {
  .starter-strip .starter-thumb { display: none; }
  .starter-strip .starter { padding: 6px 12px; border-radius: 999px; box-shadow: none; }
  .starter-strip .starter-name { font-size: 12.5px; }
  .starter-strip { padding: 6px 0 8px; }
}
#browse { white-space: nowrap; }

/* ---------- Asset page ---------- */
[hidden] { display: none !important; }
.tool.refine-tool { color: var(--violet-hover); }
.tool.refine-tool:hover { background: white; }

.asset-page .sheet-head:has(img) { grid-template-columns: clamp(76px, 15vw, 132px) 1fr auto; }
.asset-page .sheet-head img { width: 100%; }
.asset-page-about { margin: 8px 0 0; max-width: 58ch; font-size: 14px; line-height: 1.45; color: var(--ink); }
.asset-page-tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0 0; }
.asset-page-tag { padding: 2px 10px; border-radius: 999px; background: var(--green-soft); color: var(--green); font-size: 12px; font-weight: 600; }
.asset-page .wu-card .why { margin: 4px 0 0; font-size: 12.5px; line-height: 1.4; color: var(--muted); }

/* ---------- Home & Studio layout ---------- */
body.view-home .studio, body.view-studio .hero, body.view-studio .launcher, body.view-studio .roles, body.view-studio .library { display: none !important; }
body.view-studio main { padding-top: 14px; }

.launcher { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 11px; width: 100%; max-width: 1120px; margin: 2px auto 0; animation: rise .45s .06s var(--ease) both; }
.launch-tile {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 16px;
  background: var(--card); text-align: left; cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color .2s var(--ease), box-shadow .24s var(--ease), transform .22s var(--spring), background-color .2s var(--ease);
}
.launch-tile:hover, .launch-tile:focus-visible { border-color: var(--green); box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.launch-tile:hover .launch-icon { transform: scale(1.08) rotate(-4deg); }
.launch-icon { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; background: var(--green-soft); color: var(--green); transition: transform .25s var(--spring), background-color .2s var(--ease); }
.launch-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.launch-icon-catalog { background: var(--amber-soft); color: var(--amber); }
.launch-icon-import { background: var(--violet-soft); color: var(--violet); }
.launch-icon-scene { background: #e0f2fe; color: #0369a1; }
.launch-body { display: grid; gap: 2px; min-width: 0; }
.launch-tile b { font-size: 14.5px; font-weight: 650; color: var(--ink); line-height: 1.22; }
.launch-tile small { color: var(--muted); font-size: 12px; line-height: 1.32; }
.bring-in-tile:hover, .bring-in-tile:focus-visible { border-color: var(--violet); }
.catalog-tile:hover, .catalog-tile:focus-visible { border-color: #d97706; }
@media (max-width: 960px) { .launcher { grid-template-columns: 1fr 1fr; } .bring-in-tile { grid-column: auto; } }
@media (max-width: 520px) { .launcher { grid-template-columns: 1fr; } }

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-height: 36px; }
.crumb-home { display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--ink); font-weight: 600; font-size: 13px; box-shadow: var(--shadow-xs); }
.crumb-home:hover { background: var(--surface-tonal); border-color: var(--line-strong); }
.crumb-trail { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14.5px; }
.crumb-here { font-weight: 700; color: var(--ink); }

.studio-status { margin: 0; padding: 0 16px 12px; }
#authorship { display: none !important; }
body:not(.making-backdrop) .starter-strip { display: none !important; }

.make-from { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.make-from .pill { min-height: 32px; font-size: 12.5px; padding: 0 12px; }
.ai-pill { border-color: var(--violet-line); background: var(--violet-soft); color: var(--violet-hover); }
.ai-pill:hover { background: #e8e0fe; border-color: var(--violet); }
.pill.primary-pill { border-color: var(--violet-line); background: var(--violet-soft); color: var(--violet-hover); font-weight: 600; }
.pill.primary-pill:hover { background: #e8e0fe; border-color: var(--violet); }

/* ---------- Architectural boundary strip (below the library on home) ---------- */
.roles { width: 100%; max-width: 1120px; margin: 36px auto 12px; padding-top: 24px; border-top: 1px solid var(--line); }
.roles-title { margin: 0 0 14px; color: var(--muted); font-size: 13.5px; text-align: left; }
.roles-title b { color: var(--ink); }
.roles-list { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin: 0; padding: 0; list-style: none; }
.roles-list li {
  position: relative; display: grid; align-content: start; gap: 3px;
  padding: 14px 14px 15px;
  border: 1px solid var(--line); border-top: 3px solid var(--line-strong); border-radius: 14px;
  background: white; box-shadow: var(--shadow-xs);
  animation: rise .4s calc(.04s * var(--n, 0)) var(--ease) both;
  transition: transform .22s var(--ease), box-shadow .22s var(--ease), border-color .22s var(--ease);
}
.roles-list li:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.roles-list li:nth-child(2) { --n: 1; } .roles-list li:nth-child(3) { --n: 2; } .roles-list li:nth-child(4) { --n: 3; } .roles-list li:nth-child(5) { --n: 4; }
.roles-list b { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.roles-list span { font: 700 16.5px/1.25 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: -.015em; }
.roles-list small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.role-you { border-top-color: var(--green) !important; }
.role-you span { color: var(--green); }
.role-ai { border-top-color: var(--violet) !important; }
.role-ai span { color: var(--violet); }
.role-voyage { border-top-color: #0e7490 !important; }
.role-voyage span { color: #0e7490; }
.role-atlas { border-top-color: #15803d !important; }
.role-atlas span { color: #15803d; }
.role-out { border-top-color: var(--ink) !important; }
.role-out span { color: var(--ink); }
@media (max-width: 860px) {
  .roles-list { grid-template-columns: 1fr 1fr; }
  .roles-list li:first-child { grid-column: 1 / -1; }
}

/* ---------- Studio stepper ---------- */
.steps { display: flex; align-items: center; gap: 4px; margin: 0 0 0 auto; padding: 0; list-style: none; counter-reset: st; }
.steps li { counter-increment: st; display: flex; align-items: center; }
.steps li + li::before { content: ""; width: 14px; height: 1.5px; margin: 0 4px; background: var(--line-strong); }
.steps button, .steps span { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 10px 0 4px; border: 1px solid transparent; border-radius: 999px; background: none; color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 600; }
.steps button::before, .steps span::before { content: counter(st); display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--surface-tonal); color: var(--muted); font-size: 11px; font-weight: 700; }
.steps .done::before { content: "✓"; background: var(--green-soft); color: var(--green); }
.steps .now { border-color: var(--green-line); color: var(--ink); background: var(--card); box-shadow: var(--shadow-xs); }
.steps .now::before { background: var(--green); color: white; }
.steps button { cursor: pointer; }
.steps button:hover { border-color: var(--green); color: var(--ink); }
.steps button.next-up { color: var(--green); border-color: var(--green); border-style: dashed; }
.step-hint { margin: 4px 2px 10px; color: var(--muted); font-size: 13.5px; }
.step-hint:empty { display: none; }
.step-hint b { color: var(--ink); font-weight: 600; }

/* Tools with words */
.tool .tool-word { margin-left: 5px; font-size: 12.5px; font-weight: 600; }
.tool:has(.tool-word) { display: inline-flex; flex-direction: row; align-items: center; width: auto; padding: 0 10px 0 8px; white-space: nowrap; }

/* Refine & Moment pickers */
.canvas-card { position: relative; }
.refine-pick { position: absolute; z-index: 40; top: 58px; left: 12px; display: grid; gap: 10px; width: min(440px, calc(100% - 24px)); padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); box-shadow: var(--shadow-lg); animation: rise .22s var(--ease) both; }
.refine-pick-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.refine-pick-title { margin: 0; font-size: 15px; font-weight: 700; color: var(--violet-hover); }
.panel-close { width: 32px; height: 32px; font-size: 18px; flex: none; }
.refine-options { display: grid; gap: 6px; max-height: 250px; overflow-y: auto; }
.refine-option { position: relative; display: grid; grid-template-columns: 72px 1fr; align-items: center; gap: 10px; padding: 6px 8px; border: 1.5px solid var(--line); border-radius: 12px; background: white; text-align: left; font: inherit; cursor: pointer; }
.refine-option:hover { border-color: var(--violet-line); background: #fcfbff; }
.refine-option canvas { width: 72px; height: 48px; border-radius: 7px; background: #fff; border: 1px solid var(--line); }
.refine-option b { display: block; font-size: 13.5px; font-weight: 650; }
.refine-option small { color: var(--muted); font-size: 12px; }
.refine-option[aria-checked="true"] { border-color: var(--violet); background: var(--violet-soft); box-shadow: inset 0 0 0 1px rgba(109, 40, 217, 0.25); }
.refine-combine-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 6px 10px; border-radius: 10px; background: #faf8ff; border: 1px solid var(--violet-line); }
.refine-combine-row[hidden] { display: none; }
.refine-new-wrap { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink); cursor: pointer; }
.refine-new-wrap input { min-height: auto; width: 16px; height: 16px; accent-color: var(--violet); margin: 0; padding: 0; }
.refine-pick > input { min-height: 40px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 10px; font: inherit; font-size: 14px; }
.refine-pick > input:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px rgba(109, 40, 217, 0.14); }
.refine-pick-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.refine-pick-actions small { color: var(--muted); font-size: 12px; line-height: 1.4; }
@media (max-width: 720px) { .steps { margin-left: 0; width: 100%; } .tool .tool-word { display: none; } .tool:has(.tool-word) { width: revert; padding: 0 7px; } }

.tray-plan { display: block; margin-top: 5px; padding: 4px 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.12); color: #ddd6fe; font: 500 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: normal; }

/* ---------- Perspectives: one query, four Voyage views ---------- */
.lenses { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 6px; scrollbar-width: none; }
.lenses[hidden] { display: none; }
.lenses::-webkit-scrollbar { display: none; }
.lens { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: white; font-size: 13px; font-weight: 600; color: var(--ink); }
.lens:hover:not(:disabled) { border-color: var(--line-strong); background: var(--surface-tonal); }
.lens-count { min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--green-soft); color: var(--green); font-size: 11px; font-weight: 700; text-align: center; }
.lens[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: white; }
.lens[aria-selected="true"] .lens-count { background: rgba(255, 255, 255, 0.18); color: var(--lime); }
.rank-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.rank-badge { padding: 2px 7px; border-radius: 6px; background: var(--violet-soft); color: var(--violet-hover); font: 600 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
.rank-badge.miss { background: transparent; color: #9fb1ab; border: 1px dashed var(--line); }

/* ---------- Export ---------- */
.ex-formats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin: 14px 0; }
.ex-format { display: grid; gap: 3px; align-content: start; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: white; text-align: left; }
.ex-format:hover { border-color: var(--line-strong); background: #fafcfa; }
.ex-format b { font: 700 12px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--green); }
.ex-format span { font-weight: 650; font-size: 14.5px; }
.ex-format small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.ex-format[aria-checked="true"] { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); background: var(--green-soft); }
.ex-options { display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; margin: 8px 0 12px; font-size: 13.5px; font-weight: 600; }
.ex-option { display: inline-flex; align-items: center; gap: 8px; }
.ex-option[hidden] { display: none; }
.ex-option select { min-height: 36px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: white; }
.ex-actions { display: flex; gap: 8px; margin-top: 12px; }

/* ---------- Asset page: versions; breakdown: layer by layer ---------- */
.ap-versions .evo-step { position: relative; flex: none; display: grid; gap: 4px; width: 152px; margin: 0; padding: 7px; border: 1px solid var(--line); border-radius: 12px; background: white; scroll-snap-align: start; }
.ap-versions .evo-step img { width: 100%; aspect-ratio: 1000 / 650; object-fit: contain; border-radius: 8px; border: 1px solid var(--line); background: #fafbfa; }
.ap-versions figcaption { font-size: 11.5px; color: var(--muted); }
.ap-versions figcaption b { margin-right: 4px; color: var(--ink); font-size: 13px; }
.ap-versions .mini { position: absolute; top: 10px; right: 10px; min-height: 26px; padding: 0 9px; }
.bd-layers { display: grid; gap: 8px; }
.bd-layer { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.bd-layer canvas { flex: none; width: 96px; height: auto; border: 1px solid var(--line); border-radius: 8px; }
.bd-layer .card-text { flex: 1; min-width: 0; }
.bd-layer small { display: block; color: var(--muted); font-size: 12px; }

/* ---------- AI tools group ---------- */
.ai-group { background: var(--violet-soft); }
.tool.ai-tool { color: var(--violet-hover); font-size: 14px; }
.tool.ai-tool:hover, .tool.ai-tool[aria-expanded="true"] { background: white; box-shadow: var(--shadow-xs); }
@media (max-width: 639px) {
  .ai-group { flex: none; }
  .ai-group .tool { flex: none; min-width: 34px; }
}
.spark-why { margin: 0 0 10px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.spark-why[hidden] { display: none; }
.spark-card.loading .nudge-prompt { color: var(--muted); animation: breathe 1.4s ease-in-out infinite; }
.moment-pick .examples { display: flex; flex-wrap: wrap; gap: 6px; }
.moment-pick .voice-input { display: flex; gap: 6px; }
.moment-pick .voice-input input { flex: 1; min-width: 0; }
.starter-spark { margin-left: auto; margin-right: 6px; padding: 4px 11px; border: 1px solid var(--violet-line); border-radius: 999px; background: var(--violet-soft); color: var(--violet-hover); font-size: 12px; font-weight: 600; pointer-events: auto; }
.starter-spark:hover { background: #e8e0fe; }

/* Sparks shelf */
.ap-sparks { display: grid; grid-template-columns: repeat(auto-fill, minmax(195px, 1fr)); gap: 10px; }
.ap-spark { position: relative; display: grid; align-content: start; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: white; animation: rise .3s calc(.04s * var(--i)) var(--ease) both; }
.ap-spark.idea { background: linear-gradient(160deg, #fffcf0, var(--violet-soft)); border-color: var(--violet-line); }
.ap-spark-figure img { display: block; width: 100%; aspect-ratio: 1000 / 650; object-fit: contain; border-radius: 10px; background: #fafbfa; border: 1px solid var(--line); }
.ap-spark.reference .ap-spark-figure img { aspect-ratio: 1; }
.ap-spark strong { display: block; font-size: 14px; font-weight: 650; line-height: 1.3; }
.ap-spark-kind { display: block; margin-bottom: 3px; color: var(--violet); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.ap-spark .why { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.ap-spark-remove { position: absolute; top: 8px; right: 8px; width: 26px; min-height: 26px; padding: 0; border-radius: 50%; background: rgba(255, 255, 255, 0.9); }

/* Patterns */
.patterns-sheet { width: min(980px, calc(100vw - 24px)); }
.pt-body { display: grid; gap: 6px; }
.pt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.pt-pair, .pt-theme { display: grid; align-content: start; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: white; box-shadow: var(--shadow-xs); animation: rise .3s var(--ease) both; }
.pt-faces { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; }
.pt-face { display: grid; gap: 5px; padding: 0; border: 0; background: none; color: var(--ink); font-size: 12.5px; font-weight: 600; text-align: left; }
.pt-face img, .pt-mini img { display: block; width: 100%; aspect-ratio: 1000 / 650; object-fit: contain; border: 1px solid var(--line); border-radius: 10px; background: #fafbfa; }
.pt-face span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pt-pair .why, .pt-theme .why { margin: 0; color: var(--muted); font-size: 13px; }
.pt-scores { margin: 0; color: var(--violet); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pt-theme strong { font-size: 15px; font-weight: 700; text-transform: capitalize; }
.pt-theme small { color: var(--muted); font-size: 12px; }
.pt-strip { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; }
.pt-mini { padding: 0; border: 0; background: none; }
.pt-theme .mini { justify-self: start; }

/* ---------- The AI rail (wide screens): generous width, zero cramped buttons ---------- */
.ai-rail { display: none; }
@media (min-width: 1024px) {
  .canvas-body { grid-template-columns: minmax(0, 1fr) 0 0; transition: grid-template-columns .3s var(--ease); }
  .canvas-body.rail-open { grid-template-columns: minmax(0, 1fr) 324px 0; }
  .canvas-body:has(.layers.open) { grid-template-columns: minmax(0, 1fr) 0 228px; }
  .canvas-body.rail-open:has(.layers.open) { grid-template-columns: minmax(0, 1fr) 324px 228px; }
  .focus-mode .canvas-body:has(.layers.open) { grid-template-columns: minmax(0, 1fr) 0 240px; }
  .focus-mode .canvas-body.rail-open:has(.layers.open) { grid-template-columns: minmax(0, 1fr) 324px 240px; }
  .ai-rail { display: grid; align-content: start; gap: 12px; min-width: 0; align-self: stretch; justify-self: stretch; overflow: hidden; }
  .canvas-body.rail-open .ai-rail { contain: size; padding: 14px; overflow-y: auto; border-left: 1px solid var(--line); background: linear-gradient(180deg, #f7f4ff 0%, #fafcfa 160px); }
  .ai-rail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
  .ai-rail-head p { display: grid; gap: 2px; margin: 0; font-size: 13px; color: var(--violet-hover); }
  .ai-rail-head small { color: var(--muted); font-size: 12px; }
  .ai-rail-head .close { flex: none; width: 28px; height: 28px; font-size: 17px; }
  .ai-rail > .nudge, .ai-rail > .refine-pick { position: static; inset: auto; transform: none; width: auto; margin: 0; padding: 16px; border: 1px solid var(--violet-line); border-radius: 16px;
    background: white; box-shadow: var(--shadow-sm); backdrop-filter: none; animation: railIn .3s var(--ease) both; }
  .ai-rail > .nudge.dealt { animation: railIn .36s var(--spring) both; }
  .ai-rail .nudge-prompt { font-size: 18px; }
  .ai-rail .nudge-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .ai-rail .nudge-actions #spark-go { grid-column: 1 / -1; }
  .ai-rail .nudge-actions .scene-go { width: 100%; min-height: 38px; padding: 0 12px; font-size: 13px; }
  .ai-rail .spark-card.kept .nudge-fine { display: none; }
  .ai-rail .spark-card.kept { border-color: #bbf7d0; background: linear-gradient(180deg, #f0fdf4 0%, white 70%); }
  .ai-rail .refine-options { grid-template-columns: 1fr; }
  .ai-rail .refine-pick-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .ai-rail .refine-pick-actions .primary { width: 100%; }
  .ai-rail .refine-pick-actions small { grid-column: 1 / -1; }
  .ai-rail .spark-card.kept #spark-go { background: #dcfce7; color: #166534; box-shadow: none; opacity: 1; }
}
@keyframes railIn { from { opacity: 0; transform: translateX(16px); } }

/* Live AI status indicator on toolbar buttons */
.tool.ai-tool.working::after, .tool.ai-tool.ready::after { content: ""; position: absolute; top: 3px; right: 3px; width: 6px; height: 6px; border-radius: 50%; background: var(--violet); }
.tool.ai-tool.working::after { animation: aiPulse 1.2s ease-in-out infinite; }
.tool.ai-tool.ready::after { background: #10b981; animation: readyPing 2.2s ease-out infinite; }
@keyframes aiPulse { 0%, 100% { transform: scale(.85); box-shadow: 0 0 0 0 rgba(109, 40, 217, 0.5); } 50% { transform: scale(1.15); box-shadow: 0 0 0 4px rgba(109, 40, 217, 0); } }
@keyframes readyPing { 0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55); } 75%, 100% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); } }

/* Drop zone */
.drop-zone { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 24px; background: rgba(243, 239, 254, 0.88);
  backdrop-filter: blur(6px); pointer-events: none; animation: fadeIn .18s var(--ease) both; }
.drop-zone[hidden] { display: none; }
.drop-zone > div { display: grid; gap: 10px; max-width: 500px; padding: 40px 44px; border: 2px dashed var(--violet); border-radius: 24px;
  background: white; text-align: center; box-shadow: var(--shadow-lg); animation: rise .28s var(--spring) both; }
.drop-zone b { font: 700 clamp(24px, 3.6vw, 32px)/1.15 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: -.025em; color: var(--violet-hover); }
.drop-zone span { color: var(--muted); font-size: 14.5px; line-height: 1.5; }
@keyframes fadeIn { from { opacity: 0; } }

/* ---------- Library Organize, Type/Sort Bar, Bulk Toolbar ---------- */
.catalog-pill { border-color: var(--green-line); background: var(--green-soft); color: var(--green); }
.catalog-pill:hover { background: #d6efe9; border-color: var(--green); }
.type-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-top: 6px; }
.type-filters { display: flex; flex-wrap: wrap; gap: 5px; }
.sort-control { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.sort-control select { min-height: 30px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; background: white; font-size: 12.5px; color: var(--ink); }

.bulk-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px;
  margin-top: 10px; padding: 10px 14px;
  border: 1px solid var(--green-line); border-radius: 14px;
  background: var(--green-soft); box-shadow: var(--shadow-sm);
  animation: rise .2s var(--ease) both;
}
.bulk-bar[hidden] { display: none; }
.bulk-count { font-size: 13px; font-weight: 700; color: var(--green); margin-right: 4px; }
.bulk-select, .bulk-tag { min-height: 30px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 999px; background: white; font-size: 12.5px; }
.bulk-tag { width: 130px; }
.bulk-bar #bulk-done { margin-left: auto; }

.card-check {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  display: grid; place-items: center; width: 26px; height: 26px;
  border: 2px solid white; border-radius: 50%;
  background: rgba(24, 34, 30, 0.45); color: white;
  box-shadow: var(--shadow-xs); opacity: 0; transform: scale(.85); pointer-events: none;
  transition: opacity .16s var(--ease), transform .18s var(--spring), background-color .16s;
}
.card-check svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
@media (hover: hover) { .card:hover .card-check { opacity: .92; transform: scale(1); pointer-events: auto; } }
.results.selecting .card-check, .card.is-selected .card-check, .cat-card .card-check { opacity: 1; transform: scale(1); pointer-events: auto; }
.card.is-selected .card-check { background: var(--green); border-color: white; }
.card.is-selected .card-check svg { opacity: 1; }
.card.is-selected { border-color: var(--green); box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.22), var(--shadow); }

.icon-mini { display: inline-grid; place-items: center; width: 30px; min-height: 30px; padding: 0; margin-left: auto; }
.icon-mini svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.danger-mini { border-color: transparent; background: transparent; color: var(--muted); }
.danger-mini:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); border-color: #f6b8b6; }
.danger-outline { border-color: #f6b8b6; background: white; color: var(--danger); }
.danger-outline:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }
.pill.danger { background: var(--danger); border-color: var(--danger); color: white; }
.pill.danger:hover:not(:disabled) { background: #a81c19; }

.empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 12px; }

/* ---------- Search Scores (bars + badges) ---------- */
.rank-summary { display: grid; gap: 5px; margin-top: 4px; }
.score-meter { display: flex; align-items: center; gap: 7px; font-size: 11.5px; font-weight: 650; color: var(--muted); font-variant-numeric: tabular-nums; cursor: help; }
.score-meter.strong { color: var(--green); }
.score-meter-track { flex: 1; min-width: 48px; height: 5px; border-radius: 999px; background: var(--surface-tonal); overflow: hidden; }
.score-meter-fill { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #0f766e, #6d28d9); transform-origin: left; animation: grow .55s var(--ease) both; }
.score-meter-val { flex: none; white-space: nowrap; }

/* ---------- Asset Page inline organize form ---------- */
.ap-meta-form { display: grid; gap: 8px; margin-top: 14px; padding: 14px 16px; border: 1px solid var(--green-line); border-radius: 14px; background: #fafcfa; animation: rise .2s var(--ease) both; }
.ap-meta-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 640px) { .ap-meta-grid { grid-template-columns: 1.5fr 1fr; } }
.ap-meta-form label { display: block; font-size: 12px; font-weight: 650; color: var(--ink); margin-bottom: 4px; }
.ap-meta-form label small { font-weight: 400; color: var(--muted); }
.ap-meta-form input, .ap-meta-form select, .ap-meta-form textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 9px; background: white; font-size: 14px; }
.ap-meta-actions { display: flex; gap: 8px; margin-top: 4px; }

/* ---------- Pre-baked Starter Assets Catalog ---------- */
.catalog-sheet { width: min(1040px, calc(100vw - 24px)); }
.cat-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 16px; }
.cat-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.cat-search { min-width: 170px; height: 34px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: white; font-size: 13px; outline: none; }
.cat-search:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12); }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 14px; }
.cat-card .thumb-button { cursor: pointer; }

/* ---------- Side-by-side Reference Card ---------- */
.ref-prompt { margin: 6px 0 8px; font-size: 16px; font-weight: 700; color: var(--ink); line-height: 1.25; }
.ref-stage {
  position: relative; display: grid; place-items: center; min-height: 160px; margin-bottom: 10px;
  border: 1px solid var(--line); border-radius: 12px; background: #fafbfa; overflow: hidden;
}
.ref-stage img { display: block; width: 100%; max-height: 240px; object-fit: contain; animation: fade .28s both; }
.ref-loading { padding: 16px; font-size: 13px; color: var(--violet-hover); font-weight: 600; text-align: center; animation: breathe 1.3s ease-in-out infinite; }
.ref-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.ref-actions #ref-keep { grid-column: 1 / -1; }
@media (min-width: 1024px) {
  .ai-rail .ref-stage img { max-height: 220px; }
}

/* ---------- Confirm dialog ---------- */
.confirm-sheet {
  width: min(420px, calc(100vw - 32px)); padding: 22px 24px;
  border: 1px solid var(--line); border-radius: 20px; background: white; color: var(--ink);
  box-shadow: var(--shadow-lg); animation: popIn .22s var(--spring) both;
}
.confirm-sheet::backdrop { background: rgba(15, 23, 20, 0.45); backdrop-filter: blur(4px); }
.confirm-sheet h3 { margin: 0 0 6px; font-size: 18px; font-weight: 700; letter-spacing: -.015em; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ---------- Chain color pill & Fill cursor ---------- */
.chain-pill {
  display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: 999px; background: white;
  font-size: 12px; font-weight: 650; color: var(--muted); white-space: nowrap;
  transition: border-color .18s var(--ease), background-color .18s var(--ease), color .18s var(--ease), box-shadow .18s var(--ease);
}
.chain-pill:hover { background: var(--surface-tonal); color: var(--ink); border-color: var(--line-strong); }
.chain-pill[aria-pressed="true"] {
  border-color: var(--violet); background: var(--violet-soft); color: var(--violet-hover);
  box-shadow: 0 0 0 2px rgba(109, 40, 217, 0.16);
}
canvas.fill-mode { cursor: cell; }
canvas.magic-mode { cursor: crosshair; }
.tool.magic-tool[aria-pressed="true"] { background: var(--violet-soft); color: var(--violet-hover); box-shadow: 0 0 0 1px var(--violet-line), var(--shadow-sm); }
.ps-stage canvas.magic-ready { cursor: crosshair; }
.ps-hint { margin: 8px 0 0; font-size: 12px; color: var(--violet-hover); font-weight: 500; }

/* ---------- Photo to B&W Pencil Sketch Sheet ---------- */
.photo-sketch-sheet { width: min(680px, calc(100vw - 24px)); }
.ps-stage {
  display: grid; place-items: center; margin-top: 14px; min-height: 200px;
  border: 1px solid var(--line); border-radius: 14px;
  background: repeating-conic-gradient(#f2f5f3 0% 25%, #ffffff 0% 50%) 0 0 / 18px 18px;
  overflow: hidden;
}
.ps-stage canvas { display: block; width: 100%; max-height: 320px; object-fit: contain; height: auto; aspect-ratio: auto; cursor: default; }
.ps-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-top: 12px; }
.ps-strength { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink); }
.ps-strength input[type="range"] { width: 120px; accent-color: var(--green); }
.ps-strength output { min-width: 28px; font-variant-numeric: tabular-nums; color: var(--green); }
.ps-modes { display: flex; flex-wrap: wrap; gap: 6px; }
.ps-modes .pill[aria-pressed="true"] { border-color: var(--violet); background: var(--violet-soft); color: var(--violet-hover); }

/* ---------- Touch & Mobile Drawers / Bottom Sheets ---------- */
.drawer-scrim { position: fixed; inset: 0; z-index: 88; background: rgba(15, 23, 20, 0.38); backdrop-filter: blur(3px); animation: fade .2s both; }
.drawer-scrim[hidden] { display: none !important; }
.layers-close { display: none; }

@media (max-width: 1023px) {
  .layers-close { display: grid; }
  .layers { display: none; }
  .layers.open {
    display: block; position: fixed; inset: 0 0 0 auto; z-index: 95;
    width: min(340px, 88vw); height: 100dvh; border-top: 0; border-left: 1px solid var(--line);
    padding: max(14px, env(safe-area-inset-top)) 14px max(22px, env(safe-area-inset-bottom));
    background: #ffffff; box-shadow: -16px 0 48px rgba(15, 23, 20, 0.22);
    overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
    animation: mobileDrawerIn .24s var(--ease) both;
  }
  @keyframes mobileDrawerIn { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
  .nudge, .refine-pick {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; transform: none;
    width: 100%; max-width: 100%; max-height: 82dvh; margin: 0; z-index: 92;
    border-radius: 24px 24px 0 0; border: 0; border-top: 1px solid var(--violet-line);
    padding: 12px 16px max(22px, env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.99); box-shadow: 0 -12px 44px rgba(15, 23, 20, 0.24);
    overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
    animation: sheetSlideUp .26s var(--spring) both;
  }
  .nudge::before, .refine-pick::before {
    content: ""; display: block; width: 38px; height: 4px; margin: 0 auto 10px;
    border-radius: 999px; background: var(--line-strong);
  }
  .nudge.dealt { animation: sheetSlideUp .28s var(--spring) both; }
  @keyframes sheetSlideUp { from { opacity: 0; transform: translateY(28px); } to { opacity: 1; transform: none; } }
  .close, .panel-close, .layers-close { min-width: 44px; min-height: 44px; font-size: 22px; }
  .tool, .icon-button, .layers-toggle, .focus-button { min-height: 40px; }
  .chain-pill { min-height: 36px; padding: 0 12px; }
}
@media (pointer: coarse) {
  .close, .panel-close, .layers-close { min-width: 44px; min-height: 44px; }
  .chain-pill { min-height: 38px; }
}



