/* StreamifyExpress — Premium Streaming design system */
:root {
  --bg: #0a0b0d;
  --ink: #f4f5f7;
  --muted: #8b929e;
  --line: #2a2f3a;
  --panel: #12141a;
  --panel-2: #1a1d26;
  --accent: #2ec4b6;
  --accent-hover: #26a99d;
  --accent-soft: #2ec4b61a;
  --accent-2: #1a9e92;
  --cyan: #2ec4b6;
  --pink: #e85d75;
  --ok: #3ecf8e;
  --warn: #e6b84d;
  --danger: #e85d75;
  --tg: #2aabee;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 2px #00000040;
  --shadow-md: 0 8px 24px #00000050;
  --shadow: var(--shadow-md);
  --font: "Manrope", ui-sans-serif, system-ui, sans-serif;
  --display: "Outfit", "Manrope", sans-serif;
  --brand: "Outfit", "Manrope", sans-serif;
  --surface: var(--panel);
  --surface-flat: #0e1014;
  --surface-soft: #ffffff08;
  --surface-input: #0e1014;
  --surface-tabs: #0e1014;
  --surface-empty: #0e1014;
  --surface-card: #ffffff06;
  --surface-day: #0e1014;
  --surface-modal: var(--panel);
  --border-soft: #ffffff12;
  --border-input: #343a46;
  --border-chip: #ffffff14;
  --inset-shine: none;
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px; --space-8: 64px;
  --control-h: 40px; --control-h-sm: 32px;
  --ease: 160ms ease;
  --ease-modal: 240ms ease;
}

html[data-theme="light"],
body.light-theme {
  color-scheme: light;
  --bg: #f5f6f8;
  --ink: #12141a;
  --muted: #5c6570;
  --line: #d8dce3;
  --panel: #ffffff;
  --panel-2: #f0f2f5;
  --accent: #0f9f90;
  --accent-hover: #0d8a7d;
  --accent-soft: #0f9f9014;
  --accent-2: #0d8a7d;
  --cyan: #0f9f90;
  --pink: #c44766;
  --ok: #1f9d62;
  --warn: #a87a12;
  --danger: #c44766;
  --shadow-sm: 0 1px 2px #12141a0a;
  --shadow-md: 0 8px 28px #12141a14;
  --shadow: var(--shadow-md);
  --surface: var(--panel);
  --surface-flat: #eef0f3;
  --surface-soft: #12141a06;
  --surface-input: #f5f6f8;
  --surface-tabs: #eef0f3;
  --surface-empty: #eef0f3;
  --surface-card: #f5f6f8;
  --surface-day: #f5f6f8;
  --surface-modal: #ffffff;
  --border-soft: #d8dce3;
  --border-input: #c5cad3;
  --border-chip: #d0d5dd;
  --focus: 0 0 0 2px #fff, 0 0 0 4px var(--accent);
}

* { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  overflow-x: hidden;
  max-width: 100%;
  color-scheme: dark;
}
html[data-theme="light"] { color-scheme: light; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  background:
    radial-gradient(ellipse 80% 50% at 0% -10%, #1a2a2c 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 0%, #121820 0%, transparent 50%),
    var(--bg);
  overflow-x: hidden;
  overscroll-behavior-x: none;
}
body.light-theme {
  background:
    radial-gradient(ellipse 70% 45% at 0% -10%, #d8ece9 0%, transparent 55%),
    radial-gradient(ellipse 50% 40% at 100% 0%, #e2e8f0 0%, transparent 50%),
    var(--bg) !important;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
img { display: block; max-width: 100%; }

:focus { outline: none; }
:focus-visible { box-shadow: var(--focus); outline: none; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 10px 16px;
  background: var(--accent);
  color: #041210;
  font-weight: 700;
  border-radius: 0 0 var(--radius-sm) 0;
  text-decoration: none;
}
.skip-link:focus {
  left: 0;
  box-shadow: none;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

.atmosphere { display: none; }

.shell {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 40px));
  max-width: 100%;
  margin: 0 auto;
}

/* —— Topbar —— */
.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}
.brand-logo {
  width: 40px; height: 40px;
  border-radius: var(--radius);
  object-fit: cover;
}
.brand-text {
  font-family: var(--brand);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -.03em;
}
.brand-text span { color: var(--accent); margin-left: .1em; }
.site-preferences {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.site-preferences select {
  width: auto;
  min-width: 64px;
  height: var(--control-h-sm);
  padding: 0 10px;
  border-radius: var(--radius-sm);
  font-size: .8rem;
  font-weight: 600;
}
.user-bar {
  font-size: .85rem;
  color: var(--muted);
  padding: 8px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: var(--surface-soft);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* —— Hero / Auth —— */
.hero {
  min-height: calc(100vh - 72px);
  display: grid;
  grid-template-columns: 1fr minmax(300px, 400px);
  gap: 48px;
  align-items: center;
  padding: 48px 0 64px;
  max-width: 100%;
  min-width: 0;
}
.hero-copy, .hero-stage { min-width: 0; max-width: 100%; }
.brand-signal {
  margin: 0 0 16px;
  font-family: var(--brand);
  font-size: clamp(1.75rem, 5vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: 1.05;
  color: var(--ink);
}
.hero h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.35rem, 3.5vw, 1.85rem);
  font-weight: 600;
  letter-spacing: -.03em;
  line-height: 1.25;
  color: var(--muted);
}
.lead {
  margin: 16px 0 0;
  max-width: 32rem;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}
.auth-panel {
  margin-top: 28px;
  width: min(100%, 400px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 14px;
  padding: 4px;
  border-radius: var(--radius);
  background: var(--surface-tabs);
}
.auth-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  transition: background var(--ease), color var(--ease);
}
.auth-tab.active,
.auth-tab[aria-selected="true"] {
  color: var(--ink);
  background: var(--panel-2);
  box-shadow: inset 0 0 0 1px var(--border-soft);
}
.auth-pane { display: grid; gap: 10px; }
.auth-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.auth-switch button {
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.code-inputs {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}
.code-inputs input {
  text-align: center;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: .05em;
  padding: 12px 0;
}
.tg-login-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: var(--control-h);
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--tg);
  color: #fff !important;
  text-decoration: none;
  font-weight: 700;
  font-size: .95rem;
  transition: filter var(--ease), transform var(--ease);
}
.tg-login-btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.link-telegram-btn { width: auto; max-width: 320px; }
.login-fallback { margin: 0; font-size: .82rem; }
.skeleton-login {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: .95rem;
}
.skeleton-login::before {
  content: "";
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--border-soft);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
.hint { margin-top: 14px; color: var(--muted); font-size: .88rem; }

.hero-stage {
  min-height: 360px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 50% 40%, #2ec4b618, transparent 55%),
    linear-gradient(160deg, var(--panel-2), var(--surface-flat));
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  position: relative;
}
.hero-logo {
  width: min(72%, 280px);
  border-radius: 50%;
  position: relative;
  z-index: 1;
  animation: float 6s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to { opacity: 1; transform: none; }
}

/* —— Cabinet chrome —— */
.welcome {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 32px 0 16px;
}
.eyebrow {
  margin: 0 0 6px;
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}
.welcome h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.5rem, 2.8vw, 2rem);
  letter-spacing: -.03em;
  font-weight: 700;
}

.onboarding {
  margin-bottom: 16px;
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  background: var(--accent-soft);
}
.onboarding h2 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: 1.1rem;
}
.onboarding ol {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
  display: grid;
  gap: 6px;
}
.onboarding-checklist {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.onboarding-checklist li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  background: var(--panel);
}
.onboarding-step-num {
  flex: 0 0 28px;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
  font-size: .8rem;
}

.mode-picker { margin: 8px 0 16px; }
.mode-toggle {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius);
  background: var(--surface-tabs);
  border: 1px solid var(--line);
  max-width: 420px;
  width: 100%;
}
.mode-seg {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: .9rem;
  transition: background var(--ease), color var(--ease);
}
.mode-seg.active,
.mode-seg[aria-pressed="true"] {
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.mode-toggle-hint {
  margin: 8px 0 0;
  font-size: .85rem;
}
/* legacy switch support */
.mode-switch {
  width: 48px; height: 28px;
  border-radius: 999px;
  border: 1px solid var(--border-input);
  background: var(--surface-input);
  position: relative;
  padding: 0;
}
.mode-switch span {
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--ink);
  transition: transform var(--ease);
}
.mode-toggle.subscriber .mode-switch span { transform: translateX(20px); background: var(--accent); }
.mode-toggle-label { font-weight: 700; font-size: .85rem; }
.mode-card { display: none; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  border-radius: var(--radius);
  background: var(--surface-tabs);
  border: 1px solid var(--line);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button,
.tabs [role="tab"] {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: .88rem;
  white-space: nowrap;
  transition: background var(--ease), color var(--ease);
}
.tabs button:hover,
.tabs [role="tab"]:hover { background: var(--surface-soft); color: var(--ink); }
.tabs button.active,
.tabs [role="tab"][aria-selected="true"],
.tabs button.active:hover {
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.chat-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.chat-bar .label {
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 4px;
}
.chat-select {
  display: none;
  width: 100%;
  max-width: 360px;
}

.chip {
  border: 1px solid var(--border-chip);
  background: var(--surface-card);
  color: var(--ink);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 700;
  transition: border-color var(--ease), background var(--ease);
}
.chip:hover { border-color: var(--accent); }
.chip.active {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
  color: var(--ink);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent);
}

/* —— Layout —— */
#content { padding-bottom: 48px; }
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.panel.half { grid-column: span 1; }
.panel > h2:first-child,
.panel .split h2 { margin-top: 0; }
.panel h2 {
  margin: 0 0 6px;
  font-family: var(--display);
  font-size: 1.15rem;
  letter-spacing: -.02em;
}
.panel h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}
.stack { display: grid; gap: 12px; }
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.row.wrap { flex-wrap: wrap; }
.split {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.muted { color: var(--muted); margin: 0; }
.mini, .mini-label {
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin: 20px 0 12px;
}

/* —— Forms & buttons —— */
.field { display: grid; gap: 6px; margin: 0 0 12px; }
.field > label,
.field .mini-label { font-size: .82rem; font-weight: 650; color: var(--muted); }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select,
textarea,
.rich-editor {
  width: 100%;
  min-height: var(--control-h);
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border-input);
  background: var(--surface-input);
  transition: border-color var(--ease), box-shadow var(--ease);
}
textarea, .rich-editor-multiline { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus, .rich-editor:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input:disabled, select:disabled, textarea:disabled, button:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.primary, .ghost, .danger, .icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--control-h);
  padding: 0 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-weight: 700;
  font-size: .9rem;
  text-decoration: none;
  transition: background var(--ease), border-color var(--ease), transform var(--ease), filter var(--ease);
}
.primary {
  background: var(--accent);
  color: #041210;
  border-color: transparent;
}
.primary:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-1px); }
.ghost {
  background: var(--surface-soft);
  border-color: var(--border-soft);
  color: var(--ink);
}
.ghost:hover:not(:disabled) { background: var(--panel-2); border-color: var(--line); }
.danger {
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  border-color: color-mix(in srgb, var(--danger) 40%, var(--line));
  color: var(--danger);
}
.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 22%, transparent); }
.small, .primary.small, .ghost.small, .danger.small {
  min-height: var(--control-h-sm);
  padding: 0 12px;
  font-size: .8rem;
}
.icon-btn {
  width: var(--control-h-sm);
  min-height: var(--control-h-sm);
  padding: 0;
  background: var(--surface-soft);
  border-color: var(--border-soft);
}
a.primary.disabled,
a.primary[aria-disabled="true"] {
  opacity: .45;
  pointer-events: none;
}

.ui-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  margin: 4px 0 12px;
  user-select: none;
}
.ui-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.ui-switch-track {
  width: 44px; height: 26px;
  border-radius: 999px;
  background: var(--border-input);
  border: 1px solid var(--border-input);
  position: relative;
  flex: 0 0 auto;
  transition: background var(--ease);
}
.ui-switch-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--ease);
}
.ui-switch input:checked + .ui-switch-track {
  background: var(--accent);
  border-color: var(--accent);
}
.ui-switch input:checked + .ui-switch-track .ui-switch-thumb { transform: translateX(18px); }
.ui-switch input:focus-visible + .ui-switch-track { box-shadow: var(--focus); }
.ui-switch-text { font-weight: 650; font-size: .9rem; }

.color-picker { display: flex; flex-wrap: wrap; gap: 10px; }
.color-swatch { cursor: pointer; }
.color-swatch input { position: absolute; opacity: 0; }
.color-swatch span:not(.sr-only) {
  display: block;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--swatch);
  border: 2px solid var(--border-soft);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--ease);
}
.color-swatch input:checked + span:not(.sr-only) {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.color-swatch input:focus-visible + span:not(.sr-only) { box-shadow: var(--focus); }

/* —— Feedback —— */
.notice {
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--cyan) 35%, var(--line));
  background: color-mix(in srgb, var(--cyan) 10%, transparent);
  color: var(--ink);
  font-size: .9rem;
}
.notice.warn {
  border-color: color-mix(in srgb, var(--warn) 45%, var(--line));
  background: color-mix(in srgb, var(--warn) 12%, transparent);
}
.empty {
  padding: 36px 20px;
  text-align: center;
  border-radius: var(--radius);
  border: 1px dashed var(--line);
  background: var(--surface-empty);
}
.empty h3 { margin: 0 0 8px; font-family: var(--display); }
.empty p { margin: 0; color: var(--muted); }
.empty .primary { margin-top: 16px; }

.toasts {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 80;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  animation: toast-in var(--ease-modal);
  font-weight: 650;
  font-size: .9rem;
}
.toast.error {
  border-color: color-mix(in srgb, var(--danger) 50%, var(--line));
  background: color-mix(in srgb, var(--danger) 12%, var(--panel));
  color: var(--danger);
}

/* —— Modal —— */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: #00000088;
  backdrop-filter: blur(4px);
}
.modal {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  max-height: min(88vh, 720px);
  overflow: auto;
  background: var(--surface-modal);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  animation: modal-in var(--ease-modal);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 0;
}
.modal-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.15rem;
}
.modal-body { padding: 12px 16px 18px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

/* —— Cards / lists —— */
.subscription, .list-item, .platform-card, .catalog-card {
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-card);
}
.platform-card .platform,
.subscription .platform { font-weight: 700; }
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 750;
  background: var(--surface-soft);
  color: var(--muted);
  border: 1px solid var(--border-soft);
}
.status.live {
  background: color-mix(in srgb, var(--danger) 16%, transparent);
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, var(--line));
}
.status.live::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.oauth-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 8px;
}
.oauth-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control-h-sm);
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--panel-2);
  color: var(--ink);
  text-decoration: none;
  font-size: .82rem;
  font-weight: 700;
  transition: border-color var(--ease), background var(--ease);
}
.oauth-chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.catalog-card-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
}
.catalog-avatar, .public-avatar, .avatar-preview {
  width: 48px; height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
  border: 1px solid var(--border-soft);
  background: var(--surface);
}
.public-avatar, .avatar-preview { width: 96px; height: 96px; }
.catalog-avatar-fallback, .public-avatar-fallback {
  display: grid;
  place-items: center;
  font-weight: 800;
  color: var(--accent);
  font-family: var(--brand);
}
.public-avatar-fallback { font-size: 2rem; }
.catalog-card-meta { min-width: 0; }
.catalog-card-meta b {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.catalog-platforms {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.catalog-platform {
  font-size: .72rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
}

/* —— Appearance —— */
.subtabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin: 0 0 16px;
  border-radius: var(--radius);
  background: var(--surface-tabs);
  border: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.subtabs::-webkit-scrollbar { display: none; }
.subtabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: .82rem;
  white-space: nowrap;
}
.subtabs button.active,
.subtabs button[aria-selected="true"] {
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.appearance-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, .9fr);
  gap: 16px;
  align-items: start;
}
.appearance-preview-sticky {
  position: sticky;
  top: 16px;
}
.settings-subsection { margin-top: 16px; }
.preset-block { margin: 0 0 16px; }
.preset-panel {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface-soft);
}
.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
.preset-card {
  display: grid;
  gap: 6px;
  text-align: left;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border-chip);
  background: var(--surface-card);
  color: inherit;
  cursor: pointer;
  transition: border-color var(--ease), transform var(--ease);
}
.preset-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.preset-card strong { font-size: .92rem; }
.preset-card span, .preset-card em {
  color: var(--muted);
  font-size: .78rem;
  font-style: normal;
  line-height: 1.35;
}
.preset-card em { font-family: var(--brand); color: var(--ink); }

.variable-menu {
  margin: 0 0 12px;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  background: var(--surface-soft);
}
.variable-groups { display: grid; gap: 10px; margin-top: 8px; }
.variable-group-title {
  font-size: .75rem;
  font-weight: 750;
  color: var(--muted);
  margin-bottom: 6px;
}

.rich-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}
.rich-editor {
  line-height: 1.45;
  outline: none;
}
.rich-editor b, .rich-editor strong { font-weight: 800; }

.twitch-layout-chips {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}
.twitch-layout-chip {
  display: grid;
  place-items: center;
  min-height: 36px;
  padding: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-chip);
  background: var(--surface-card);
  font-size: .75rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}
.twitch-layout-chip input { position: absolute; opacity: 0; }
.twitch-layout-chip.selected,
.twitch-layout-chip:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.twitch-layout-select { margin-top: 8px; }

.tg-preview {
  padding: 14px;
  border-radius: var(--radius);
  background: #1c2733;
  border: 1px solid #2a3a4a;
}
body.light-theme .tg-preview {
  background: #d5e0ea;
  border-color: #aebecb;
}
.tg-preview-image {
  width: 100%;
  border-radius: 10px;
  margin-bottom: 10px;
  max-height: 200px;
  object-fit: cover;
}
.tg-preview-image-fallback {
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: .85rem;
  margin-bottom: 10px;
  border-radius: 10px;
  background: #ffffff10;
}
.tg-bubble {
  background: #182533;
  color: #e8eef4;
  padding: 12px 14px;
  border-radius: 12px 12px 4px 12px;
  font-size: .92rem;
  line-height: 1.45;
  word-break: break-word;
}
body.light-theme .tg-bubble {
  background: #eef3f7;
  color: #1f2c38;
}
.tg-bubble code {
  background: #ffffff14;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: .85em;
}
.tg-bubble a { color: #6ec1ff; }
.tg-bubble tg-spoiler {
  background: #ffffff33;
  border-radius: 3px;
  color: transparent;
}
.tg-buttons { display: grid; gap: 6px; margin-top: 10px; }
.tg-button-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tg-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 8px;
  background: #2aabee;
  color: #fff;
  font-size: .8rem;
  font-weight: 700;
}
.tg-style-success { background: #31a66a; }
.tg-style-danger { background: #e8505b; }
.tg-style-primary { background: #2aabee; }
.tg-button-emoji { width: 18px; height: 18px; }
.tg-button-emoji-text { font-size: 1rem; line-height: 1; }

.button-card {
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-card);
  margin-bottom: 12px;
}
.button-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}
.button-card-url {
  font-size: .78rem;
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.button-channel-list {
  display: grid;
  gap: 12px;
  padding-left: 8px;
  border-left: 2px solid var(--line);
}
.button-row, .subscription-button-row, .custom-button-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 72px minmax(120px, 1fr);
  gap: 10px;
  align-items: end;
}
.custom-button-row { grid-template-columns: 56px minmax(0, 1fr) 72px minmax(120px, 1fr) auto; }
.button-row-actions { display: flex; gap: 6px; align-items: end; }
.button-emoji-field { width: 56px; }
.emoji-preview-btn {
  width: 48px; height: 48px;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  background: var(--surface-input);
  display: grid;
  place-items: center;
  padding: 0;
}
.custom-emoji-thumb { width: 32px; height: 32px; }
.emoji-preview-fallback { font-size: 1.25rem; }
.platform-emoji-field { width: auto; }

/* —— Schedule —— */
.week-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.schedule-day-nav {
  display: none;
  gap: 6px;
  margin: 12px 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.schedule-day-nav::-webkit-scrollbar { display: none; }
.schedule-wrap { overflow-x: auto; }
.schedule-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  gap: 8px;
  min-width: 0;
}
.day {
  min-height: 140px;
  padding: 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-day);
}
.day h4 {
  margin: 0 0 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .8rem;
  font-weight: 750;
}
.day h4 time {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-soft);
  font-size: .75rem;
}
.event {
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  font-size: .82rem;
  font-weight: 650;
}
.event time {
  display: block;
  font-size: .72rem;
  color: var(--muted);
  margin-bottom: 2px;
}
.event .actions {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}
.upload-preview {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  margin-top: 10px;
}
.schedule-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* —— Help —— */
.help-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}
.help-list > div {
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-card);
  font-size: .9rem;
  line-height: 1.5;
}
.help-list strong { color: var(--ink); }

/* —— Emoji picker —— */
.emoji-picker {
  position: fixed;
  z-index: 70;
  width: min(320px, calc(100vw - 24px));
  max-height: 320px;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 10px;
}
.emoji-picker-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.emoji-picker-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}
.emoji-tab {
  border: 0;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: .78rem;
  font-weight: 700;
}
.emoji-tab.active { background: var(--accent-soft); color: var(--ink); }
.emoji-picker-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
}
.emoji-option {
  border: 0;
  background: transparent;
  font-size: 1.25rem;
  padding: 6px;
  border-radius: 6px;
}
.emoji-option:hover { background: var(--surface-soft); }
.emoji-pack-title {
  font-size: .75rem;
  font-weight: 750;
  color: var(--muted);
  margin: 10px 0 6px;
}
.emoji-field-wrap {
  display: flex;
  gap: 6px;
  align-items: center;
}
.emoji-field-wrap input { flex: 1; }
.emoji-trigger {
  border: 1px solid var(--border-soft);
  background: var(--surface-soft);
  border-radius: var(--radius-sm);
  width: 40px; height: 40px;
  font-size: 1.1rem;
}

/* —— Donate / Footer —— */
.donate-fab {
  position: fixed;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 40;
  min-height: var(--control-h);
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-weight: 700;
  font-size: .85rem;
  box-shadow: var(--shadow-md);
  transition: transform var(--ease);
}
.donate-fab:hover { transform: translateY(-2px); }
.donate-options {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}
.donate-option { display: grid; gap: 8px; }
.donate-external { text-align: center; }

.site-legal-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 28px 16px calc(28px + env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: .85rem;
}
.site-legal-footer a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 650;
}
.site-legal-footer a:hover { color: var(--accent); }
.footer-donate {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* —— Public page —— */
.public-page { min-height: 100vh; }
.public-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 20px 0;
}
.public-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  font-family: var(--brand);
  font-weight: 700;
}
.public-brand img { border-radius: 10px; }
.public-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  display: grid;
  gap: 18px;
}
.public-hero h1 {
  margin: 8px 0 10px;
  font-family: var(--brand);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  letter-spacing: -.04em;
  line-height: 1.05;
}
.public-hero-head {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  flex-wrap: wrap;
}
.public-hero-copy { min-width: 0; flex: 1 1 220px; }
.public-platforms {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}
.public-platform {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  max-width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  text-decoration: none;
  color: inherit;
  transition: border-color var(--ease), transform var(--ease);
}
.public-platform:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.public-platform span {
  color: var(--muted);
  font-size: .72rem;
  white-space: nowrap;
}
.public-platform strong {
  font-size: .9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 14rem;
}
.public-platform em {
  font-style: normal;
  color: var(--danger);
  font-size: .78rem;
  font-weight: 700;
}
.public-platform.is-live {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--line));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 20%, transparent);
}
.public-platform.is-live em::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 5px;
  border-radius: 50%;
  background: currentColor;
  vertical-align: middle;
}
.public-cover {
  display: block;
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  border-radius: var(--radius-lg);
  margin-top: 16px;
}
.public-footer {
  text-align: center;
  margin: 8px 0 0;
}
.public-toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 80;
  display: grid;
  gap: 8px;
  width: min(320px, calc(100vw - 32px));
}

/* —— Legal —— */
.legal-page { min-height: 100vh; }
.legal-main {
  max-width: 760px;
  margin: 20px auto 48px;
  padding: 28px 24px 36px;
}
.legal-main h1 {
  font-family: var(--brand);
  letter-spacing: -.03em;
  margin: 8px 0 10px;
}
.legal-main h2 { margin: 1.6rem 0 .6rem; font-size: 1.1rem; }
.legal-main p, .legal-main li { line-height: 1.55; color: var(--ink); }
.legal-main ul { padding-left: 1.2rem; }
.legal-main a { color: var(--accent); }
.legal-main hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2rem 0;
}
.legal-nav a { color: var(--muted); text-decoration: none; font-weight: 650; }
.legal-nav a:hover { color: var(--accent); }

/* —— Responsive —— */
@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 28px;
    padding: 32px 0 48px;
    min-height: auto;
  }
  .hero-stage { min-height: 220px; order: -1; }
  .auth-panel { width: 100%; }
  .grid { grid-template-columns: 1fr; }
  .panel.half { grid-column: span 1; }
  .appearance-layout { grid-template-columns: 1fr; }
  .appearance-preview-sticky { position: static; }
}

@media (max-width: 700px) {
  .shell { width: calc(100% - 28px); }
  .topbar {
    height: auto;
    min-height: 64px;
    flex-wrap: wrap;
    padding: 10px 0;
  }
  .user-bar {
    order: 3;
    width: 100%;
    max-width: none;
    margin-top: 4px;
  }
  .mode-toggle { max-width: none; }
  .twitch-layout-chips { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 600px) {
  .brand-text { font-size: .92rem; }
  .brand-logo { width: 36px; height: 36px; }
  .donate-fab { display: none; }
  #content { padding: 12px 0 calc(32px + env(safe-area-inset-bottom)); }
  .chat-bar .chip { display: none; }
  .chat-bar .chat-select { display: block; }
  .chat-bar:has(.chat-select) .chip-group { display: none; }
  .schedule-day-nav { display: flex; }
  .schedule-grid { grid-template-columns: 1fr; }
  .schedule-grid .day { display: none; }
  .schedule-grid .day.is-active { display: block; }
  .button-row, .subscription-button-row {
    grid-template-columns: 48px minmax(0, 1fr) 64px minmax(100px, 1fr);
  }
  .custom-button-row {
    grid-template-columns: 48px minmax(0, 1fr) 64px minmax(100px, 1fr);
  }
  .custom-button-row .button-row-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }
  .modal-root {
    padding: 0;
    align-items: end;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .modal {
    width: 100%;
    max-height: min(92vh, 720px);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .modal-actions {
    flex-direction: column-reverse;
  }
  .modal-actions .primary,
  .modal-actions .ghost,
  .modal-actions .danger { width: 100%; }
  .toasts {
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    width: auto;
  }
  .week-picker .chip {
    flex: 1 1 calc(50% - 8px);
    text-align: center;
  }
  .panel .row > .primary,
  .panel .row > .ghost,
  .panel .row > .danger {
    flex: 1 1 calc(50% - 10px);
    min-width: 132px;
  }
  form.row, #image-form.row {
    flex-direction: column;
    align-items: stretch;
  }
  form.row > .primary,
  form.row > .ghost,
  form.row > .danger { width: 100%; }
  .primary, .ghost, .danger { -webkit-tap-highlight-color: transparent; }
}

@media (max-width: 420px) {
  .week-picker .chip { flex-basis: 100%; }
  .hero-stage { display: none; }
  .code-inputs { gap: 4px; }
  .preset-grid { grid-template-columns: 1fr; }
  .twitch-layout-chips { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px) {
  .public-top, .public-main { padding-left: 14px; padding-right: 14px; }
  .preset-grid { grid-template-columns: 1fr 1fr; }
}
