:root {
  --bg: #050811;
  --bg-deep: #02040a;
  --panel: #0a101d;
  --panel-raised: #0e1728;
  --panel-soft: #101b2f;
  --line: #26364f;
  --line-bright: #3d587e;
  --text: #edf5ff;
  --text-soft: #a6b5ca;
  --muted: #65758d;
  --cyan: #31e8ff;
  --green: #69ff86;
  --north: #ff4f68;
  --south: #3c8cff;
  --amber: #ffc95c;
  --violet: #ad78ff;
  --danger: #ff5876;
  --shadow: 0 18px 55px #00000078;
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  background: var(--bg-deep);
  color: var(--text);
  height: 100%;
  margin: 0;
  min-height: 100%;
}

body {
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="range"],
input[type="checkbox"] {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

.app-shell {
  background:
    radial-gradient(circle at 51% 43%, #183f5721, transparent 43%),
    var(--bg);
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr) 28px;
  height: 100svh;
  min-height: 540px;
  min-width: 320px;
  overflow: hidden;
}

.topbar {
  align-items: center;
  background: linear-gradient(180deg, #0d1422f7, #080d17f7);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 5px 22px #0006;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  padding: 8px 14px;
  position: relative;
  z-index: 80;
}

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

.brand-mark {
  border: 1px solid #ffffff22;
  border-radius: 8px;
  display: flex;
  flex: 0 0 47px;
  height: 30px;
  overflow: hidden;
  position: relative;
  transform: rotate(-5deg);
  width: 47px;
  box-shadow: 0 0 22px #31e8ff1e;
}

.brand-mark::after {
  border: 1px solid #fff9;
  border-radius: inherit;
  content: "";
  inset: 2px;
  pointer-events: none;
  position: absolute;
}

.brand-pole {
  align-items: center;
  color: #fff;
  display: flex;
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .6rem;
  font-weight: 950;
  justify-content: center;
  text-shadow: 0 1px 2px #0009;
}

.brand-pole--north {
  background: linear-gradient(145deg, #ff7185, #d72f4a);
  box-shadow: inset 0 1px #fff5;
}

.brand-pole--south {
  background: linear-gradient(145deg, #54a2ff, #2563d5);
  box-shadow: inset 0 1px #fff4;
}

.brand-copy {
  min-width: 0;
}

.brand-copy p,
.panel-kicker {
  color: var(--cyan);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .51rem;
  font-weight: 900;
  letter-spacing: .19em;
  margin: 0 0 2px;
  white-space: nowrap;
}

.brand-copy h1 {
  font-size: 1.12rem;
  font-weight: 950;
  letter-spacing: .075em;
  line-height: 1;
  margin: 0;
  text-shadow: 0 0 20px #31e8ff30;
  white-space: nowrap;
}

.topbar-actions,
.mobile-panel-actions {
  align-items: center;
  display: flex;
  gap: 7px;
}

.mobile-panel-actions {
  display: none;
}

.topbar-button,
.icon-button,
.panel-close,
.dialog-close {
  align-items: center;
  background: linear-gradient(180deg, #152139, #0b1221);
  border: 1px solid #385174;
  border-radius: 8px;
  color: #b9c8dc;
  cursor: pointer;
  display: inline-flex;
  font-size: .66rem;
  font-weight: 800;
  gap: 7px;
  justify-content: center;
  letter-spacing: .045em;
  min-height: 34px;
  padding: 0 11px;
  transition: border-color .16s, color .16s, background .16s, transform .16s, box-shadow .16s;
}

.topbar-button:hover,
.topbar-button:focus-visible,
.icon-button:hover,
.icon-button:focus-visible,
.panel-close:hover,
.panel-close:focus-visible,
.dialog-close:hover,
.dialog-close:focus-visible {
  border-color: #31e8ff9c;
  color: #fff;
  outline: none;
  transform: translateY(-1px);
}

.topbar-button--active {
  background: linear-gradient(180deg, #11352f, #0a1d1b);
  border-color: #44d77775;
  color: #dfffe7;
}

.run-indicator,
.status-dot {
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 9px var(--green);
  height: 6px;
  width: 6px;
}

.run-symbol {
  display: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .7rem;
  font-weight: 950;
}

.topbar-button:not(.topbar-button--active) .run-indicator {
  background: var(--amber);
  box-shadow: 0 0 9px var(--amber);
}

.icon-button {
  font-size: .86rem;
  min-width: 34px;
  padding: 0;
  width: 34px;
}

.workspace {
  display: grid;
  grid-template-columns: 248px minmax(340px, 1fr) 292px;
  min-height: 0;
  position: relative;
}

.side-panel {
  background: linear-gradient(180deg, #0a101df7, #070c15fa);
  min-height: 0;
  position: relative;
  z-index: 40;
}

.sources-panel {
  border-right: 1px solid var(--line);
}

.inspector-panel {
  border-left: 1px solid var(--line);
}

.panel-header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  height: 68px;
  justify-content: space-between;
  padding: 12px 14px;
}

.panel-header h2 {
  font-size: 1.01rem;
  letter-spacing: -.015em;
  margin: 0;
}

.panel-close {
  display: none;
  font-size: 1.1rem;
  min-height: 31px;
  min-width: 31px;
  padding: 0;
}

.panel-scroll {
  height: calc(100% - 68px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px;
  scrollbar-color: #344967 #080d16;
  scrollbar-width: thin;
}

.panel-scroll::-webkit-scrollbar,
.dialog-body::-webkit-scrollbar {
  width: 8px;
}

.panel-scroll::-webkit-scrollbar-track,
.dialog-body::-webkit-scrollbar-track {
  background: #080d16;
}

.panel-scroll::-webkit-scrollbar-thumb,
.dialog-body::-webkit-scrollbar-thumb {
  background: #344967;
  border-radius: 99px;
}

.add-source-grid {
  display: grid;
  gap: 7px;
  grid-template-columns: 1fr 1fr;
}

.action-card {
  align-items: center;
  background: linear-gradient(145deg, #111d31, #0a1220);
  border: 1px solid #304766;
  border-radius: 11px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-height: 88px;
  padding: 10px 5px 8px;
  text-align: center;
  transition: border-color .16s, transform .16s, box-shadow .16s;
}

.action-card:hover,
.action-card:focus-visible {
  border-color: #31e8ff8a;
  box-shadow: 0 0 20px #31e8ff13;
  outline: none;
  transform: translateY(-1px);
}

.action-card strong {
  color: #e7f0fc;
  display: block;
  font-size: .65rem;
}

.action-card small {
  color: var(--muted);
  display: block;
  font-size: .52rem;
  margin-top: 2px;
}

.mini-magnet {
  border: 1px solid #fff7;
  border-radius: 5px;
  display: flex;
  height: 24px;
  overflow: hidden;
  transform: rotate(-8deg);
  width: 48px;
}

.mini-magnet i {
  align-items: center;
  background: var(--north);
  color: #fff;
  display: flex;
  flex: 1;
  font-size: .52rem;
  font-style: normal;
  font-weight: 950;
  justify-content: center;
}

.mini-magnet i:last-child {
  background: var(--south);
}

.mini-wire {
  color: var(--amber);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 2rem;
  line-height: .75;
  text-shadow: 0 0 13px #ffc95c8a;
}

.panel-section {
  border-top: 1px solid #26364fba;
  margin-top: 14px;
  padding-top: 13px;
}

.section-title-row {
  align-items: center;
  color: #8090a8;
  display: flex;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .56rem;
  font-weight: 900;
  justify-content: space-between;
  letter-spacing: .14em;
  margin-bottom: 9px;
}

.section-title-row strong {
  align-items: center;
  background: #16233a;
  border: 1px solid #334c6d;
  border-radius: 99px;
  color: var(--cyan);
  display: flex;
  font-size: .55rem;
  height: 20px;
  justify-content: center;
  min-width: 25px;
  padding: 0 7px;
}

.select-row {
  display: grid;
  gap: 6px;
  grid-template-columns: minmax(0, 1fr) auto;
}

select,
.field input[type="text"],
.field input[type="number"] {
  background: #070c16;
  border: 1px solid #314661;
  border-radius: 8px;
  color: #dce8f7;
  font-size: .67rem;
  height: 34px;
  min-width: 0;
  outline: none;
  padding: 0 9px;
  width: 100%;
}

select:focus,
.field input:focus {
  border-color: #31e8ffa6;
  box-shadow: 0 0 0 2px #31e8ff18;
}

.small-button,
.text-button,
.dialog-primary {
  align-items: center;
  background: linear-gradient(180deg, #17263e, #0c1525);
  border: 1px solid #3a557a;
  border-radius: 8px;
  color: #bdcce0;
  cursor: pointer;
  display: inline-flex;
  font-size: .61rem;
  font-weight: 800;
  gap: 6px;
  justify-content: center;
  min-height: 34px;
  padding: 0 10px;
  transition: border-color .15s, color .15s, transform .15s, background .15s;
}

.small-button:hover,
.small-button:focus-visible,
.text-button:hover,
.text-button:focus-visible,
.dialog-primary:hover,
.dialog-primary:focus-visible {
  border-color: #31e8ff9c;
  color: #fff;
  outline: none;
  transform: translateY(-1px);
}

.small-button:disabled {
  cursor: default;
  opacity: .35;
  transform: none;
}

.small-button--danger {
  border-color: #7b3548;
  color: #ff9aac;
}

.small-button--danger:hover,
.small-button--danger:focus-visible {
  background: #39121d;
  border-color: var(--danger);
}

.source-list {
  display: grid;
  gap: 5px;
}

.source-list-empty {
  align-items: center;
  border: 1px dashed #30445f;
  border-radius: 10px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  font-size: .62rem;
  justify-content: center;
  line-height: 1.5;
  min-height: 104px;
  padding: 16px;
  text-align: center;
}

.source-list-empty span {
  color: #476382;
  font-size: 1.5rem;
  margin-bottom: 3px;
}

.source-item {
  align-items: center;
  background: #0b1423;
  border: 1px solid #2a3b54;
  border-radius: 9px;
  cursor: pointer;
  display: grid;
  gap: 8px;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  min-height: 50px;
  padding: 5px 7px;
  text-align: left;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .15s;
  width: 100%;
}

.source-item:hover,
.source-item:focus-visible {
  background: #101d31;
  border-color: #48678e;
  outline: none;
}

.source-item.is-selected {
  background: linear-gradient(90deg, #102b32, #0d1929);
  border-color: #31e8ff9c;
  box-shadow: inset 3px 0 var(--cyan), 0 0 17px #31e8ff13;
}

.source-item-icon {
  align-items: center;
  border: 1px solid #ffffff45;
  color: #fff;
  display: flex;
  font-size: .52rem;
  font-weight: 950;
  height: 22px;
  justify-content: center;
  justify-self: center;
  width: 28px;
}

.source-item-icon--dipole {
  background: linear-gradient(90deg, var(--north) 0 50%, var(--south) 50%);
  border-radius: 4px;
}

.source-item-icon--wire {
  background: #121b2b;
  border-color: #ffc95c8a;
  border-radius: 50%;
  color: var(--amber);
  font-size: .95rem;
  height: 27px;
  width: 27px;
}

.source-item-copy {
  min-width: 0;
}

.source-item-copy strong {
  color: #dce8f6;
  display: block;
  font-size: .65rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-item-copy small {
  color: #667993;
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .5rem;
  margin-top: 2px;
}

.source-item-strength {
  color: #8ba0bc;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .52rem;
  white-space: nowrap;
}

.project-buttons {
  display: grid;
  gap: 6px;
  grid-template-columns: 1fr 1fr;
}

.microcopy {
  color: #5f7089;
  font-size: .57rem;
  line-height: 1.5;
  margin: 9px 0 0;
}

.canvas-stage {
  background: #02040a;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  position: relative;
  touch-action: none;
}

.canvas-stage::before {
  background:
    radial-gradient(circle at 50% 46%, #07232340, transparent 47%),
    linear-gradient(135deg, #08111b44, transparent 43%);
  content: "";
  inset: 0;
  pointer-events: none;
  position: absolute;
  z-index: 0;
}

#fieldCanvas {
  display: block;
  height: 100%;
  outline: none;
  position: relative;
  touch-action: none;
  width: 100%;
  z-index: 1;
}

.canvas-stage[data-tool="select"] #fieldCanvas {
  cursor: default;
}

.canvas-stage[data-tool="pan"] #fieldCanvas {
  cursor: grab;
}

.canvas-stage[data-tool="pan"].is-dragging #fieldCanvas {
  cursor: grabbing;
}

.canvas-stage[data-tool="probe"] #fieldCanvas {
  cursor: crosshair;
}

.canvas-toolbar {
  align-items: center;
  background: #09111ee8;
  border: 1px solid #334a68;
  border-radius: 10px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 4px;
  left: 12px;
  padding: 5px;
  position: absolute;
  top: 12px;
  z-index: 12;
}

.tool-button {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #8294ae;
  cursor: pointer;
  display: inline-flex;
  font-size: .59rem;
  font-weight: 800;
  gap: 5px;
  justify-content: center;
  min-height: 31px;
  padding: 0 8px;
}

.tool-button > span:first-child {
  font-size: .85rem;
}

.tool-button:hover,
.tool-button:focus-visible {
  background: #15233a;
  border-color: #3b5679;
  color: #eaf3ff;
  outline: none;
}

.tool-button.is-active {
  background: #10303a;
  border-color: #31e8ff7d;
  color: var(--cyan);
  box-shadow: inset 0 0 13px #31e8ff12;
}

.tool-button--icon {
  font-size: .9rem;
  min-width: 30px;
  padding: 0;
}

.toolbar-separator {
  background: #31445e;
  height: 20px;
  margin: 0 1px;
  width: 1px;
}

.field-legend {
  background: #07101de3;
  border: 1px solid #314762;
  border-radius: 9px;
  bottom: 46px;
  box-shadow: var(--shadow);
  padding: 8px 9px 7px;
  position: absolute;
  right: 12px;
  width: 132px;
  z-index: 10;
}

.field-legend > span {
  color: #8a9bb3;
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .45rem;
  font-weight: 900;
  letter-spacing: .12em;
  margin-bottom: 6px;
}

.legend-gradient {
  background: linear-gradient(90deg, #101947, #533283, #087fa3, #25c489, #e7eb6b);
  border: 1px solid #ffffff38;
  border-radius: 99px;
  height: 6px;
}

.field-legend > div:last-child {
  color: #5d6d84;
  display: flex;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .42rem;
  font-weight: 900;
  justify-content: space-between;
  margin-top: 3px;
}

.field-legend i {
  font-style: normal;
}

.field-legend:not(.is-visible) {
  display: none;
}

.canvas-readout {
  align-items: center;
  background: #060d18e8;
  border: 1px solid #2d435f;
  border-radius: 8px;
  bottom: 10px;
  box-shadow: 0 10px 35px #0007;
  color: #9aacbf;
  display: flex;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .52rem;
  gap: 12px;
  left: 12px;
  min-height: 28px;
  padding: 0 10px;
  position: absolute;
  z-index: 10;
}

.canvas-readout span {
  white-space: nowrap;
}

.canvas-readout b {
  color: var(--cyan);
  font-size: .48rem;
  margin-right: 2px;
}

.canvas-readout output {
  color: #d5e2f1;
}

.canvas-hint {
  background: #060d18d1;
  border: 1px solid #2d435f;
  border-radius: 8px;
  bottom: auto;
  color: #64768e;
  font-size: .52rem;
  left: auto;
  max-width: 42%;
  overflow: hidden;
  padding: 6px 10px;
  position: absolute;
  right: 12px;
  text-overflow: ellipsis;
  top: 13px;
  transform: none;
  white-space: nowrap;
  z-index: 9;
}

.type-badge {
  background: #142237;
  border: 1px solid #334e71;
  border-radius: 99px;
  color: #8095b1;
  font-size: .49rem;
  letter-spacing: .09em;
  padding: 3px 7px;
}

.type-badge.is-dipole {
  border-color: #b44962;
  color: #ff8da0;
}

.type-badge.is-wire {
  border-color: #8a6a2e;
  color: var(--amber);
}

.empty-inspector {
  align-items: center;
  border: 1px dashed #30435d;
  border-radius: 11px;
  color: #67778e;
  display: flex;
  flex-direction: column;
  min-height: 126px;
  padding: 17px;
  text-align: center;
}

.empty-inspector > span {
  color: #486682;
  font-size: 1.7rem;
  margin-bottom: 7px;
}

.empty-inspector strong {
  color: #a6b5c9;
  font-size: .68rem;
}

.empty-inspector p {
  font-size: .58rem;
  line-height: 1.5;
  margin: 5px 0 0;
}

.source-inspector {
  display: grid;
  gap: 10px;
}

.source-inspector[hidden] {
  display: none;
}

.field {
  display: grid;
  gap: 5px;
}

.field > span,
.field--range > span {
  color: #75869f;
  font-size: .57rem;
  font-weight: 700;
}

.field-grid {
  display: grid;
  gap: 7px;
  grid-template-columns: 1fr 1fr;
}

.field--range > span {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.field--range output {
  color: var(--cyan);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .57rem;
}

input[type="range"] {
  accent-color: var(--cyan);
  cursor: pointer;
  height: 18px;
  margin: 0;
  width: 100%;
}

.inspector-actions {
  display: grid;
  gap: 5px;
  grid-template-columns: 1fr 1fr 1fr;
  margin-top: 1px;
}

.toggle-list {
  display: grid;
  gap: 2px;
}

.toggle-row {
  align-items: center;
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  gap: 9px;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 44px;
  padding: 5px 2px;
}

.toggle-row:hover {
  background: #111b2b;
}

.toggle-row > span {
  min-width: 0;
}

.toggle-row strong {
  color: #b5c3d6;
  display: block;
  font-size: .62rem;
}

.toggle-row small {
  color: #5f7189;
  display: block;
  font-size: .52rem;
  margin-top: 2px;
}

.toggle-row input {
  height: 1px;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.toggle-row i {
  background: #182337;
  border: 1px solid #3b4c65;
  border-radius: 99px;
  height: 20px;
  position: relative;
  transition: background .16s, border-color .16s;
  width: 35px;
}

.toggle-row i::after {
  background: #7c8ca3;
  border-radius: 50%;
  content: "";
  height: 14px;
  left: 2px;
  position: absolute;
  top: 2px;
  transition: left .16s, background .16s, box-shadow .16s;
  width: 14px;
}

.toggle-row input:checked + i {
  background: #103333;
  border-color: #29bfc3;
}

.toggle-row input:checked + i::after {
  background: var(--cyan);
  box-shadow: 0 0 9px #31e8ffb0;
  left: 17px;
}

.toggle-row input:focus-visible + i {
  box-shadow: 0 0 0 2px #31e8ff4d;
}

.compact-range {
  border-top: 1px solid #1e2b3e;
  margin-top: 8px;
  padding-top: 9px;
}

.text-button {
  background: transparent;
  border: 0;
  color: #7190ad;
  min-height: 24px;
  padding: 0 2px;
}

.probe-help {
  margin-top: -3px;
}

.probe-list {
  display: grid;
  gap: 5px;
  margin-top: 9px;
}

.probe-empty {
  color: #51647d;
  font-size: .57rem;
  padding: 10px 0;
  text-align: center;
}

.probe-item {
  background: #09121f;
  border: 1px solid #293d57;
  border-radius: 8px;
  display: grid;
  gap: 7px;
  grid-template-columns: 23px minmax(0, 1fr) auto;
  min-height: 48px;
  padding: 6px 7px;
}

.probe-index {
  align-items: center;
  background: #12303b;
  border: 1px solid #31e8ff61;
  border-radius: 50%;
  color: var(--cyan);
  display: flex;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .52rem;
  font-weight: 900;
  height: 22px;
  justify-content: center;
  width: 22px;
}

.probe-values {
  min-width: 0;
}

.probe-values strong {
  color: #bfd0e4;
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .55rem;
}

.probe-values small {
  color: #60728b;
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .47rem;
  margin-top: 3px;
}

.probe-remove {
  align-self: center;
  background: transparent;
  border: 0;
  color: #65758b;
  cursor: pointer;
  font-size: .85rem;
  padding: 4px;
}

.probe-remove:hover,
.probe-remove:focus-visible {
  color: var(--danger);
  outline: none;
}

.export-probes-button {
  margin-top: 7px;
  width: 100%;
}

.statusbar {
  align-items: center;
  background: #080d16;
  border-top: 1px solid #23334a;
  color: #4e6077;
  display: flex;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .47rem;
  font-weight: 800;
  justify-content: space-between;
  letter-spacing: .09em;
  min-width: 0;
  padding: 0 12px;
  position: relative;
  z-index: 70;
}

.statusbar span {
  align-items: center;
  display: flex;
  gap: 7px;
  white-space: nowrap;
}

.statusbar strong {
  color: #7f93ab;
  font-size: inherit;
}

.status-dot {
  height: 5px;
  width: 5px;
}

.status-dot.is-paused {
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber);
}

.panel-scrim {
  background: #01030bba;
  inset: 0;
  position: absolute;
  z-index: 35;
}

.help-dialog {
  background: transparent;
  border: 0;
  color: var(--text);
  max-height: calc(100svh - 24px);
  max-width: 680px;
  padding: 0;
  width: calc(100% - 24px);
}

.help-dialog::backdrop {
  backdrop-filter: blur(10px);
  background: #01030bd9;
}

.dialog-card {
  background:
    radial-gradient(circle at 50% 0%, #1b5a7042, transparent 37%),
    linear-gradient(145deg, #111c30, #070c16);
  border: 1px solid #426181;
  border-radius: 18px;
  box-shadow: 0 35px 100px #000c, 0 0 50px #31e8ff18;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: calc(100svh - 24px);
  overflow: hidden;
}

.dialog-header {
  align-items: center;
  border-bottom: 1px solid #2a3d56;
  display: flex;
  justify-content: space-between;
  padding: 17px 19px;
}

.dialog-header h2 {
  font-size: clamp(1.25rem, 4vw, 1.75rem);
  letter-spacing: -.03em;
  margin: 0;
}

.dialog-close {
  font-size: 1.15rem;
  min-height: 34px;
  min-width: 34px;
  padding: 0;
}

.dialog-body {
  overflow-y: auto;
  padding: 18px 19px;
}

.dialog-lead {
  color: #a7b6c9;
  font-size: .78rem;
  line-height: 1.62;
  margin: 0 0 16px;
}

.help-grid {
  display: grid;
  gap: 7px;
  grid-template-columns: 1fr 1fr;
}

.help-grid article {
  background: #070d17a3;
  border: 1px solid #2e425c;
  border-radius: 10px;
  display: grid;
  gap: 10px;
  grid-template-columns: 27px 1fr;
  min-height: 86px;
  padding: 10px;
}

.help-grid article > span {
  color: var(--cyan);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .58rem;
  font-weight: 900;
}

.help-grid strong {
  color: #e5effb;
  display: block;
  font-size: .68rem;
}

.help-grid p {
  color: #72839b;
  font-size: .6rem;
  line-height: 1.48;
  margin: 4px 0 0;
}

.shortcut-section {
  border-top: 1px solid #293b53;
  margin-top: 15px;
  padding-top: 14px;
}

.shortcut-section h3 {
  color: #8394ad;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .56rem;
  letter-spacing: .14em;
  margin: 0 0 9px;
}

.shortcut-grid {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(3, 1fr);
}

.shortcut-grid span {
  align-items: center;
  color: #8393aa;
  display: flex;
  font-size: .58rem;
  gap: 7px;
}

kbd {
  align-items: center;
  background: #111d2e;
  border: 1px solid #3b5271;
  border-bottom-width: 2px;
  border-radius: 5px;
  color: #d4e0ee;
  display: inline-flex;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .51rem;
  justify-content: center;
  min-height: 22px;
  min-width: 28px;
  padding: 0 5px;
}

.technical-note {
  background: #12221e;
  border: 1px solid #3b6b5a;
  border-radius: 10px;
  margin-top: 15px;
  padding: 10px 12px;
}

.technical-note strong {
  color: var(--green);
  display: block;
  font-size: .63rem;
}

.technical-note p {
  color: #809b91;
  font-size: .58rem;
  line-height: 1.52;
  margin: 4px 0 0;
}

.dialog-primary {
  background: linear-gradient(90deg, #123538, #132746);
  border-color: #31e8ff9c;
  border-radius: 0;
  min-height: 50px;
  width: 100%;
}

.toast-region {
  bottom: 42px;
  display: grid;
  gap: 7px;
  pointer-events: none;
  position: fixed;
  right: 14px;
  z-index: 300;
}

.toast {
  animation: toast-in .22s ease-out both;
  background: #101a2af2;
  border: 1px solid #3a5679;
  border-left: 3px solid var(--cyan);
  border-radius: 8px;
  box-shadow: 0 15px 45px #000a;
  color: #b8c7da;
  font-size: .63rem;
  max-width: 300px;
  padding: 10px 12px;
}

.toast.is-error {
  border-left-color: var(--danger);
}

.toast.is-leaving {
  animation: toast-out .18s ease-in both;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(5px); }
}

@media (max-width: 1100px) and (min-width: 901px) {
  .workspace {
    grid-template-columns: 220px minmax(320px, 1fr) 266px;
  }

  .side-panel .panel-scroll {
    padding-left: 10px;
    padding-right: 10px;
  }

  .button-label {
    display: none;
  }

  .topbar-button {
    min-width: 34px;
    padding: 0 9px;
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-rows: 62px minmax(0, 1fr) 26px;
  }

  .workspace {
    display: block;
  }

  .canvas-stage {
    height: 100%;
    width: 100%;
  }

  .side-panel {
    bottom: 0;
    box-shadow: 18px 0 60px #000c;
    position: absolute;
    top: 0;
    transition: transform .22s ease, visibility .22s;
    visibility: hidden;
    width: min(88vw, 340px);
    z-index: 45;
  }

  .sources-panel {
    left: 0;
    transform: translateX(-103%);
  }

  .inspector-panel {
    right: 0;
    transform: translateX(103%);
  }

  body.sources-open .sources-panel,
  body.inspector-open .inspector-panel {
    transform: translateX(0);
    visibility: visible;
  }

  .panel-close {
    display: inline-flex;
  }

  .mobile-panel-actions {
    display: flex;
  }

  .topbar {
    gap: 10px;
    padding-inline: 10px;
  }

  .brand-copy p {
    display: none;
  }

  .topbar-actions .button-label {
    display: none;
  }

  .topbar-actions #runBtn .run-indicator {
    display: none;
  }

  .topbar-actions #runBtn .run-symbol {
    display: inline;
  }

  .topbar-actions .topbar-button {
    min-width: 34px;
    padding: 0 9px;
  }

  .canvas-hint {
    display: none;
  }
}

@media (max-width: 620px) {
  .app-shell {
    grid-template-rows: 58px minmax(0, 1fr) 24px;
    min-height: 460px;
  }

  .topbar {
    padding: 7px 8px;
  }

  .brand-mark {
    flex-basis: 39px;
    height: 25px;
    width: 39px;
  }

  .brand-copy h1 {
    font-size: .88rem;
  }

  .topbar-button--compact {
    font-size: 0;
    min-width: 33px;
    padding: 0;
    width: 33px;
  }

  .topbar-button--compact span {
    font-size: .9rem;
  }

  .topbar-actions {
    gap: 4px;
  }

  .topbar-actions #clearTrailsBtn,
  .topbar-actions #resetViewBtn {
    display: none;
  }

  .canvas-toolbar {
    bottom: 44px;
    left: 50%;
    top: auto;
    transform: translateX(-50%);
  }

  .tool-button span:last-child {
    display: none;
  }

  .tool-button {
    min-width: 32px;
    padding: 0 6px;
  }

  .canvas-readout {
    bottom: 8px;
    gap: 8px;
    left: 50%;
    transform: translateX(-50%);
  }

  .canvas-readout span:nth-child(4) {
    display: none;
  }

  .field-legend {
    bottom: 91px;
    right: 8px;
  }

  .statusbar span:nth-child(2),
  .statusbar span:nth-child(3) {
    display: none;
  }

  .statusbar {
    justify-content: center;
  }

  .help-grid,
  .shortcut-grid {
    grid-template-columns: 1fr;
  }

  .help-grid article {
    min-height: 68px;
  }

  .dialog-body {
    padding: 14px;
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  .app-shell {
    grid-template-rows: 50px minmax(0, 1fr) 22px;
    min-height: 320px;
  }

  .brand-copy p,
  .statusbar span:nth-child(3),
  .canvas-hint {
    display: none;
  }

  .topbar {
    padding-block: 5px;
  }

  .panel-header {
    height: 56px;
    padding-block: 8px;
  }

  .panel-scroll {
    height: calc(100% - 56px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
