/* Kanzelclips — shared theme ("Light from above": gold → coral → violet).
   Light and dark themes via tokens; data-theme on <html> wins over system. */

:root {
  --bg: #f7f4ee;
  --bg-elevated: #fdfbf7;
  --card: #ffffff;
  --border: #e6e0d3;
  --text: #201b2e;
  --text-dim: #625c74;
  --accent: #6d4fd3;
  --accent-warm: #e85d5b;
  --gold: #e8a02e;
  --good: #2f9e6e;
  --bad: #d64550;
  --grad: linear-gradient(100deg, #e8a02e 0%, #e85d5b 48%, #7c5cff 100%);
  --grad-soft: linear-gradient(100deg, rgba(232,160,46,.14), rgba(232,93,91,.12) 48%, rgba(124,92,255,.14));
  --nav-bg: rgba(251, 249, 244, 0.86);
  --shadow: 0 10px 30px rgba(32, 27, 46, 0.09);
  --shadow-lg: 0 24px 60px -18px rgba(32, 27, 46, 0.22);
  --ink-on-grad: #17121f;
}
[data-theme="dark"] { color-scheme: dark; }
[data-theme="dark"]:root {
  --bg: #100d1c;
  --bg-elevated: #161227;
  --card: #1b1630;
  --border: #2d2749;
  --text: #f3f0fb;
  --text-dim: #a9a2c4;
  --accent: #a48bff;
  --accent-warm: #ff7d76;
  --gold: #f0b448;
  --good: #4adf9e;
  --bad: #ff6b74;
  --grad-soft: linear-gradient(100deg, rgba(240,180,72,.12), rgba(255,125,118,.10) 48%, rgba(164,139,255,.14));
  --nav-bg: rgba(14, 11, 24, 0.85);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 60px -18px rgba(0, 0, 0, 0.6);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #100d1c;
    --bg-elevated: #161227;
    --card: #1b1630;
    --border: #2d2749;
    --text: #f3f0fb;
    --text-dim: #a9a2c4;
    --accent: #a48bff;
    --accent-warm: #ff7d76;
    --gold: #f0b448;
    --good: #4adf9e;
    --bad: #ff6b74;
    --grad-soft: linear-gradient(100deg, rgba(240,180,72,.12), rgba(255,125,118,.10) 48%, rgba(164,139,255,.14));
    --nav-bg: rgba(14, 11, 24, 0.85);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 24px 60px -18px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 24px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Nav ---------- */
header.nav {
  position: sticky; top: 0; z-index: 20;
  background: var(--nav-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav-inner { display: flex; align-items: center; gap: 18px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.12rem; color: var(--text); letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.brand .mark {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  background: var(--grad);
  display: grid; place-items: center;
  color: var(--ink-on-grad); font-weight: 900; font-size: 1.05rem;
  box-shadow: 0 4px 14px rgba(232, 93, 91, 0.35);
}
.nav-links { display: flex; gap: 20px; margin-left: 10px; }
.nav-links a { color: var(--text-dim); font-weight: 500; font-size: 0.95rem; }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-spacer { flex: 1; }
.theme-toggle {
  border: 1px solid var(--border); background: transparent; color: var(--text-dim);
  width: 38px; height: 38px; border-radius: 9px; cursor: pointer; font-size: 1.15rem;
  font-family: inherit; line-height: 1;
  display: grid; place-items: center;
}
.theme-toggle:hover { color: var(--text); border-color: var(--accent); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 22px; border-radius: 10px; font-weight: 650; font-size: 0.95rem;
  cursor: pointer; border: 1px solid transparent; font-family: inherit;
  transition: filter .15s ease, transform .15s ease, border-color .15s ease, color .15s ease;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--grad); color: var(--ink-on-grad); }
.btn-primary:hover { filter: saturate(1.15) brightness(1.05); transform: translateY(-1px); }
.btn-ghost { border-color: var(--border); color: var(--text); background: transparent; }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 8px 14px; font-size: 0.88rem; border-radius: 8px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; filter: grayscale(0.4); }
.btn:focus-visible, a:focus-visible, button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- Sections / cards ---------- */
section { padding: 52px 0; }
h1 { font-size: clamp(2rem, 4.6vw, 3.1rem); line-height: 1.12; letter-spacing: -0.025em; margin: 0 0 16px; }
h2 { font-size: clamp(1.4rem, 2.6vw, 1.9rem); letter-spacing: -0.02em; margin: 0 0 8px; }
h3 { font-size: 1.05rem; margin: 0 0 6px; }
.section-lead { color: var(--text-dim); max-width: 44em; margin: 0 0 28px; }
.grad-text {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 24px; box-shadow: var(--shadow);
}
.grid { display: grid; gap: 18px; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.tile { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 22px; }
.tile .icon {
  width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center;
  font-size: 1.25rem; background: var(--grad-soft); border: 1px solid var(--border); margin-bottom: 12px;
}
.tile p { color: var(--text-dim); font-size: 0.93rem; margin: 0; }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--card);
  padding: 5px 13px; font-size: 0.82rem; font-weight: 650; color: var(--text-dim);
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); }

/* ---------- Footer ---------- */
footer { border-top: 1px solid var(--border); margin-top: 40px; padding: 30px 0 40px; color: var(--text-dim); font-size: 0.9rem; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 12px 26px; align-items: center; justify-content: space-between; }
.footer-links { display: flex; flex-wrap: wrap; gap: 18px; }

/* ---------- Landing hero ---------- */
.hero { padding: 64px 0 56px; position: relative; }
.hero::before {
  content: ""; position: absolute; inset: -140px -10% auto -10%; height: 480px; z-index: -1;
  background:
    radial-gradient(circle at 18% 30%, rgba(232, 160, 46, 0.16), transparent 42%),
    radial-gradient(circle at 82% 22%, rgba(124, 92, 255, 0.16), transparent 44%),
    radial-gradient(circle at 55% 70%, rgba(232, 93, 91, 0.10), transparent 40%);
  filter: blur(28px);
  pointer-events: none;
}
.hero-grid { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 44px; align-items: center; }
.hero .lead { color: var(--text-dim); font-size: 1.12rem; max-width: 34em; margin: 0 0 26px; }
.hero-ctas { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 22px; }
.hero-pills { display: flex; flex-wrap: wrap; gap: 9px; }

/* Phone mockup */
.phone-stage { display: grid; place-items: center; perspective: 1400px; }
.phone {
  width: clamp(210px, 24vw, 260px); aspect-ratio: 9 / 18.4; border-radius: 40px; padding: 9px;
  background: linear-gradient(155deg, #6d6478, #241d31 16%, #0b0913 66%, #3d3450);
  box-shadow:
    0 50px 90px -35px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.18),
    18px 0 55px -34px rgba(124, 92, 255, 0.45),
    -18px 0 55px -34px rgba(232, 160, 46, 0.45);
  transform: rotateY(-7deg) rotateX(2deg);
  animation: phone-float 7s ease-in-out infinite;
}
@keyframes phone-float {
  0%, 100% { transform: rotateY(-7deg) rotateX(2deg) translateY(0); }
  50% { transform: rotateY(-7deg) rotateX(2deg) translateY(-12px); }
}
.phone-screen {
  width: 100%; height: 100%; border-radius: 32px; overflow: hidden; position: relative;
  background:
    radial-gradient(circle at 50% 0%, rgba(240, 180, 72, 0.35), transparent 55%),
    linear-gradient(170deg, #221a38 0%, #120d20 60%, #0b0813 100%);
  display: flex; flex-direction: column; justify-content: flex-end; padding: 18px 16px 22px;
}
.phone-screen::before {
  content: ""; position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  width: 34%; height: 15px; border-radius: 999px; background: #06040c;
}
.caption-line {
  height: 13px; border-radius: 7px; margin-top: 9px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}
.caption-line.hot { background: var(--grad); width: 78%; }
.caption-line.w60 { width: 60%; }
.caption-line.w88 { width: 88%; }
.phone-badge {
  position: absolute; top: 42px; left: 16px;
  font-size: 0.62rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  color: #ffe9c4; background: rgba(0, 0, 0, 0.4); border: 1px solid rgba(255, 233, 196, 0.35);
  padding: 3px 8px; border-radius: 999px;
}
.phone-progress {
  position: absolute; left: 16px; right: 16px; bottom: 12px; height: 4px;
  border-radius: 999px; background: rgba(255, 255, 255, 0.18); overflow: hidden;
}
.phone-progress::after {
  content: ""; position: absolute; inset: 0; width: 40%;
  border-radius: 999px; background: var(--grad);
  animation: progress-sweep 5.5s ease-in-out infinite;
}
@keyframes progress-sweep { 0% { width: 8%; } 55% { width: 82%; } 100% { width: 8%; } }

/* Steps */
.steps { counter-reset: step; display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.step { position: relative; padding: 22px 22px 22px 64px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; }
.step::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 18px; top: 20px;
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  background: var(--grad); color: var(--ink-on-grad); font-weight: 900;
}
.step p { color: var(--text-dim); font-size: 0.93rem; margin: 0; }

/* Scope cards */
.scope { position: relative; overflow: hidden; }
.scope::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--grad);
}
.scope code {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  font-size: 0.82rem; color: var(--text); background: var(--grad-soft);
  border: 1px solid var(--border); border-radius: 6px; padding: 2px 7px;
}

/* ---------- Legal pages ---------- */
.legal { max-width: 46em; margin: 0 auto; padding: 46px 24px 20px; }
.legal h1 { font-size: 2rem; }
.legal h2 { font-size: 1.2rem; margin-top: 34px; }
.legal p, .legal li { color: var(--text-dim); font-size: 0.97rem; }
.legal .updated { font-size: 0.85rem; color: var(--text-dim); margin-bottom: 30px; }

/* ---------- App ---------- */
.app-main { min-height: calc(100vh - 200px); padding: 40px 0; }
.account-row { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.avatar {
  width: 52px; height: 52px; border-radius: 50%; object-fit: cover; flex: none;
  border: 2px solid transparent; background: var(--grad); padding: 2px;
}
.avatar-fallback {
  width: 52px; height: 52px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--grad); color: var(--ink-on-grad); font-weight: 900; font-size: 1.3rem;
}
.account-meta { flex: 1; min-width: 200px; }
.account-meta .name { font-weight: 750; font-size: 1.08rem; }
.account-meta .sub { color: var(--text-dim); font-size: 0.85rem; }
.env-badge {
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border);
}
.env-badge.sandbox { color: var(--gold); border-color: var(--gold); }
.env-badge.production { color: var(--good); border-color: var(--good); }

.login-card { max-width: 440px; margin: 8vh auto 0; text-align: center; padding: 38px 30px; }
.login-card .mark-lg {
  width: 62px; height: 62px; border-radius: 17px; margin: 0 auto 18px;
  background: var(--grad); display: grid; place-items: center;
  color: var(--ink-on-grad); font-weight: 900; font-size: 1.9rem;
  box-shadow: 0 10px 30px rgba(232, 93, 91, 0.35);
}
.login-card p { color: var(--text-dim); font-size: 0.94rem; }
.env-select { display: flex; gap: 8px; justify-content: center; margin: 20px 0; }
.env-select label {
  border: 1px solid var(--border); border-radius: 10px; padding: 9px 16px;
  font-size: 0.9rem; font-weight: 600; cursor: pointer; color: var(--text-dim);
}
.env-select input { display: none; }
.env-select label:has(input:checked) {
  border-color: var(--accent); color: var(--accent); background: var(--grad-soft);
}
.login-note { font-size: 0.82rem; margin-top: 16px; }

.gallery-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin: 34px 0 14px; }
.gallery-head h2 { margin: 0; }
.gallery-head .count { color: var(--text-dim); font-size: 0.9rem; }
.clip-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.clip-card { display: flex; flex-direction: column; overflow: hidden; padding: 0; }
.clip-thumb {
  position: relative; aspect-ratio: 16 / 10; overflow: hidden;
  background:
    radial-gradient(circle at 30% 25%, rgba(232, 160, 46, 0.35), transparent 55%),
    radial-gradient(circle at 75% 70%, rgba(124, 92, 255, 0.4), transparent 60%),
    #191430;
}
.clip-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.clip-thumb .brand-chip {
  position: absolute; top: 10px; left: 10px;
  font-size: 0.68rem; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase;
  background: rgba(10, 8, 18, 0.72); color: #fff; border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 3px 9px; border-radius: 999px; backdrop-filter: blur(4px);
}
.clip-body { padding: 15px 16px 16px; display: flex; flex-direction: column; gap: 9px; flex: 1; }
.clip-title { font-weight: 700; font-size: 0.95rem; line-height: 1.35; }
.clip-caption {
  color: var(--text-dim); font-size: 0.83rem; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.clip-meta { color: var(--text-dim); font-size: 0.78rem; display: flex; gap: 10px; flex-wrap: wrap; }
.clip-actions { display: flex; gap: 8px; margin-top: auto; }
.clip-actions .btn { flex: 1; }
.clip-status { font-size: 0.82rem; min-height: 1.3em; font-weight: 600; }
.clip-status.ok { color: var(--good); }
.clip-status.err { color: var(--bad); }
.clip-status.busy { color: var(--gold); }
.spinner {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--gold); border-top-color: transparent;
  animation: spin 0.8s linear infinite; vertical-align: -1px; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 44px 24px; color: var(--text-dim); }
.empty-state .icon { font-size: 2.2rem; margin-bottom: 10px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  border-radius: 12px; padding: 12px 20px; font-size: 0.9rem; z-index: 50;
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
  max-width: min(90vw, 480px);
}
.toast.show { opacity: 1; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; gap: 34px; text-align: center; }
  .hero .lead { margin-inline: auto; }
  .hero-ctas, .hero-pills { justify-content: center; }
  .phone { transform: none; animation: none; }
}
@media (max-width: 700px) {
  .nav-links { display: none; }
  section { padding: 38px 0; }
}

@media (prefers-reduced-motion: reduce) {
  .phone, .phone-progress::after, .spinner { animation: none !important; }
  .btn-primary:hover { transform: none; }
}
.clip-caption { cursor: pointer; }
.clip-caption.expanded { -webkit-line-clamp: unset; }
.btn-copy { align-self: flex-start; flex: 0 0 auto; }
