/* ═══════════════════════════════════════════════════════════════════
   BLACKMIRROR — design system
   ═══════════════════════════════════════════════════════════════════ */

:root {
  /* Surfaces */
  --page:    #1d1d1f;
  --card:    #2a2a2d;
  --sheet:   #2c2c2e;
  --inset:   #19191b;
  --black:   #000;
  --overlay: rgba(0, 0, 0, .6);

  /* Hairlines */
  --line:     rgba(255, 255, 255, .08);
  --line-mid: rgba(255, 255, 255, .14);

  /* Text */
  --t1: #f5f5f7;
  --t2: #a1a1a6;
  --t3: #86868b;
  --t4: #6e6e73;

  /* Accent */
  --blue:      #0a84ff;
  --blue-hi:   #409cff;
  --blue-lo:   #0071e3;
  --blue-tint: rgba(10, 132, 255, .15);

  /* Status */
  --green: #30d158;  --green-tint: rgba(48, 209, 88, .15);
  --amber: #ffd60a;  --amber-tint: rgba(255, 214, 10, .15);
  --red:   #ff453a;  --red-tint:   rgba(255, 69, 58, .15);

  /* Radii */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-pill: 9999px;

  /* Type */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
          "Helvetica Neue", "Segoe UI", Roboto, system-ui, sans-serif;
  --mono: "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  /* Motion */
  --ease: cubic-bezier(.25, 1, .5, 1);
  --fast: 150ms;
  --med:  200ms;

  /* Layout */
  --topbar-h: 56px;
}

/* ═══════════════════════════════════════════════════════════════════
   RESET
   ═══════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--t1);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body.is-app { overflow: hidden; }

h1, h2, h3 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -.015em;
  line-height: 1.15;
}
p { margin: 0; }

a {
  color: var(--blue);
  text-decoration: none;
  transition: color var(--fast) var(--ease);
}
a:hover { color: var(--blue-hi); }

code { font-family: var(--mono); }

button, input {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  margin: 0;
}
button {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

img, video { display: block; max-width: 100%; }

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
button:focus:not(:focus-visible) { outline: none; }

::selection { background: rgba(10, 132, 255, .35); }

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .12) transparent;
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .12);
  border-radius: var(--r-pill);
  border: 2px solid transparent;
  background-clip: padding-box;
}

.hidden { display: none !important; }

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

/* ═══════════════════════════════════════════════════════════════════
   KEYFRAMES
   ═══════════════════════════════════════════════════════════════════ */

@keyframes viewIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes sheetUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes backdropIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes pulse {
  0%, 100% { opacity: .4; }
  50%      { opacity: 1; }
}
@keyframes dotPulse {
  0%, 100% { opacity: .3; }
  50%      { opacity: 1; }
}
@keyframes lowPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .55; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════════════
   SHARED UTILITIES
   ═══════════════════════════════════════════════════════════════════ */

.hint  { font-size: 12px; color: var(--t3); line-height: 1.5; }
.muted { color: var(--t3); }
.small { font-size: 12px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Absolute-fill empty state inside a media frame */
.placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--t3);
  font-size: 13px;
  text-align: center;
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 20px;
  background: rgba(255, 255, 255, .09);
  border-radius: var(--r-pill);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--fast) var(--ease), opacity var(--fast) var(--ease);
}
.btn:hover:not(:disabled) { background: rgba(255, 255, 255, .14); }
.btn:disabled { opacity: .35; cursor: not-allowed; }

.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--blue-hi); }

.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.ghost:hover:not(:disabled) { background: rgba(255, 255, 255, .05); }

.btn.small { padding: 6px 14px; font-size: 13px; }

/* Full-width sheet CTA */
.btn-block {
  display: block;
  width: 100%;
  padding: 13px;
  background: var(--blue);
  color: #fff;
  border-radius: var(--r-md);
  font-size: 15px;
  font-weight: 500;
  text-align: center;
  transition: background var(--fast) var(--ease);
}
.btn-block:hover  { background: var(--blue-hi); color: #fff; }
.btn-block:active { background: var(--blue-lo); }

/* Centered blue text action */
.link-btn {
  display: block;
  margin: 0 auto;
  font-size: 14px;
  color: var(--blue);
  transition: color var(--fast) var(--ease);
}
.link-btn:hover { color: var(--blue-hi); }

/* White landing CTA */
.pill-light {
  background: #fff;
  color: #1d1d1f;
  font-size: 15px;
  font-weight: 500;
  padding: 11px 36px;
  border-radius: var(--r-pill);
  transition: opacity var(--fast) var(--ease);
}
.pill-light:hover  { opacity: .85; }
.pill-light:active { opacity: .7; }

/* ═══════════════════════════════════════════════════════════════════
   STATUS PILLS
   ═══════════════════════════════════════════════════════════════════ */

.pill {
  display: inline-flex;
  padding: 2px 9px;
  border-radius: var(--r-pill);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  line-height: 1.7;
}
.pill.ok     { background: var(--green-tint); color: var(--green); }
.pill.muted  { background: rgba(255, 255, 255, .07); color: var(--t3); }
.pill.accent { background: var(--blue-tint); color: var(--blue); }

/* Soft system badge (pending) */
.pill.warn {
  background: rgba(255, 255, 255, .08);
  color: rgba(255, 255, 255, .6);
  font-weight: 500;
}
/* Muted red text (failed) */
.pill.err {
  background: none;
  padding: 2px 0;
  color: rgba(255, 69, 58, .75);
  font-weight: 500;
  letter-spacing: .03em;
}

/* ═══════════════════════════════════════════════════════════════════
   HUD TOAST
   ═══════════════════════════════════════════════════════════════════ */

.toast-host {
  position: fixed;
  top: 18px;
  left: 0;
  right: 0;
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 8px 16px;
  background: rgba(0, 0, 0, .8);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: var(--r-pill);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -.01em;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 220ms var(--ease), transform 220ms var(--ease);
}
.toast.in   { opacity: 1; transform: translateY(0); }
.toast.ok   { color: var(--green); }
.toast.warn { color: var(--amber); }
.toast.err  { color: var(--red); }

/* ═══════════════════════════════════════════════════════════════════
   FOOTER — shared by landing, auth and app
   ═══════════════════════════════════════════════════════════════════ */

.site-footer,
.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  height: auto;
  padding: 16px 24px;
  border-top: 1px solid rgba(255, 255, 255, .06);
  font-size: 12px;
  color: rgba(255, 255, 255, .4);
}
.site-footer { margin-top: auto; }
.app-footer  { flex-shrink: 0; }

.footer-links {
  display: flex;
  align-items: center;
  gap: 12px;
}
.footer-links a,
.footer-copy {
  font-size: 12px;
  color: rgba(255, 255, 255, .4);
}
.footer-links a:hover { color: rgba(255, 255, 255, .8); }

.footer-sep {
  width: 1px;
  height: 11px;
  background: var(--line-mid);
}

/* ═══════════════════════════════════════════════════════════════════
   LANDING
   ═══════════════════════════════════════════════════════════════════ */

.landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.landing-hero {
  min-height: 86vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 24px;
  gap: 30px;
}

.wordmark {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
  font-size: clamp(56px, 11vw, 132px);
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: 1;
  color: #ffffff;
}

.landing-sub {
  font-size: clamp(20px, 2.4vw, 28px);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -.02em;
  max-width: 620px;
}

.landing-cards {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 24px 120px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.landing-card {
  background: var(--card);
  border-radius: var(--r-xl);
  padding: 48px 36px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.landing-card h2 { font-size: 26px; letter-spacing: -.02em; }
.landing-card p  { font-size: 15px; line-height: 1.6; color: var(--t2); }

/* ═══════════════════════════════════════════════════════════════════
   AUTH VIEW — full page, not an overlay
   ═══════════════════════════════════════════════════════════════════ */

.auth-view {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: var(--page);
  display: flex;
  flex-direction: column;
  animation: viewIn 260ms var(--ease);
}
.auth-view.hidden { display: none !important; }

.auth-view-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 40px;
  padding: 40px 20px;
  overflow-y: auto;
}

.auth-brand {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
  font-size: clamp(40px, 6vw, 64px);
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: 1;
  color: #ffffff;
  text-align: center;
  animation: sheetUp 300ms var(--ease);
}

/* Solid, not glass — this is a full page with nothing behind it */
.auth-sheet {
  width: 100%;
  max-width: 440px;
  background: var(--sheet);
  border-radius: var(--r-xl);
  padding: 44px 44px 40px;
  animation: sheetUp 300ms var(--ease);
}

/* Tab buttons exist for auth.js but are never shown */
.auth-tabs-hidden { display: none; }

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.auth-form.hidden { display: none; }

.sheet-title {
  font-size: 27px;
  font-weight: 600;
  letter-spacing: -.02em;
  text-align: center;
  margin-bottom: 4px;
}

/* ─── Floating-label fields ─── */

.float-group {
  background: rgba(0, 0, 0, .2);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: var(--r-md);
  overflow: hidden;
  transition: border-color var(--med) var(--ease);
}
.float-group:focus-within { border-color: var(--blue); }

.float-field {
  position: relative;
  display: block;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.float-field:last-child { border-bottom: none; }

.float-field input {
  width: 100%;
  background: transparent;
  border: none;
  padding: 23px 16px 9px;
  font-size: 15px;
  color: var(--t1);
}
.float-field input:focus { outline: none; }

.float-field > span {
  position: absolute;
  left: 16px;
  top: 17px;
  font-size: 15px;
  color: var(--t3);
  pointer-events: none;
  transform-origin: left top;
  transition: transform var(--med) var(--ease),
              font-size var(--med) var(--ease),
              color var(--med) var(--ease);
}
.float-field input:focus + span,
.float-field input:not(:placeholder-shown) + span {
  transform: translateY(-11px);
  font-size: 11px;
}

/* Error state — red border and labels, no background flood */
.float-group.error { border-color: var(--red); }
.float-group.error .float-field { border-bottom-color: rgba(255, 69, 58, .3); }
.float-group.error .float-field > span { color: var(--red); }

.field-note {
  font-size: 12px;
  color: var(--t3);
  margin-top: -10px;
}

.auth-error {
  display: none;
  font-size: 13px;
  color: var(--red);
  line-height: 1.45;
}
.auth-error.visible {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.auth-error.visible::before {
  content: "⊘";
  flex-shrink: 0;
}

.arrow-link {
  display: block;
  margin: 0 auto;
  font-size: 14px;
  font-weight: 400;
  color: var(--blue);
  text-decoration: none;
  transition: color var(--fast) var(--ease);
}
.arrow-link:hover { color: var(--blue-hi); }

/* ═══════════════════════════════════════════════════════════════════
   APP SHELL
   ═══════════════════════════════════════════════════════════════════ */

.app-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Topbar ─── */

.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -.025em;
  color: #ffffff;
}

.brand-badge {
  padding: 3px 9px;
  background: rgba(255, 255, 255, .08);
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: -.005em;
  color: rgba(255, 255, 255, .6);
  white-space: nowrap;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.meter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 13px 5px 11px;
  background: rgba(255, 255, 255, .08);
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 500;
  color: var(--t2);
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
}

.meter-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  opacity: .75;
}

.meter.live {
  background: var(--blue-tint);
  color: var(--blue);
}
.meter.live .meter-icon { opacity: 1; }

.meter.low,
.meter.live.low {
  background: var(--red-tint);
  color: var(--red);
  animation: lowPulse 1.6s ease-in-out infinite;
}
.meter.low .meter-icon { opacity: 1; }

/* ─── Account chip + menu ─── */

.account-wrap { position: relative; }

.account-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .06);
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 500;
  color: var(--t1);
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.account-btn:hover {
  background: rgba(255, 255, 255, .14);
  border-color: rgba(255, 255, 255, .1);
}
.account-btn .caret {
  font-size: 11px;
  line-height: 1;
  color: var(--t3);
}

.account-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 200;
  min-width: 240px;
  padding: 6px;
  background: var(--sheet);
  border: 1px solid var(--line-mid);
  border-radius: var(--r-md);
}

.account-menu-email {
  padding: 8px 12px 9px;
  font-size: 12px;
  color: var(--t3);
  word-break: break-all;
}

.account-menu-stat {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--t3);
}
.account-menu-stat strong {
  color: var(--t1);
  font-variant-numeric: tabular-nums;
}

.menu-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  text-align: left;
  font-size: 14px;
  border-radius: var(--r-sm);
  transition: background var(--fast) var(--ease);
}
.menu-item:hover { background: rgba(255, 255, 255, .06); }

/* ═══════════════════════════════════════════════════════════════════
   WORKSPACE
   ═══════════════════════════════════════════════════════════════════ */

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 330px;
  gap: 16px;
  padding: 16px 24px;
}

/* ─── Hero: video stage only, no surrounding panel ─── */

.hero {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: transparent;
  padding: 0;
  gap: 0;
}

.video-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--black);
  border-radius: var(--r-xl);
  overflow: hidden;
}
.video-stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Status text is routed to the HUD toast by shell.js */
.status { display: none; }

#aiPlaceholder:not(.hidden) #aiPlaceholderText {
  font-size: 15px;
  animation: pulse 1.6s ease-in-out infinite;
}

/* ─── Stream-offline empty state ─── */

.stage-idle {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: rgba(255, 255, 255, .34);
  pointer-events: none;
  opacity: 1;
  transition: opacity 280ms var(--ease);
}
.stage-idle.hidden {
  display: flex !important;   /* keep it in flow so it can animate */
  opacity: 0;
}

.stage-icon {
  width: 46px;
  height: 46px;
  stroke: currentColor;
}
.stage-text {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -.01em;
  color: rgba(255, 255, 255, .44);
}
.stage-dot { margin: 0 2px; opacity: .5; }

/* ─── Floating QuickTime control capsule ─── */

.capsule {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(30, 30, 32, .75);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: var(--r-pill);
}

.cap-btn {
  height: 32px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .08);
  border-radius: var(--r-pill);
  color: var(--t1);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -.01em;
  white-space: nowrap;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.cap-btn:hover:not(:disabled) { background: rgba(255, 255, 255, .16); color: var(--t1); }
.cap-btn:disabled {
  background: rgba(255, 255, 255, .05);
  color: var(--t4);
  opacity: 1;
  cursor: not-allowed;
}

.cap-btn.primary {
  padding: 0 18px;
  background: var(--blue);
  color: #fff;
  font-weight: 600;
}
.cap-btn.primary:hover:not(:disabled) { background: var(--blue-hi); color: #fff; }
.cap-btn.primary:disabled {
  background: rgba(255, 255, 255, .08);
  color: var(--t4);
  font-weight: 500;
  opacity: 1;
}

.cap-btn.danger { color: var(--t2); }
.cap-btn.danger:hover:not(:disabled) { background: var(--red-tint); color: var(--red); }
.cap-btn.danger:disabled { color: var(--t4); opacity: .5; }

/* Start button becomes a live countdown while waiting for an AI slot.
   Tabular figures stop the label jittering as digits change. */
.cap-btn.counting,
.cap-btn.counting:disabled {
  min-width: 134px;
  background: rgba(255, 255, 255, .06);
  color: var(--t3);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  opacity: 1;
  cursor: default;
}

/* ═══════════════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════════════ */

.side {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  padding-right: 2px;
}

.card {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--card);
  border-radius: var(--r-lg);
}
.card h2 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: rgba(255, 255, 255, .48);
}
.card-actions { display: flex; gap: 8px; }

/* ─── Camera preview ─── */

.cam-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: var(--black);
  border-radius: var(--r-md);
  overflow: hidden;
}
.cam-stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ─── Reference dropzone ─── */

.ref-canvas { position: relative; }

.ref-drop {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: var(--sheet);
  border: 1px solid transparent;
  border-radius: var(--r-lg);
  overflow: hidden;
  cursor: pointer;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.ref-drop:hover { background: #313134; border-color: transparent; }
.ref-drop.dragging {
  background: rgba(10, 132, 255, .12);
  border-color: var(--blue);
}

.ref-drop img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none;
}
.ref-drop img.visible { display: block; }

.ref-drop .placeholder { gap: 10px; padding: 0 20px; }

.drop-icon {
  width: 28px;
  height: 28px;
  color: rgba(255, 255, 255, .38);
}
.drop-text {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  color: rgba(255, 255, 255, .46);
}

.canvas-clear {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .65);
  border-radius: 50%;
  color: #fff;
  font-size: 15px;
  line-height: 1;
  transition: background var(--fast) var(--ease), opacity var(--fast) var(--ease);
}
.canvas-clear:hover:not(:disabled) { background: var(--red); }
.canvas-clear:disabled { opacity: 0; pointer-events: none; }

/* ─── OBS stream URL ─── */

.stream-url-box {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  background: transparent;
  border-radius: 0;
}
.stream-url-box code {
  display: block;
  font-size: 11px;
  color: var(--t1);
  overflow-x: auto;
  white-space: nowrap;
  user-select: all;
}

/* URL field — single horizontal input group, actions pinned inside */
.url-field {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px 4px 14px;
  background: var(--card);
  border-radius: var(--r-md);
}
.url-field code {
  flex: 1;
  min-width: 0;
  padding: 6px 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--t2);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}
.url-field code::-webkit-scrollbar { display: none; }

.url-actions-inline {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  padding-left: 4px;
}

.url-icon {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  color: var(--t3);
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.url-icon svg { width: 14px; height: 14px; }
.url-icon:hover { background: rgba(255, 255, 255, .08); color: var(--t1); }
.url-icon.copied { color: var(--green); }
.url-icon.spinning svg { animation: spin .7s linear infinite; }

/* Legacy / pre-restructure markup — never shown */
#streamViewerBadge,
.viewer-badge,
.stream-qr-wrap,
.url-links,
.stream-url-box .url-actions { display: none !important; }

/* ═══════════════════════════════════════════════════════════════════
   SHEET MODALS — glass over the video stage
   ═══════════════════════════════════════════════════════════════════ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal.hidden { display: none; }

/* Heavy blur with a light dim — the stage behind reads as soft colour
   rather than flattening to grey. No data-close here: the sheet's own
   X is the only dismissal, so a stray click can't lose a payment. */
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  animation: backdropIn 240ms var(--ease);
}

/* One surface only. Inner content sits directly on the glass —
   no nested panels, no boxes inside boxes. */
.sheet {
  position: relative;
  width: 100%;
  max-width: 360px;
  max-height: 88vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 32px 28px 28px;
  background: rgba(60, 60, 64, .55);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .4);
  animation: sheetUp var(--med) var(--ease);
}
.sheet-wide { max-width: 380px; }

/* Bare glyph — no chip, no fill. Only brightens on hover. */
.sheet-x {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 10;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0;
  color: rgba(255, 255, 255, .3);
  transition: color var(--fast) var(--ease);
}
.sheet-x svg { width: 13px; height: 13px; display: block; }
.sheet-x:hover { color: rgba(255, 255, 255, .85); background: none; }

.sheet-sub {
  font-size: 13px;
  line-height: 1.5;
  color: rgba(255, 255, 255, .5);
  text-align: center;
}

/* ─── Packages — hairline-separated rows, not cards ─── */

.packages {
  display: flex;
  flex-direction: column;
  margin: 2px 0;
}

/* Loading / empty / error messages injected into the list */
.packages > .muted {
  padding: 28px 0;
  text-align: center;
  font-size: 13px;
}

.package-card,
.pkg {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 15px 10px;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  border-radius: 10px;
  color: var(--t1);
  transition: background var(--fast) var(--ease);
}
.package-card:last-child,
.pkg:last-child { border-bottom: none; }

.package-card:hover,
.pkg:hover { background: rgba(255, 255, 255, .06); }

.pkg-left {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.pkg-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  flex-shrink: 0;
}
.pkg-label { font-size: 15px; font-weight: 500; }
.pkg-sub   { font-size: 11px; color: rgba(255, 255, 255, .4); }
.pkg-price {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.pkg-kas {
  font-size: 11px;
  color: rgba(255, 255, 255, .4);
  font-variant-numeric: tabular-nums;
}

/* ─── Pay flow ─── */

/* ─── Payment success — self-dismissing, no action needed ─── */

#buyViewSuccess {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  text-align: center;
}
#buyViewSuccess.hidden { display: none !important; }

.success-check {
  width: 34px;
  height: 34px;
  color: var(--blue);
  animation: checkIn 420ms var(--ease) both;
}

@keyframes checkIn {
  from { opacity: 0; transform: scale(.8); }
  to   { opacity: 1; transform: scale(1); }
}

/* The whole sheet fades out once the message has been read */
.modal.fading .sheet,
.modal.fading .modal-backdrop {
  opacity: 0;
  transition: opacity 400ms var(--ease);
}

.pay-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: center;
}
.pay-title {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -.02em;
  color: #ffffff;
}
.pay-sub {
  font-size: 13px;
  color: rgba(255, 255, 255, .5);
}

/* The QR is already a white block — it needs no frame around it */
.qr-card {
  display: flex;
  justify-content: center;
  width: fit-content;
  margin: 2px auto 0;
  padding: 0;
  background: none;
  border: none;
  border-radius: 0;
}
.qr-card img {
  width: 164px;
  height: 164px;
  display: block;
  padding: 10px;
  background: #fff;
  border-radius: 12px;
}

/* Amount and action sit on the glass, separated by hairlines */
.pay-action-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 2px 0;
  padding: 14px 2px;
  background: none;
  border-top: 1px solid rgba(255, 255, 255, .07);
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  border-radius: 0;
}

/* Sheet CTA — translucent blue so the glass reads through, rather
   than a solid block sitting on top of it. */
.sheet .btn-block {
  padding: 11px;
  background: rgba(10, 132, 255, .9);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -.01em;
  transition: background var(--fast) var(--ease);
}
.sheet .btn-block:hover  { background: rgba(10, 132, 255, 1); color: #fff; }
.sheet .btn-block:active { background: rgba(0, 113, 227, 1); }

.pay-amount-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.pay-amount {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--t1);
  font-variant-numeric: tabular-nums;
}
.pay-meta {
  font-size: 11px;
  color: rgba(255, 255, 255, .4);
}
.pay-meta:empty { display: none; }

.copy-pill {
  flex-shrink: 0;
  padding: 6px 13px;
  background: rgba(255, 255, 255, .1);
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 500;
  color: var(--t1);
  white-space: nowrap;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.copy-pill:hover { background: rgba(255, 255, 255, .18); }
.copy-pill.copied { color: var(--green); }

/* Pulsing dot + soft gray text */
.pay-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
  padding: 0;
  background: none;
  font-size: 12px;
  color: rgba(255, 255, 255, .45);
  text-align: center;
}
.pay-status::before {
  content: "";
  width: 6px;
  height: 6px;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(48, 209, 88, .75);
  animation: dotPulse 1.5s ease-in-out infinite;
}
.pay-status.expired { color: var(--red); }
.pay-status.expired::before { background: var(--red); animation: none; }

.pay-expiry {
  font-size: 11px;
  color: rgba(255, 255, 255, .35);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ─── Payment history — a list, not a stack of cards ─── */

.history-list {
  display: flex;
  flex-direction: column;
  max-height: 340px;
  overflow-y: auto;
  margin: 2px 0;
}

.history-list > .muted {
  padding: 28px 0;
  text-align: center;
  font-size: 13px;
}

.history-item,
.history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 13px 2px;
  background: none;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  border-radius: 0;
}
.history-item:last-child,
.history-row:last-child { border-bottom: none; }

.h-left {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.h-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
}
.h-label { font-size: 14px; font-weight: 500; }
.h-date  { font-size: 11px; color: rgba(255, 255, 255, .4); }
.h-price {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.h-kas {
  font-size: 11px;
  color: rgba(255, 255, 255, .35);
  font-variant-numeric: tabular-nums;
}

/* Back action reads as a system pill, not a link */
#btnBackToPackages {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 2px auto 0;
  padding: 8px 20px;
  background: rgba(255, 255, 255, .1);
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 500;
  color: var(--t1);
  transition: background var(--fast) var(--ease);
}
#btnBackToPackages:hover { background: rgba(255, 255, 255, .18); color: var(--t1); }

/* ═══════════════════════════════════════════════════════════════════
   DOCUMENT PAGES — status, privacy, terms
   ═══════════════════════════════════════════════════════════════════ */

.doc-body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.doc-topbar {
  flex-shrink: 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
}
.doc-back {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -.025em;
  color: #ffffff;
  transition: opacity var(--fast) var(--ease);
}
.doc-back:hover { color: #ffffff; opacity: .7; }

.doc-page {
  flex: 1;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 64px 24px 96px;
}

.doc-title {
  font-size: clamp(32px, 5vw, 44px);
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.1;
  color: #ffffff;
}
.doc-lede {
  margin-top: 10px;
  font-size: 15px;
  color: var(--t3);
}

.doc-page h2 {
  margin-top: 40px;
  margin-bottom: 10px;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -.015em;
  color: var(--t1);
}
.doc-page p {
  margin-bottom: 14px;
  font-size: 15px;
  line-height: 1.65;
  color: var(--t2);
}
.doc-page a { color: var(--blue); }

.doc-note {
  margin-top: 28px;
  font-size: 12px;
  color: var(--t4);
}

/* ─── Status page ─── */

.status-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 32px;
  padding: 16px 20px;
  background: var(--card);
  border-radius: var(--r-lg);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -.015em;
  color: var(--t1);
}
.status-banner.ok   { color: var(--green); }
.status-banner.down { color: var(--red); }

.status-list {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  background: var(--card);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.status-row:last-child { border-bottom: none; }

.status-dot {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--t4);
}
.status-banner.ok   .status-dot,
.status-row.ok      .status-dot { background: var(--green); }
.status-banner.down .status-dot,
.status-row.down    .status-dot { background: var(--red); }

.status-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.status-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--t1);
}
.status-desc {
  font-size: 12px;
  color: var(--t3);
}
.status-state {
  flex-shrink: 0;
  font-size: 13px;
  color: var(--t3);
}
.status-row.ok   .status-state { color: var(--green); }
.status-row.down .status-state { color: var(--red); }

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 1000px) {
  .workspace {
    grid-template-columns: 1fr 290px;
    gap: 12px;
    padding: 12px 16px;
  }
  .topbar { padding: 0 16px; }
}

@media (max-width: 820px) {
  body.is-app { overflow: auto; }

  .app-shell {
    height: auto;
    min-height: 100vh;
  }
  .workspace { grid-template-columns: 1fr; }
  .side { overflow: visible; }
  .video-stage { aspect-ratio: 16 / 10; min-height: 0; }
  .meter { display: none; }

  .capsule { bottom: 14px; padding: 5px 10px; gap: 4px; }
  .cap-btn { height: 30px; padding: 0 13px; font-size: 12px; }
  .cap-btn.primary { padding: 0 15px; }

  .sheet { padding: 28px 20px 24px; }
  .auth-sheet { padding: 32px 24px 28px; }
}

@media (max-width: 600px) {
  .doc-page { padding: 44px 20px 72px; }
  .doc-topbar { padding: 0 20px; }
}