:root {
  color-scheme: light;
  --bg: #f3f3f1;
  --panel: #ffffff;
  --panel-2: #e9e9e6;
  --ink: #171717;
  --muted: #6f6f69;
  --line: #d7d7d2;
  --line-strong: #afafa8;
  --black: #111111;
  --blue: #2f5ff3;
  --green: #12805c;
  --amber: #a16207;
  --red: #b42318;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
}

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

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 56px;
  background: #1d2022;
  color: #f8f8f6;
  display: grid;
  grid-template-columns: 260px minmax(180px, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 8px 14px;
}

.brand,
.top-actions,
.manager-actions,
.button-row,
.tool-row,
.code-head,
.preview-top,
.section-title,
.sheet-head,
.flow-drawer,
.filter-row {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  min-width: 0;
}

.brand > div {
  min-width: 0;
}

.brand strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand span,
.muted,
.site-card small,
.saved-table small,
.source-grid span,
.section-label {
  color: var(--muted);
}

.topbar .brand span:not(.mark) {
  color: #c7c7c2;
  display: block;
  font-size: 12px;
  margin-top: 1px;
}

.mark,
.site-logo {
  width: 34px;
  height: 34px;
  border: 2px solid currentColor;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-family: Georgia, serif;
  font-weight: 700;
  flex: 0 0 auto;
}

.site-logo.dark {
  background: var(--black);
  color: #fff;
}

.pathbar {
  min-width: 0;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.pathbar input {
  width: 100%;
  border: 1px solid #3e4448;
  background: #30363b;
  color: #f8f8f6;
  border-radius: 7px;
  min-height: 34px;
  padding: 0 12px;
}

.top-actions {
  gap: 8px;
  justify-content: flex-end;
}

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 308px minmax(520px, 1fr) 300px;
  gap: 12px;
  padding: 12px;
}

.site-rail,
.manager,
.preview-rail,
.flow-drawer,
.gallery-sheet,
.save-modal form,
.export-popover {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.75) inset;
}

.site-rail,
.manager,
.preview-rail {
  min-height: calc(100vh - 80px);
  overflow: hidden;
}

.site-rail {
  border-radius: 10px;
  display: flex;
  flex-direction: column;
}

.rail-head,
.manager-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.rail-head h1,
.manager-header h2,
.sheet-head h2,
.flow-drawer h2,
.modal-head h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.rail-section {
  padding: 12px;
  display: grid;
  gap: 8px;
}

.rail-section.compact {
  border-top: 1px solid var(--line);
  margin-top: auto;
}

.section-label {
  margin: 0 0 2px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.site-card,
.rail-section.compact button,
.source-grid button,
.saved-table button,
.filter-row button,
.tree-item,
.tool-row button,
.button-row button,
.blueprint-grid article,
.ghost-button,
.small-button,
.primary-button,
.link-button,
.icon-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 7px;
}

.site-card {
  width: 100%;
  display: grid;
  grid-template-columns: 36px 1fr 10px;
  gap: 10px;
  text-align: left;
  padding: 12px;
  align-items: center;
}

.site-card.active {
  border-color: var(--black);
  background: #f8f8f6;
  box-shadow: 3px 0 0 var(--black) inset;
}

.site-card strong,
.site-card small,
.saved-table small {
  display: block;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.dot.amber {
  background: var(--amber);
}

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

.dot.blue {
  background: var(--blue);
}

.rail-section.compact button {
  text-align: left;
  padding: 10px 12px;
}

.manager {
  min-width: 0;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
}

.manager-header {
  padding-bottom: 16px;
}

.manager-header p {
  margin: 6px 0 0;
}

.manager-actions {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 14px 10px 12px;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  font-weight: 700;
}

.tab.active {
  color: var(--ink);
  border-color: var(--black);
}

.tab-panels {
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

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

.status-grid article,
.list-panel,
.database-card,
.log-grid article,
.notice {
  border: 1px solid var(--line);
  background: #fbfbfa;
  border-radius: 8px;
  padding: 16px;
}

.status-grid h3,
.list-panel h3,
.database-card h3 {
  margin: 10px 0 7px;
  font-size: 17px;
}

.status-grid p,
.database-card p {
  margin: 0 0 12px;
  color: #3f3f3a;
  line-height: 1.45;
}

.chip {
  display: inline-flex;
  align-items: center;
  width: max-content;
  max-width: 100%;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.1;
  border: 1px solid currentColor;
  font-style: normal;
}

.chip.warning {
  color: var(--amber);
  background: #fff7db;
}

.chip.success {
  color: var(--green);
  background: #e7f7ef;
}

.chip.info {
  color: var(--blue);
  background: #eef3ff;
}

.progress {
  height: 7px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--panel-2);
  margin: 12px 0 6px;
}

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

.split-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 12px;
}

.section-title {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-title h3 {
  margin: 0;
}

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

.source-grid button {
  min-height: 82px;
  text-align: left;
  padding: 12px;
}

.source-grid strong,
.source-grid span {
  display: block;
}

.source-grid span {
  margin-top: 6px;
  line-height: 1.3;
}

.saved-table {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.saved-table [role="row"] {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 120px 170px;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}

.saved-table [role="row"]:first-child {
  border-top: 0;
}

.table-head {
  background: #efefec;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.saved-table button {
  padding: 6px 8px;
  margin-right: 4px;
}

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

label {
  color: #3b3b36;
  font-weight: 700;
  display: grid;
  gap: 8px;
}

input,
select {
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  min-height: 40px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 500;
}

.check input {
  min-height: 0;
  width: 16px;
  height: 16px;
}

.notice {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 180px 1fr auto auto;
  gap: 12px;
  align-items: center;
}

.notice.destructive {
  border-left: 4px solid var(--red);
}

.editor-layout {
  min-height: 520px;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.file-tree {
  background: #f5f5f3;
  border-right: 1px solid var(--line);
  padding: 10px;
  overflow: auto;
}

.narrow-tree {
  max-width: 220px;
}

.tool-row {
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.tool-row button,
.ghost-button,
.small-button,
.primary-button,
.link-button,
.icon-button,
.button-row button,
.filter-row button {
  min-height: 34px;
  padding: 0 11px;
  font-weight: 700;
}

.tree-item {
  width: 100%;
  text-align: left;
  padding: 10px;
  margin-bottom: 4px;
}

.tree-item.active {
  border-color: var(--blue);
  box-shadow: 3px 0 0 var(--blue) inset;
}

.code-pane {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.code-head {
  min-height: 52px;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 8px 12px;
  color: var(--muted);
}

pre {
  margin: 0;
  padding: 16px;
  overflow: auto;
  flex: 1;
  color: #1e1e1c;
  background:
    linear-gradient(90deg, #eef2f6 42px, transparent 42px),
    repeating-linear-gradient(#fff, #fff 31px, #f7f7f5 32px);
  font: 13px/1.7 "SFMono-Regular", Consolas, monospace;
}

.blueprint-actions {
  justify-content: flex-end;
}

.database-card {
  max-width: 760px;
}

dl {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 8px 18px;
  margin: 18px 0;
}

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

dd {
  margin: 0;
}

.button-row {
  gap: 8px;
  flex-wrap: wrap;
}

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

.log-grid article {
  display: grid;
  gap: 10px;
}

.preview-rail {
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  background: #fefefe;
}

.preview-top {
  justify-content: space-between;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.browser-mini {
  margin: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  min-height: 560px;
  background: #fff;
}

.wp-adminbar {
  min-height: 34px;
  background: #202427;
  color: #f4f4f2;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 9px;
}

.site-nav {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  border-bottom: 1px solid #f0f0ed;
  font-size: 12px;
}

.hero-mini {
  padding: 72px 18px 20px;
}

.hero-mini h2 {
  font: 33px/1.15 Georgia, serif;
  margin: 0 0 20px;
}

.hero-mini h2 span {
  color: #3157f4;
}

.hero-mini p {
  font-size: 15px;
  line-height: 1.45;
}

.hero-mini mark {
  background: #fff2a6;
  display: inline;
}

.hero-mini button {
  width: 100%;
  margin-top: 24px;
  min-height: 48px;
  border: 0;
  color: #fff;
  background: #3855eb;
  border-radius: 3px;
  font-weight: 800;
}

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

.ghost-button,
.small-button,
.link-button {
  background: #fff;
}

.link-button {
  border: 0;
  color: var(--blue);
  padding: 0;
  min-height: auto;
}

.icon-button {
  width: 34px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  background: transparent;
  color: inherit;
  border-color: currentColor;
}

.flow-drawer {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(150%);
  z-index: 20;
  width: min(900px, calc(100vw - 24px));
  border-radius: 12px;
  padding: 16px;
  gap: 18px;
  justify-content: space-between;
  box-shadow: var(--shadow);
  transition: transform 180ms ease;
}

.flow-drawer.open {
  transform: translateX(-50%) translateY(0);
}

.flow-form {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.flow-form label {
  min-width: 260px;
}

.gallery-sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  transform: translateY(100%);
  transition: transform 190ms ease;
  overflow: auto;
  padding: 20px clamp(16px, 7vw, 88px) 48px;
  background: #202427;
  color: #f8f8f6;
  border: 0;
}

.gallery-sheet.open {
  transform: translateY(0);
}

.sheet-head {
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid #363b3f;
  padding-bottom: 16px;
}

.gallery-sheet .eyebrow,
.gallery-sheet .muted {
  color: #b9bbb7;
}

.filter-row {
  gap: 8px;
  flex-wrap: wrap;
  margin: 20px 0 12px;
}

.filter-row button {
  background: #30363a;
  color: #cfd2d4;
  border-color: #43494d;
  border-radius: 999px;
}

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

.search {
  max-width: 420px;
  color: #d7dadb;
  margin-bottom: 20px;
}

.search input {
  width: 100%;
  background: #30363a;
  border-color: #43494d;
  color: #fff;
}

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

.blueprint-grid article {
  overflow: hidden;
  background: #2c3135;
  color: #f8f8f6;
  border-color: #3f464b;
  padding-bottom: 14px;
}

.blueprint-grid img {
  display: block;
  width: 100%;
  height: 148px;
  object-fit: cover;
  filter: grayscale(1) contrast(1.05);
}

.blueprint-grid strong,
.blueprint-grid p,
.blueprint-grid span {
  margin-left: 14px;
  margin-right: 14px;
}

.blueprint-grid strong {
  display: block;
  margin-top: 13px;
}

.blueprint-grid p {
  color: #bfc3c5;
  line-height: 1.45;
  min-height: 42px;
}

.blueprint-grid span {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 9px;
  background: #42494e;
  color: #d5d7d9;
  font-size: 12px;
}

.save-modal {
  border: 0;
  padding: 0;
  background: transparent;
}

.save-modal::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.save-modal form {
  width: min(430px, calc(100vw - 28px));
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 9px;
}

fieldset label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

fieldset input {
  min-height: 0;
}

.export-popover {
  position: fixed;
  top: 126px;
  right: 328px;
  z-index: 25;
  border-radius: 8px;
  padding: 6px;
  box-shadow: var(--shadow);
}

.export-popover button {
  display: block;
  width: 180px;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 10px;
  border-radius: 6px;
}

.export-popover button:hover {
  background: #f0f0ed;
}

.mobile-nav {
  display: none;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 260px minmax(420px, 1fr);
  }

  .preview-rail {
    display: none;
  }

  .export-popover {
    right: 22px;
  }

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

@media (max-width: 820px) {
  body {
    padding-bottom: 68px;
  }

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

  .brand {
    justify-content: flex-start;
  }

  .top-actions {
    display: none;
  }

  .workspace {
    display: block;
    padding: 8px;
  }

  .site-rail,
  .manager {
    min-height: auto;
    border-radius: 9px;
  }

  .site-rail {
    margin-bottom: 8px;
  }

  .rail-head,
  .manager-header {
    padding: 14px;
  }

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

  .section-label {
    grid-column: 1 / -1;
  }

  .manager-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .manager-header {
    display: grid;
  }

  .manager-actions .ghost-button {
    flex: 1 1 96px;
  }

  .status-grid,
  .source-grid,
  .settings-grid,
  .log-grid,
  .blueprint-grid {
    grid-template-columns: 1fr;
  }

  .saved-table [role="row"] {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .table-head {
    display: none !important;
  }

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

  .editor-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .file-tree {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 220px;
  }

  pre {
    min-height: 360px;
  }

  dl {
    grid-template-columns: 1fr;
  }

  .flow-drawer {
    display: block;
    bottom: 76px;
  }

  .flow-form {
    display: grid;
    gap: 10px;
    margin-top: 12px;
  }

  .flow-form label {
    min-width: 0;
  }

  .gallery-sheet {
    padding: 14px 12px 84px;
  }

  .blueprint-grid img {
    height: 176px;
  }

  .mobile-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    min-height: 60px;
    background: #1d2022;
    border-top: 1px solid #3a3f43;
  }

  .mobile-nav button {
    border: 0;
    background: transparent;
    color: #c9cccd;
    font-size: 12px;
    font-weight: 800;
  }

  .mobile-nav button.active {
    color: #fff;
    box-shadow: 0 -3px 0 var(--blue) inset;
  }
}

@media (max-width: 480px) {
  .rail-section.compact {
    grid-template-columns: 1fr;
  }

  .tabs {
    padding: 0 8px;
  }

  .tab-panels {
    padding: 10px;
  }

  .manager-header {
    display: grid;
  }
}
