:root {
  --bg: #f6f7f8;
  --panel: #ffffff;
  --panel-2: #fbfcfd;
  --text: #1c2228;
  --muted: #68717c;
  --line: #d8dde3;
  --line-strong: #b8c0ca;
  --blue: #2457e6;
  --blue-dark: #163db5;
  --blue-soft: #edf2ff;
  --green: #16835a;
  --yellow: #a66800;
  --red: #b3261e;
  --ink: #11161b;
  --shadow: 0 18px 50px rgba(26, 35, 46, 0.08);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

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

button,
input,
select {
  font: inherit;
}

button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: var(--line-strong);
  background: var(--panel-2);
}

button.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

button.primary:hover {
  border-color: var(--blue-dark);
  background: var(--blue-dark);
}

button.danger {
  border-color: #f1cbc8;
  color: var(--red);
}

input,
select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  min-height: 58px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
}

.brand-mark {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.main-nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.main-nav button {
  flex: 0 0 auto;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  padding: 0 11px;
}

.main-nav button.active {
  border-color: var(--line);
  background: var(--blue-soft);
  color: var(--blue-dark);
}

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

.state-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  color: var(--muted);
  white-space: nowrap;
}

.state-pill.warning {
  border-color: #f1d38c;
  background: #fff9e8;
  color: var(--yellow);
}

.icon-button {
  width: 36px;
  padding: 0;
}

.workspace {
  padding: 16px;
}

.command-row {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 1480px;
  margin: 0 auto 12px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.path-control {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr);
  align-items: center;
  gap: 8px;
  flex: 1 1 440px;
}

.path-control span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.divider {
  width: 1px;
  height: 28px;
  background: var(--line);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(420px, 1fr) minmax(340px, 420px);
  gap: 12px;
  max-width: 1480px;
  margin: 0 auto;
  align-items: start;
}

.runbook,
.main-stage,
.context-drawer {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.runbook {
  padding: 16px;
}

.section-heading p,
.stage-header p,
.drawer-heading p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.section-heading h1,
.stage-header h2,
.drawer-heading h2 {
  margin: 0;
  line-height: 1.16;
}

.section-heading h1 {
  font-size: 20px;
}

.stage-header h2,
.drawer-heading h2 {
  font-size: 18px;
}

.checklist {
  display: grid;
  gap: 8px;
  margin: 18px 0;
  padding: 0;
  list-style: none;
}

.checklist button {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  grid-template-areas:
    "num title"
    "num desc";
  width: 100%;
  min-height: 72px;
  gap: 2px 10px;
  align-items: center;
  padding: 10px;
  text-align: left;
}

.checklist .check {
  grid-area: num;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
}

.checklist strong {
  grid-area: title;
}

.checklist small {
  grid-area: desc;
  color: var(--muted);
  line-height: 1.35;
}

.checklist li.done .check {
  border-color: #b7e1d2;
  background: #eaf8f2;
  color: var(--green);
}

.checklist li.active button {
  border-color: #9db4ff;
  background: var(--blue-soft);
}

.compact-note,
.info-card {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--blue);
  border-radius: 6px;
  background: #fbfcff;
}

.compact-note span,
.info-card span {
  color: var(--muted);
  line-height: 1.4;
}

.main-stage {
  min-width: 0;
  overflow: hidden;
}

.stage-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

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

.site-table {
  padding: 8px;
}

.table-row {
  display: grid;
  grid-template-columns: minmax(190px, 1.25fr) minmax(130px, 0.8fr) minmax(120px, 0.65fr) minmax(160px, auto);
  gap: 12px;
  align-items: center;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
  padding: 8px;
}

.table-row:last-child {
  border-bottom: 0;
}

.table-head {
  min-height: 36px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.table-row.selected {
  border: 1px solid #b6c4f8;
  border-radius: 6px;
  background: #f4f7ff;
}

.table-row strong,
.table-row small {
  display: block;
}

.table-row small {
  color: var(--muted);
  margin-top: 3px;
}

.table-row mark,
.preview-copy mark {
  border-radius: 3px;
  background: #fff1a8;
  color: inherit;
  padding: 1px 4px;
}

.table-row span:last-child {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preview-card {
  margin: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.preview-chrome {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-weight: 700;
}

.preview-chrome nav {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  color: #444b54;
  font-weight: 500;
}

.wp-preview {
  display: grid;
  grid-template-columns: minmax(240px, 0.85fr) minmax(180px, 1fr);
  gap: 22px;
  align-items: center;
  min-height: 360px;
  padding: 36px 24px;
  overflow: hidden;
}

.preview-copy {
  max-width: 420px;
}

.preview-copy h3 {
  margin: 0 0 14px;
  color: #111;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 40px;
  font-weight: 400;
  line-height: 1.22;
}

.preview-copy h3 span {
  color: #3858e9;
}

.preview-copy p {
  color: #111;
  font-size: 17px;
  line-height: 1.45;
}

.preview-copy button {
  width: 100%;
  margin-top: 10px;
  border-color: #3858e9;
  background: #3858e9;
  color: #fff;
}

.preview-emblem {
  display: grid;
  justify-self: center;
  width: min(330px, 38vw);
  aspect-ratio: 1;
  place-items: center;
  border: 24px solid #24d977;
  border-radius: 50%;
  color: #151515;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(86px, 13vw, 176px);
  font-weight: 800;
}

.context-drawer {
  position: sticky;
  top: 74px;
  max-height: calc(100vh - 92px);
  overflow: auto;
}

.drawer-panel {
  display: none;
  padding: 16px;
}

.drawer-panel.active {
  display: block;
}

.body-copy {
  color: var(--muted);
  line-height: 1.55;
}

.progress-card {
  display: grid;
  gap: 10px;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
}

.progress-card strong,
.progress-card span {
  display: block;
}

.progress-card span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.meter {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe5eb;
}

.meter span {
  display: block;
  height: 100%;
  background: var(--blue);
}

.button-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.source-list,
.saved-list,
.transfer-stack,
.log-stack {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.source-list button {
  display: grid;
  gap: 3px;
  width: 100%;
  height: auto;
  min-height: 58px;
  padding: 10px;
  text-align: left;
}

.source-list span,
.transfer-stack span,
.saved-list small {
  color: var(--muted);
  line-height: 1.35;
}

.stack-form {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.stack-form label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.stack-form .check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  text-transform: none;
}

.check-row input {
  width: auto;
  min-height: auto;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef1f5;
}

.segmented button {
  border-color: transparent;
  background: transparent;
}

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

.saved-list article {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
}

.status-dot.warning {
  background: #d88b00;
}

.status-dot.success {
  background: var(--green);
}

.tabs,
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 14px 0;
}

.tabs button,
.filter-row button {
  min-height: 30px;
  padding: 0 10px;
}

.tabs button.active,
.filter-row button.active {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.manager-panel {
  display: none;
}

.manager-panel.active {
  display: block;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.file-editor {
  display: grid;
  grid-template-columns: 38% 1fr;
  min-height: 240px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.file-editor ul {
  margin: 0;
  padding: 8px;
  border-right: 1px solid var(--line);
  background: #f3f5f7;
  list-style: none;
}

.file-editor li {
  padding: 7px 6px;
  border-radius: 4px;
  color: #343b44;
  font-size: 12px;
}

.file-editor li.active {
  background: #fff;
  color: var(--blue-dark);
  font-weight: 800;
}

pre {
  margin: 0;
  overflow: auto;
  color: #8f2e00;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.6;
}

.file-editor pre {
  padding: 10px;
}

.code-card {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.meta-list {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 8px 12px;
  margin: 14px 0;
}

.meta-list dt {
  color: var(--muted);
  font-weight: 800;
}

.meta-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.log-stack article,
.transfer-stack article {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
}

.log-stack span {
  color: var(--green);
}

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

.blueprint-grid article {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

.blueprint-grid strong,
.blueprint-grid small {
  display: block;
  padding: 0 10px;
}

.blueprint-grid strong {
  margin-top: 9px;
}

.blueprint-grid small {
  margin: 4px 0 10px;
  color: var(--muted);
}

.thumb {
  display: block;
  height: 76px;
  border-bottom: 1px solid var(--line);
}

.thumb.art {
  background: linear-gradient(90deg, #456a60 0 34%, #d2a24d 34% 67%, #704641 67%);
}

.thumb.coffee {
  background: linear-gradient(120deg, #51236f, #f2a64a 58%, #58331d);
}

.thumb.feed {
  background: linear-gradient(180deg, #ffffff, #e9efff);
}

.thumb.game {
  background: linear-gradient(135deg, #050505 0 40%, #f05a28 40% 67%, #f5f5f5 67%);
}

.thumb.nonprofit {
  background: linear-gradient(120deg, #4a2314, #d18d55 48%, #121212);
}

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

  .brand {
    min-width: 0;
  }

  .top-actions {
    justify-content: space-between;
  }

  .content-grid {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .context-drawer {
    grid-column: 1 / -1;
    position: static;
    max-height: none;
  }
}

@media (max-width: 820px) {
  .workspace {
    padding: 10px;
  }

  .command-row,
  .stage-header,
  .preview-chrome {
    align-items: stretch;
    flex-direction: column;
  }

  .command-row {
    display: grid;
    grid-template-columns: auto 1fr;
  }

  .command-row .divider {
    display: none;
  }

  .path-control {
    grid-column: 1 / -1;
    grid-template-columns: 1fr;
  }

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

  .table-head {
    display: none;
  }

  .table-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .wp-preview {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .preview-copy h3 {
    font-size: 32px;
  }

  .preview-emblem {
    width: min(240px, 70vw);
  }

  .file-editor,
  .blueprint-grid {
    grid-template-columns: 1fr;
  }

  .file-editor ul {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .meta-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .topbar {
    padding: 10px;
  }

  .main-nav,
  .top-actions,
  .stage-actions,
  .button-grid {
    width: 100%;
  }

  .top-actions button,
  .stage-actions button,
  .button-grid button {
    flex: 1 1 auto;
  }

  .state-pill {
    flex: 1 1 100%;
    justify-content: center;
  }
}
