/* Create Studio — light/dark theme after Christian's reference designs (soft swirl, pill controls, long rounded bar). */
:root {
  --bg: #f4f3f1;
  --text: #161514;
  --muted: #8a8580;
  --faint: rgba(22, 21, 20, 0.08);
  --line: rgba(22, 21, 20, 0.12);
  --surface: rgba(255, 255, 255, 0.55);
  --surface-strong: rgba(255, 255, 255, 0.78);
  --chip: rgba(22, 21, 20, 0.06);
  --accent: #161514;
  --accent-text: #f4f3f1;
  --mention-bg: rgba(196, 106, 43, 0.16);
  --mention-text: #a2531c;
  --danger: #b4412b;
  --swirl-a: #f3ece6;
  --swirl-b: #e9b49a;
  --swirl-c: #c46a2b;
  --swirl-d: #d9cfc4;
  --shadow: 0 18px 50px rgba(60, 40, 20, 0.12);
  --radius: 22px;
  --font: -apple-system, "SF Pro Display", "Inter", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #141312;
  --text: #f2efe9;
  --muted: #8f8981;
  --faint: rgba(242, 239, 233, 0.07);
  --line: rgba(242, 239, 233, 0.12);
  --surface: rgba(30, 28, 26, 0.55);
  --surface-strong: rgba(28, 26, 24, 0.82);
  --chip: rgba(242, 239, 233, 0.07);
  --accent: #f2efe9;
  --accent-text: #141312;
  --mention-bg: rgba(226, 140, 72, 0.2);
  --mention-text: #f0a86c;
  --danger: #e2735c;
  --swirl-a: #1b1918;
  --swirl-b: #6b4a33;
  --swirl-c: #c2793a;
  --swirl-d: #3a332d;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
[hidden] { display: none !important; }

/* Background: drifting swirl (CSS) with an optional video layer on top. */
.bg { position: fixed; inset: 0; z-index: -2; overflow: hidden; background: var(--bg); }
.bg::before, .bg::after {
  content: ""; position: absolute; inset: -30%;
  background:
    radial-gradient(ellipse 38% 30% at 50% 52%, var(--swirl-a) 0%, transparent 70%),
    conic-gradient(from 210deg at 50% 55%, var(--swirl-d), var(--swirl-b), var(--swirl-c), var(--swirl-b), var(--swirl-d), var(--swirl-a), var(--swirl-d));
  filter: blur(60px); opacity: 0.9; animation: drift 40s ease-in-out infinite alternate;
}
.bg::after {
  background: radial-gradient(ellipse 42% 34% at 50% 50%, var(--swirl-a) 10%, transparent 72%);
  filter: blur(30px); opacity: 1; animation-duration: 55s; animation-direction: alternate-reverse;
}
.bg video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 1.2s ease; }
.bg video.ready { opacity: 1; }
@keyframes drift { from { transform: rotate(0deg) scale(1); } to { transform: rotate(28deg) scale(1.08); } }
@media (prefers-reduced-motion: reduce) { .bg::before, .bg::after { animation: none; } }

/* Top bar */
.topbar {
  position: fixed; top: 20px; left: 20px; right: 20px; z-index: 20; height: 54px; border-radius: 999px;
  display: flex; align-items: center; gap: 14px; padding: 0 10px 0 16px;
  background: var(--surface); border: 1px solid var(--line); backdrop-filter: blur(24px) saturate(1.2); -webkit-backdrop-filter: blur(24px) saturate(1.2);
}
.theme-switch { width: 34px; height: 18px; border-radius: 999px; background: var(--chip); border: 1px solid var(--line); position: relative; flex: none; }
.theme-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--text); transition: transform 0.25s ease; }
:root[data-theme="dark"] .theme-switch::after { transform: translateX(16px); }
.tabs { display: flex; gap: 4px; margin: 0 auto; }
.tab { padding: 8px 16px; border-radius: 999px; color: var(--muted); font-weight: 550; letter-spacing: -0.01em; transition: background 0.2s, color 0.2s; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--accent); color: var(--accent-text); }
.account { position: relative; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--chip); border: 1px solid var(--line); font-weight: 650; text-transform: uppercase; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 200px; padding: 6px; border-radius: 16px; z-index: 40;
  background: var(--surface-strong); border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
}
.menu .who { padding: 8px 10px; color: var(--muted); font-size: 12px; word-break: break-all; }
.menu button, .menu .option { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 9px 10px; border-radius: 10px; }
.menu button:hover, .menu .option:hover, .menu .option.on { background: var(--chip); }

/* Pages */
main { padding: 96px 20px 260px; margin: 0; }
.hero { min-height: calc(100vh - 380px); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.hero h1 { font-size: clamp(34px, 5vw, 56px); line-height: 1.04; letter-spacing: -0.035em; font-weight: 650; margin: 0; }
.hero h1 span { color: var(--muted); display: block; }
.hero p { color: var(--muted); margin: 16px 0 0; }

.library-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 16px; flex-wrap: wrap; }
.segmented { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.segmented button { padding: 7px 14px; border-radius: 999px; color: var(--muted); font-weight: 550; }
.segmented button.on { background: var(--accent); color: var(--accent-text); }

/* Grid: newest top-left to oldest bottom-right */
.grid { --row-h: 230px; display: flex; flex-wrap: wrap; gap: 6px; }
.grid::after { content: ""; flex-grow: 1000000; }
.tile { --ar: 1; position: relative; flex: var(--ar) 1 calc(var(--ar) * var(--row-h)); aspect-ratio: var(--ar); min-width: 0; max-width: 100%; border-radius: 12px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); }
.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .overlay { position: absolute; inset: 0; opacity: 0; transition: opacity 0.2s; background: linear-gradient(to bottom, rgba(0,0,0,0.35), transparent 30%, transparent 65%, rgba(0,0,0,0.45)); }
.tile:hover .overlay, .tile:focus-within .overlay { opacity: 1; }
.icon-btn { position: absolute; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: rgba(20, 19, 18, 0.55); color: #fff; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.icon-btn:hover { background: rgba(20, 19, 18, 0.8); }
.icon-btn.download { top: 10px; right: 10px; }
.overlay .pill-btn.recreate { position: absolute; left: 10px; bottom: 10px; background: rgba(255,255,255,0.92); color: #161514; }
.tile .meta { position: absolute; right: 10px; bottom: 12px; color: #fff; font-size: 11px; opacity: 0.85; }
.tile.pending { display: grid; place-items: center; text-align: center; }
.tile.pending::before { content: ""; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, var(--faint) 50%, transparent 70%); background-size: 220% 100%; animation: shimmer 1.6s linear infinite; }
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }
.tile .status { position: relative; color: var(--muted); font-size: 12px; line-height: 1.6; padding: 0 16px; }
.tile .status strong { display: block; color: var(--text); font-weight: 600; font-size: 13px; }
.progress { position: absolute; left: 14px; right: 14px; bottom: 14px; height: 3px; border-radius: 3px; background: var(--faint); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--text); border-radius: 3px; transition: width 1s linear; }
.tile.failed { display: flex; flex-direction: column; justify-content: center; gap: 10px; padding: 18px; color: var(--muted); font-size: 12px; }
.tile.failed strong { color: var(--danger); font-size: 13px; }
.tile.expired { display: grid; place-items: center; color: var(--muted); font-size: 12px; text-align: center; padding: 16px; }
.sentinel { height: 40px; }
.empty-note { color: var(--muted); text-align: center; padding: 40px 0; }

/* Buttons */
.pill-btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 999px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.pill-btn.primary { background: var(--accent); color: var(--accent-text); }
.pill-btn.ghost { border: 1px solid var(--line); background: var(--chip); }
.pill-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Composer */
.composer {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 15; width: min(1040px, calc(100% - 32px));
  border-radius: 26px; padding: 14px; background: var(--surface-strong); border: 1px solid var(--line); box-shadow: var(--shadow);
  backdrop-filter: blur(28px) saturate(1.2); -webkit-backdrop-filter: blur(28px) saturate(1.2);
}
.composer.dragging { outline: 2px dashed var(--muted); outline-offset: -8px; }
.composer-top { display: flex; gap: 12px; align-items: flex-start; }
.refs { display: flex; gap: 8px; flex-wrap: wrap; max-width: 46%; }
.thumb { position: relative; width: 56px; height: 56px; border-radius: 12px; overflow: hidden; background: var(--chip); border: 1px solid var(--line); flex: none; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .n { position: absolute; left: 4px; bottom: 3px; font-size: 10px; font-weight: 700; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.6); }
.thumb .x { position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%; background: rgba(0,0,0,0.6); color: #fff; display: none; place-items: center; font-size: 12px; line-height: 1; }
.thumb:hover .x { display: grid; }
.thumb.loading::after { content: ""; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, var(--faint) 50%, transparent 70%); background-size: 220% 100%; animation: shimmer 1.2s linear infinite; }
.thumb.missing { border: 1.5px dashed var(--danger); display: grid; place-items: center; font-size: 9px; text-align: center; color: var(--danger); padding: 2px; }
.add-thumb { width: 56px; height: 56px; border-radius: 12px; border: 1.5px dashed var(--line); color: var(--muted); display: grid; place-items: center; font-size: 22px; flex: none; }
.add-thumb:hover { color: var(--text); border-color: var(--muted); }
.frame-slot { width: 74px; height: 74px; border-radius: 14px; border: 1.5px dashed var(--line); color: var(--muted); display: grid; place-items: center; text-align: center; font-size: 11px; line-height: 1.3; position: relative; overflow: hidden; flex: none; }
.frame-slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.frame-slot:disabled { opacity: 0.4; }
.frame-slot .x { position: absolute; top: 4px; right: 4px; z-index: 2; width: 18px; height: 18px; border-radius: 50%; background: rgba(0,0,0,0.6); color: #fff; display: grid; place-items: center; font-size: 12px; }

.prompt-wrap { position: relative; flex: 1; min-width: 0; }
.prompt { min-height: 56px; max-height: 180px; overflow-y: auto; padding: 8px 4px; outline: none; font-size: 15px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.prompt:empty::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
.mention { display: inline-block; padding: 0 6px; margin: 0 1px; border-radius: 6px; background: var(--mention-bg); color: var(--mention-text); font-weight: 600; user-select: all; }
.mention-menu { position: absolute; left: 0; right: auto; top: auto; bottom: calc(100% + 6px); width: 200px; min-width: 0; max-height: 260px; overflow-y: auto; }
.mention-menu .option { padding: 6px 8px; }
.mention-menu .option img { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; }

.controls { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.control-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: 1; min-width: 0; }
.control { position: relative; }
.control > button { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px; background: var(--chip); border: 1px solid var(--line); font-weight: 550; white-space: nowrap; }
.control > button .label { color: var(--muted); font-weight: 500; }
.control .menu { top: auto; bottom: calc(100% + 8px); left: 0; right: auto; max-height: 320px; overflow-y: auto; }
.stepper { display: inline-flex; align-items: center; height: 34px; border-radius: 999px; background: var(--chip); border: 1px solid var(--line); }
.stepper button { width: 30px; height: 32px; font-size: 16px; color: var(--muted); }
.stepper button:hover { color: var(--text); }
.stepper span { min-width: 34px; text-align: center; font-weight: 600; }
.style-pill { height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-weight: 550; }
.style-pill.on { background: var(--mention-bg); color: var(--mention-text); border-color: transparent; }
.spacer { flex: 1; }
.generate { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; min-width: 156px; height: 46px; padding: 0 20px; border-radius: 999px; background: var(--accent); color: var(--accent-text); font-weight: 650; letter-spacing: -0.01em; line-height: 1.15; }
.generate small { font-weight: 500; opacity: 0.7; font-size: 11px; }
.generate:disabled { opacity: 0.45; cursor: not-allowed; }
.composer .error { color: var(--danger); font-size: 12px; margin-top: 8px; }
.composer .note { color: var(--muted); font-size: 12px; margin-top: 8px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(380px, 100%); text-align: center; }
.login-card h1 { font-size: clamp(34px, 6vw, 48px); line-height: 1.04; letter-spacing: -0.035em; font-weight: 650; margin: 0 0 28px; }
.login-card h1 span { display: block; color: var(--muted); }
.login-card form { display: grid; gap: 10px; }
.field { height: 46px; border-radius: 999px; padding: 0 18px; border: 1px solid var(--line); background: var(--surface-strong); outline: none; backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.field:focus { border-color: var(--muted); }
.login-card .pill-btn { height: 46px; justify-content: center; font-size: 15px; }
.login-card .msg { min-height: 20px; font-size: 13px; color: var(--danger); margin-top: 6px; }
.login-card .hint { color: var(--muted); font-size: 12px; margin-top: 16px; }
.login-top { position: fixed; top: 20px; left: 20px; right: 20px; }

@media (max-width: 720px) {
  .topbar { left: 10px; right: 10px; top: 10px; gap: 8px; padding: 0 6px 0 12px; }
  .tab { padding: 8px 11px; }
  main { padding: 80px 10px 340px; }
  .grid { --row-h: 150px; }
  .composer { bottom: 10px; width: calc(100% - 20px); padding: 10px; }
  .composer-top { flex-direction: column; }
  .refs { max-width: 100%; }
  .generate { width: 100%; }
}

/* KIE balance (owner only), top right */
.balance { position: relative; display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; border-radius: 999px; background: var(--chip); border: 1px solid var(--line); font-weight: 600; font-variant-numeric: tabular-nums; cursor: default; outline: none; }
.balance-dot { width: 8px; height: 8px; border-radius: 50%; background: #3f9a5b; box-shadow: 0 0 0 3px rgba(63, 154, 91, 0.18); }
.balance.low .balance-dot { background: #d9822b; box-shadow: 0 0 0 3px rgba(217, 130, 43, 0.2); }
.balance.empty .balance-dot { background: var(--danger); box-shadow: 0 0 0 3px rgba(180, 65, 43, 0.2); }
.balance-tip { position: absolute; right: 0; top: calc(100% + 10px); width: 290px; background: var(--bg) !important; padding: 12px 14px; border-radius: 14px; font-weight: 500; line-height: 1.5; font-size: 13px; color: var(--text);
  background: var(--surface-strong); border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  opacity: 0; transform: translateY(-4px); pointer-events: none; transition: opacity 0.15s, transform 0.15s; z-index: 40; }
.balance-tip strong { display: block; font-size: 15px; }
.balance-tip span { color: var(--muted); display: block; }
.balance:hover .balance-tip, .balance:focus .balance-tip { opacity: 1; transform: none; }
@media (max-width: 720px) { .balance { padding: 0 9px; } .balance-tip { right: -44px; } }

.style-control > button.on { background: var(--mention-bg); color: var(--mention-text); border-color: transparent; }
.style-control > button.on .label { color: inherit; opacity: 0.75; }
.control .menu .option { min-width: 230px; }

/* Full-screen viewer (click a finished tile) */
.viewer { position: fixed; inset: 0; z-index: 60; display: grid; grid-template-columns: 56px 1fr 56px 360px; align-items: stretch; gap: 0;
  background: rgba(12, 11, 10, 0.88); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); color: #f2efe9; }
.viewer-media { display: grid; place-items: center; padding: 24px 8px; min-width: 0; min-height: 0; cursor: zoom-out; }
.viewer-media img, .viewer-media video { max-width: 100%; max-height: calc(100vh - 48px); object-fit: contain; border-radius: 10px; cursor: default; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.viewer-nav { align-self: center; justify-self: center; width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,0.08); color: #f2efe9; font-size: 26px; line-height: 1; }
.viewer-nav:hover { background: rgba(255,255,255,0.16); }
.viewer-nav:disabled { opacity: 0.2; cursor: default; }
.viewer-panel { margin: 14px 14px 14px 0; padding: 14px; border-radius: 20px; background: rgba(34, 32, 30, 0.92); border: 1px solid rgba(242,239,233,0.1); display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.viewer-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.viewer-model strong { display: block; font-size: 15px; letter-spacing: -0.01em; }
.viewer-model span { color: #8f8981; font-size: 12px; }
.viewer-close { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #f2efe9; background: rgba(255,255,255,0.06); }
.viewer-close:hover { background: rgba(255,255,255,0.14); }
.viewer-card { padding: 12px; border-radius: 14px; background: rgba(255,255,255,0.04); border: 1px solid rgba(242,239,233,0.07); }
.viewer-label { display: flex; align-items: center; justify-content: space-between; color: #8f8981; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 10px; }
.viewer-label .pill-btn { height: 28px; padding: 0 10px; text-transform: none; letter-spacing: 0; color: #f2efe9; border-color: rgba(242,239,233,0.14); background: rgba(255,255,255,0.05); }
.viewer-refs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.viewer-refs:empty { display: none; }
.viewer-refs .thumb { width: 64px; height: 64px; border-color: rgba(242,239,233,0.12); }
.viewer-prompt { font-size: 14px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; max-height: 38vh; overflow-y: auto; }
.viewer .mention { background: rgba(226, 140, 72, 0.2); color: #f0a86c; }
.viewer-details { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; margin: 0; font-size: 13px; }
.viewer-details dt { color: #8f8981; }
.viewer-details dd { margin: 0; text-align: right; }
.viewer-actions { margin-top: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.viewer-actions .pill-btn { height: 42px; justify-content: center; text-decoration: none; }
.viewer-actions .primary { background: #f2efe9; color: #141312; }
.viewer-actions .ghost { color: #f2efe9; border-color: rgba(242,239,233,0.14); background: rgba(255,255,255,0.05); }
.tile[data-state="success"] { cursor: zoom-in; }
@media (max-width: 900px) {
  .viewer { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; overflow-y: auto; }
  .viewer-nav { display: none; }
  .viewer-media { padding: 12px; }
  .viewer-media img, .viewer-media video { max-height: 60vh; }
  .viewer-panel { margin: 0 10px 10px; }
}

/* Logo (black on light, white on dark) */
.logo { display: inline-flex; align-items: center; height: 54px; }
.logo img { height: 21px; width: auto; display: block; }
.logo .logo-on-dark { display: none; }
:root[data-theme="dark"] .logo .logo-on-light { display: none; }
:root[data-theme="dark"] .logo .logo-on-dark { display: block; }

/* Trash on hover, and the undo toast */
.icon-btn.trash { top: 10px; right: 50px; }
.tile.failed .icon-btn.trash { top: 10px; right: 10px; opacity: 0; transition: opacity 0.2s; }
.tile.failed:hover .icon-btn.trash { opacity: 1; }
.toast { position: fixed; left: 50%; bottom: 210px; transform: translateX(-50%); z-index: 70; display: flex; align-items: center; gap: 14px; padding: 8px 8px 8px 16px; border-radius: 999px;
  background: var(--surface-strong); border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); font-weight: 550; }
@media (max-width: 720px) { .logo { display: none; } .toast { bottom: 360px; } }

/* "Last downloaded" / "Last viewed" badges */
.tile-badge { position: absolute; z-index: 2; max-width: calc(100% - 12px); overflow: hidden; text-overflow: ellipsis; display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 10px; border-radius: 999px;
  background: rgba(30, 28, 26, 0.72); color: #fff; font-size: 11px; font-weight: 600; white-space: nowrap; pointer-events: none;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: 0 4px 14px rgba(0,0,0,0.25); }
.tile-badge i { width: 6px; height: 6px; border-radius: 50%; background: #fff; }
.badge-downloaded { top: 10px; left: 50%; transform: translateX(-50%); }
.badge-viewed { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.badge-viewed i { background: none; border: 1.5px solid #fff; width: 8px; height: 8px; }
.tile.is-last-viewed::after { content: ""; position: absolute; inset: 0; background: rgba(120, 116, 112, 0.42); pointer-events: none; transition: opacity 0.2s; }
.tile.is-last-viewed:hover::after, .tile.is-last-viewed:hover .badge-viewed { opacity: 0; }
.tile:hover .badge-downloaded { opacity: 0; }

/* Zoom slider (top right): five sizes, from many small tiles to a few large ones */
.zoom { position: fixed; top: 86px; right: 20px; z-index: 12; display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 14px 0 10px; border-radius: 999px;
  background: var(--surface-strong); border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); color: var(--muted); }
.zoom input { -webkit-appearance: none; appearance: none; width: 120px; height: 4px; border-radius: 4px; background: var(--faint); outline: none; cursor: pointer; }
.zoom input::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--text); border: 0; box-shadow: 0 1px 4px rgba(0,0,0,0.3); }
.zoom input::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--text); border: 0; }
main { padding-top: 136px; }
@media (max-width: 720px) { .zoom { top: 74px; right: 10px; } .zoom input { width: 90px; } main { padding-top: 124px; } }

/* Small modal (OpenAI balance) */
.modal-backdrop { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; background: rgba(12, 11, 10, 0.5); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.modal { width: min(400px, 100%); display: grid; gap: 12px; padding: 20px; border-radius: 22px; background: var(--surface-strong); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--text); }
.modal strong { font-size: 16px; }
.modal p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal .msg { color: var(--danger); font-size: 12px; min-height: 16px; }

/* Reference order: drag to reorder; hovering an @Image tag highlights its thumbnail */
.refs .thumb[draggable="true"] { cursor: grab; }
.refs .thumb.dragging { opacity: 0.4; }
.refs .thumb.drop-target, .refs .thumb.hl { outline: 2px solid var(--mention-text); outline-offset: 2px; }
.thumb .n { font-size: 11px; background: rgba(0,0,0,0.55); border-radius: 6px; padding: 0 5px; left: 3px; bottom: 3px; }
