:root {
  --space: #08070e;
  --panel: #141319;
  --panel-raised: #1b1922;
  --ink: #f7f6fa;
  --muted: #9ca3af;
  --primary: #9466ff;
  --indigo: #6366f1;
  --border: rgba(255,255,255,.1);
  --green: #5ee7a0;
  --amber: #f2b84b;
  --red: #ff6b7a;
  --max: 1180px;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body { margin: 0; min-height: 100vh; overflow-x: hidden; background: var(--space); color: var(--ink); font: 400 15px/1.6 "Plus Jakarta Sans", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
h1, h2, h3, strong { font-family: "Archivo", sans-serif; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { letter-spacing: -.035em; line-height: 1.02; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; border-radius: 6px; }

.cosmos { position: fixed; inset: 0; z-index: -4; width: 100%; height: 100%; pointer-events: none; }
.nebula { position: fixed; z-index: -3; width: 56vw; height: 56vw; border-radius: 50%; filter: blur(120px); pointer-events: none; opacity: .13; }
.nebula-a { top: -30vw; right: -18vw; background: var(--primary); }
.nebula-b { bottom: -39vw; left: -25vw; background: var(--indigo); opacity: .09; }

.site-header { position: sticky; z-index: 40; top: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 76px; padding: 11px max(24px, calc((100vw - var(--max)) / 2)); border-bottom: 1px solid rgba(255,255,255,.07); background: rgba(8,7,14,.76); backdrop-filter: blur(20px); }
.brand { display: flex; align-items: center; gap: 14px; justify-self: start; text-decoration: none; }
.brand img { width: 154px; height: auto; }
.brand span { padding-left: 14px; border-left: 1px solid var(--border); color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.site-header nav { display: flex; gap: 8px; padding: 5px; border: 1px solid var(--border); border-radius: 999px; background: rgba(255,255,255,.025); }
.site-header nav a { padding: 7px 14px; border-radius: 999px; color: var(--muted); font-size: 12px; text-decoration: none; transition: .2s ease; }
.site-header nav a:hover { background: rgba(255,255,255,.06); color: var(--ink); }
.header-actions { display: flex; align-items: center; gap: 9px; justify-self: end; }
.header-actions form { margin: 0; }

.app-shell { width: min(calc(100% - 48px), var(--max)); margin: 0 auto; padding: 65px 0 100px; }
.eyebrow { display: block; margin-bottom: 13px; color: var(--primary); font-size: 10px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
.button { display: inline-flex; min-height: 48px; align-items: center; justify-content: center; gap: 14px; padding: 0 22px; border: 1px solid transparent; border-radius: 12px; background: linear-gradient(110deg, var(--primary), var(--indigo)); box-shadow: 0 18px 42px -25px var(--primary); color: #fff; font-weight: 700; text-decoration: none; cursor: pointer; transition: transform .22s ease, box-shadow .22s ease; }
.button:hover { transform: translateY(-2px); box-shadow: 0 22px 50px -22px var(--primary); }
.button-small { min-height: 39px; padding-inline: 16px; font-size: 11px; }
.button-secondary { border-color: var(--border); background: rgba(255,255,255,.035); box-shadow: none; }
.icon-button { display: grid; width: 40px; height: 40px; place-items: center; padding: 0; border: 1px solid var(--border); border-radius: 11px; background: rgba(255,255,255,.025); color: var(--muted); cursor: pointer; }
.icon-button:hover { color: var(--ink); border-color: rgba(255,255,255,.22); }
.text-link { padding: 0; border: 0; background: none; color: #c8b7ff; font-size: 12px; font-weight: 700; text-decoration: none; cursor: pointer; }
code { padding: 3px 7px; border: 1px solid var(--border); border-radius: 7px; background: rgba(255,255,255,.04); color: #cdbfff; font-size: .85em; }

.page-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 40px; padding: 35px 0 65px; }
.page-hero h1 { margin-bottom: 23px; font-size: clamp(3.2rem, 6.5vw, 6.2rem); line-height: .92; }
.page-hero h1 em, .login-card h1 em { background: linear-gradient(110deg, var(--primary), var(--indigo)); background-clip: text; -webkit-background-clip: text; color: transparent; font-style: normal; }
.page-hero p { max-width: 55ch; margin: 0; color: var(--muted); font-size: 17px; }

.stats-strip { display: grid; grid-template-columns: repeat(4, 1fr); overflow: hidden; border: 1px solid var(--border); border-radius: 20px; background: rgba(20,19,25,.74); backdrop-filter: blur(14px); }
.stats-strip > div { padding: 24px 27px; border-right: 1px solid var(--border); }
.stats-strip > div:last-child { border-right: 0; }
.stats-strip strong { display: block; margin-bottom: 4px; font-size: 28px; }
.stats-strip span { color: var(--muted); font-size: 11px; }

.content-section { padding-top: 90px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 32px; }
.section-heading h1, .section-heading h2 { margin-bottom: 0; font-size: clamp(2.2rem, 4.5vw, 4rem); }
.section-heading p { margin: 13px 0 0; color: var(--muted); }
.timezone-pill { padding: 8px 13px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: 11px; }

.timeline { position: relative; }
.timeline::before { content: ""; position: absolute; top: 10px; bottom: 10px; left: 141px; width: 1px; background: linear-gradient(var(--primary), rgba(148,102,255,.08)); }
.post-row { position: relative; display: grid; grid-template-columns: 122px 8px minmax(0,1fr) auto; gap: 20px; align-items: center; min-height: 156px; padding: 22px 24px 22px 0; border-bottom: 1px solid var(--border); }
.post-row:first-child { border-top: 1px solid var(--border); }
.post-date { text-align: right; }
.post-date span { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.post-date strong { display: block; margin-top: 5px; font-size: 21px; }
.post-accent { position: relative; z-index: 1; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 7px var(--space), 0 0 24px var(--primary); }
.post-accent.status-sent { background: var(--green); box-shadow: 0 0 0 7px var(--space), 0 0 20px var(--green); }
.post-accent.status-failed { background: var(--red); box-shadow: 0 0 0 7px var(--space), 0 0 20px var(--red); }
.post-accent.status-draft { background: #6b7280; box-shadow: 0 0 0 7px var(--space); }
.post-title-line { display: flex; align-items: center; gap: 11px; margin-bottom: 8px; }
.post-main h3 { margin: 0; font-size: 21px; }
.post-main > p { display: -webkit-box; overflow: hidden; max-width: 72ch; margin: 0; color: var(--muted); font-size: 13px; white-space: pre-line; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.status { padding: 4px 8px; border: 1px solid rgba(148,102,255,.25); border-radius: 999px; background: rgba(148,102,255,.08); color: #cdbfff; font-size: 9px; font-weight: 700; text-transform: uppercase; }
.status-sent { border-color: rgba(94,231,160,.25); background: rgba(94,231,160,.08); color: var(--green); }
.status-failed { border-color: rgba(255,107,122,.28); background: rgba(255,107,122,.08); color: var(--red); }
.status-draft { border-color: var(--border); background: rgba(255,255,255,.03); color: var(--muted); }
.status-sending { color: var(--amber); border-color: rgba(242,184,75,.25); background: rgba(242,184,75,.08); }
.media-chip { display: inline-block; max-width: 100%; margin-top: 12px; padding: 5px 9px; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; color: #c7c3ce; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.post-main .error-copy { margin-top: 9px; color: var(--red); font-size: 11px; }
.post-actions { display: flex; align-items: center; gap: 13px; }
.post-actions form { margin: 0; }

.empty-state { display: flex; align-items: center; justify-content: space-between; gap: 32px; padding: 38px 42px; border: 1px solid var(--border); border-radius: 20px; background: rgba(20,19,25,.72); }
.empty-state h2 { margin: 8px 0 7px; font-size: clamp(1.7rem, 3vw, 2.4rem); }
.empty-state p { margin: 0; color: var(--muted); }
.empty-state .button { flex: 0 0 auto; }

.form-layout { display: grid; grid-template-columns: .78fr 1.22fr; gap: clamp(45px, 8vw, 110px); align-items: start; padding-top: 35px; }
.form-layout aside { position: sticky; top: 120px; }
.form-layout aside h1 { margin-bottom: 20px; font-size: clamp(2.8rem, 5vw, 4.8rem); }
.form-layout aside > p { max-width: 44ch; color: var(--muted); }
.back-link { display: inline-block; margin-bottom: 70px; color: var(--muted); font-size: 12px; text-decoration: none; }
.process-mini { display: flex; align-items: center; gap: 9px; margin-top: 42px; color: var(--muted); font-size: 9px; font-weight: 700; text-transform: uppercase; }
.process-mini span { display: grid; width: 31px; height: 31px; place-items: center; border: 1px solid rgba(148,102,255,.3); border-radius: 9px; background: rgba(148,102,255,.08); color: var(--primary); }
.process-mini i { width: 22px; height: 1px; background: var(--border); }

.editor-card { display: grid; gap: 26px; padding: clamp(28px, 5vw, 50px); border: 1px solid var(--border); border-radius: 24px; background: rgba(20,19,25,.82); box-shadow: 0 40px 100px -70px var(--primary); backdrop-filter: blur(18px); }
.editor-card.narrow { max-width: 740px; }
label { display: grid; gap: 9px; color: #ddd9e5; font-size: 12px; font-weight: 700; }
label small { color: var(--muted); font-size: 10px; font-weight: 400; }
input, textarea { width: 100%; border: 1px solid var(--border); border-radius: 12px; background: rgba(255,255,255,.035); color: var(--ink); outline: none; transition: border-color .2s ease, box-shadow .2s ease; }
input { min-height: 49px; padding: 0 14px; }
textarea { min-height: 190px; padding: 14px; resize: vertical; line-height: 1.65; }
input:focus, textarea:focus { border-color: rgba(148,102,255,.65); box-shadow: 0 0 0 4px rgba(148,102,255,.08); }
input::placeholder, textarea::placeholder { color: #686571; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.upload-field { position: relative; }
.upload-field input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-field span { display: flex; min-height: 49px; align-items: center; padding: 0 14px; overflow: hidden; border: 1px dashed rgba(148,102,255,.4); border-radius: 12px; background: rgba(148,102,255,.045); color: #cdbfff; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.current-media { margin: -12px 0 0; color: var(--muted); font-size: 10px; }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; padding-top: 8px; }
.readonly-box { display: grid; gap: 6px; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: rgba(255,255,255,.02); }
.readonly-box span { color: var(--muted); font-size: 10px; }
.readonly-box code { overflow-wrap: anywhere; }

.settings-layout { padding-top: 35px; }
.settings-layout > .section-heading { margin-bottom: 48px; }
.split-heading { align-items: center; }
.connection-state { display: inline-flex; align-items: center; gap: 9px; padding: 8px 13px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: 11px; }
.connection-state i { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 14px var(--amber); }
.state-open { color: var(--green); border-color: rgba(94,231,160,.28); }
.state-open i { background: var(--green); box-shadow: 0 0 14px var(--green); }
.connection-panel { display: grid; grid-template-columns: 1fr auto; gap: 40px; align-items: center; min-height: 280px; padding: clamp(30px, 6vw, 65px); border: 1px solid var(--border); border-radius: 25px; background: linear-gradient(130deg, rgba(148,102,255,.1), rgba(20,19,25,.85)); }
.connection-panel h2, .group-picker h2 { margin-bottom: 15px; font-size: clamp(2rem, 4vw, 3.7rem); }
.connection-panel p, .group-picker header p { margin: 0; color: var(--muted); }
.qr-panel { grid-template-columns: 1fr 280px; }
.qr-panel img { width: 280px; padding: 14px; border-radius: 20px; background: #fff; }
.group-picker { display: grid; grid-template-columns: .68fr 1.32fr; gap: clamp(40px, 7vw, 90px); }
.group-list { overflow: hidden; border: 1px solid var(--border); border-radius: 20px; background: rgba(20,19,25,.72); }
.group-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px; border-bottom: 1px solid var(--border); }
.group-row:last-child { border-bottom: 0; }
.group-row strong, .group-row small { display: block; }
.group-row strong { font-size: 14px; }
.group-row small { margin-top: 5px; color: var(--muted); font-size: 9px; }
.empty-inline { padding: 24px; color: var(--muted); }

.login-shell { display: grid; min-height: 100vh; place-items: center; padding: 40px 24px; }
.login-card { width: min(100%, 520px); padding: clamp(32px, 7vw, 60px); border: 1px solid var(--border); border-radius: 28px; background: linear-gradient(145deg, rgba(27,25,34,.92), rgba(12,10,20,.9)); box-shadow: 0 50px 140px -80px var(--primary); backdrop-filter: blur(22px); }
.login-brand { width: 168px; height: auto; margin-bottom: 70px; }
.login-card h1 { margin-bottom: 22px; font-size: clamp(2.7rem, 8vw, 4.4rem); }
.login-card > p { color: var(--muted); }
.stack { display: grid; gap: 18px; margin-top: 36px; }

.toast { position: fixed; z-index: 80; top: 92px; left: 50%; max-width: min(90vw, 620px); padding: 12px 18px; border: 1px solid rgba(94,231,160,.3); border-radius: 12px; background: rgba(16,35,28,.95); box-shadow: 0 15px 50px rgba(0,0,0,.35); color: #bcf8d5; font-size: 12px; transform: translateX(-50%); }
.toast-error { border-color: rgba(255,107,122,.35); background: rgba(49,19,26,.96); color: #ffc0c7; }

.reveal { animation: rise .7s cubic-bezier(.22,1,.36,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

@media (max-width: 900px) {
  .site-header { grid-template-columns: minmax(0,1fr) auto; padding-inline: 14px; }
  .site-header .brand { display: none; }
  .site-header nav { position: static; justify-self: start; gap: 2px; padding: 4px; background: rgba(20,19,25,.78); }
  .site-header nav a { padding-inline: 11px; }
  .header-actions .button { display: none; }
  .page-hero { align-items: flex-start; flex-direction: column; }
  .stats-strip { grid-template-columns: repeat(2,1fr); }
  .stats-strip > div:nth-child(2) { border-right: 0; }
  .stats-strip > div:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .form-layout { grid-template-columns: 1fr; }
  .form-layout aside { position: static; }
  .back-link { margin-bottom: 42px; }
  .group-picker { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .app-shell { width: min(calc(100% - 28px), var(--max)); padding-top: 38px; }
  .site-header nav a { padding-inline: 9px; font-size: 10px; }
  .page-hero { padding-bottom: 45px; }
  .page-hero h1 { font-size: 3.3rem; }
  .page-hero .button { width: 100%; }
  .stats-strip > div { padding: 18px; }
  .content-section { padding-top: 62px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .timeline::before { left: 4px; }
  .post-row { grid-template-columns: 8px minmax(0,1fr); gap: 15px; padding: 22px 0; }
  .post-date { grid-column: 2; grid-row: 1; text-align: left; }
  .post-date span, .post-date strong { display: inline; margin-right: 8px; font-size: 11px; }
  .post-accent { grid-column: 1; grid-row: 1 / span 3; align-self: start; margin-top: 6px; }
  .post-main { grid-column: 2; }
  .post-title-line { align-items: flex-start; flex-direction: column; }
  .post-actions { grid-column: 2; justify-content: flex-start; }
  .empty-state { align-items: flex-start; flex-direction: column; padding: 28px 24px; }
  .empty-state .button { width: 100%; }
  .field-grid { grid-template-columns: 1fr; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .button { width: 100%; }
  .process-mini { flex-wrap: wrap; }
  .connection-panel, .qr-panel { grid-template-columns: 1fr; }
  .qr-panel img { width: min(100%, 280px); }
  .group-row { align-items: flex-start; flex-direction: column; }
}

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