:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --text: #182033;
  --muted: #657083;
  --line: #dfe5ee;
  --line-strong: #c8d1df;
  --accent: #1f6feb;
  --accent-dark: #174ea6;
  --accent-soft: #eaf2ff;
  --green: #0f766e;
  --red: #b42318;
  --amber: #a16207;
  --sidebar: #101624;
  --sidebar-active: #1c2738;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

.sidebar {
  min-height: 100vh;
  background: var(--sidebar);
  color: #f8fafc;
  padding: 24px 16px;
}

.brand {
  padding: 0 8px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 18px;
}

.brand-kicker {
  font-size: 12px;
  line-height: 1.4;
  color: #9ca3af;
  text-transform: uppercase;
}

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

h1 {
  margin-top: 5px;
  font-size: 22px;
  line-height: 1.32;
}

h2 {
  font-size: 22px;
  line-height: 1.35;
}

h3 {
  font-size: 16px;
  line-height: 1.45;
}

.brand p {
  margin: 8px 0 0;
  color: #cbd5e1;
  font-size: 13px;
}

.nav-list {
  display: grid;
  gap: 7px;
}

.nav {
  width: 100%;
  border: 0;
  border-radius: 7px;
  padding: 11px 12px;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
  cursor: pointer;
}

.nav.active,
.nav:hover {
  background: var(--sidebar-active);
  color: #fff;
}

.main {
  min-width: 0;
}

.topbar {
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 30px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.topbar p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.page {
  display: none;
  padding: 22px 30px 40px;
}

.page.active {
  display: block;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.metric .label {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 7px;
}

.metric .value {
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  font-weight: 750;
  word-break: break-word;
}

.metric .value.ok,
.ok {
  color: var(--green);
}

.metric .value.bad,
.bad {
  color: var(--red);
}

.metric .value.warn,
.warn {
  color: var(--amber);
}

.overview-grid,
.split {
  display: grid;
  grid-template-columns: minmax(360px, 520px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.wide-right {
  grid-template-columns: minmax(340px, 460px) minmax(0, 1fr);
}

.channel-layout {
  display: grid;
  grid-template-columns: minmax(520px, 1fr) minmax(340px, 460px);
  gap: 16px;
  align-items: start;
}

.channel-editor {
  min-width: 0;
}

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

button {
  border: 0;
  border-radius: 6px;
  padding: 9px 12px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  background: var(--accent-dark);
}

button.secondary {
  background: #eef2f7;
  color: #243044;
  border: 1px solid var(--line);
}

button.secondary:hover {
  background: #e2e8f0;
}

button.danger {
  background: #fff1f0;
  color: var(--red);
  border: 1px solid #ffd0cc;
}

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

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.12);
}

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

.form,
.runtime-grid,
.source-grid {
  display: grid;
  gap: 12px;
}

.form.two,
.runtime-grid {
  grid-template-columns: repeat(3, minmax(160px, 1fr));
}

.source-grid {
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  margin: 15px 0;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.inline-check {
  min-height: 40px;
  align-self: end;
}

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

.check input {
  width: auto;
  box-shadow: none;
}

.segmented {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.segmented button {
  background: var(--accent-soft);
  color: #1d4f91;
}

.segmented button.active {
  background: var(--accent);
  color: #fff;
}

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

.item,
.summary-item,
.article-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
  background: #fbfcff;
}

.item.selected,
.article-card.active {
  outline: 2px solid var(--accent);
  background: #f7fbff;
}

.item-title {
  color: var(--text);
  font-weight: 750;
  line-height: 1.45;
  margin-bottom: 5px;
}

.meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  word-break: break-word;
}

.button-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.button-row select {
  min-width: 230px;
}

.codex-runner {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: end;
}

.codex-runner button {
  grid-column: 1 / -1;
}

.article-workbench {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 14px;
}

.article-list {
  display: grid;
  gap: 10px;
  align-content: start;
  max-height: 780px;
  overflow: auto;
  padding-right: 4px;
}

.article-card {
  cursor: pointer;
}

.article-card .check {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 7px;
}

#previewFrame {
  width: 100%;
  min-height: 780px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.code {
  margin: 0;
  overflow: auto;
  background: #111827;
  color: #e5e7eb;
  border-radius: 7px;
  padding: 14px;
  line-height: 1.55;
  font-size: 13px;
  white-space: pre-wrap;
}

.code.tall {
  min-height: 680px;
}

.raw-panel {
  position: sticky;
  top: 18px;
}

@media (max-width: 1240px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

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

  .overview-grid,
  .split,
  .wide-right,
  .channel-layout,
  .article-workbench,
  .status-grid,
  .form.two,
  .runtime-grid,
  .source-grid {
    grid-template-columns: 1fr;
  }

  .raw-panel {
    position: static;
  }
}
