:root {
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --ink: #17202a;
  --muted: #68727f;
  --line: #d7dee8;
  --blue: #285ce8;
  --blue-2: #113a99;
  --green: #0a7f58;
  --yellow: #936800;
  --red: #c1372b;
  --red-bg: #fff0ef;
  --shadow: 0 18px 45px rgba(20, 32, 46, 0.13);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

.app {
  min-height: 100vh;
}

.shell {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(220px, 310px) minmax(280px, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  background: #182028;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

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

.mark {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 2px solid #111;
  border-radius: 50%;
  background: #fff;
  color: #111;
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong,
.brand span:not(.mark) {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand strong {
  font-size: 14px;
}

.brand span:not(.mark) {
  max-width: 230px;
  color: #aeb7c2;
  font-size: 12px;
}

.pathbar {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) auto auto;
  gap: 8px;
  min-width: 0;
}

.pathbar input,
.search,
label input,
label select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
}

.pathbar input {
  border-color: #3b4653;
  background: #2d3742;
  color: #e9edf3;
}

.shell-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.icon-button,
.ghost,
.primary,
.danger,
.danger-ghost {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 11px;
  background: #fff;
  color: var(--ink);
  font-weight: 650;
  white-space: nowrap;
}

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

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

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

.danger-ghost {
  border-color: #e6bab5;
  background: var(--red-bg);
  color: var(--red);
}

.shell .ghost,
.shell .icon-button {
  border-color: #4a5562;
  background: #26303a;
  color: #f3f5f8;
}

.shell .danger-ghost {
  border-color: #69413d;
  background: #302226;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(520px, 45vw) minmax(0, 1fr);
  gap: 12px;
  height: calc(100vh - 59px);
  padding: 12px;
}

.console,
.preview {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.console {
  display: flex;
  flex-direction: column;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.tab {
  min-width: 0;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  padding: 13px 8px;
  color: var(--muted);
  font-weight: 750;
}

.tab.is-active {
  background: #fff;
  color: var(--blue);
  box-shadow: inset 0 -3px 0 var(--blue);
}

.panel-section {
  display: none;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.panel-section.is-active {
  display: block;
}

.section-head,
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head h1,
.card h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.card h2 {
  font-size: 16px;
}

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

.eyebrow.danger {
  color: var(--red);
}

.counter,
.state-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 9px;
  background: #e8edf5;
  color: #334154;
  font-size: 12px;
  font-weight: 800;
}

.state-badge.temporary {
  background: #fff2cb;
  color: var(--yellow);
}

.state-badge.saved {
  background: #dff7ed;
  color: var(--green);
}

.state-badge.local {
  background: #e6f0ff;
  color: var(--blue-2);
}

.state-badge.running {
  background: #e7efff;
  color: var(--blue);
}

.contract-layout {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.route-list {
  display: grid;
  gap: 8px;
}

.route {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 11px;
  text-align: left;
}

.route strong,
.route span {
  display: block;
}

.route strong {
  font-size: 13px;
}

.route span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.route.is-active {
  border-color: var(--blue);
  background: #f3f7ff;
  box-shadow: inset 3px 0 0 var(--blue);
}

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

.contract-card label,
.save-drawer label,
.settings-grid label,
.blueprint-card label {
  display: grid;
  gap: 6px;
  color: #3d4754;
  font-size: 13px;
  font-weight: 700;
}

.contract-card p,
.transfer-grid p {
  color: var(--muted);
  line-height: 1.45;
}

.contract-actions,
.tools-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.wrap {
  flex-wrap: wrap;
}

.progress-shell {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.progress {
  height: 7px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4e9f1;
}

.progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
  transition: width 0.35s ease;
}

.danger-progress span {
  background: var(--red);
}

.hidden {
  display: none !important;
}

.receipt-grid,
.transfer-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.78fr) minmax(0, 1.22fr);
  gap: 12px;
  margin-top: 12px;
}

dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

dl div {
  display: grid;
  gap: 3px;
}

dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 10px;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f4f7fb;
  padding: 7px 10px;
  color: #465363;
  font-weight: 750;
}

.chip.is-active {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

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

.blueprint-item {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafc;
  padding: 10px;
  text-align: left;
}

.blueprint-item.is-active {
  border-color: var(--blue);
  background: #eff5ff;
}

.blueprint-item strong,
.blueprint-item span {
  display: block;
}

.blueprint-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.blueprint-detail {
  margin-top: 10px;
  border-left: 3px solid var(--blue);
  background: #f6f8fc;
  padding: 10px;
  color: #455161;
  font-size: 13px;
  line-height: 1.42;
}

.save-drawer {
  margin-bottom: 12px;
  border: 1px solid #cbd7ea;
  border-radius: 8px;
  background: #f8fbff;
  padding: 14px;
}

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

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

.destination input {
  width: auto;
}

.destination strong,
.destination span {
  display: block;
}

.destination span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.destination.is-selected {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
}

.form-grid {
  margin-top: 10px;
}

.saved-list {
  display: grid;
  gap: 9px;
}

.saved-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.saved-row.is-active {
  border-color: var(--blue);
  background: #f4f7ff;
}

.saved-row h3 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.saved-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.row-actions button {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 12px;
}

.confirm-panel {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  border-color: #e3a5a0;
  background: var(--red-bg);
}

.manager-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: flex-end;
}

.manager-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.mini-tab {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 8px 11px;
  color: var(--muted);
  font-weight: 800;
}

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

.manager-panel {
  display: none;
}

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

.settings-grid {
  align-items: start;
}

.check {
  display: flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
}

.check input {
  width: auto;
}

.warning-box {
  grid-column: 1 / -1;
  border-left: 4px solid #e7b10a;
  background: #fff9e7;
  padding: 11px;
}

.warning-box strong,
.warning-box span {
  display: block;
}

.warning-box span {
  margin-top: 4px;
  color: #6d5b18;
  font-size: 13px;
}

.split-card {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(0, 1.2fr);
  gap: 12px;
}

.file-list {
  display: grid;
  align-content: start;
  gap: 8px;
}

.file-row {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7f9fc;
  padding: 9px;
  text-align: left;
  overflow-wrap: anywhere;
}

.file-row.is-active {
  border-color: var(--blue);
  background: #eff5ff;
}

.editor {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.editor-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: #f7f9fc;
  padding: 10px;
  color: #465363;
  font-size: 13px;
}

textarea {
  display: block;
  width: 100%;
  min-height: 220px;
  border: 0;
  resize: vertical;
  padding: 12px;
  color: #8d2e16;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.45;
}

.data-card {
  display: grid;
  gap: 14px;
}

.db-facts {
  display: grid;
  gap: 10px;
}

.db-facts div {
  display: grid;
  grid-template-columns: minmax(120px, 0.42fr) minmax(0, 1fr);
  gap: 10px;
}

.db-facts span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.db-facts strong {
  overflow-wrap: anywhere;
}

.logs {
  display: grid;
  gap: 8px;
}

.log-row {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
}

.log-row span {
  color: var(--muted);
  font-weight: 800;
}

code {
  overflow-wrap: anywhere;
  color: #334154;
}

.log-row.warning {
  border-color: #f0ce79;
  background: #fffaf0;
}

.history-card {
  margin-top: 12px;
}

.history {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
}

.history li {
  color: #435063;
  line-height: 1.35;
}

.preview {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  background: #fff;
}

.preview-chrome {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  background: #182028;
  color: #fff;
}

.preview-chrome .icon-button {
  border-color: #4a5562;
  background: #26303a;
  color: #fff;
}

#previewPath {
  overflow: hidden;
  border-radius: 6px;
  background: #303a45;
  padding: 8px 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#previewStatus {
  color: #ffe17a;
  font-size: 12px;
  font-weight: 800;
}

.wpbar {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  overflow: hidden;
  padding: 7px 10px;
  background: #22282f;
  color: #d9dee5;
  font-size: 13px;
}

.wpbar span:first-child {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid #d9dee5;
  border-radius: 50%;
}

.wpbar button {
  border: 0;
  background: transparent;
  color: inherit;
}

.spacer {
  flex: 1;
}

.site-preview {
  min-height: 0;
  overflow: auto;
  background: #fff;
}

.site-preview nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 25px 34px;
}

.site-preview nav div {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  color: #3c4652;
}

.hero-preview {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(240px, 1.2fr);
  gap: 24px;
  align-items: center;
  min-height: 560px;
  padding: 30px 34px 58px;
}

.hero-preview h2 {
  margin: 0 0 18px;
  color: #1d44db;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(38px, 4.6vw, 64px);
  line-height: 1.12;
  letter-spacing: 0;
}

.hero-preview p:not(.eyebrow) {
  max-width: 430px;
  color: #111;
  font-size: 18px;
  line-height: 1.5;
}

.hero-preview button {
  border: 0;
  border-radius: 4px;
  background: #3858e9;
  color: #fff;
  padding: 13px 18px;
  font-weight: 800;
}

.wp-orbit {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 420px;
}

.wp-orbit::before,
.wp-orbit::after {
  content: "";
  position: absolute;
  width: min(520px, 44vw);
  aspect-ratio: 1.3 / 1;
  border: clamp(26px, 4vw, 54px) solid #31e875;
  border-radius: 50%;
  transform: rotate(0deg);
}

.wp-orbit::after {
  width: min(430px, 36vw);
  border-top-color: transparent;
  border-left-color: transparent;
  border-right-color: transparent;
  transform: rotate(180deg) translateY(-72px);
}

.wp-orbit span {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: clamp(170px, 24vw, 300px);
  height: clamp(170px, 24vw, 300px);
  border: clamp(12px, 1.4vw, 20px) solid #1f1f1f;
  border-radius: 50%;
  color: #1f1f1f;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(110px, 17vw, 220px);
  font-weight: 800;
}

.bottom-nav {
  display: none;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: minmax(470px, 48vw) minmax(0, 1fr);
  }

  .receipt-grid,
  .transfer-grid,
  .contract-layout {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 860px) {
  body {
    padding-bottom: 64px;
  }

  .shell {
    position: static;
    grid-template-columns: 1fr;
  }

  .pathbar {
    grid-template-columns: auto minmax(0, 1fr) auto auto;
  }

  .shell-actions {
    justify-content: stretch;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .workspace {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 0;
    padding: 8px;
  }

  .console,
  .preview {
    overflow: visible;
    box-shadow: none;
  }

  .console {
    order: 2;
  }

  .preview {
    order: 1;
  }

  .tabs {
    display: none;
  }

  .panel-section {
    overflow: visible;
    padding: 14px;
  }

  .preview-chrome {
    grid-template-columns: auto minmax(0, 1fr);
  }

  #previewStatus {
    grid-column: 1 / -1;
  }

  .wpbar {
    flex-wrap: wrap;
  }

  .site-preview nav,
  .hero-preview {
    padding-left: 18px;
    padding-right: 18px;
  }

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

  .wp-orbit {
    min-height: 250px;
    overflow: hidden;
  }

  .wp-orbit::before {
    width: 330px;
  }

  .wp-orbit::after {
    width: 270px;
  }

  .bottom-nav {
    position: fixed;
    right: 8px;
    bottom: 8px;
    left: 8px;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    padding: 6px;
    box-shadow: var(--shadow);
  }

  .bottom-nav button {
    min-width: 0;
    border: 0;
    border-radius: 7px;
    background: transparent;
    padding: 10px 4px;
    color: var(--muted);
    font-weight: 800;
  }

  .bottom-nav button.is-active {
    background: var(--blue);
    color: #fff;
  }
}

@media (max-width: 640px) {
  .brand span:not(.mark) {
    max-width: 100%;
    white-space: normal;
  }

  .pathbar {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .pathbar .ghost {
    min-width: 0;
  }

  .pathbar .ghost:nth-of-type(2),
  .pathbar .ghost:nth-of-type(3) {
    grid-row: 2;
  }

  .route-list,
  .destination-grid,
  .form-grid,
  .settings-grid,
  .split-card,
  .blueprint-grid,
  .db-facts div,
  .log-row {
    grid-template-columns: 1fr;
  }

  .section-head,
  .card-head,
  .saved-row {
    grid-template-columns: 1fr;
    display: grid;
  }

  .row-actions,
  .contract-actions,
  .tools-row,
  .manager-shortcuts {
    justify-content: stretch;
  }

  .row-actions button,
  .contract-actions button,
  .tools-row button,
  .manager-shortcuts button {
    flex: 1 1 auto;
    white-space: normal;
  }

  .site-preview nav {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero-preview h2 {
    font-size: 38px;
  }
}
