:root {
  color-scheme: dark;
  --bg: #0b0b12;
  --surface: rgba(17,16,25,.88);
  --surface-strong: #111019;
  --surface-soft: rgba(255,255,255,.035);
  --text: #f8f5ff;
  --muted: #aaa0b5;
  --muted-strong: #c9c1d6;
  --border: #2d2735;
  --border-strong: #493c55;
  --pink: #ff5cad;
  --purple: #9c76ff;
  --yellow: #ffd35c;
  --success: #65d58a;
  --danger: #ff6b76;
  --warning: #ffd35c;
  --radius: 22px;
  font-family: Inter, ui-rounded, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body {
  min-height: 100vh;
  padding: max(16px, env(safe-area-inset-top)) 14px max(26px, env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 8% 4%, rgba(255,78,173,.20), transparent 28%),
    radial-gradient(circle at 92% 3%, rgba(116,91,255,.24), transparent 31%),
    radial-gradient(circle at 72% 82%, rgba(255,199,75,.08), transparent 34%),
    #0b0b12;
  background-attachment: fixed;
}
button, input, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
a { color: #d9c6ff; text-decoration: none; }
.hidden { display: none !important; }

.app-shell { width: min(760px, 100%); margin: 0 auto; }
.brand-mark { font-weight: 950; letter-spacing: .12em; font-size: 15px; color: #fff; }
.brand-mark span { letter-spacing: 0; }
.page-header { padding: 10px 5px 22px; }
.page-header .brand-mark { margin-bottom: 28px; }
.eyebrow { margin: 0 0 8px; font-weight: 850; letter-spacing: .13em; font-size: 11px; color: #b8a9c8; }
h1 { margin: 0; font-size: clamp(34px, 9vw, 52px); line-height: .98; letter-spacing: -.048em; }
h2 { margin: 0; font-size: 20px; line-height: 1.2; letter-spacing: -.02em; }
p { line-height: 1.5; }
.subtitle { color: #bdb3c8; margin: 12px 0 0; font-size: 15px; max-width: 560px; }

.state-card, .empty-card {
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 28px 24px;
  text-align: center;
  background: linear-gradient(145deg, rgba(255,92,173,.07), rgba(17,16,25,.90));
  box-shadow: 0 24px 70px rgba(0,0,0,.24);
}
.state-card { margin-top: 17vh; }
.state-card .brand-mark { margin-bottom: 24px; }
.state-card h1 { font-size: 30px; }
.state-card p, .empty-card p { color: var(--muted); margin-bottom: 0; }
.state-icon { margin: 0 auto 18px; width: 46px; height: 46px; border-radius: 16px; display: grid; place-items: center; background: rgba(255,107,118,.12); color: var(--danger); font-weight: 900; font-size: 23px; border: 1px solid rgba(255,107,118,.2); }
.loader { width: 32px; height: 32px; margin: 0 auto 20px; border: 3px solid #302838; border-top-color: var(--pink); border-right-color: var(--purple); border-radius: 50%; animation: spin .72s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.groups-list { display: grid; gap: 12px; }
.group-card {
  width: 100%;
  position: relative;
  overflow: hidden;
  color: var(--text);
  padding: 16px;
  display: grid;
  grid-template-columns: 56px minmax(0,1fr) auto;
  align-items: center;
  gap: 14px;
  text-align: left;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(255,92,173,.055), rgba(17,16,25,.88) 42%, rgba(156,118,255,.055));
  box-shadow: 0 12px 38px rgba(0,0,0,.12);
  transition: transform .16s ease, border-color .16s ease;
}
.group-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: linear-gradient(var(--pink),var(--purple)); opacity: .82; }
.group-card:active { transform: scale(.992); border-color: #51435e; }
.avatar {
  position: relative;
  width: 56px; height: 56px;
  display: grid; place-items: center;
  overflow: hidden;
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(255,92,173,.22), rgba(156,118,255,.22));
  border: 1px solid rgba(255,255,255,.08);
  color: #f6eaff;
  font-size: 22px;
  font-weight: 900;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.group-title { display: block; font-weight: 850; font-size: 16px; line-height: 1.25; margin-bottom: 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group-meta { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.chevron { color: #756a80; font-size: 29px; font-weight: 250; padding-left: 3px; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 8px; font-size: 11px; font-weight: 800; background: rgba(255,255,255,.06); color: var(--muted-strong); border: 1px solid rgba(255,255,255,.05); }
.badge.premium { background: rgba(255,211,92,.11); color: var(--yellow); border-color: rgba(255,211,92,.16); }
.badge.active { background: rgba(101,213,138,.10); color: var(--success); border-color: rgba(101,213,138,.14); }
.badge.paused { background: rgba(255,107,118,.10); color: var(--danger); border-color: rgba(255,107,118,.14); }

.back-button { border: 0; background: transparent; color: #d9c6ff; padding: 8px 5px 15px 1px; font-weight: 750; font-size: 15px; }
.back-button:first-letter { font-size: 27px; line-height: 0; vertical-align: -2px; }
.group-hero {
  position: relative;
  overflow: hidden;
  padding: 20px;
  border-radius: 28px;
  margin-bottom: 14px;
  border: 1px solid #44374f;
  background: linear-gradient(145deg, rgba(255,92,173,.13), rgba(17,16,25,.92) 52%, rgba(120,90,255,.12));
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.group-hero::after { content: "🍒"; position: absolute; right: 14px; top: 10px; font-size: 44px; opacity: .11; transform: rotate(10deg); pointer-events: none; }
.hero-top { display: flex; gap: 15px; align-items: center; min-width: 0; }
.hero-top > div { min-width: 0; }
.hero-avatar { width: 64px; height: 64px; border-radius: 20px; font-size: 25px; flex: 0 0 auto; }
.hero-title { font-size: 24px; margin: 0 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

.section-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 12px 0;
  overflow: hidden;
  background: rgba(17,16,25,.82);
  box-shadow: 0 12px 38px rgba(0,0,0,.10);
}
.section-card.accent-card { background: linear-gradient(145deg, rgba(255,92,173,.08), rgba(17,16,25,.86) 52%, rgba(156,118,255,.07)); border-color: #392e43; }
.section-head { padding: 18px 17px 10px; }
.section-head p { color: var(--muted); margin: 6px 0 0; font-size: 13px; }
.setting-row { min-height: 62px; display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 14px; padding: 12px 17px; border-top: 1px solid var(--border); }
.setting-copy strong { display: block; font-size: 15px; font-weight: 760; }
.setting-copy small { display: block; color: var(--muted); margin-top: 4px; line-height: 1.35; font-size: 12.5px; }
.setting-row.locked { opacity: .56; }
.setting-row.nested { margin-left: 16px; padding-left: 13px; border-left: 1px solid #3a3043; }
.setting-row.nested .setting-copy strong { font-size: 14px; }
.subsection-title { padding: 16px 17px 7px; border-top: 1px solid var(--border); color: #f1e9f8; font-size: 14px; font-weight: 850; }
.subsection-title small { display: block; margin-top: 4px; color: var(--muted); font-weight: 450; line-height: 1.35; }

.switch { position: relative; width: 48px; height: 28px; flex: 0 0 auto; }
.switch input { opacity: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: #332c3b; transition: .18s ease; border: 1px solid rgba(255,255,255,.055); }
.switch span::after { content: ""; position: absolute; width: 22px; height: 22px; border-radius: 50%; top: 2px; left: 2px; background: #ece7f2; box-shadow: 0 2px 7px rgba(0,0,0,.32); transition: .18s ease; }
.switch input:checked + span { background: linear-gradient(135deg,var(--pink),var(--purple)); border-color: transparent; }
.switch input:checked + span::after { transform: translateX(20px); background: #fff; }
.switch input:disabled + span { filter: grayscale(.42); }

.role-editor { padding: 0 17px 17px; }
.role-editor textarea { width: 100%; min-height: 118px; resize: vertical; border: 1px solid #3b3245; border-radius: 16px; background: #0d0c13; color: var(--text); padding: 13px 14px; outline: none; line-height: 1.45; }
.role-editor textarea:focus { border-color: #8f6ec6; box-shadow: 0 0 0 3px rgba(156,118,255,.10); }
.action-row { display: flex; gap: 9px; margin-top: 10px; }

.primary-button, .secondary-button, .ghost-button { border: 1px solid var(--border-strong); border-radius: 999px; min-height: 43px; padding: 0 16px; font-weight: 800; cursor: pointer; color: #fff; }
.primary-button { background: linear-gradient(135deg,var(--pink),var(--purple)); border: 0; box-shadow: 0 10px 30px rgba(185,84,255,.17); }
.secondary-button, .ghost-button { background: rgba(255,255,255,.035); }
.primary-button:disabled, .secondary-button:disabled, .ghost-button:disabled { opacity: .48; cursor: default; }

.warning-box { margin: 12px 0; background: rgba(255,211,92,.07); border: 1px solid rgba(255,211,92,.17); border-radius: var(--radius); padding: 15px 17px; }
.warning-box strong { display: block; margin-bottom: 5px; color: #ffe28c; }
.warning-box ul { padding-left: 20px; margin: 7px 0 0; color: #c8bda5; font-size: 13px; line-height: 1.4; }
.warning-box li + li { margin-top: 5px; }
.premium-card { background: linear-gradient(145deg, rgba(255,211,92,.10), rgba(17,16,25,.88) 62%); border-color: rgba(255,211,92,.18); }
.premium-price { font-size: 24px; font-weight: 900; letter-spacing: -.025em; margin: 8px 0 4px; }
.premium-copy { color: var(--muted); margin: 0 0 14px; font-size: 13px; }
.premium-status { margin-top: 10px; font-size: 13px; color: var(--muted); }
.premium-consent { display: flex; align-items: flex-start; gap: 9px; margin: 0 0 13px; color: var(--muted-strong); font-size: 13px; line-height: 1.4; cursor: pointer; }
.premium-consent input { margin: 2px 0 0; width: 17px; height: 17px; flex: 0 0 auto; accent-color: var(--purple); }

.group-loading { padding: 18px; display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.group-loading .loader { width: 20px; height: 20px; margin: 0; border-width: 2px; }
.skeleton-line { height: 12px; border-radius: 999px; background: linear-gradient(90deg,#1e1a25,#2c2535,#1e1a25); background-size: 180% 100%; animation: shimmer 1.15s linear infinite; }
@keyframes shimmer { to { background-position: -180% 0; } }

.footer-links { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; color: #8f8498; font-size: 12px; padding: 26px 0 8px; }
.footer-links a { color: #b8acc3; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: min(92vw,520px); padding: 11px 15px; border-radius: 14px; background: #f4eef9; color: #15101a; font-weight: 760; font-size: 13px; box-shadow: 0 12px 40px rgba(0,0,0,.35); }

@media (min-width: 700px) {
  body { padding-left: 22px; padding-right: 22px; }
  .state-card { margin-top: 12vh; }
}
