:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --line: #d9dee7;
  --line-soft: #e8ecf2;
  --text: #18212f;
  --muted: #657386;
  --soft: #8793a4;
  --teal: #0f9f8f;
  --teal-dark: #087c72;
  --indigo: #3c5ccf;
  --amber: #c98214;
  --green: #138a58;
  --red: #c9364a;
  --coral: #d85f4c;
  --violet: #7357c6;
  --radius: 8px;
  --shadow: 0 14px 38px rgba(31, 42, 68, .08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
}

img {
  display: block;
  max-width: 100%;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 12px;
  border-right: 1px solid var(--line);
  background: #111827;
  color: #f8fafc;
}

.brand {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 6px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.brand img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: var(--radius);
  background: #fff;
}

.brand-title {
  font-weight: 800;
  line-height: 1.15;
}

.brand-subtitle {
  margin-top: 3px;
  color: #aab5c5;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 5px;
}

.nav-btn {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  color: #c9d2df;
  background: transparent;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
}

.nav-btn:hover,
.nav-btn.active {
  color: #fff;
  background: rgba(255, 255, 255, .09);
}

.nav-btn.active {
  outline: 1px solid rgba(15, 159, 143, .55);
}

.nav-btn i,
.btn i,
.icon-btn i,
.segmented i,
.chip i,
.platform-mark i,
.status-tag i {
  width: 18px;
  height: 18px;
  flex: none;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding: 14px 10px 2px;
  color: #aab5c5;
  font-size: 12px;
  line-height: 1.45;
  border-top: 1px solid rgba(255, 255, 255, .12);
}

.mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #f8fafc;
  font-weight: 700;
}

.mode-pill span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 4px rgba(15, 159, 143, .18);
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(244, 246, 248, .92);
  backdrop-filter: blur(16px);
}

.eyebrow {
  color: var(--teal-dark);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  margin-top: 3px;
  font-size: 24px;
  line-height: 1.16;
}

h2 {
  margin-top: 3px;
  font-size: 18px;
  line-height: 1.2;
}

h3 {
  font-size: 15px;
  line-height: 1.25;
}

.top-actions,
.toolbar-controls,
.split-head,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.top-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.status-pill {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(19, 138, 88, .14);
}

.page {
  display: none;
  padding: 26px 28px 42px;
}

.page.active {
  display: block;
}

.content-band {
  width: min(1440px, 100%);
  margin-bottom: 18px;
}

.content-grid {
  width: min(1440px, 100%);
  display: grid;
  gap: 18px;
}

.content-grid.two {
  grid-template-columns: minmax(0, 1.18fr) minmax(340px, .82fr);
}

.content-grid.bottom {
  margin-top: 18px;
}

.generator-grid {
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  align-items: start;
}

.plan-layout {
  grid-template-columns: minmax(0, 1fr) 360px;
  align-items: start;
}

.plan-layout.calendar-active {
  grid-template-columns: 1fr;
}

.plan-layout.calendar-active .form-panel {
  max-width: 520px;
}

.tool-panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.tool-panel.compact,
.form-panel.compact {
  padding: 16px;
}

.section-head {
  margin-bottom: 16px;
}

.btn,
.icon-btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  transition: transform .16s ease, background .16s ease, color .16s ease, border-color .16s ease;
}

.btn {
  padding: 9px 13px;
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--surface);
  font-weight: 700;
}

.btn.primary {
  border-color: var(--teal);
  color: #fff;
  background: var(--teal);
}

.btn.ghost {
  background: var(--surface-2);
}

.btn.danger {
  border-color: rgba(201, 54, 74, .28);
  color: var(--red);
  background: rgba(201, 54, 74, .08);
}

.btn.warning {
  border-color: rgba(201, 130, 20, .28);
  color: #8a5609;
  background: rgba(201, 130, 20, .1);
}

.btn:hover,
.icon-btn:hover,
.segmented button:hover,
.chip:hover {
  transform: translateY(-1px);
}

.btn:disabled,
.icon-btn:disabled {
  cursor: not-allowed;
  opacity: .56;
  transform: none;
}

.btn.wide {
  width: 100%;
}

.icon-btn {
  width: 38px;
  padding: 0;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric-card {
  min-height: 112px;
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card .label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric-card .value {
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
}

.metric-card .hint {
  color: var(--soft);
  font-size: 12px;
}

.pipeline {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.pipeline-step {
  min-height: 134px;
  display: grid;
  align-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.pipeline-step strong {
  display: block;
  margin-top: 8px;
  line-height: 1.2;
}

.pipeline-step span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.step-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: #fff;
}

.mini-plan,
.activity-list {
  display: grid;
  gap: 10px;
}

.mini-plan-row,
.activity-row,
.platform-card,
.plan-row,
.post-card {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
}

.mini-plan-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
}

.mini-date {
  display: grid;
  place-items: center;
  min-height: 58px;
  border-radius: var(--radius);
  background: #eef7f6;
  color: var(--teal-dark);
  font-weight: 800;
  text-align: center;
  line-height: 1.2;
}

.mini-title {
  font-weight: 800;
  line-height: 1.25;
}

.muted,
.mini-meta,
.row-meta,
.post-meta,
.activity-row p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

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

.platform-card {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.platform-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.platform-mark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--teal);
}

.activity-row {
  padding: 12px;
}

.activity-row strong {
  display: block;
  margin-bottom: 4px;
}

.form-panel {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.field > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

input,
textarea,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 11px;
  color: var(--text);
  background: #fff;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 112px;
  line-height: 1.45;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(15, 159, 143, .7);
  box-shadow: 0 0 0 3px rgba(15, 159, 143, .13);
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.chip input {
  display: none;
}

.chip.active {
  color: var(--teal-dark);
  border-color: rgba(15, 159, 143, .45);
  background: rgba(15, 159, 143, .09);
}

.chip-grid.small .chip {
  min-height: 31px;
  padding: 6px 9px;
}

.preview-panel {
  min-height: 640px;
}

.empty-state {
  min-height: 220px;
  display: grid;
  place-items: center;
  padding: 26px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
  background: var(--surface-2);
}

.post-grid {
  width: min(1440px, 100%);
  display: grid;
  grid-template-columns: repeat(3, minmax(280px, 1fr));
  gap: 16px;
}

.post-card {
  overflow: hidden;
  background: #fff;
}

.post-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #e5e7eb;
}

.post-body {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.post-text {
  max-height: 162px;
  overflow: auto;
  color: #364253;
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.5;
}

.post-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.status-tag,
.platform-tag {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: #eef2f7;
  color: #455266;
}

.status-tag.warning {
  color: #8a5609;
  background: rgba(201, 130, 20, .13);
}

.status-tag.success,
.status-tag.done {
  color: var(--green);
  background: rgba(19, 138, 88, .12);
}

.status-tag.draft {
  color: var(--indigo);
  background: rgba(60, 92, 207, .1);
}

.status-tag.danger {
  color: var(--red);
  background: rgba(201, 54, 74, .1);
}

.plan-toolbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.segmented {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.segmented button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 800;
}

.segmented button.active {
  color: var(--text);
  background: #fff;
  box-shadow: 0 1px 2px rgba(20, 28, 42, .08);
}

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

.plan-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 13px;
}

.plan-time {
  min-height: 64px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: var(--teal-dark);
  background: #eef7f6;
  font-weight: 800;
  text-align: center;
  line-height: 1.2;
}

.plan-main {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.plan-title {
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.plan-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  flex-wrap: wrap;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  padding-bottom: 4px;
}

.calendar-day {
  min-width: 0;
  min-height: 280px;
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.calendar-item {
  min-width: 0;
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  border-radius: var(--radius);
  background: #fff;
}

.calendar-item strong {
  font-size: 13px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  max-width: min(420px, calc(100vw - 40px));
  display: none;
  padding: 12px 14px;
  border-radius: var(--radius);
  color: #fff;
  background: #111827;
  box-shadow: 0 18px 42px rgba(17, 24, 39, .24);
}

.toast.show {
  display: block;
}

@media (max-width: 1180px) {
  .stats-grid,
  .pipeline {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid.two,
  .generator-grid,
  .plan-layout {
    grid-template-columns: 1fr;
  }

  .post-grid {
    grid-template-columns: repeat(2, minmax(260px, 1fr));
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 12px;
  }

  .brand {
    grid-template-columns: 38px minmax(0, 1fr);
    padding-bottom: 10px;
  }

  .brand img {
    width: 38px;
    height: 38px;
  }

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

  .sidebar-footer {
    display: none;
  }

  .topbar,
  .plan-toolbar,
  .split-head,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    padding: 16px;
  }

  .top-actions,
  .toolbar-controls {
    justify-content: flex-start;
  }

  .page {
    padding: 18px 16px 34px;
  }

  .stats-grid,
  .pipeline,
  .platform-grid,
  .post-grid {
    grid-template-columns: 1fr;
  }

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

  .plan-row {
    grid-template-columns: 1fr;
  }

  .plan-time {
    min-height: 46px;
    place-items: start;
    padding: 10px;
    text-align: left;
  }
}

@media (max-width: 520px) {
  .nav {
    grid-template-columns: 1fr;
  }

  .toolbar-controls {
    display: grid;
    width: 100%;
  }

  .segmented {
    width: 100%;
  }

  .segmented button {
    flex: 1;
    justify-content: center;
  }

  .btn,
  .status-pill {
    width: 100%;
  }

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