:root {
  --bg: #07111f;
  --bg-soft: #0d1628;
  --card: rgba(15, 24, 40, 0.92);
  --card-strong: rgba(11, 18, 31, 0.98);
  --line: rgba(148, 163, 184, 0.16);
  --line-strong: rgba(148, 163, 184, 0.24);
  --text: #edf4ff;
  --muted: #8da3c4;
  --muted-2: #6e82a2;
  --accent: #5aa7ff;
  --accent-2: #6d7cff;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #fb7185;
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --shadow-lg: 0 28px 90px rgba(0, 0, 0, 0.34);
  --shadow-md: 0 16px 36px rgba(0, 0, 0, 0.22);
  --shadow-sm: 0 10px 22px rgba(0, 0, 0, 0.14);
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--text);
  font-family: var(--sans);
  background:
    radial-gradient(900px 550px at 8% -8%, rgba(71, 125, 255, 0.32), transparent 54%),
    radial-gradient(850px 600px at 100% 0%, rgba(31, 185, 153, 0.16), transparent 52%),
    linear-gradient(180deg, #08101c 0%, #07111f 38%, #091424 100%);
  min-height: 100vh;
}
body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  opacity: .18;
  z-index: 0;
}
body::before {
  left: -90px;
  bottom: 80px;
  background: #316dff;
}
body::after {
  right: -110px;
  top: 130px;
  background: #16c79a;
}

::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.03); }
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.22);
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.34); background-clip: padding-box; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 24px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(7, 13, 23, 0.82);
  backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.brand__logo {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: white;
  font-weight: 900;
  font-size: 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 12px 24px rgba(90, 167, 255, 0.26);
}
.brand__title {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.01em;
}
.brand__subtitle {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  max-width: 720px;
}
.topbar__right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.layout {
  position: relative;
  z-index: 1;
  max-width: 1480px;
  margin: 28px auto;
  padding: 0 18px 42px;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.16fr) minmax(380px, .84fr);
  grid-template-areas:
    "config config"
    "composer preview"
    "subs preview"
    "queue preview"
    "console preview";
  align-items: start;
}
#configPanel { grid-area: config; }
#composerPanel { grid-area: composer; }
#previewPanel { grid-area: preview; }
#subscribersPanel { grid-area: subs; }
#queuePanel { grid-area: queue; }
#consolePanel { grid-area: console; }

.card {
  position: relative;
  background: linear-gradient(180deg, rgba(18, 28, 46, 0.92), rgba(11, 18, 31, 0.94));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 22px;
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, rgba(255,255,255,0.16), transparent 30%, transparent 70%, rgba(255,255,255,0.08));
}
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}
.card--wide { grid-column: auto; }
#configPanel { grid-column: 1 / -1; }

#configPanel {
  padding: 18px 20px;
  background: linear-gradient(180deg, rgba(16, 28, 49, 0.95), rgba(10, 18, 31, 0.95));
}
#previewPanel {
  position: sticky;
  top: 90px;
  align-self: start;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 108px);
}

.sectionHead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}
.sectionHead > div { min-width: 0; }
h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.25;
  letter-spacing: 0.01em;
}
p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}
#composerPanel h2::before,
#previewPanel h2::before,
#subscribersPanel h2::before,
#queuePanel h2::before,
#consolePanel h2::before,
#configPanel h2::before {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 78px;
  margin: 0 0 10px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(90, 167, 255, 0.22);
  background: rgba(90, 167, 255, 0.08);
  color: #bfdcff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}
#configPanel h2::before { content: "Setup"; }
#composerPanel h2::before { content: "Editor"; }
#previewPanel h2::before { content: "Preview"; }
#subscribersPanel h2::before { content: "Audience"; }
#queuePanel h2::before { content: "Queue"; }
#consolePanel h2::before { content: "Logs"; }

.grid2, .grid3 {
  display: grid;
  gap: 14px;
}
.grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.compact { align-items: end; }
.field {
  display: grid;
  gap: 8px;
}
.field--wide { grid-column: 1 / -1; }
.field--textarea { margin-top: 14px; }
.smallTop { margin-top: 14px; }
.field span,
.rateBox span,
.stat span {
  color: #a9bdd8;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
}
.field small {
  color: var(--muted-2);
  font-size: 11px;
  line-height: 1.55;
}
input,
textarea,
select {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: linear-gradient(180deg, rgba(4, 10, 19, 0.66), rgba(8, 15, 28, 0.92));
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease, transform .08s ease, background .2s ease;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}
input::placeholder,
textarea::placeholder { color: #6d81a0; }
input:hover,
textarea:hover { border-color: rgba(148, 163, 184, 0.28); }
input:focus,
textarea:focus,
select:focus {
  border-color: rgba(90, 167, 255, 0.68);
  box-shadow: 0 0 0 4px rgba(90, 167, 255, 0.12), 0 8px 22px rgba(12, 35, 75, 0.18);
  background: linear-gradient(180deg, rgba(8, 16, 31, 0.76), rgba(10, 19, 34, 0.98));
}
textarea {
  resize: vertical;
  font-family: var(--mono);
  line-height: 1.52;
}
input[type="file"] {
  padding: 10px 12px;
  min-height: 48px;
}
input[type="file"]::file-selector-button {
  margin-right: 10px;
  border: 1px solid rgba(90, 167, 255, 0.34);
  background: rgba(90, 167, 255, 0.12);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
}

.btn,
.chip {
  appearance: none;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
  color: var(--text);
  border-radius: 14px;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: transform .08s ease, border-color .2s ease, background .2s ease, box-shadow .2s ease, opacity .2s ease;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
.btn:hover,
.chip:hover {
  transform: translateY(-1px);
  border-color: rgba(148, 163, 184, 0.34);
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03));
}
.btn:active,
.chip:active { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary {
  border-color: rgba(90, 167, 255, 0.38);
  background: linear-gradient(180deg, rgba(90, 167, 255, 0.24), rgba(90, 167, 255, 0.12));
  box-shadow: 0 10px 24px rgba(90, 167, 255, 0.16);
}
.btn--primary:hover {
  border-color: rgba(90, 167, 255, 0.52);
  background: linear-gradient(180deg, rgba(90, 167, 255, 0.3), rgba(90, 167, 255, 0.14));
}
.btn--danger {
  border-color: rgba(251, 113, 133, 0.38);
  background: linear-gradient(180deg, rgba(251, 113, 133, 0.18), rgba(251, 113, 133, 0.1));
}
.btn--danger:hover {
  border-color: rgba(251, 113, 133, 0.52);
  background: linear-gradient(180deg, rgba(251, 113, 133, 0.24), rgba(251, 113, 133, 0.12));
}
.toolbar,
.actionsRow,
.chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.toolbar {
  justify-content: space-between;
  margin-top: 16px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(148, 163, 184, 0.1);
}
.toolbar__left,
.toolbar__right {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.chips {
  margin-top: 14px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(148, 163, 184, 0.08);
}
.chip {
  padding: 9px 11px;
  border-radius: 12px;
  font-family: var(--mono);
  font-weight: 600;
  color: #d9ebff;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge--ok {
  color: #b8f6df;
  border-color: rgba(52, 211, 153, 0.28);
  background: rgba(52, 211, 153, 0.08);
}
.badge--warn {
  color: #ffe5a1;
  border-color: rgba(251, 191, 36, 0.28);
  background: rgba(251, 191, 36, 0.08);
}
.badge--bad {
  color: #ffc1cc;
  border-color: rgba(251, 113, 133, 0.28);
  background: rgba(251, 113, 133, 0.08);
}

.notice,
.statusBox {
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: #bfd0e7;
  border-radius: 16px;
  padding: 13px 14px;
  font-size: 13px;
  line-height: 1.6;
}
.notice { margin-top: 12px; }
.notice--warn {
  background: rgba(251, 191, 36, 0.08);
  border-color: rgba(251, 191, 36, 0.18);
  color: #ffe0a2;
  margin-top: 0;
}
.notice--ok {
  background: rgba(52, 211, 153, 0.08);
  border-color: rgba(52, 211, 153, 0.18);
  color: #bbf7de;
}
.notice--bad {
  background: rgba(251, 113, 133, 0.08);
  border-color: rgba(251, 113, 133, 0.18);
  color: #ffd1d9;
}


#previewPanel .sectionHead,
#previewPanel .previewMeta {
  flex: 0 0 auto;
}
#previewPanel .previewFrame {
  flex: 1 1 auto;
}

.previewMeta {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}
.previewMeta div {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 12px;
  align-items: center;
  padding: 13px 14px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 16px;
  background: rgba(255,255,255,0.03);
}
.previewMeta span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.previewMeta strong {
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
}
.previewFrame {
  width: 100%;
  height: min(860px, calc(100vh - 300px));
  min-height: 520px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 22px;
  background: linear-gradient(180deg, #f4f7fb, #ffffff);
  box-shadow: inset 0 0 0 10px rgba(255,255,255,0.95), 0 18px 40px rgba(0,0,0,0.18);
}

.statsRow {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 12px;
}
.stat,
.rateBox {
  position: relative;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
  padding: 14px;
  min-height: 84px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}
.stat strong,
.rateBox strong {
  display: block;
  margin-top: 10px;
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.rateBox {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.tableWrap {
  margin-top: 14px;
  overflow: auto;
  max-height: 500px;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(4, 10, 19, 0.32);
}
.table {
  width: 100%;
  min-width: 780px;
  border-collapse: separate;
  border-spacing: 0;
}
.table th,
.table td {
  padding: 12px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
  font-size: 13px;
}
.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(11, 18, 31, 0.98);
  color: #c5d7f0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.table tbody tr {
  transition: background .15s ease;
}
.table tbody tr:hover {
  background: rgba(90, 167, 255, 0.04);
}
.table tr:last-child td { border-bottom: 0; }
.muted { color: var(--muted); }

.checkRow {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.1);
  background: rgba(255,255,255,0.025);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}
.checkRow input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  margin-top: 1px;
  box-shadow: none;
}

.progressBar {
  margin-top: 14px;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(255,255,255,0.03);
}
.progressBar__fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2) 54%, var(--success));
  transition: width .18s ease;
  box-shadow: 0 0 18px rgba(90, 167, 255, 0.24);
}
.statusBox { margin-top: 12px; }

#configPanel .grid3.compact {
  grid-template-columns: minmax(0, 1.2fr) minmax(200px, .8fr) minmax(0, 1fr);
}
#composerPanel textarea#htmlBody {
  min-height: 560px;
}
#console {
  margin-top: 12px;
  min-height: 260px;
  border-radius: 18px;
  background: linear-gradient(180deg, #07101d, #060c17);
  color: #bbf7de;
  border-color: rgba(52, 211, 153, 0.16);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02);
}

code {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(255,255,255,0.05);
  color: #dcecff;
  font-family: var(--mono);
  font-size: 12px;
}

.footer {
  position: relative;
  z-index: 1;
  max-width: 1480px;
  margin: 4px auto 30px;
  padding: 0 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

@media (max-width: 1220px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "config"
      "composer"
      "preview"
      "subs"
      "queue"
      "console";
  }
  #previewPanel { position: static; }
  .previewFrame { height: 680px; }
}

@media (max-width: 920px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    padding: 16px 18px;
  }
  .topbar__right { justify-content: flex-start; }
  .layout {
    margin-top: 20px;
    padding: 0 14px 32px;
  }
  .grid3,
  #configPanel .grid3.compact,
  .grid2 {
    grid-template-columns: 1fr;
  }
  .toolbar {
    align-items: stretch;
  }
  .toolbar__left,
  .toolbar__right,
  .actionsRow {
    width: 100%;
  }
  .previewFrame { height: 620px; }
}

@media (max-width: 680px) {
  .card { padding: 18px; border-radius: 20px; }
  .brand__title { font-size: 17px; }
  .brand__subtitle { font-size: 11px; }
  h2 { font-size: 18px; }
  .btn,
  .chip { width: 100%; justify-content: center; }
  .toolbar__left .btn,
  .toolbar__right .btn,
  .actionsRow .btn { flex: 1 1 100%; }
  .actionsRow input[type="file"] { width: 100%; }
  .previewMeta div { grid-template-columns: 1fr; }
  #composerPanel textarea#htmlBody { min-height: 450px; }
  .previewFrame { height: 560px; border-radius: 18px; }
  .stat strong,
  .rateBox strong { font-size: 20px; }
}
