:root {
  --bg: #0a0f1c;
  --bg-alt: #0f1629;
  --card: #131c33;
  --border: #1f2b4a;
  --text: #dbe4ff;
  --muted: #8a9bc4;
  --accent: #3b82f6;
  --accent-2: #22d3ee;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
a { color: inherit; text-decoration: none; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }

.nav {
  position: sticky; top: 0; z-index: 10;
  background: rgba(10, 15, 28, .85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.logo { display: flex; align-items: center; flex-shrink: 0; }
.logo-img { display: block; height: 40px; width: auto; }
.nav nav { display: flex; align-items: center; gap: 24px; }
.nav nav a:not(.btn) { color: var(--muted); transition: color .2s; }
.nav nav a:not(.btn):hover { color: var(--text); }

.btn {
  display: inline-block; padding: 12px 24px; border-radius: 8px; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), #2563eb); color: #fff; font: inherit; font-weight: 600;
  transition: transform .15s, box-shadow .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(59, 130, 246, .35); }
.btn-sm { padding: 8px 16px; }
.btn-ghost { background: transparent; border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--accent); box-shadow: none; }

.hero {
  padding: 120px 0 100px;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(59, 130, 246, .25), transparent 60%),
    radial-gradient(ellipse at 90% 30%, rgba(34, 211, 238, .12), transparent 50%);
}
.eyebrow { color: var(--accent-2); text-transform: uppercase; letter-spacing: .15em; font-size: .85rem; margin-bottom: 16px; }
h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); line-height: 1.15; max-width: 800px; }
.accent {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lead { color: var(--muted); font-size: 1.15rem; max-width: 620px; margin: 24px 0 36px; }
.hero-actions { display: flex; gap: 16px; flex-wrap: wrap; }

.section { padding: 90px 0; }
.section-alt { background: var(--bg-alt); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
h2 { font-size: 2rem; margin-bottom: 40px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 20px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 28px;
  transition: border-color .2s, transform .2s;
}
.card:hover { border-color: var(--accent); transform: translateY(-3px); }
.icon { font-size: 1.5rem; color: var(--accent); margin-bottom: 16px; font-weight: 700; }
.card h3 { margin-bottom: 8px; }
.card p { color: var(--muted); }

.about { display: grid; grid-template-columns: 1.3fr 1fr; gap: 48px; align-items: center; }
.about h2 { margin-bottom: 20px; }
.about p { color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.stats div { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; text-align: center; }
.stats strong { display: block; font-size: 1.6rem; color: var(--accent-2); }
.stats span { color: var(--muted); font-size: .9rem; }

.steps { list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; }
.steps li { border-left: 2px solid var(--accent); padding: 4px 0 4px 20px; }
.steps span { color: var(--accent); font-weight: 700; font-family: ui-monospace, monospace; }
.steps p { color: var(--muted); }

.contact { max-width: 640px; }
form { display: grid; gap: 14px; }
input, textarea {
  width: 100%; padding: 14px; border-radius: 8px; font: inherit;
  background: var(--card); border: 1px solid var(--border); color: var(--text);
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
.status { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; }
.status.ok { background: rgba(34, 211, 238, .12); color: var(--accent-2); }
.status.err { background: rgba(239, 68, 68, .12); color: #f87171; }

.footer { padding: 32px 0; color: var(--muted); font-size: .9rem; text-align: center; }
.notfound { min-height: 100vh; display: grid; place-items: center; text-align: center; }
.notfound .lead { margin-left: auto; margin-right: auto; }

.inline { display: inline; }
.nav-auth { display: flex; align-items: center; gap: 16px; }
.lang-pick { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 8px; font-size: .8rem; font-weight: 600; }
.lang-pick > * { padding: 3px 8px; border-radius: 6px; line-height: 1.4; }
.lang-pick b { background: var(--accent); color: #fff; }
.nav nav .lang-pick a { color: var(--muted); }
.nav nav .lang-pick a:hover { color: var(--text); }
.auth-page {
  min-height: calc(100vh - 64px); display: grid; place-items: center; padding: 48px 24px;
  background: radial-gradient(ellipse at 50% 0%, rgba(59, 130, 246, .18), transparent 60%);
}
.auth-card { width: 100%; max-width: 440px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 36px; }
.auth-card h1 { font-size: 1.7rem; margin-bottom: 24px; }
.auth-card input { background: var(--bg); }
.muted { color: var(--muted); margin-top: 18px; font-size: .95rem; }
.muted a, .accent-text { color: var(--accent-2); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 10px 20px; }
.kv dt { color: var(--muted); }

.footer-inner { display: grid; gap: 10px; }
.footer { border-top: 1px solid var(--border); }
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px 0; }
.footer-links > * { padding: 0 16px; }
.footer-links > * + * { border-left: 1px solid var(--border); }
.footer-links a:hover { color: var(--accent-2); }
.requisites { font-size: .82rem; opacity: .85; }
.check { display: flex; gap: 12px; align-items: flex-start; color: var(--muted); font-size: .9rem; line-height: 1.5; cursor: pointer; margin: 2px 0 4px; }
.check span { flex: 1; }
.check a { color: var(--accent-2); }
.check a:hover { text-decoration: underline; }
.check input {
  appearance: none; -webkit-appearance: none; flex: none;
  width: 20px; height: 20px; padding: 0; margin-top: 1px; border-radius: 5px; cursor: pointer;
  border: 1.5px solid #34446e; background: var(--bg); display: grid; place-items: center;
  transition: background .15s, border-color .15s;
}
.check input::after {
  content: ""; width: 5px; height: 10px; margin-top: -2px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) scale(0); transition: transform .15s;
}
.check input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::after { transform: rotate(45deg) scale(1); }
.check input:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

.pw { position: relative; }
.pw input { padding-right: 48px; }
.pw-toggle {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  width: 38px; height: 38px; display: grid; place-items: center;
  background: none; border: none; border-radius: 6px; color: var(--muted); cursor: pointer;
}
.pw-toggle:hover, .pw-toggle:focus-visible { color: var(--text); background: rgba(255, 255, 255, .05); outline: none; }
.pw-toggle .eye-off { display: none; }
.pw-toggle.on .eye-off { display: inline; }
.pw-toggle.on .eye-open { display: none; }
input:user-invalid { border-color: #b4495a; }
.auth-card .btn { width: 100%; padding: 14px; }
.doc-page { padding: 56px 0 80px; }
.doc { max-width: 820px; }
.doc h1 { font-size: 2.1rem; margin-bottom: 8px; }
.doc h2 { font-size: 1.25rem; margin: 36px 0 12px; }
.doc p { color: #b8c5e8; margin-bottom: 10px; }
.doc a { color: var(--accent-2); }
.doc .kv { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 20px 24px; }
.lead-sm { color: var(--muted); font-size: 1.1rem; }

.lang-switch { display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 28px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
.lang-switch > * { padding: 6px 14px; border-radius: 7px; font-size: .9rem; }
.doc .lang-switch a { color: var(--muted); }
.doc .lang-switch a:hover { color: var(--text); }
.lang-switch .active { background: var(--accent); color: #fff; }

.forgot { justify-self: end; margin-top: -6px; font-size: .88rem; color: var(--accent-2); }
.forgot:hover { text-decoration: underline; }
.hint { margin: -4px 0 16px; }
.lead-in { margin: 0 0 18px; }

/* ---- Admin panel ---- */
.admin h1 { font-size: 2rem; margin-bottom: 24px; }
.muted-sm { color: var(--muted); font-size: .88rem; }
.warn-text { color: #fbbf24; }
.admin-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.admin-stats div { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.admin-stats strong { display: block; font-size: 1.6rem; color: var(--accent-2); }
.admin-stats span { color: var(--muted); font-size: .9rem; }
.admin-search { display: flex; gap: 10px; margin-bottom: 8px; }
.admin-search input { flex: 1; padding: 10px 14px; }
.table-wrap { overflow-x: auto; margin-top: 12px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.admin-table th, .admin-table td { padding: 12px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.admin-table th { color: var(--muted); font-weight: 600; font-size: .85rem; white-space: nowrap; }
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table .actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.admin-table .btn-sm { padding: 6px 10px; font-size: .82rem; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; background: var(--bg); border: 1px solid var(--border); color: var(--muted); }
.badge-admin { color: #fff; background: var(--accent); border-color: var(--accent); }
.btn-danger { background: transparent; border: 1px solid #7f2a37; color: #f87171; }
.btn-danger:hover { background: rgba(239, 68, 68, .12); box-shadow: none; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 20px; }

@media (max-width: 760px) {
  .container { padding: 0 18px; }
  .nav-inner { height: 58px; }
  .logo-img { height: 32px; }
  .nav nav { gap: 14px; }
  .nav nav a.nav-sec { display: none; }
  .nav-auth { gap: 12px; }
  .nav-auth > a:not(.btn), .nav nav > a[href="/account"] { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .hero { padding: 64px 0 56px; }
  .lead { font-size: 1.02rem; margin: 18px 0 28px; }
  .hero-actions .btn { flex: 1 1 100%; text-align: center; }
  .section { padding: 56px 0; }
  h2 { font-size: 1.6rem; margin-bottom: 24px; }
  .card { padding: 22px; }
  .about { grid-template-columns: 1fr; gap: 28px; }
  .stats { gap: 10px; }
  .stats div { padding: 14px 8px; }
  .stats strong { font-size: 1.3rem; }

  .auth-page { padding: 24px 14px 40px; place-items: start center; min-height: auto; }
  .auth-card { padding: 26px 20px; border-radius: 12px; }
  .auth-card h1 { font-size: 1.5rem; }
  /* 16px prevents iOS from zooming into focused inputs */
  input, textarea, .btn { font-size: 16px; }

  .doc-page { padding: 32px 0 56px; }
  .doc h1 { font-size: 1.6rem; }
  .doc h2 { font-size: 1.1rem; margin-top: 28px; }
  .doc .kv { padding: 16px; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 10px; word-break: break-word; }

  .footer { padding: 24px 0; font-size: .85rem; }
  .footer-links { flex-direction: column; gap: 10px; }
  .footer-links > * { padding: 0; }
  .footer-links > * + * { border-left: none; }

  .admin h1 { font-size: 1.5rem; }
  .admin-stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .table-wrap { background: none; border: none; }
  .admin-table thead { display: none; }
  .admin-table, .admin-table tbody, .admin-table tr, .admin-table td { display: block; width: 100%; }
  .admin-table tr { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
  .admin-table td { border: none; padding: 4px 0; }
  .admin-table td[data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-size: .85rem; }
  .admin-table .actions { justify-content: flex-start; padding-top: 10px; }
}

@media (max-width: 380px) {
  .nav-auth .btn-sm { padding: 7px 12px; font-size: .9rem; }
  .stats { grid-template-columns: 1fr; }
}

/* ---- Account ---- */
.acc { display: grid; grid-template-columns: 250px 1fr; gap: 28px; align-items: start; }
.acc-side { position: sticky; top: 88px; display: flex; flex-direction: column; gap: 16px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 20px; }
.acc-user { display: flex; gap: 12px; align-items: center; min-width: 0; }
.acc-user > div { display: flex; flex-direction: column; min-width: 0; }
.acc-user strong, .acc-user .muted-sm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 1.2rem; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.acc-nav { display: flex; flex-direction: column; gap: 2px; }
.acc-nav a { padding: 8px 12px; border-radius: 8px; color: var(--muted); transition: background .15s, color .15s; }
.acc-nav a:hover { background: var(--bg-alt); color: var(--text); }
.acc-chat { text-align: center; }
.acc-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.acc-main h1 { font-size: 2rem; margin-bottom: 0; }
.acc-main > .status { margin-bottom: 0; }
.acc-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 24px 26px; scroll-margin-top: 84px; display: flex; flex-direction: column; gap: 14px; }
.acc-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.acc-card h2 { font-size: 1.25rem; margin: 0; }
.acc-card h3 { font-size: 1rem; margin-top: 6px; }
.acc-card .muted { margin-top: 0; }
.acc-card .table-wrap { margin-top: 0; background: var(--bg-alt); }
.acc-card .kv { margin: 0; }
.acc-sep { height: 1px; background: var(--border); margin: 4px 0; }
.acc-form { display: grid; gap: 10px; max-width: 460px; }
.acc-form label { display: grid; gap: 6px; color: var(--muted); font-size: .9rem; }
.acc-form input { background: var(--bg); padding: 11px 14px; }
.acc-form .btn { justify-self: start; }
.actions-row { display: flex; flex-wrap: wrap; gap: 8px; }
.plan-tag { padding: 3px 12px; border-radius: 999px; font-size: .85rem; font-weight: 700; border: 1px solid var(--border); color: var(--muted); }
.plan-tag.pro { color: #fff; border-color: transparent; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.pill { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: .8rem; border: 1px solid var(--border); color: var(--muted); }
.pill.ok { color: var(--accent-2); border-color: rgba(34, 211, 238, .4); background: rgba(34, 211, 238, .08); }
.pill.warn { color: #fbbf24; border-color: rgba(251, 191, 36, .4); background: rgba(251, 191, 36, .08); }
.meter-head { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: .92rem; }
.meter-head strong { color: var(--text); }
.meter { height: 10px; border-radius: 999px; background: var(--bg-alt); border: 1px solid var(--border); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

/* ---- Pricing ---- */
.plans { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin: 32px 0 24px; }
.plan { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.doc .plan h2 { margin: 0; font-size: 1.4rem; display: flex; gap: 10px; align-items: center; }
.plan-best { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 16px 48px rgba(59, 130, 246, .22); }
.plan-price { font-size: 2.4rem; font-weight: 700; line-height: 1.1; color: var(--text) !important; margin: 0 !important; }
.plan-price small { font-size: 1rem; color: var(--muted); font-weight: 400; }
.plan-list { list-style: none; display: grid; gap: 8px; flex: 1; }
.plan-list li { padding-left: 26px; position: relative; color: #b8c5e8; }
.plan-list li::before { content: '✓'; position: absolute; left: 0; color: var(--accent-2); font-weight: 700; }
.plan-buy { display: flex; flex-wrap: wrap; gap: 8px; }
.plan .badge { align-self: flex-start; }
.plan-notes { display: grid; gap: 4px; max-width: 760px; }
.plan h3 { font-size: 1.4rem; margin: 0; }
.plans-home { max-width: 820px; margin: 0 0 8px; }
.plan .btn { align-self: flex-start; }
.sf-note a { color: var(--accent-2); }
.doc .plan-notes p { color: var(--muted); margin: 0; }

@media (max-width: 760px) {
  .acc { grid-template-columns: 1fr; gap: 16px; }
  .acc-side { position: static; padding: 16px; }
  .acc-nav { flex-direction: row; overflow-x: auto; gap: 4px; }
  .acc-nav a { white-space: nowrap; padding: 6px 10px; background: var(--bg-alt); }
  .acc-main h1 { font-size: 1.5rem; }
  .acc-card { padding: 18px 16px; }
  .acc-form { max-width: none; }
  .acc-card .table-wrap { background: none; }
  .plans { grid-template-columns: 1fr; }
  .plan { padding: 22px; }
  .plan-price { font-size: 2rem; }
}

/* ---- Cookie banner & privacy ---- */
.cookie-banner { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: var(--card); border-top: 1px solid var(--border); box-shadow: 0 -8px 24px rgba(0, 0, 0, .35); }
.cookie-inner { display: flex; gap: 16px 24px; align-items: center; justify-content: space-between; padding-top: 16px; padding-bottom: 16px; }
.cookie-inner p { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.cookie-inner a:not(.btn) { color: var(--accent-2); }
.cookie-actions { display: flex; gap: 8px; flex-wrap: wrap; flex-shrink: 0; }
.privacy-form { display: flex; flex-direction: column; gap: 12px; margin-bottom: 8px; }
.privacy-form .btn { align-self: flex-start; }
.check input:disabled { opacity: .6; cursor: not-allowed; }
.doc-table { width: 100%; border-collapse: collapse; margin: 8px 0 16px; font-size: .92rem; }
.doc-table th, .doc-table td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; vertical-align: top; }
.doc-table th { color: var(--muted); font-weight: 600; }
@media (max-width: 760px) {
  .cookie-inner { flex-direction: column; align-items: stretch; }
  .cookie-actions .btn { flex: 1; text-align: center; }
}

/* ---- StoryForge landing ---- */
.sf-hero { padding: 96px 0 80px; }
.sf-hero-grid { display: grid; grid-template-columns: 1fr 1.05fr; gap: 48px; align-items: center; }
.sf-hero h1 { font-size: clamp(2rem, 4.2vw, 3.2rem); }
.sf-note { margin-top: 16px; }
.sf-window { background: var(--card); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; box-shadow: 0 30px 80px rgba(0, 0, 0, .5), 0 0 0 1px rgba(59, 130, 246, .08); }
.sf-bar { display: flex; align-items: center; gap: 6px; padding: 10px 14px; background: var(--bg-alt); border-bottom: 1px solid var(--border); font-size: .8rem; color: var(--muted); }
.sf-bar i { width: 10px; height: 10px; border-radius: 50%; background: #2a3a62; }
.sf-bar span { margin-left: 10px; }
.sf-editor { display: grid; grid-template-columns: 150px 1fr; min-height: 300px; }
.sf-tree { display: flex; flex-direction: column; gap: 6px; padding: 14px; border-right: 1px solid var(--border); font-size: .8rem; color: var(--muted); }
.sf-tree b { color: var(--text); font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; margin-bottom: 4px; }
.sf-tree .on { color: var(--accent-2); }
.sf-page { padding: 18px 22px; font-family: "Courier Prime", "Courier New", ui-monospace, monospace; font-size: .82rem; line-height: 1.5; }
.sf-slug { font-weight: 700; margin-bottom: 10px; }
.sf-act { color: #b8c5e8; margin-bottom: 10px; }
.sf-who { text-align: center; margin-top: 6px; }
.sf-line { margin: 0 12% 6px; color: #b8c5e8; }
.sf-typing::after { content: '|'; color: var(--accent-2); animation: blink 1s infinite; }
.sf-hint { margin-top: 14px; padding: 10px 12px; border-radius: 8px; font-family: system-ui, sans-serif; font-size: .8rem; color: var(--muted); background: rgba(59, 130, 246, .1); border: 1px solid rgba(59, 130, 246, .35); }
.sf-hint b { display: block; color: var(--accent-2); margin-bottom: 2px; }

.sf-strip { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--bg-alt); }
.sf-strip-inner { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 40px; padding: 18px 24px; color: var(--muted); font-size: .9rem; letter-spacing: .05em; }

.sf-feature { display: grid; grid-template-columns: 1fr 1fr; gap: 56px; align-items: center; margin-top: 72px; }
.sf-feature:first-of-type { margin-top: 24px; }
.sf-rev .sf-text { order: 2; }
.sf-text h3 { font-size: 1.6rem; margin-bottom: 14px; }
.sf-text p { color: var(--muted); margin-bottom: 18px; }
.sf-list { list-style: none; display: grid; gap: 8px; }
.sf-list li { padding-left: 24px; position: relative; }
.sf-list li::before { content: '✦'; position: absolute; left: 0; color: var(--accent-2); }
.sf-art { background: radial-gradient(ellipse at 50% 0%, rgba(59, 130, 246, .14), transparent 70%), var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 20px; }
.sf-art svg { display: block; width: 100%; height: auto; }
.sf-chat { display: flex; flex-direction: column; gap: 10px; font-size: .9rem; }
.sf-dir { color: #f59e0b; font-size: .82rem; padding: 8px 12px; border: 1px dashed rgba(245, 158, 11, .4); border-radius: 8px; }
.sf-msg { max-width: 85%; padding: 10px 14px; border-radius: 12px; background: var(--bg-alt); border: 1px solid var(--border); }
.sf-msg b { display: block; font-size: .75rem; color: var(--accent-2); margin-bottom: 2px; }
.sf-msg em { color: var(--muted); }
.sf-r { align-self: flex-end; background: rgba(59, 130, 246, .18); border-color: rgba(59, 130, 246, .4); }
.sf-takes { display: flex; gap: 8px; margin-top: 4px; font-size: .8rem; }
.sf-takes span { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.sf-takes .on { border-color: var(--accent); color: var(--text); }
.sf-diff { font-family: ui-monospace, monospace; font-size: .85rem; display: grid; gap: 6px; }
.sf-diff-h { font-family: system-ui, sans-serif; color: var(--muted); font-size: .82rem; margin-bottom: 6px; }
.sf-diff .del { padding: 8px 12px; border-radius: 6px; background: rgba(239, 68, 68, .1); color: #f87171; text-decoration: line-through; }
.sf-diff .add { padding: 8px 12px; border-radius: 6px; background: rgba(34, 211, 238, .1); color: var(--accent-2); }
.sf-diff-a { display: flex; gap: 8px; margin-top: 8px; font-family: system-ui, sans-serif; }

.sf-price { font-size: 2rem; font-weight: 700; color: var(--text) !important; margin: 6px 0 10px; }
.sf-price small { font-size: .9rem; color: var(--muted); font-weight: 400; }
.sf-best { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 12px 40px rgba(59, 130, 246, .2); }
.sf-cta { text-align: center; background: radial-gradient(ellipse at 50% 100%, rgba(59, 130, 246, .22), transparent 65%); }
.sf-cta h2 { margin-bottom: 28px; }

@media (max-width: 760px) {
  .sf-hero { padding: 56px 0 48px; }
  .sf-hero-grid, .sf-feature { grid-template-columns: 1fr; gap: 28px; }
  .sf-rev .sf-text { order: 0; }
  .sf-feature { margin-top: 48px; }
  .sf-editor { grid-template-columns: 1fr; }
  .sf-tree { display: none; }
  .sf-text h3 { font-size: 1.35rem; }
}

/* ---- AI chat (/app) ---- */
.chat-list { list-style: none; margin: 0; padding: 0; }
.chat-list li { display: flex; align-items: center; border-radius: 8px; }
.chat-list li.active, .chat-list li:hover { background: var(--bg-alt); }
.chat-item { flex: 1; min-width: 0; text-align: left; background: none; border: 0; color: var(--text); padding: 8px 10px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: inherit; font-size: .92rem; }
.chat-del { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1.1rem; padding: 4px 10px; }
.chat-del:hover { color: #f87171; }
.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.chat-empty { margin: auto; text-align: center; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 12px; white-space: pre-wrap; word-wrap: break-word; line-height: 1.55; }
.msg.md { white-space: normal; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md pre, .md blockquote { margin: 0 0 .6em; }
.md h3, .md h4, .md h5, .md h6, .md h7, .md h8 { margin: .9em 0 .4em; font-size: 1rem; line-height: 1.35; }
.md h3 { font-size: 1.08rem; }
.md ul, .md ol { padding-left: 1.4em; }
.md li { margin: .15em 0; }
.md li > ul, .md li > ol { margin: .15em 0 0; }
.md code { padding: .1em .35em; border-radius: 4px; background: rgba(255, 255, 255, .08); font-family: ui-monospace, monospace; font-size: .88em; }
.md pre { padding: 8px 10px; border-radius: 6px; background: rgba(0, 0, 0, .3); overflow-x: auto; white-space: pre; }
.md pre code { padding: 0; background: none; }
.md blockquote { padding-left: 10px; border-left: 3px solid var(--border); color: #a9b6d9; }
.md hr { border: 0; border-top: 1px solid var(--border); margin: .8em 0; }
.msg-user { align-self: flex-end; background: var(--accent); color: #fff; }
.msg-assistant { align-self: flex-start; background: var(--bg-alt); border: 1px solid var(--border); }
.msg-error { align-self: center; color: #f87171; border: 1px solid #7f2a37; font-size: .9rem; }
.msg.pending::after { content: '…'; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.chat-form { display: flex; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border); }
.chat-form textarea { flex: 1; resize: none; max-height: 200px; }
.chat-note { margin: 0; }
.mod-banner { margin: 0 16px 8px; padding: 10px 14px; border-radius: 10px; background: rgba(239, 68, 68, .14); border: 1px solid rgba(239, 68, 68, .55); color: #fca5a5; font-weight: 600; font-size: .92rem; }
.mod-banner[hidden] { display: none; }
.sanction-row { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-bottom: 8px; }
.sanction-row select { margin-left: 6px; }
/* ---- admin: user violations page ---- */
.um-head { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 18px; padding: 18px 20px; margin: 8px 0 16px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; }
.um-avatar { width: 52px; height: 52px; flex: none; display: grid; place-items: center; border-radius: 50%; font-weight: 700; font-size: 1.35rem; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.um-id { flex: 1; min-width: 200px; }
.um-name { font-size: 1.15rem; font-weight: 700; }
.um-status { display: flex; flex-wrap: wrap; gap: 6px; }
.um-flag { display: inline-block; padding: 3px 12px; border-radius: 999px; font-size: .82rem; font-weight: 600; border: 1px solid; }
.um-flag-ok { color: var(--accent-2); border-color: rgba(34, 211, 238, .4); background: rgba(34, 211, 238, .08); }
.um-flag-ai { color: #fbbf24; border-color: rgba(251, 191, 36, .45); background: rgba(251, 191, 36, .1); }
.um-flag-ban { color: #f87171; border-color: rgba(239, 68, 68, .5); background: rgba(239, 68, 68, .12); }
.um-flag.off { opacity: .55; }
.um-stats { margin-bottom: 16px; }
.um-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; }
.um-card { padding: 18px 20px; margin-bottom: 16px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; min-width: 0; }
.um-card h2 { margin: 0 0 14px; font-size: 1.1rem; }
.um-form { display: grid; gap: 10px; }
.um-label { font-size: .85rem; font-weight: 600; color: var(--muted); margin-top: 4px; }
.seg-group { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg, .chip { position: relative; }
.seg input, .chip input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.seg span { display: grid; gap: 2px; height: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); cursor: pointer; transition: border-color .15s, background .15s; }
.seg small { color: var(--muted); font-size: .78rem; line-height: 1.3; }
.seg input:checked + span { border-color: var(--accent); background: rgba(59, 130, 246, .12); }
.seg input[value="ban"]:checked + span { border-color: #b4495a; background: rgba(239, 68, 68, .12); }
.seg input:focus-visible + span, .chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chip span { display: inline-block; padding: 5px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg); font-size: .88rem; cursor: pointer; }
.chip input:checked + span { border-color: var(--accent); background: var(--accent); color: #fff; }
.um-days { display: none; align-items: center; gap: 6px; font-size: .88rem; color: var(--muted); }
.um-days input { width: 90px; padding: 5px 8px; }
.chip-group:has(input[value="custom"]:checked) .um-days { display: inline-flex; }
.um-form textarea { padding: 10px 12px; resize: vertical; }
.um-timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--border); display: grid; gap: 12px; }
.um-timeline li { position: relative; display: grid; gap: 4px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.um-timeline li::before { content: ''; position: absolute; left: -21px; top: 16px; width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.um-timeline li.on::before { background: #f87171; box-shadow: 0 0 0 3px rgba(239, 68, 68, .2); }
.um-timeline form { display: block; }
.um-tl-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.um-reason { font-size: .9rem; white-space: pre-wrap; word-break: break-word; }
.um-events { display: grid; gap: 8px; }
.um-ev { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid var(--border); border-left-width: 3px; border-radius: 10px; background: var(--bg); }
.um-ev.block { border-left-color: #fbbf24; }
.um-ev-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.um-ev-top .muted-sm { margin-left: auto; }
.um-cats { display: flex; flex-wrap: wrap; gap: 4px; }
.cat-chip { padding: 1px 8px; border-radius: 6px; font-size: .78rem; font-family: ui-monospace, monospace; background: rgba(255, 255, 255, .05); border: 1px solid var(--border); color: var(--muted); }
.cat-chip b { color: var(--text); font-weight: 600; }
.um-excerpt { padding: 8px 10px; border-radius: 6px; background: rgba(0, 0, 0, .25); font-size: .88rem; white-space: pre-wrap; word-break: break-word; }
@media (max-width: 760px) {
  .um-grid { grid-template-columns: 1fr; }
  .seg-group { grid-template-columns: 1fr; }
  .um-ev-top .muted-sm { margin-left: 0; }
}
.mod-banner-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.mod-report-link { background: none; border: 0; padding: 0; color: #fecaca; text-decoration: underline; font: inherit; font-weight: 500; cursor: pointer; }
.mod-report { display: grid; gap: 8px; margin-top: 10px; font-weight: 400; color: var(--text); }
.mod-report textarea { width: 100%; resize: vertical; }
.mod-report .check { font-size: .85rem; }
.mod-report-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.mod-report-done { margin: 8px 0 0; font-weight: 500; color: var(--text); }
.report-pre { margin: 0 0 10px; padding: 8px 10px; border-radius: 6px; background: var(--bg); border: 1px solid var(--border); white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, monospace; font-size: .82rem; max-height: 420px; overflow: auto; }
.report-msg { margin-bottom: 6px; }
.report-msg.report-user b { color: var(--accent-2); }
.mod-form { display: grid; gap: 14px; margin: 18px 0 28px; }
.mod-flags { display: grid; gap: 8px; }
.mod-table select, .num-in { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; font: inherit; }
.num-in { width: 90px; }
.mod-test { display: grid; gap: 10px; max-width: 760px; }
.mod-test .btn { justify-self: start; }
.err-text { color: #f87171; font-weight: 600; }

/* ---- Script studio (/app/studio) ---- */
.studio-title { width: 100%; min-width: 160px; padding: 2px 6px; margin-left: -6px; font-size: 1.5rem; font-weight: 700; background: transparent; border-color: transparent; }
.studio-title:hover { border-color: var(--border); }
.studio-hint { margin: 0; padding: 10px 14px 0; }
.studio-hint label { display: grid; gap: 4px; }
.studio-hint input { padding: 8px 12px; background: var(--bg); }
.studio-foot { display: flex; justify-content: space-between; gap: 10px; }
.linkish { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; text-decoration: underline; }
.linkish:hover { color: var(--text); }
.studio-proposal { display: flex; flex-direction: column; gap: 10px; white-space: normal; max-width: 100%; }
.studio-proposal p { margin: 0; white-space: pre-wrap; }
.edit-block { display: grid; gap: 6px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.edit-block.done { opacity: .6; }
.edit-block pre { margin: 0; padding: 8px 10px; border-radius: 6px; white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, monospace; font-size: .82rem; }
.edit-block .del { background: rgba(239, 68, 68, .1); color: #f87171; text-decoration: line-through; }
.edit-block .add { background: rgba(34, 211, 238, .1); color: var(--accent-2); }
.edit-block .btn { justify-self: start; }
.edit-block.rejected { opacity: .45; }
.edit-block.rejected pre { text-decoration: line-through; }
.edit-actions { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 760px) {
  .msg { max-width: 92%; }
}

/* ==== App shell (/app: studio, chat) — StoryForge prototype layout ==== */
/* thin dark scrollbars (Firefox: scrollbar-*, Chromium/Safari: ::-webkit-scrollbar) */
.ap-body, .ap-body * { scrollbar-width: thin; scrollbar-color: #2a3a63 transparent; }
.ap-body ::-webkit-scrollbar { width: 8px; height: 8px; }
.ap-body ::-webkit-scrollbar-track { background: transparent; }
.ap-body ::-webkit-scrollbar-thumb { background: #2a3a63; border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
.ap-body ::-webkit-scrollbar-thumb:hover { background: #3b82f6; background-clip: padding-box; }
.ap-body ::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
.ap-body ::-webkit-scrollbar-corner { background: transparent; }
.ap-body { height: 100vh; height: 100dvh; overflow: hidden; display: grid; grid-template-rows: 56px minmax(0, 1fr); }
.ap-top { display: flex; align-items: center; gap: 14px; padding: 0 16px; background: rgba(10, 15, 28, .85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); position: relative; z-index: 70; }
.ap-logo { display: flex; align-items: center; flex: none; }
.ap-logo img { height: 30px; width: auto; display: block; }
.ap-crumb { color: var(--muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; padding-left: 14px; border-left: 1px solid var(--border); }
.ap-top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; flex: none; }
.ap-avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); font-weight: 700; color: #fff; }
.ap-avatar:hover { box-shadow: 0 0 0 2px rgba(59, 130, 246, .45); }
.ap-burger { display: none; }
.icon-btn { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--border); background: var(--card); color: var(--muted); cursor: pointer; font: inherit; font-size: .95rem; }
.icon-btn:hover { color: var(--text); border-color: var(--accent); }

.ap { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 0; height: 100%; }
/* AI panel (prototype): slides in from the right; pinned on wide screens it becomes the third grid column */
.ap.ap-with-ai .ai {
  position: fixed; top: 56px; right: 0; bottom: 0; width: 380px; max-width: 100vw; z-index: 60;
  transform: translateX(100%); transition: transform .22s ease, visibility .22s; box-shadow: -16px 0 40px rgba(0, 0, 0, .35); visibility: hidden;
}
.ap.ap-with-ai.ai-open .ai { transform: none; visibility: visible; }
@media (min-width: 1000px) {
  .ap.ap-with-ai.ai-pinned.ai-open { grid-template-columns: 232px minmax(0, 1fr) 380px; }
  .ap.ap-with-ai.ai-pinned.ai-open .ai { position: static; transform: none; transition: none; box-shadow: none; width: auto; }
}
@media (max-width: 999px) { #ai-pin { display: none; } }
.ai-pill {
  position: fixed; right: 18px; bottom: 18px; z-index: 55; padding: 9px 14px; border-radius: 999px; cursor: pointer; font: inherit;
  background: var(--card); border: 1px solid var(--accent); color: var(--text); font-size: .88rem; box-shadow: 0 10px 28px rgba(0, 0, 0, .4); transition: opacity .15s;
}
.ai-pill:hover { background: rgba(59, 130, 246, .15); }
.ap.ai-open .ai-pill { opacity: 0; pointer-events: none; }
.ap-ai-toggle.on { background: rgba(34, 211, 238, .15); }
.ap-project { width: auto; max-width: 240px; padding: 6px 10px; border-radius: 8px; font: inherit; font-size: .88rem; background: var(--bg); border: 1px solid var(--border); color: var(--text); }
.icon-btn.on { color: var(--text); border-color: var(--accent); background: rgba(59, 130, 246, .15); }
.head-actions { display: flex; gap: 6px; }
.pop-wrap { position: relative; }
.pop { position: absolute; right: 0; top: 38px; width: 270px; z-index: 5; display: grid; gap: 12px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 12px; box-shadow: 0 12px 30px rgba(0, 0, 0, .45); }
.pop[hidden] { display: none; }
.pop-field { display: grid; gap: 4px; font-size: .82rem; color: var(--muted); }
.pop-field select { width: 100%; max-width: none; }
.pop .linkish { justify-self: start; font-size: .85rem; }
.ai-ctx { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 14px; border: 0; border-bottom: 1px solid var(--border); background: none; cursor: pointer; font: inherit; font-size: .8rem; color: var(--muted); text-align: left; }
.ai-ctx:hover { color: var(--text); }
.ai-ctx .budget { flex: 1; }
.ai-ctx .caret { transition: transform .15s; }
.ai-ctx.open .caret { transform: rotate(180deg); }
.ai-ctx.warn { color: var(--warn, #fbbf24); }
.ai-ctx.warn .budget > i { background: var(--warn, #fbbf24); }
.budget { height: 4px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.budget > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .2s; }
.ctx-warn { padding: 6px 14px; font-size: .78rem; color: var(--warn, #fbbf24); background: rgba(251, 191, 36, .08); border-bottom: 1px solid var(--border); }
.ai-ctx-details { padding: 8px 14px 10px; border-bottom: 1px solid var(--border); display: grid; gap: 6px; }
.ai-ctx-details[hidden], .ctx-warn[hidden] { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chips .badge { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.cmd-btn { flex: none; width: 40px; height: 40px; padding: 0; display: grid; place-items: center; font-size: 1rem; }
.quick .quick-clear { color: #f87171; border-color: rgba(248, 113, 113, .35); }
.quick .quick-clear:hover { color: #fff; border-color: #f87171; }
.cmd-btn.on { border-color: var(--accent); background: rgba(59, 130, 246, .15); }
.quick[hidden] { display: none; }
.ai .msg-user { background: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important; align-self: flex-end; }
.badge-warn { color: var(--warn, #fbbf24); border-color: rgba(251, 191, 36, .5); }
.pj-new { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: 10px; align-items: center; margin-bottom: 16px; }
.pj-new input { padding: 9px 12px; background: var(--bg); }
.pj-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pj-settings { margin-top: 22px; display: grid; gap: 12px; }
.pj-settings summary { cursor: pointer; color: var(--muted); }
.pj-settings .pj-new { margin: 12px 0; }
@media (max-width: 760px) { .pj-new { grid-template-columns: 1fr; } }

/* ---- studio: project structure (prototype «Структура сцен») ---- */
.side-foot { margin-top: 18px; padding-top: 10px; border-top: 1px solid var(--border); }
.ap-side .nav-item .count { margin-left: auto; font-size: .75rem; }
.st-badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .74rem; white-space: nowrap; border: 1px solid var(--border); color: var(--muted); }
.st-done { color: #34d399; border-color: rgba(52, 211, 153, .45); }
.st-wip { color: #fff; background: var(--accent); border-color: var(--accent); }
.st-idea { color: #fbbf24; border-color: rgba(251, 191, 36, .5); }
.st-draft { color: var(--muted); background: var(--bg); }
.sx-group { margin-bottom: 18px; }
.sx-act { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 8px; }
.sx-act h3 { font-size: 1rem; display: inline; }
.sx-act-edit summary { cursor: pointer; list-style: none; }
.sx-act-edit summary::-webkit-details-marker { display: none; }
.sx-act-edit summary::after { content: ' ✎'; color: var(--muted); font-size: .8rem; opacity: 0; }
.sx-act-edit summary:hover::after { opacity: 1; }
.sx-act-edit[open] { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.sx-rename { display: inline-flex; gap: 6px; }
.sx-rename input { padding: 5px 9px; width: 220px; background: var(--bg); }
.sx-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; margin-bottom: 6px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
.sx-row:hover { border-color: var(--accent); }
.sx-main { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; color: var(--text); }
.sx-n, .snum { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 8px; background: var(--bg); color: var(--accent-2); font-weight: 700; font-size: .85rem; }
.sx-text { display: grid; min-width: 0; }
.sx-text strong { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sx-slug { font-size: .8rem; color: var(--muted); text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sx-links { font-size: .8rem; color: var(--muted); white-space: nowrap; font-family: ui-monospace, monospace; }
.sx-move { display: flex; gap: 4px; opacity: .35; }
.sx-row:hover .sx-move { opacity: 1; }
.sx-move .icon-btn { width: 26px; height: 26px; font-size: .8rem; }
.sx-empty { padding: 6px 2px 10px; }
.icon-btn.disabled { opacity: .35; cursor: default; pointer-events: none; }
a.icon-btn { text-decoration: none; }

/* editor: title with scene picker, properties */
.title-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.title-row .studio-title { flex: 1; }
.title-btn { display: flex; align-items: center; gap: 4px; padding: 2px 4px; background: none; border: 1px solid transparent; border-radius: 8px; color: var(--text); cursor: pointer; font: inherit; }
.title-btn:hover { border-color: var(--border); }
.title-btn .caret { color: var(--muted); font-size: .8rem; }
.scene-pop { left: 0; right: auto; width: 340px; max-height: 70vh; overflow-y: auto; gap: 2px; padding: 8px; }
.scene-pop .sp-act { font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin: 10px 8px 4px; font-weight: 600; }
.scene-pop .sp-act:first-child { margin-top: 4px; }
.scene-pop a { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; color: var(--text); }
.scene-pop a:hover, .scene-pop a.cur { background: var(--bg); }
.scene-pop a.cur { box-shadow: inset 2px 0 0 var(--accent); }
.scene-pop .sp-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scene-pop .sp-all { margin-top: 6px; border-top: 1px solid var(--border); border-radius: 0; padding-top: 10px; color: var(--accent-2); }
.props-pop { width: 320px; }
.tab-n { font-family: ui-monospace, monospace; font-size: .75rem; color: var(--muted); margin-left: 4px; }
.links-list { list-style: none; margin: 4px 0; padding: 0; display: grid; gap: 4px; color: var(--text); font-size: .86rem; }
.links-list:empty { display: none; }
.link-add { display: grid; gap: 6px; }
.link-add input, .link-add select { width: 100%; max-width: none; padding: 6px 9px; background: var(--bg); }
.ai-tool { align-self: flex-start; font-size: .8rem; color: var(--accent-2); font-family: ui-monospace, monospace; padding: 2px 4px; }
.ai-tool a { text-decoration: underline; }
.ap:not(.adv-mode) .ai-tool { opacity: .75; }
@media (max-width: 760px) {
  .sx-links, .sx-move { display: none; }
  .scene-pop, .props-pop { width: min(320px, calc(100vw - 30px)); }
}
.ap-side { background: var(--bg-alt); border-right: 1px solid var(--border); padding: 12px 10px; overflow-y: auto; min-height: 0; }
.ap-side h4 { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; margin: 14px 8px 6px; }
.ap-side h4:first-child { margin-top: 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; border: 0; background: none; cursor: pointer; text-align: left; color: var(--muted); font: inherit; font-size: .94rem; white-space: nowrap; }
.nav-item:hover { color: var(--text); background: var(--card); }
.nav-item.active { color: var(--text); background: var(--card); box-shadow: inset 2px 0 0 var(--accent); }
.nav-item .ico { width: 18px; flex: none; text-align: center; color: var(--accent); font-weight: 700; }
.nav-item .lbl { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.nav-item.sub { padding: 6px 10px; font-size: .88rem; }
.nav-item.sub .ico { color: var(--muted); }
.nav-new .ico { color: var(--accent-2); }
.ap-side .chat-list li { display: flex; align-items: center; border-radius: 8px; }
.ap-side .chat-list li:hover, .ap-side .chat-list li.active { background: var(--card); }
.ap-side .chat-list li.active { box-shadow: inset 2px 0 0 var(--accent); }
.ap-side .chat-item { flex: 1; min-width: 0; padding: 6px 10px; font-size: .88rem; color: var(--muted); background: none; border: 0; text-align: left; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: inherit; }
.ap-side .chat-list li.active .chat-item, .ap-side .chat-item:hover { color: var(--text); }
.ap-side .chat-del { opacity: 0; padding: 2px 8px; }
.ap-side .chat-list li:hover .chat-del, .ap-side .chat-list li.active .chat-del { opacity: 1; }
.ap-scrim { display: none; }

.ap-main { overflow-y: auto; padding: 22px 26px; min-width: 0; min-height: 0; }
.ap-main.fill { display: flex; flex-direction: column; overflow: hidden; }
.ap-main.fill > .stage { flex: 1; min-height: 0; }
.ap-main h1 { font-size: 1.5rem; line-height: 1.25; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 16px; margin-bottom: 16px; flex-wrap: wrap; flex: none; }
.ph-title { flex: 1; min-width: 200px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.zone-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 600; }
.crumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); margin-bottom: 2px; }
.crumbs a:hover { color: var(--accent-2); }
.credits { font-size: .85rem; color: var(--muted); }
.ap select { width: auto; max-width: 100%; padding: 6px 10px; border-radius: 8px; font: inherit; font-size: .88rem; background: var(--bg); border: 1px solid var(--border); color: var(--text); }
.ap select:focus { outline: none; border-color: var(--accent); }
.placeholder { border: 1px dashed var(--border); border-radius: 12px; padding: 32px; text-align: center; color: var(--muted); }

/* segmented control */
.ap-seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--card); border: 1px solid var(--border); border-radius: 9px; }
.ap-seg button { padding: 5px 12px; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; font: inherit; font-size: .86rem; font-weight: 600; }
.ap-seg button:hover { color: var(--text); }
.ap-seg button.active { background: var(--accent); color: #fff; }
.ap-seg-full { display: flex; margin: 10px 14px 0; }
.ap-seg-full button { flex: 1; }

/* stage: the screenplay sheet */
.stage { background: var(--card); border: 1px solid var(--border); border-radius: 12px; display: flex; flex-direction: column; overflow: hidden; }
.script { flex: 1; min-height: 0; overflow-y: auto; padding: 28px 10%; font-family: "Courier Prime", "Courier New", ui-monospace, monospace; font-size: .95rem; line-height: 1.6; }
textarea.script { width: 100%; resize: none; border: 0; border-radius: 0; background: transparent; color: var(--text); tab-size: 4; }
textarea.script:focus { border: 0; }
textarea.script::placeholder { color: #4b5b85; }
.script-view .slug { text-transform: uppercase; font-weight: 700; margin: 22px 0 14px; }
.script-view .slug:first-child { margin-top: 0; }
.script-view .action { margin: 0 0 14px; color: #c7d2f0; }
.script-view .who { text-align: center; text-transform: uppercase; margin-top: 6px; }
.script-view .paren { text-align: center; color: var(--muted); font-style: italic; }
.script-view .line { margin: 0 18% 4px; }
.script-view .line + .action, .script-view .line + .who, .script-view .paren + .action { margin-top: 14px; }

/* AI panel (right column) */
.ai { background: var(--bg-alt); border-left: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.ai-head { padding: 10px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ai-head h3 { font-size: 1rem; }
.ai-head h3::before { content: '✦ '; color: var(--accent-2); }
.ai-head select { max-width: 170px; }
.ai-log { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.ai-form { padding: 10px 14px 12px; border-top: 1px solid var(--border); display: grid; gap: 8px; }
.chat-stage .ai-form { background: var(--bg-alt); }
.ai-input-row { display: flex; gap: 6px; align-items: flex-end; }
.ai-input-row textarea { flex: 1; min-height: 40px; max-height: 200px; padding: 9px 12px; resize: none; background: var(--bg); line-height: 1.45; overflow-y: auto; }
.ai-input-row textarea::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-ai { background: transparent; border: 1px solid var(--accent-2); color: var(--accent-2); }
.btn-ai:hover { background: rgba(34, 211, 238, .12); box-shadow: none; }
.send-btn { flex: none; width: 42px; height: 40px; padding: 0; display: grid; place-items: center; font-size: 1rem; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; }
.quick:empty { display: none; }
.quick button { font: inherit; font-size: .78rem; padding: 4px 10px; border-radius: 999px; background: var(--card); border: 1px solid var(--border); color: var(--muted); cursor: pointer; }
.quick button:hover { color: var(--text); border-color: var(--accent-2); }
.ap .msg { font-size: .92rem; padding: 9px 12px; border-radius: 10px; }
.ap .msg-user { background: rgba(34, 211, 238, .12); border: 1px solid rgba(34, 211, 238, .35); color: var(--text); max-width: 90%; }
.ap .msg-assistant { background: var(--card); border: 1px solid var(--border); }
.ap .chat-stage .msg-assistant { background: var(--bg-alt); }
.ap .studio-proposal { max-width: 100%; }
.ap .mod-banner { margin: 0; }

/* script cards (list page) */
.sc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.sc-card { display: flex; align-items: center; gap: 12px; padding: 14px 16px; transition: border-color .15s, transform .15s; }
.sc-card:hover { border-color: var(--accent); }
.sc-ico { width: 38px; height: 38px; flex: none; border-radius: 10px; display: grid; place-items: center; font-weight: 700; background: var(--bg); color: var(--accent-2); border: 1px solid var(--border); }
.sc-meta { display: grid; min-width: 0; flex: 1; }
.sc-meta strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { white-space: nowrap; }

@media (max-width: 1200px) {
  .ap, .ap.ap-with-ai { grid-template-columns: 64px minmax(0, 1fr); }
  .ap.ap-with-ai.ai-pinned.ai-open { grid-template-columns: 64px minmax(0, 1fr) 340px; }
  .ap-side { padding: 10px 6px; }
  .ap-side h4, .ap-side .lbl, .ap-side .chat-list, .ap-side .nav-item.sub { display: none; }
  .ap-side .nav-item { justify-content: center; padding: 10px 0; }
  .ap-side .nav-item .ico { width: auto; font-size: 1.05rem; }
  .ap-side.open-labels .lbl { display: inline; }
  /* the chat list is needed on the chat page: keep the full drawer via ☰ */
  .ap-burger { display: grid; }
  .ap.side-open .ap-side { position: fixed; top: 56px; left: 0; bottom: 0; width: 260px; z-index: 65; padding: 12px 10px; box-shadow: 16px 0 40px rgba(0, 0, 0, .45); }
  .ap.side-open .ap-side h4, .ap.side-open .ap-side .lbl { display: block; }
  .ap.side-open .ap-side .chat-list { display: block; }
  .ap.side-open .ap-side .nav-item.sub { display: flex; }
  .ap.side-open .ap-side .nav-item { justify-content: flex-start; padding: 8px 10px; }
  .ap.side-open .ap-side .nav-item .ico { width: 18px; font-size: inherit; }
  .ap.side-open .ap-scrim { display: block; position: fixed; inset: 56px 0 0 0; z-index: 60; background: rgba(5, 8, 16, .5); }
}
@media (max-width: 1000px) {
  .ap.ap-with-ai .ai { width: min(420px, 100vw); }
}
@media (max-width: 760px) {
  .ap-top { padding: 0 10px; gap: 8px; }
  .ap-crumb, .ap-top .lang-pick { display: none; }
  .ap, .ap.ap-with-ai, .ap.ap-with-ai.ai-pinned.ai-open { grid-template-columns: 1fr; }
  .ap > .ap-side { display: none; }
  .ap.side-open > .ap-side { display: block; }
  .ap-ai-toggle .ai-lbl, .cmd-lbl, .ap-project { display: none; }
  .ap-main { padding: 14px; }
  .ap-main h1, .studio-title { font-size: 1.2rem; }
  .page-head { margin-bottom: 12px; }
  .page-head .toolbar { width: 100%; }
  .script { padding: 16px; font-size: .88rem; }
  .script-view .line { margin: 0 4% 4px; }
  .ai-input-row textarea, .ap select, .ap input { font-size: 16px; }
  .credits { display: none; }
}

/* ---- admin: billing ---- */
.switch { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: .92rem; line-height: 1.4; }
.switch input { width: auto; margin-top: 3px; accent-color: var(--accent); }
.bill-form { display: block; }
.gw { display: grid; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); margin-bottom: 12px; }
.gw-head { display: flex; align-items: baseline; gap: 10px; font-size: 1.05rem; }
.gw-kv { grid-template-columns: auto 1fr; font-size: .85rem; }
.gw-kv dt { font-family: ui-monospace, monospace; color: var(--muted); }
.plan-edit { display: grid; gap: 10px; }
.pe-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; align-items: end; }
.pe-row label, .price-row label { display: grid; gap: 4px; font-size: .82rem; color: var(--muted); }
.pe-row input, .price-row input { padding: 8px 10px; background: var(--bg); }
.price-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) minmax(0, 1.3fr); gap: 10px; align-items: end; padding: 10px; border: 1px solid var(--border); border-radius: 10px; }
.price-row .switch { align-self: center; }
.grant-row { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) 100px minmax(0, 1.5fr) auto; }
.plan-box { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; }
.plan-box code { font-size: .78rem; color: var(--muted); margin-left: 6px; text-transform: none; letter-spacing: 0; }
.plan-del { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.plans.plans-many { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
@media (max-width: 760px) {
  .pe-row, .price-row, .grant-row { grid-template-columns: 1fr; }
}
