:root {
  color-scheme: light;
  --bg: #f3f6ff;
  --surface: #ffffff;
  --surface-soft: #eef3ff;
  --surface-strong: #e4ebff;
  --text: #11182b;
  --muted: #64708b;
  --line: #cfd9f1;
  --line-strong: #a9b6dc;
  --accent: #4169ff;
  --accent-strong: #2448d8;
  --accent-soft: #e9eeff;
  --blue: #5f87ff;
  --blue-soft: #eaf0ff;
  --amber: #c78b18;
  --danger: #c2412d;
  --danger-soft: #fff0ec;
  --ok: #12805c;
  --shadow: 0 18px 42px rgba(41, 61, 121, 0.1);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0f1f;
  --surface: #121a2f;
  --surface-soft: #18233d;
  --surface-strong: #223054;
  --text: #eef4ff;
  --muted: #97a7c7;
  --line: #2c3d63;
  --line-strong: #415581;
  --accent: #5f79ff;
  --accent-strong: #8fd9ff;
  --accent-soft: #172456;
  --blue: #7aa6ff;
  --blue-soft: #17274f;
  --amber: #f3bd57;
  --danger: #ff7968;
  --danger-soft: #351d1a;
  --ok: #5fd2a6;
  --shadow: 0 24px 54px rgba(1, 7, 20, 0.42);
}

html[data-theme="contrast"] {
  color-scheme: dark;
  --bg: #050816;
  --surface: #0e1630;
  --surface-soft: #152248;
  --surface-strong: #1f3270;
  --text: #f8fbff;
  --muted: #b6c3ea;
  --line: #31457d;
  --line-strong: #4f67b0;
  --accent: #7b61ff;
  --accent-strong: #7fe0ff;
  --accent-soft: #1b245f;
  --blue: #69a7ff;
  --blue-soft: #122458;
  --amber: #8fd7ff;
  --danger: #ff8ea4;
  --danger-soft: #3d1d31;
  --ok: #75e0ff;
  --shadow: 0 26px 60px rgba(2, 6, 24, 0.58);
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 680px at -10% -10%, rgba(97, 123, 255, 0.2), transparent 62%),
    radial-gradient(960px 600px at 100% 0%, rgba(103, 224, 255, 0.14), transparent 58%),
    radial-gradient(900px 520px at 50% 100%, rgba(123, 97, 255, 0.12), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Inter, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
select,
input,
textarea {
  color: var(--text);
}

button {
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}

button:active { transform: translateY(1px); }

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 28%, transparent);
  outline-offset: 2px;
}

.shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 18px 14px 40px;
}

.hero {
  position: relative;
  overflow: hidden;
  margin-bottom: 14px;
  padding: 18px;
  border: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
  border-radius: 16px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--surface) 88%, transparent) 0%, color-mix(in srgb, var(--surface-soft) 92%, transparent) 100%);
  box-shadow: var(--shadow);
}

.hero::before,
.hero::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
}

.hero::before {
  top: -120px;
  right: -100px;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 22%, transparent) 0%, transparent 72%);
}

.hero::after {
  bottom: -140px;
  left: -110px;
  width: 360px;
  height: 360px;
  background: radial-gradient(circle, color-mix(in srgb, var(--blue) 18%, transparent) 0%, transparent 70%);
}

.heroGrid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  gap: 18px;
  align-items: stretch;
}

.heroCopy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 204px;
}

.heroText {
  max-width: 560px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.heroBadges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.heroBadge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid color-mix(in srgb, var(--line) 74%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-soft) 78%, transparent);
  color: var(--text);
  font-size: 13px;
  font-weight: 760;
}

.topbar,
.editorHeader,
.itemHeader,
.planHeader,
.draftHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  position: relative;
  z-index: 1;
  margin-bottom: 16px;
}

.topActions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.05;
}

h2 {
  font-size: 24px;
  line-height: 1.15;
}

h3 {
  font-size: 18px;
}

.themeSelect,
.iconButton,
.tab,
.inlineForm button,
.ghostButton,
.primaryButton,
.actionGrid button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-weight: 800;
}

.themeSelect {
  min-height: 42px;
  padding: 0 10px;
}

.iconButton {
  width: 44px;
  height: 42px;
  font-size: 21px;
  cursor: pointer;
}

.summaryGrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

.metric,
.item,
.profileBox,
.editor,
.bootStatus,
.notice,
.lockedBox,
.draftPreview,
.imagePreview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}

.metric {
  min-height: 102px;
  padding: 16px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 88%, var(--surface-soft)) 0%, var(--surface) 100%);
  box-shadow: var(--shadow);
}

.metric span,
.muted,
.hintLine {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 9px;
  font-size: 22px;
}

.bootStatus,
.notice {
  margin: 0 0 12px;
  padding: 12px 14px;
  font-weight: 760;
}

.bootStatus {
  color: var(--muted);
  background: var(--surface-soft);
}

.bootStatus.ok {
  color: var(--ok);
}

.bootStatus.warn,
.notice.warn {
  color: var(--amber);
  border-color: color-mix(in srgb, var(--amber) 42%, var(--line));
  background: color-mix(in srgb, var(--amber) 10%, var(--surface));
}

.notice {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.notice.danger,
.error,
.danger {
  color: var(--danger);
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 0 14px;
  padding: 8px;
  border: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.tab,
.inlineForm button,
.ghostButton,
.primaryButton,
.actionGrid button {
  min-height: 44px;
  padding: 0 14px;
  cursor: pointer;
}

.tab:hover,
.inlineForm button:hover,
.ghostButton:hover,
.actionGrid button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.tab.active,
.inlineForm button,
.primaryButton,
.actionGrid button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 24px color-mix(in srgb, var(--accent) 22%, transparent);
}

.primaryButton.danger,
.ghostButton.danger {
  border-color: color-mix(in srgb, var(--danger) 52%, var(--line));
  color: var(--danger);
  background: var(--danger-soft);
}

.primaryButton.danger {
  color: #fff;
  background: var(--danger);
}

.panel { display: none; }
.panel.active {
  display: block;
  animation: panelIn 0.22s ease;
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.inlineForm {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  box-shadow: var(--shadow);
}

input,
textarea,
select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 11px 12px;
}

textarea {
  resize: vertical;
  line-height: 1.48;
}

input::placeholder,
textarea::placeholder {
  color: color-mix(in srgb, var(--muted) 72%, transparent);
}

.list {
  display: grid;
  gap: 10px;
}

.sectionIntro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 12px;
}

.sectionText {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.item {
  width: 100%;
  padding: 14px;
  text-align: left;
  box-shadow: var(--shadow);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 92%, var(--surface-soft)) 0%, var(--surface) 100%);
}

button.item {
  cursor: pointer;
}

.channelItem:hover,
.item:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.channelItem {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 10px;
  padding: 16px;
}

.channelItem::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 65%, transparent) 0%, transparent 85%);
  opacity: 0.9;
}

.channelItem.active {
  border-color: color-mix(in srgb, var(--accent) 72%, var(--line));
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent-soft) 45%, var(--surface)) 0%, var(--surface) 100%);
  box-shadow: 0 12px 28px color-mix(in srgb, var(--accent) 16%, transparent);
}

.channelItemHead,
.channelItemFooter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.channelItemEyebrow {
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 840;
  text-transform: uppercase;
}

.channelItemSummary {
  line-height: 1.5;
}

.channelMetaTags {
  margin-top: 0;
}

.channelMetaTags span {
  padding: 5px 9px;
  border: 1px solid color-mix(in srgb, var(--line) 84%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-soft) 82%, transparent);
}

.channelItemHint,
.channelItemArrow {
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 760;
}

.channelItemArrow {
  font-size: 16px;
}

.itemTitle {
  color: var(--text);
  font-size: 16px;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.itemMeta,
.miniActions,
.toolbarActions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.itemMeta {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.editorMount {
  margin-top: 12px;
}

.editor {
  padding: 18px;
  margin-bottom: 12px;
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.channelMenu {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 90%, var(--surface-soft)) 0%, var(--surface) 100%);
}

.actionPanel {
  display: none;
}

.actionPanel.active {
  display: block;
}

.actionGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.actionGrid button {
  text-align: left;
}

.actionGrid button.locked {
  opacity: 0.55;
}

.actionCard {
  position: relative;
  display: grid;
  gap: 8px;
  min-height: 134px;
  padding: 14px;
  overflow: hidden;
}

.actionCard::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 9%, transparent) 0%, transparent 48%, color-mix(in srgb, var(--blue) 10%, transparent) 100%);
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
}

.actionCard:hover::before,
.actionCard.active::before {
  opacity: 1;
}

.actionCard > * {
  position: relative;
  z-index: 1;
}

.actionCardEyebrow {
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 840;
  text-transform: uppercase;
}

.actionCardTitle {
  color: var(--text);
  font-size: 18px;
  font-weight: 840;
  line-height: 1.15;
}

.actionCardHint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.actionCardState {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  margin-top: auto;
  padding: 0 10px;
  border: 1px solid color-mix(in srgb, var(--line) 84%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-soft) 82%, transparent);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

.actionCardState.locked {
  color: var(--muted);
}

.formGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 7px;
  margin: 12px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.field span {
  color: var(--muted);
}

.toggleGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.toggleGrid label,
.publisherMode label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 760;
}

.toggleGrid input,
.publisherMode input {
  width: auto;
}

.settingsGroup {
  margin: 14px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.settingsGroup h3 {
  margin-bottom: 8px;
}

.compactSettingsGroup {
  margin-top: 18px;
}

.mediaTypeGrid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.statusLine {
  min-height: 22px;
  margin-top: 10px;
  color: var(--accent-strong);
  font-weight: 780;
}

.empty,
.lockedBox,
.error {
  padding: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-soft);
}

.lockedBox p {
  margin: 8px 0 12px;
  color: var(--muted);
}

.planBox,
.nestedEditor,
.workbenchCard {
  margin-top: 14px;
}

.planHeader {
  margin: 10px 0;
}

.planPost {
  background: var(--surface);
}

.draftPreview {
  margin-top: 14px;
  overflow: hidden;
}

.draftHeader {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.draftPreview pre {
  margin: 0;
  padding: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
}

.imagePreview {
  margin-top: 14px;
  padding: 10px;
  background: var(--surface-soft);
}

.imagePreview img {
  display: block;
  width: 100%;
  max-height: 520px;
  object-fit: contain;
  border-radius: 8px;
  background: #000;
}

.imagePreview a {
  display: inline-block;
  margin-top: 8px;
  color: var(--blue);
  font-weight: 800;
}

.publisherMode {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.publisherList {
  display: grid;
  gap: 8px;
  margin: 10px 0;
}

.publisherItem {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.publisherItem.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.tariffCard.current {
  border-color: color-mix(in srgb, var(--accent) 72%, var(--line));
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent-soft) 55%, var(--surface)) 0%, var(--surface) 100%);
}

.tariffPrice {
  margin-top: 4px;
}

.tariffMetaGrid {
  gap: 10px 14px;
}

.tariffHint {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-soft) 78%, transparent);
  color: var(--muted);
  font-size: 13px;
}

.tariffActions,
.profileActions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-top: 14px;
}

.compactField {
  margin: 0;
  min-width: 148px;
  flex: 0 0 148px;
}

.tariffTermSelect {
  min-height: 44px;
}

.tariffActions .primaryButton {
  min-width: 220px;
}

.tariffActions .ghostButton {
  background: color-mix(in srgb, var(--surface-soft) 76%, transparent);
}

.profileBox {
  padding: 16px;
}

.profileGrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.profileGrid div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.profileGrid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.hidden {
  display: none !important;
}

@media (max-width: 760px) {
  .shell {
    padding: 16px 10px 28px;
  }

  .hero {
    padding: 14px;
    border-radius: 14px;
  }

  .heroGrid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
  }

  h1 {
    font-size: 30px;
  }

  .summaryGrid,
  .formGrid,
  .toggleGrid,
  .mediaTypeGrid,
  .publisherMode,
  .profileGrid {
    grid-template-columns: 1fr;
  }

  .actionGrid {
    grid-template-columns: 1fr;
  }

  .inlineForm {
    grid-template-columns: 1fr;
  }

  .editor {
    padding: 14px;
  }

  .editorHeader {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbarActions {
    width: 100%;
  }

  .toolbarActions button,
  .miniActions button,
  .topActions select,
  .tariffActions button,
  .profileActions button {
    flex: 1 1 auto;
  }
}

@media (max-width: 460px) {
  .topbar {
    display: grid;
  }

  .topActions {
    width: 100%;
  }

  .themeSelect {
    flex: 1;
  }

  .tabs {
    gap: 6px;
  }

  .tab {
    padding: 0 8px;
    font-size: 14px;
  }
}
