:root {
  color-scheme: light;
  --ink: #111111;
  --muted: #4f5357;
  --line: #aeb4bb;
  --line-soft: #d9dde1;
  --chrome: #eef1f4;
  --chrome-2: #d7e2eb;
  --dock: #f7f8f9;
  --canvas: #ffffff;
  --tool-blue: #2d66dd;
  --tool-blue-dark: #1d4fb6;
  --accent: #1468a8;
  --ok: #006c3b;
  --warn: #b02b22;
  --white: #ffffff;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  background: var(--chrome);
  color: var(--ink);
  margin: 0;
  min-width: 320px;
  overflow: hidden;
}

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

button {
  background: linear-gradient(#ffffff, #e5e9ed);
  border: 1px solid #9ba5af;
  border-radius: 2px;
  color: var(--ink);
  cursor: pointer;
  min-height: 24px;
  padding: 2px 8px;
}

button:hover {
  border-color: #4a7bbb;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

h1 {
  font-size: 1.05rem;
  font-weight: 400;
  line-height: 1.1;
}

h2,
h3 {
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.2;
}

p,
.muted {
  color: var(--muted);
  line-height: 1.35;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0;
  margin-bottom: 2px;
  text-transform: none;
}

.studio-window {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) 25px;
  height: 100svh;
  min-width: 0;
}

.app-bar {
  background: var(--chrome);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-rows: 31px 26px 36px;
  min-width: 0;
}

.title-strip {
  align-items: center;
  background: #f7f7f7;
  display: flex;
  justify-content: space-between;
  min-width: 0;
  padding: 5px 9px 4px 2px;
}

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

.brand-icon {
  height: 20px;
  image-rendering: auto;
  width: 20px;
}

.brand h1 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.window-controls {
  display: flex;
  gap: 20px;
  padding-right: 6px;
}

.window-controls span {
  border: 1px solid transparent;
  display: block;
  height: 12px;
  position: relative;
  width: 12px;
}

.window-controls span:nth-child(1)::before {
  background: #8290a0;
  content: "";
  height: 1px;
  left: 2px;
  position: absolute;
  top: 8px;
  width: 8px;
}

.window-controls span:nth-child(2) {
  border-color: #52616f;
}

.window-controls span:nth-child(3)::before,
.window-controls span:nth-child(3)::after {
  background: #222222;
  content: "";
  height: 1px;
  left: 1px;
  position: absolute;
  top: 6px;
  width: 12px;
}

.window-controls span:nth-child(3)::before {
  transform: rotate(45deg);
}

.window-controls span:nth-child(3)::after {
  transform: rotate(-45deg);
}

.menu-strip {
  align-items: center;
  display: flex;
  gap: 2px;
  min-width: 0;
  overflow-x: auto;
  padding: 0 4px;
}

.menu-button {
  background: transparent;
  border-color: transparent;
  border-radius: 0;
  min-height: 22px;
  padding: 2px 9px;
}

.menu-button:hover {
  background: #dce9f8;
  border-color: #93b9e8;
}

.command-strip {
  align-items: center;
  background: #f6f6f6;
  border-top: 1px solid #e4e4e4;
  display: flex;
  gap: 12px;
  min-width: 0;
  overflow-x: auto;
  padding: 3px 8px 4px 22px;
}

.icon-bank,
.trace-bank,
.tool-actions,
.button-row {
  align-items: center;
  display: flex;
  gap: 5px;
}

.icon-bank {
  border-right: 1px solid var(--line-soft);
  padding-right: 10px;
}

.icon-button {
  min-width: 28px;
  padding: 2px 5px;
}

.trace-button {
  min-width: 128px;
}

.trace-bank select {
  min-width: 118px;
}

.trace-light {
  background: #b8b8b8;
  border: 1px solid #d1d1d1;
  border-radius: 50%;
  display: block;
  height: 14px;
  width: 14px;
}

.secondary {
  background: linear-gradient(#ffffff, #edf0f3);
}

.studio-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 466px;
  grid-template-rows: minmax(0, 1fr) 214px;
  min-height: 0;
  min-width: 0;
}

.workbench {
  background: var(--canvas);
  border-right: 1px solid #8b9299;
  display: grid;
  grid-template-rows: 27px minmax(0, 1fr);
  min-height: 0;
  min-width: 0;
}

.document-tabs {
  align-items: end;
  background: #f4f4f4;
  border-bottom: 1px solid var(--line);
  display: flex;
  min-width: 0;
  padding: 0 0 0 1px;
}

.document-tab {
  align-items: center;
  background: #ffffff;
  border: 1px solid #b5b5b5;
  border-bottom-color: #ffffff;
  border-radius: 0;
  display: inline-flex;
  gap: 4px;
  height: 25px;
  margin-bottom: -1px;
  max-width: 240px;
  min-width: 76px;
  overflow: hidden;
  padding: 3px 10px 3px 6px;
  text-align: left;
}

.document-tab span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-dot {
  border: 1px solid #cf1d42;
  border-radius: 50%;
  height: 9px;
  width: 9px;
}

.canvas-stage {
  min-height: 0;
  min-width: 0;
}

.canvas-scroll {
  height: 100%;
  min-width: 0;
  overflow: auto;
}

.script-canvas {
  background: var(--canvas);
  min-height: 100%;
  min-width: 100%;
  position: relative;
}

.canvas-map {
  min-height: 100%;
  min-width: 100%;
  position: relative;
}

.branch-lines {
  inset: 0;
  overflow: visible;
  position: absolute;
}

.branch-lines path {
  fill: none;
  stroke: rgba(45, 102, 221, 0.64);
  stroke-linecap: round;
  stroke-width: 2;
}

.branch-lines text {
  fill: #555555;
  font-size: 11px;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: 5px;
}

.action-node {
  align-content: center;
  background: #fbfbfb;
  border: 1px solid #9aa5b0;
  border-left: 5px solid var(--node-accent, var(--accent));
  border-radius: 3px;
  color: var(--ink);
  display: grid;
  gap: 4px;
  height: 64px;
  justify-items: start;
  padding: 7px 10px;
  position: absolute;
  text-align: left;
  width: 168px;
  z-index: 2;
}

.action-node:hover,
.action-node.selected {
  background: #ffffff;
  border-color: #2d66dd;
}

.action-node span {
  font-size: 0.88rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

.action-node small {
  color: var(--muted);
  font-size: 0.74rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

.empty-state {
  align-items: center;
  display: grid;
  gap: 9px;
  grid-template-columns: 42px minmax(0, 220px);
  left: 72px;
  position: absolute;
  top: 30px;
}

.empty-state img {
  height: 38px;
  object-fit: cover;
  width: 38px;
}

.empty-state h3 {
  color: #1d1d1d;
}

.empty-state p {
  font-size: 0.78rem;
}

.inspector {
  background: #f3f3f3;
  display: grid;
  grid-row: 1;
  grid-template-rows: minmax(280px, 1fr) auto auto;
  min-height: 0;
  min-width: 0;
}

.pane {
  border-bottom: 1px solid var(--line);
  min-width: 0;
}

.dock-title {
  align-items: center;
  background: var(--chrome-2);
  border-bottom: 1px solid var(--line);
  display: flex;
  height: 29px;
  justify-content: space-between;
  padding: 5px 9px;
}

.dock-title span {
  color: #1f2730;
  font-size: 0.72rem;
}

.tools-pane {
  display: grid;
  grid-template-rows: 29px 30px minmax(0, 1fr);
  min-height: 0;
}

.tool-filter {
  align-items: center;
  background: #f7f7f7;
  border-bottom: 1px solid #d4d4d4;
  display: grid;
  gap: 6px;
  grid-template-columns: 24px 24px minmax(0, 1fr);
  padding: 3px 7px;
}

.tool-filter label {
  align-items: center;
  display: grid;
  gap: 7px;
  grid-template-columns: auto minmax(0, 1fr);
}

.tiny-tool {
  min-height: 20px;
  padding: 0;
}

.tool-palette {
  align-content: start;
  display: grid;
  gap: 1px;
  overflow: auto;
  padding: 0 0 18px;
}

.tool-group {
  display: grid;
  gap: 1px;
}

.tool-group-heading {
  align-items: center;
  background: var(--tool-blue);
  border-bottom: 1px solid var(--tool-blue-dark);
  color: #ffffff;
  display: flex;
  font-weight: 700;
  height: 21px;
  justify-content: space-between;
  padding: 1px 10px;
}

.tool-group-heading strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-chip {
  background: #ffffff;
  border: 0;
  border-bottom: 1px solid #d6d6d6;
  border-left: 4px solid var(--tool-accent, var(--tool-blue));
  border-radius: 0;
  display: grid;
  gap: 1px;
  min-height: 45px;
  padding: 4px 8px;
  text-align: left;
  width: 100%;
}

.tool-chip:hover,
.tool-chip.selected {
  background: #eaf2ff;
}

.tool-chip span,
.tool-chip small,
.tool-chip em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

.tool-chip span {
  font-weight: 700;
}

.tool-chip small,
.tool-chip em {
  color: #555555;
  font-size: 0.72rem;
  font-style: normal;
}

.inspector-pane {
  background: #fafafa;
  max-height: 320px;
  overflow: auto;
}

.dock-tabs,
.output-tabs {
  align-items: center;
  background: #f7f7f7;
  border-top: 1px solid var(--line-soft);
  display: flex;
  gap: 2px;
  min-width: 0;
  overflow-x: auto;
  padding: 0 3px;
}

.dock-tabs button,
.output-tabs button {
  background: transparent;
  border: 0;
  border-radius: 0;
  min-height: 23px;
  padding: 2px 6px;
  white-space: nowrap;
}

.dock-tabs button.active,
.output-tabs button.active {
  background: #ffffff;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  color: #000000;
  font-weight: 700;
}

.pane-heading {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 9px;
}

.pane-heading.compact {
  padding-bottom: 5px;
}

.property-grid {
  display: grid;
  gap: 10px;
  padding: 0 9px 10px;
}

.property-section {
  border-top: 1px solid var(--line-soft);
  display: grid;
  gap: 8px;
  padding-top: 8px;
}

.property-section:first-child {
  border-top: 0;
  padding-top: 0;
}

.property-grid dl {
  display: grid;
  gap: 5px 8px;
  grid-template-columns: 100px minmax(0, 1fr);
  margin: 0;
}

.property-grid dt {
  color: var(--muted);
  font-size: 0.78rem;
}

.property-grid dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

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

.section-heading span {
  color: var(--muted);
  font-size: 0.74rem;
}

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

.branch-list ul {
  display: grid;
  gap: 5px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.branch-list li,
.component-list li,
.legacy-item {
  border: 1px solid var(--line-soft);
  border-radius: 2px;
  display: grid;
  gap: 4px;
  padding: 6px;
}

.verb-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.verb-button {
  min-height: 23px;
}

.page-designer-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1fr);
}

.page-designer small,
.page-designer-grid small {
  color: var(--muted);
  display: block;
  font-size: 0.74rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.page-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.page-flags span {
  border: 1px solid var(--line-soft);
  border-radius: 2px;
  color: var(--muted);
  font-size: 0.74rem;
  padding: 3px 5px;
}

.component-group {
  border-bottom: 1px solid var(--line-soft);
  display: grid;
  gap: 3px;
  padding: 6px 0;
}

.component-group:first-of-type {
  padding-top: 0;
}

.component-group span,
.component-list span,
.legacy-item span {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.component-list {
  display: grid;
  gap: 5px;
  list-style-position: inside;
  margin: 0;
  padding: 0;
}

.proxy-pane {
  background: #fafafa;
  padding: 7px 9px;
}

.proxy-pane details {
  display: grid;
  gap: 8px;
}

.bottom-dock {
  background: #ffffff;
  border-top: 1px solid var(--line);
  display: grid;
  grid-column: 1 / -1;
  grid-row: 2;
  grid-template-rows: 29px 34px minmax(58px, 1fr) 26px minmax(0, 96px) auto;
  min-height: 0;
  min-width: 0;
}

.search-form {
  align-items: center;
  background: #f8f8f8;
  border-bottom: 1px solid var(--line-soft);
  display: grid;
  gap: 7px;
  grid-template-columns: minmax(180px, 1.1fr) minmax(150px, 0.7fr) minmax(150px, 0.7fr) minmax(115px, 0.5fr) minmax(90px, 0.4fr) 70px auto;
  min-width: 0;
  padding: 4px 9px;
}

label {
  color: #151515;
  font-size: 0.82rem;
}

.search-form label {
  align-items: center;
  display: grid;
  gap: 6px;
  grid-template-columns: auto minmax(0, 1fr);
  min-width: 0;
}

.limit-field {
  grid-template-columns: auto 44px;
}

input,
select,
textarea {
  background: #ffffff;
  border: 1px solid #9da8b2;
  border-radius: 1px;
  color: var(--ink);
  min-width: 0;
  padding: 2px 5px;
  width: 100%;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: #2d66dd;
  outline: 1px solid #8fb6f3;
}

.script-table {
  display: grid;
  grid-template-rows: 24px minmax(0, 1fr);
  min-height: 0;
}

.script-table-head,
.script-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.15fr) 126px 120px 90px minmax(140px, 1fr) 100px 86px;
}

.script-table-head {
  background: #ffffff;
  border-bottom: 1px solid var(--line-soft);
}

.script-table-head span {
  border-right: 1px solid #eeeeee;
  font-size: 0.8rem;
  overflow: hidden;
  padding: 4px 6px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.script-list {
  display: grid;
  min-height: 0;
  overflow: auto;
}

.script-row {
  background: #ffffff;
  border: 0;
  border-bottom: 1px solid #f0f0f0;
  border-radius: 0;
  min-height: 25px;
  padding: 0;
  text-align: left;
  width: 100%;
}

.script-row:hover {
  background: #eaf2ff;
}

.script-row strong,
.script-row span {
  border-right: 1px solid #f2f2f2;
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 400;
  overflow: hidden;
  padding: 4px 6px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.output-tabs {
  border-bottom: 1px solid var(--line);
  justify-content: flex-start;
}

.output-tabs .status-pill {
  margin-left: auto;
}

.payload-console {
  background: #ffffff;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(260px, 0.9fr);
  min-height: 0;
}

.payload-column,
.console-column {
  display: grid;
  gap: 5px;
  min-height: 0;
  min-width: 0;
  padding: 6px 8px;
}

.payload-column {
  border-right: 1px solid var(--line-soft);
}

.panel-heading {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.output {
  background: #ffffff;
  border: 1px solid var(--line-soft);
  border-radius: 1px;
  color: var(--ink);
  line-height: 1.35;
  margin: 0;
  min-height: 52px;
  overflow: auto;
  padding: 6px;
  white-space: pre-wrap;
}

.output.compact {
  max-height: 160px;
  min-height: 70px;
}

code,
pre,
#scriptPayload {
  font-family: Consolas, "Liberation Mono", monospace;
}

#scriptPayload {
  min-height: 58px;
}

.connection-details {
  background: #f7f8f9;
  border-top: 1px solid var(--line-soft);
  padding: 5px 9px;
}

.connection-details summary {
  cursor: pointer;
  font-weight: 700;
}

.connection-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  margin-top: 8px;
}

.stacked-form {
  display: grid;
  gap: 8px;
}

.stacked-form label {
  display: grid;
  gap: 4px;
}

.status-pill {
  align-items: center;
  border: 1px solid #bdc5cd;
  border-radius: 2px;
  color: var(--muted);
  display: inline-flex;
  font-size: 0.78rem;
  min-height: 20px;
  padding: 2px 6px;
  white-space: nowrap;
}

.status-pill.ready {
  border-color: rgba(0, 108, 59, 0.35);
  color: var(--ok);
}

.status-pill.warn {
  border-color: rgba(176, 43, 34, 0.35);
  color: var(--warn);
}

.status-bar {
  align-items: center;
  background: #d9e1e8;
  border-top: 1px solid #95a1ad;
  display: flex;
  gap: 0;
  min-width: 0;
  overflow: hidden;
}

.status-bar span {
  border-right: 1px solid #9bacb8;
  color: #00551f;
  font-size: 0.84rem;
  min-width: 0;
  overflow: hidden;
  padding: 3px 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-bar .status-pill {
  background: transparent;
  border-bottom: 0;
  border-left: 0;
  border-top: 0;
  border-radius: 0;
  min-height: 24px;
}

.legacy-map[hidden] {
  display: none;
}

.toast {
  background: #1d1d1d;
  border: 1px solid #000000;
  border-radius: 2px;
  bottom: 34px;
  color: #ffffff;
  left: 50%;
  max-width: min(560px, calc(100% - 32px));
  opacity: 0;
  padding: 8px 10px;
  pointer-events: none;
  position: fixed;
  transform: translate(-50%, 12px);
  transition: opacity 120ms ease, transform 120ms ease;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 1180px) {
  body {
    overflow: auto;
  }

  .studio-window {
    height: auto;
    min-height: 100svh;
  }

  .studio-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 520px 420px auto;
  }

  .inspector {
    grid-row: 2;
  }

  .bottom-dock {
    grid-row: 3;
  }
}

@media (max-width: 860px) {
  .app-bar {
    grid-template-rows: auto auto auto;
  }

  .title-strip,
  .command-strip,
  .menu-strip,
  .status-bar {
    flex-wrap: wrap;
  }

  .command-strip {
    padding-left: 8px;
  }

  .search-form,
  .payload-console,
  .connection-grid,
  .page-designer-grid {
    grid-template-columns: 1fr;
  }

  .script-table-head,
  .script-row {
    grid-template-columns: minmax(160px, 1fr) 100px 90px 90px;
  }

  .script-table-head span:nth-child(n + 5),
  .script-row span:nth-child(n + 5) {
    display: none;
  }
}

@media (max-width: 560px) {
  .studio-shell {
    grid-template-rows: 440px 420px auto;
  }

  .window-controls {
    display: none;
  }

  .empty-state {
    left: 18px;
    top: 18px;
  }
}
