/* ==========================================================
   Akskar — main stylesheet (RTL, minimal)
   ========================================================== */

:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --surface-2: #f3efe9;
  --ink: #17150f;
  --ink-2: #3a362e;
  --muted: #77716a;
  --line: #e7e1d8;
  --accent: #f0603a;
  --accent-soft: #fde9e2;
  --danger: #c4322b;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --shadow: 0 1px 2px rgb(23 21 15 / .04), 0 8px 24px rgb(23 21 15 / .06);
  --shadow-lg: 0 18px 50px rgb(23 21 15 / .12);

  --font: "Vazirmatn", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --container: 1120px;
  --gutter: clamp(16px, 4vw, 32px);
  --header-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12110e; --surface: #1b1a16; --surface-2: #23211c;
    --ink: #f4f1ea; --ink-2: #d6d1c6; --muted: #9a948a; --line: #302d26;
    --accent-soft: #3a1f16;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}
/* Manual choice from the theme switch (html[data-theme]) */
:root[data-theme="dark"] {
  --bg: #12110e; --surface: #1b1a16; --surface-2: #23211c;
  --ink: #f4f1ea; --ink-2: #d6d1c6; --muted: #9a948a; --line: #302d26;
  --accent-soft: #3a1f16;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .3);
  color-scheme: dark;
}
@media (max-width: 640px) { :root { --header-h: 56px; } }

/* ---------- Theme switch ---------- */
.theme-switch { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--surface-2); }
.theme-switch button {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  height: 34px; min-width: 34px; padding: 0 .5rem; border: 0; border-radius: 999px;
  background: transparent; color: var(--muted); cursor: pointer; font-size: .85rem; font-weight: 700;
}
.theme-switch button:hover { color: var(--ink); }
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.theme-switch svg { width: 17px; height: 17px; }
.theme-switch .ts-label { display: none; }
.theme-row { display: contents; }
.theme-row-title { display: none; }
@media (max-width: 860px) {
  /* inside the hamburger menu: full-width row with labels */
  .theme-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem .9rem .2rem; border-top: 1px solid var(--line); }
  .theme-row-title { display: block; font-size: .95rem; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
  .theme-switch .ts-label { display: inline; }
  .theme-switch button { padding: 0 .6rem; font-size: .8rem; }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 16px; line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
h1, h2, h3 { line-height: 1.35; margin: 0 0 .5em; font-weight: 800; letter-spacing: -.01em; }
h1 { font-size: clamp(1.9rem, 4.6vw, 3.2rem); }
h2 { font-size: clamp(1.35rem, 2.6vw, 1.8rem); }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 1em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); }
.narrow { max-width: 760px; }
.center { text-align: center; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; inset-inline-start: 1rem; top: -100px; background: var(--ink); color: var(--bg); padding: .5rem 1rem; border-radius: 8px; z-index: 100; }
.skip-link:focus { top: 1rem; }

.eyebrow { display: inline-flex; align-items: center; gap: .5rem; font-size: .85rem; font-weight: 500; color: var(--muted); margin-bottom: .75rem; }
.eyebrow .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.lead { font-size: clamp(1rem, 1.6vw, 1.12rem); color: var(--muted); max-width: 58ch; }
.hint { font-size: .8rem; color: var(--muted); margin: .4rem 0 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  height: 42px; padding: 0 1.15rem; border-radius: 999px; border: 1px solid transparent;
  font-weight: 700; font-size: .92rem; cursor: pointer; white-space: nowrap;
  transition: background .2s, color .2s, border-color .2s, transform .15s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--ink); color: var(--bg); }
.btn-primary:hover { background: var(--accent); color: #fff; }
.btn-outline { border-color: var(--line); background: var(--surface); }
.btn-outline:hover { border-color: var(--ink); color: var(--ink); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-lg { height: 50px; padding: 0 1.6rem; font-size: 1rem; }
.btn-sm { height: 32px; padding: 0 .85rem; font-size: .82rem; }
.btn-block { width: 100%; }
.link-arrow { font-weight: 700; }
.link-arrow::after { content: " ←"; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50; height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.is-app .site-header .container { max-width: none; }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 100%; gap: 1.5rem; }
.logo { display: inline-flex; align-items: center; gap: .5rem; font-weight: 800; font-size: 1.15rem; color: var(--ink); }
.logo:hover { color: var(--ink); }
.main-nav { display: flex; align-items: center; gap: 2rem; flex: 1; justify-content: space-between; }
.main-nav ul { display: flex; gap: .2rem; list-style: none; padding: 0; margin: 0 1rem 0 auto; margin-inline: 1rem auto; }
.main-nav ul a { display: block; padding: .35rem .8rem; border-radius: 999px; font-size: .93rem; font-weight: 500; color: var(--ink-2); }
.main-nav ul a:hover { background: var(--surface-2); color: var(--ink); }
.main-nav ul a[aria-current="page"] { background: var(--surface-2); color: var(--ink); font-weight: 700; }
.nav-actions { display: flex; gap: .4rem; }
.nav-toggle { display: none; width: 44px; height: 44px; border: 0; background: transparent; cursor: pointer; padding: 12px; margin-inline-end: -10px; }
.nav-toggle span { display: block; height: 2px; background: var(--ink); border-radius: 2px; transition: transform .25s; }
.nav-toggle span + span { margin-top: 7px; }
.nav-toggle[aria-expanded="true"] span:first-child { transform: translateY(4.5px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:last-child { transform: translateY(-4.5px) rotate(-45deg); }

@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .main-nav {
    position: fixed; inset: var(--header-h) 0 auto 0; flex-direction: column; align-items: stretch; gap: 1rem;
    background: var(--bg); padding: .75rem var(--gutter) 1.25rem; border-bottom: 1px solid var(--line); box-shadow: var(--shadow);
    transform: translateY(-8px); opacity: 0; visibility: hidden; transition: .2s;
  }
  .main-nav.is-open { transform: none; opacity: 1; visibility: visible; }
  .main-nav ul { flex-direction: column; margin: 0; }
  .main-nav ul a { padding: .65rem .9rem; font-size: 1.02rem; }
  .nav-actions .btn { flex: 1; }
}

/* ---------- Breadcrumbs & page head ---------- */
.breadcrumbs ol { display: flex; flex-wrap: wrap; gap: .35rem; list-style: none; margin: 0; padding: 1.1rem 0 0; font-size: .83rem; color: var(--muted); }
.breadcrumbs li + li::before { content: "/"; margin-inline-end: .35rem; opacity: .5; }
.page-head { padding-block: clamp(1.75rem, 5vw, 3rem) clamp(1.25rem, 3vw, 2rem); }
.page-head h1 { font-size: clamp(1.7rem, 4vw, 2.5rem); }

/* ---------- Home ---------- */
.hero { padding-block: clamp(3rem, 10vw, 6.5rem) clamp(2.5rem, 6vw, 4rem); }
.hero-inner { display: flex; flex-direction: column; align-items: center; text-align: center; max-width: 820px; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero .lead { margin-bottom: 1.75rem; }

.prompt-box {
  width: 100%; text-align: start; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: .8rem; box-shadow: var(--shadow); transition: border-color .2s, box-shadow .2s;
}
.prompt-box:focus-within { border-color: var(--ink); box-shadow: var(--shadow-lg); }
.prompt-box textarea { width: 100%; border: 0; resize: none; background: transparent; padding: .35rem .5rem; font-size: 1.05rem; line-height: 1.7; outline: none; }
.prompt-box textarea::placeholder { color: var(--muted); }
.prompt-actions { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }

.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { height: 32px; padding: 0 .85rem; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); font-size: .82rem; cursor: pointer; }
.chip:hover { border-color: var(--ink); }
.chip.is-active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip-radio input { position: absolute; opacity: 0; pointer-events: none; }
.chip-radio span { display: inline-flex; align-items: center; height: 32px; padding: 0 .85rem; border: 1px solid var(--line); border-radius: 999px; font-size: .82rem; cursor: pointer; background: var(--bg); }
.chip-radio input:checked + span { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip-radio input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.examples { display: flex; gap: .6rem; list-style: none; padding: 0; margin: 2rem 0 0; justify-content: center; flex-wrap: wrap; }
.examples a { display: block; width: 64px; height: 64px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); transition: transform .2s; }
.examples a:hover { transform: translateY(-3px); }
.examples img { width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 420px) { .examples { gap: .45rem; } .examples a { width: 54px; height: 54px; border-radius: 12px; } }
.examples-more { display: grid !important; place-items: center; font-size: .8rem; font-weight: 700; background: var(--surface); }

.section { padding-block: clamp(2.5rem, 7vw, 5rem); }
.section-muted { background: var(--surface-2); }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.section-head h2 { margin: 0; }
.section-title { font-size: 1.3rem; margin-bottom: 1.25rem; }

.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.feature { display: block; padding: 1.6rem; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); transition: .2s; }
.feature:hover { border-color: var(--ink); color: var(--ink); transform: translateY(-2px); }
.feature h2, .feature h3 { font-size: 1.1rem; margin-bottom: .35rem; }
ol.features, ul.features { list-style: none; padding: 0; margin: 0; }
.steps .feature:hover { transform: none; }
ol.steps { margin-block: 1.5rem 2rem; }
.home-intro { margin-inline: auto; }
.prose h3 { font-size: 1.1rem; color: var(--ink); margin-top: 1.5rem; }
.feature p { color: var(--muted); font-size: .92rem; margin: 0; }
.tool-icon { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); margin-bottom: 1rem; }
@media (max-width: 800px) { .features { grid-template-columns: 1fr; } }
/* Home: AI tools section */
.tools-title { text-align: center; margin-inline: auto; max-width: 30ch; }
.tools .feature { text-align: center; }
@media (max-width: 800px) {
  .tools-title { font-size: 1.1rem; margin-bottom: 1rem; }
  .tools { gap: .6rem; }
  .tools .feature { display: grid; grid-template-columns: auto 1fr; column-gap: .85rem; align-items: center; padding: .9rem 1rem; text-align: start; border-radius: var(--radius); }
  .tools .tool-icon { grid-row: span 2; width: 38px; height: 38px; margin: 0; }
  .tools .feature h3 { font-size: .98rem; margin: 0 0 .15rem; }
  .tools .feature p { font-size: .84rem; line-height: 1.6; }
}

.faq { display: grid; gap: .5rem; margin-top: 1.5rem; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 1.2rem; }
.faq summary { cursor: pointer; list-style: none; padding: 1rem 0; font-weight: 700; display: flex; justify-content: space-between; gap: 1rem; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 1.3rem; line-height: 1; color: var(--muted); transition: transform .2s; }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { color: var(--muted); padding-bottom: 1rem; margin: 0; }

/* ==========================================================
   App shell (create / edit)
   ========================================================== */
.is-app { height: 100dvh; overflow: hidden; }
.is-app main { height: calc(100dvh - var(--header-h)); }
.app { height: 100%; display: flex; flex-direction: column; }
.app-canvas { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: clamp(1rem, 3vw, 2rem) var(--gutter) 1rem; }
.app-canvas > * { max-width: 980px; margin-inline: auto; }

.app-intro { text-align: center; padding-block: clamp(1.5rem, 8vh, 5rem) 1rem; }
.app-intro h1 { font-size: clamp(1.4rem, 3.4vw, 2rem); margin-bottom: .25rem; }
.app-intro p { color: var(--muted); margin: 0; font-size: .95rem; }
.app-intro-tight { padding-block: .5rem 1.25rem; }
.has-content .app-intro:not(.app-intro-tight) { padding-block: 0 1rem; }
.has-content .app-intro:not(.app-intro-tight) h1 { font-size: 1.1rem; }
.has-content .ideas { display: none; }

.ideas { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; margin-top: 1.5rem; }
.idea-chip { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: .45rem .8rem; font-size: .85rem; color: var(--ink-2); cursor: pointer; text-align: start; max-width: 100%; }
.idea-chip:hover { border-color: var(--ink); }

/* Composer */
.composer { flex: none; padding: .5rem var(--gutter) calc(.75rem + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 70%, transparent); }
.composer-box {
  max-width: 820px; margin-inline: auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: .55rem; box-shadow: var(--shadow); display: grid; gap: .45rem;
}
.composer-box:focus-within { border-color: color-mix(in srgb, var(--ink) 45%, var(--line)); }
.composer-opts { display: flex; gap: .35rem; overflow-x: auto; scrollbar-width: none; }
.composer-opts::-webkit-scrollbar { display: none; }
.composer-row { display: flex; align-items: flex-end; gap: .45rem; }
.composer-row textarea {
  flex: 1; min-width: 0; border: 0; outline: none; resize: none; background: transparent;
  padding: .45rem .55rem; line-height: 1.65; max-height: 160px; font-size: 1rem;
}
.composer-row textarea::placeholder { color: var(--muted); }
.composer-note { flex: 1; margin: 0; padding: .5rem .55rem; color: var(--muted); font-size: .9rem; }
.send-btn {
  flex: none; width: 44px; height: 44px; border-radius: 14px; border: 0; cursor: pointer;
  background: var(--ink); color: var(--bg); display: grid; place-items: center; transition: background .2s, transform .15s;
}
.send-btn:hover { background: var(--accent); color: #fff; }
.send-btn:active { transform: scale(.94); }
.send-btn:disabled { opacity: .45; cursor: progress; }

.pill-select { position: relative; flex: none; }
.pill-select select {
  appearance: none; -webkit-appearance: none; height: 32px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg); padding: 0 .85rem 0 1.8rem; font-size: .8rem; cursor: pointer; outline: none;
}
.pill-select select:hover, .pill-select select:focus { border-color: var(--ink); }
.pill-select::after { content: ""; position: absolute; left: .75rem; top: 50%; width: 6px; height: 6px; border: solid var(--muted); border-width: 0 1.5px 1.5px 0; transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.composer-row .pill-select { align-self: center; }

/* Feed (create results) */
.feed { display: grid; gap: 1.5rem; }
.batch-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; margin-bottom: .6rem; }
.batch-prompt { font-size: .9rem; color: var(--ink-2); margin: 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.batch-meta { font-size: .75rem; color: var(--muted); white-space: nowrap; }
.batch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 45%), 1fr)); gap: .6rem; }
.batch-grid.single { grid-template-columns: minmax(0, 520px); }
.shot { position: relative; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }
.shot img { width: 100%; height: 100%; object-fit: cover; }
.shot-actions { position: absolute; inset: auto .5rem .5rem .5rem; display: flex; gap: .35rem; justify-content: flex-end; opacity: 0; transition: opacity .2s; }
.shot:hover .shot-actions, .shot:focus-within .shot-actions { opacity: 1; }
@media (hover: none) { .shot-actions { opacity: 1; } }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .3rem; height: 36px; min-width: 36px; padding: 0 .6rem;
  border-radius: 11px; border: 0; cursor: pointer; font-size: .8rem; font-weight: 700;
  background: color-mix(in srgb, var(--surface) 90%, transparent); color: var(--ink); backdrop-filter: blur(8px); box-shadow: var(--shadow);
}
.icon-btn:hover { background: var(--ink); color: var(--bg); }
.shot-loading { display: grid; place-items: center; color: var(--muted); font-size: .85rem; }
.shot-loading::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 30%, color-mix(in srgb, var(--surface) 70%, transparent) 50%, transparent 70%) var(--surface-2);
  background-size: 200% 100%; animation: shimmer 1.4s linear infinite;
}
.shot-loading span { position: relative; }
@keyframes shimmer { to { background-position: -200% 0; } }
.batch-error { padding: .9rem 1rem; border-radius: var(--radius); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); color: var(--danger); font-size: .9rem; }

/* Edit stage */
.drop {
  display: grid; justify-items: center; gap: .4rem; text-align: center; cursor: pointer; color: var(--muted);
  padding: clamp(3rem, 12vh, 6rem) 1.5rem; border: 1.5px dashed var(--line); border-radius: var(--radius-lg); background: var(--surface);
  max-width: 640px !important; transition: .2s;
}
.drop svg { width: 34px; height: 34px; color: var(--ink); }
.drop strong { color: var(--ink); }
.drop span { font-size: .82rem; }
.drop:hover, .drop.is-over { border-color: var(--accent); background: var(--accent-soft); }

.has-image .app-intro { padding-block: 0 .75rem; }
.has-image .app-intro h1 { font-size: 1rem; margin: 0; }
.has-image .app-intro p { display: none; }
.stage { display: grid; gap: .75rem; justify-items: center; }
.stage-media { position: relative; border-radius: var(--radius-lg); overflow: hidden; background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface) 0 50%) 0 0 / 20px 20px; max-width: 100%; }
.stage-media img { max-height: calc(100dvh - var(--header-h) - 270px); min-height: 200px; width: auto; object-fit: contain; }
.stage-loading { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: .6rem; background: color-mix(in srgb, var(--bg) 60%, transparent); backdrop-filter: blur(3px); font-weight: 700; font-size: .9rem; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.stage-bar { display: flex; gap: .4rem; }
.stage-bar .icon-btn { background: var(--surface); border: 1px solid var(--line); box-shadow: none; }
.stage-bar .icon-btn:hover { background: var(--ink); color: var(--bg); }
.versions { display: flex; gap: .4rem; overflow-x: auto; max-width: 100%; padding-bottom: 2px; }
.versions button { flex: none; width: 48px; height: 48px; border-radius: 10px; overflow: hidden; padding: 0; border: 2px solid transparent; cursor: pointer; background: var(--surface-2); }
.versions button.is-active { border-color: var(--accent); }
.versions img { width: 100%; height: 100%; object-fit: cover; }

.tool-tabs { display: flex; gap: .3rem; overflow-x: auto; scrollbar-width: none; }
.tool-tabs::-webkit-scrollbar { display: none; }
.tool-tab input { position: absolute; opacity: 0; pointer-events: none; }
.tool-tab span { display: inline-flex; align-items: center; gap: .35rem; height: 34px; padding: 0 .8rem; border-radius: 999px; font-size: .8rem; white-space: nowrap; cursor: pointer; border: 1px solid var(--line); background: var(--bg); }
.tool-tab svg { width: 16px; height: 16px; }
.tool-tab input:checked + span { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tool-tab input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.toast {
  position: fixed; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: .55rem 1rem; border-radius: 12px; font-size: .88rem; z-index: 90;
  box-shadow: var(--shadow-lg); max-width: calc(100% - 32px); animation: toast .25s ease;
}
.toast.is-error { background: var(--danger); color: #fff; }
@keyframes toast { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------- Gallery ---------- */
.filters { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1.25rem; }
.masonry { columns: 3 260px; column-gap: .8rem; padding-bottom: 3rem; }
.masonry > * { break-inside: avoid; margin-bottom: .8rem; }
.card-media { position: relative; display: block; overflow: hidden; border-radius: var(--radius); background: var(--surface-2); }
.card-media img { width: 100%; transition: transform .6s cubic-bezier(.2,.7,.2,1); }
.card-media:hover img { transform: scale(1.03); }
.card-media-info { position: absolute; inset: auto 0 0 0; padding: 2.5rem 1rem .9rem; display: flex; flex-direction: column; align-items: flex-start; gap: .3rem; background: linear-gradient(to top, rgb(0 0 0 / .6), transparent); color: #fff; opacity: 0; transition: .3s; }
.card-media:hover .card-media-info, .card-media:focus-visible .card-media-info { opacity: 1; }
.card-media-title { font-weight: 700; font-size: .92rem; }
.badge { font-size: .72rem; padding: .05rem .55rem; border-radius: 999px; background: rgb(255 255 255 / .2); }
.card-media-fixed img { aspect-ratio: 4 / 3; object-fit: cover; }
@media (hover: none) { .card-media-info { opacity: 1; } }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .8rem; }

.gallery-item { display: grid; grid-template-columns: 1.4fr 1fr; gap: clamp(1.5rem, 4vw, 3rem); padding-top: 1.25rem; align-items: start; }
.gallery-item-media { margin: 0; }
.gallery-item-media img { border-radius: var(--radius-lg); width: 100%; max-height: 80vh; object-fit: contain; background: var(--surface-2); }
.gallery-item-info { position: sticky; top: calc(var(--header-h) + 1.5rem); display: grid; gap: 1.1rem; }
.gallery-item-info h1 { font-size: clamp(1.5rem, 3vw, 2rem); margin: 0; }
.gallery-item-info .eyebrow { margin: 0; }
.prompt-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.15rem; }
.prompt-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .3rem; }
.prompt-card h2 { font-size: .88rem; margin: 0; color: var(--muted); }
.prompt-card p { margin: 0; line-height: 1.9; }
.meta-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: 0; }
.meta-list div { background: var(--surface-2); border-radius: var(--radius-sm); padding: .55rem .8rem; }
.meta-list dt { font-size: .74rem; color: var(--muted); }
.meta-list dd { margin: 0; font-weight: 700; font-size: .88rem; }
@media (max-width: 960px) { .gallery-item { grid-template-columns: 1fr; } .gallery-item-info { position: static; } }

/* ---------- Pricing ---------- */
.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; padding-bottom: 4rem; }
.plan { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.75rem 1.5rem; }
.plan h2 { font-size: 1.2rem; margin-bottom: .2rem; }
.plan-note { color: var(--muted); font-size: .88rem; margin: 0; }
.plan-price { margin: 1.1rem 0; }
.plan-price strong { font-size: 1.9rem; font-weight: 800; }
.plan-price span { color: var(--muted); font-size: .88rem; }
.plan ul { list-style: none; padding: 0; margin: 0 0 1.75rem; display: grid; gap: .5rem; flex: 1; }
.plan li { display: flex; gap: .55rem; font-size: .93rem; }
.plan li::before { content: "✓"; color: var(--accent); font-weight: 800; }
.plan-featured { border-color: var(--ink); box-shadow: var(--shadow-lg); }
.plan-flag { position: absolute; top: -12px; inset-inline-start: 1.5rem; background: var(--accent); color: #fff; font-size: .74rem; font-weight: 700; padding: .1rem .75rem; border-radius: 999px; }
@media (max-width: 900px) { .plans { grid-template-columns: 1fr; } }

/* ---------- Misc pages ---------- */
.prose { color: var(--ink-2); }
.prose h2 { font-size: 1.4rem; color: var(--ink); }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(2rem, 5vw, 4rem); align-items: start; padding-bottom: 4rem; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.5rem; display: grid; gap: 1.1rem; }
.field { display: grid; gap: .4rem; }
.field label { font-weight: 700; font-size: .88rem; }
.field input, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); padding: .65rem .9rem; outline: none; }
.field input:focus, .field textarea:focus { border-color: var(--ink); }
.empty-state { text-align: center; color: var(--muted); display: grid; justify-items: center; gap: 1rem; border: 1px dashed var(--line); border-radius: var(--radius-lg); padding: 4rem 2rem; background: var(--surface); margin-bottom: 4rem; }
.empty-state p { margin: 0; }
.auth { display: grid; place-items: center; padding-block: 4rem 6rem; }
.auth .panel { width: 100%; max-width: 400px; }
.auth h1 { font-size: 1.4rem; margin: 0; }
.auth-sub { color: var(--muted); font-size: .92rem; margin: 0; }
.auth-step { display: grid; gap: 1rem; }
.code-input { text-align: center; font-size: 1.6rem !important; letter-spacing: .6em; font-weight: 700; padding-inline-start: 1.2rem !important; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font-size: .88rem; font-weight: 700; }
.link-btn:disabled { color: var(--muted); cursor: default; font-weight: 500; }
.auth-step .link-btn.center { justify-self: center; }
.reassure { background: var(--accent-soft); border-radius: var(--radius); padding: .9rem 1.1rem; font-size: .92rem; line-height: 1.8; }
.reassure p { margin: .2rem 0 0; color: var(--ink-2); }
.reassure-prompt { font-size: .85rem; color: var(--muted) !important; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.user-pill { display: inline-flex; align-items: center; height: 42px; padding: 0 .9rem; border-radius: 999px; background: var(--surface-2); font-size: .85rem; font-weight: 700; }
.quota { max-width: 820px; margin: 0 auto .35rem; padding-inline: .5rem; font-size: .75rem; color: var(--muted); text-align: center; }
.quota strong { color: var(--accent); }
/* ---------- Create / Edit tabs (two pages, one app feel) ---------- */
@view-transition { navigation: auto; }
.site-header { view-transition-name: site-header; }
.app-tabs { flex: none; padding: .75rem var(--gutter) 0; view-transition-name: app-tabs; }
.app-tabs-inner {
  position: relative; display: grid; grid-template-columns: 1fr 1fr; max-width: 360px; margin-inline: auto;
  background: var(--surface-2); border-radius: 999px; padding: 4px;
}
.app-tab {
  position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; gap: .4rem;
  height: 38px; border-radius: 999px; font-size: .9rem; font-weight: 700; color: var(--muted); transition: color .2s;
}
.app-tab svg { width: 17px; height: 17px; }
.app-tab:hover { color: var(--ink); }
.app-tab[aria-current="page"] { color: var(--ink); }
.app-tabs-thumb {
  position: absolute; top: 4px; bottom: 4px; inset-inline-start: 4px; width: calc(50% - 4px);
  background: var(--surface); border-radius: 999px; box-shadow: var(--shadow);
  view-transition-name: app-tab-thumb; transition: transform .25s ease;
}
/* RTL: the second tab sits on the left */
.app-tabs-inner:has(.app-tab:nth-child(2)[aria-current]) .app-tabs-thumb { transform: translateX(-100%); }
.composer { view-transition-name: composer; }
::view-transition-group(app-tab-thumb) { animation-duration: .28s; animation-timing-function: ease; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .18s; }
@media (prefers-reduced-motion: reduce) { @view-transition { navigation: none; } }

/* ---------- Mobile overflow fix: grid/flex children must be allowed to shrink ---------- */
html, body { overflow-x: clip; }
.app, .app-canvas, .composer, .composer-box, .composer-row, .stage, .stage-media { min-width: 0; max-width: 100%; }
.composer-box { grid-template-columns: minmax(0, 1fr); }
.composer-box > *, .stage > * { min-width: 0; max-width: 100%; }
.stage { grid-template-columns: minmax(0, 1fr); }
.stage-media img { max-width: 100%; height: auto; }
.drop { width: 100%; }
/* Hidden radios/file inputs are position:absolute — keep them inside their own box, otherwise
   the ones in the horizontally-scrolling tool row stretch the whole page sideways. */
.tool-tabs, .tool-tab, .chip-radio, .ratio-option, .drop, .composer-row, .pill-select { position: relative; }

/* ---------- Panel ---------- */
.panel-page { padding-block: 2rem 4rem; }
.panel-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.panel-head h1 { font-size: clamp(1.5rem, 3vw, 2rem); margin: 0; }
.panel-head .eyebrow { margin-bottom: .25rem; }
.panel-grid { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 1rem; margin-bottom: 2.5rem; }
.panel-grid h2 { font-size: 1.05rem; margin: 0; }
.quota-big { margin: 0; }
.quota-big strong { font-size: 2.2rem; color: var(--accent); }
.quota-big span { color: var(--muted); font-size: .9rem; }
.meter { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.meter span { display: block; height: 100%; background: linear-gradient(90deg, #f6b443, var(--accent), #e8577a); border-radius: 99px; }
.action-card { transition: .2s; align-content: start; }
.action-card:hover { border-color: var(--ink); color: var(--ink); transform: translateY(-2px); }
.action-card .tool-icon { margin: 0; }
.action-card p { margin: 0; color: var(--muted); font-size: .9rem; }
.recent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(180px, 45%), 1fr)); gap: .6rem; }
.recent-grid .shot { aspect-ratio: 1; }
@media (max-width: 860px) { .panel-grid { grid-template-columns: 1fr 1fr; } .quota-card { grid-column: 1 / -1; } }

.welcome-box { width: 100%; max-width: 560px; display: grid; justify-items: center; gap: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.5rem; box-shadow: var(--shadow); }
.welcome-box p { margin: 0; color: var(--ink-2); }
.welcome-box strong { color: var(--accent); }

.not-found { text-align: center; padding-block: 5rem 7rem; display: grid; justify-items: center; }
.not-found-code { font-size: clamp(4rem, 14vw, 7rem); font-weight: 800; line-height: 1; color: var(--accent); margin: 0 0 1rem; }
.not-found-actions { display: flex; gap: .6rem; margin-top: 1rem; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding-top: 3rem; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 2rem; }
.footer-brand p { color: var(--muted); font-size: .88rem; margin-top: .6rem; max-width: 30ch; }
.footer-title { font-size: .88rem; margin-bottom: .6rem; }
.site-footer ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .3rem; }
.site-footer ul a { color: var(--muted); font-size: .88rem; }
.site-footer ul a:hover { color: var(--ink); }
.footer-bottom { border-top: 1px solid var(--line); margin-top: 2.5rem; padding-block: 1.1rem; font-size: .8rem; color: var(--muted); }
.footer-bottom p { margin: 0; }
.footer-toggle { all: unset; display: flex; align-items: center; justify-content: space-between; gap: .5rem; width: 100%; font: inherit; color: inherit; cursor: default; }
.footer-toggle::after { content: ""; display: none; width: .5rem; height: .5rem; border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(45deg); margin-top: -.25rem; transition: transform .2s; }
@media (max-width: 800px) {
  .footer-grid { grid-template-columns: 1fr; gap: 0; }
  .footer-brand { padding-bottom: 1.25rem; }
  .site-footer { padding-top: 2rem; }
  .footer-col { border-top: 1px solid var(--line); }
  .footer-col .footer-title { margin: 0; font-size: .95rem; }
  .footer-toggle { padding: .85rem 0; cursor: pointer; }
  .footer-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
  .footer-toggle::after { display: block; }
  .footer-toggle[aria-expanded="true"]::after { transform: rotate(-135deg); margin-top: .25rem; }
  .footer-col ul { padding-bottom: .9rem; }
  .js .footer-col ul { display: none; }
  .js .footer-col.is-open ul { display: grid; }
  .footer-bottom { margin-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
