.app-shell > main {
  width: min(1560px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0 72px;
}

.intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 780px;
  margin-bottom: 10px;
  font-size: clamp(34px, 4vw, 58px);
  line-height: 1.02;
  letter-spacing: -0.045em;
}

.intro > div > p:last-child {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}

.status-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 270px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.status-card small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.status-dot {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 16px var(--green);
}

.status-dot.warning { background: var(--yellow); box-shadow: 0 0 16px var(--yellow); }
.status-dot.error { background: var(--red); box-shadow: 0 0 16px var(--red); }

.mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
}

.mode-switch { display: flex; gap: 6px; }

.account-rigs-panel {
  display: grid;
  grid-template-columns: minmax(150px, auto) minmax(220px, 1fr) auto auto auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--cyan) 44%, var(--line));
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface-2) 84%, transparent);
}

.account-rigs-panel > div { display: grid; gap: 2px; }
.account-rigs-panel small { color: var(--muted); font-size: 11px; }
.account-rig-choice select { width: 100%; min-height: 38px; }
.account-rig-conflicts { grid-column: 1 / -1; gap: 10px !important; }
.account-rig-conflicts[hidden] { display: none; }
.account-rig-conflict-card { display: grid; gap: 10px; padding: 14px; border: 1px solid #f2b84b; border-radius: 12px; background: color-mix(in srgb,var(--surface) 90%,#f2b84b); }
.account-rig-conflict-card > p { margin: 0; color: var(--muted); font-size: 12px; }
.account-rig-conflict-versions { display: grid !important; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px !important; }
.account-rig-conflict-version { display: grid; gap: 3px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.account-rig-conflict-version.newest { border-color: #f2b84b; }
.account-rig-conflict-version small { font-size: 9px; font-weight: 850; text-transform: uppercase; }
.account-rig-conflict-version span { color: var(--muted); font-size: 11px; }
.account-rig-conflict-actions { display: flex !important; justify-content: flex-end; gap: 8px !important; }

.mode-button,
.magnet-button {
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 750;
}

.mode-button.active {
  color: #00131e;
  background: linear-gradient(135deg, #32c7fb, #138ef7);
}

.magnet-controls { display: flex; align-items: center; gap: 9px; }
.magnet-controls[hidden] { display: none; }

.magnet-button {
  border-color: rgba(25, 186, 242, 0.25);
  background: color-mix(in srgb, var(--surface) 72%, transparent);
}

.magnet-button.active { color: #bdf0ff; border-color: rgba(25, 186, 242, 0.66); }
.magnet-button span { margin-right: 5px; color: var(--cyan); font-size: 18px; }

.magnet-controls label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 32px 7px 10px;
  color: var(--text);
  background: var(--surface-2);
  font: inherit;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(225px, 270px) minmax(480px, 1fr) minmax(245px, 300px);
  gap: 14px;
  align-items: start;
}

.panel,
.canvas-panel,
.data-preview {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(165deg, var(--surface-2), var(--surface));
  box-shadow: var(--shadow);
}

.panel {
  position: sticky;
  top: 88px;
  padding: 18px;
}

.panel-heading { margin-bottom: 18px; }
.panel-heading h2,
.canvas-toolbar h2,
.data-preview h2 { margin-bottom: 0; font-size: 20px; letter-spacing: -0.025em; }

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

.wire-tools {
  display: grid;
  gap: 9px;
  margin-bottom: 13px;
  padding: 11px;
  border: 1px solid rgba(25, 186, 242, 0.32);
  border-radius: 13px;
  background: rgba(25, 186, 242, 0.07);
}

.wire-tools[hidden] { display: none; }
.wire-tools > b { font-size: 13px; }
.wire-tools > small { color: var(--muted); font-size: 10px; line-height: 1.35; }
.wire-tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

.wire-tool-grid button {
  min-height: 34px;
  padding: 6px 7px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  font-size: 10px;
  font-weight: 750;
  cursor: pointer;
}

.wire-tool-grid button:last-child { grid-column: 1 / -1; }
.wire-tool-grid button:hover,
.wire-tool-grid button.active { border-color: var(--cyan); background: rgba(25, 186, 242, 0.2); }

.component-card {
  display: grid;
  grid-template-columns: 54px 1fr 24px;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border: 1px solid rgba(107, 196, 228, 0.2);
  border-radius: 13px;
  color: var(--text);
  text-align: left;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.component-card:hover {
  border-color: rgba(25, 186, 242, 0.68);
  background: var(--surface-3);
  transform: translateY(-1px);
}

.component-card small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.component-card .plus { color: var(--cyan); font-size: 22px; }

.component-image {
  width: 54px;
  height: 54px;
  object-fit: contain;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.42));
  pointer-events: none;
}

.button,
.icon-button {
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  transition: filter 150ms ease, transform 150ms ease, border-color 150ms ease;
}

.button:hover:not(:disabled),
.icon-button:hover:not(:disabled) { filter: brightness(1.12); transform: translateY(-1px); }

.button { min-height: 41px; padding: 9px 14px; font-weight: 700; }
.button-block { width: 100%; }
.button-primary { color: #00131e; background: linear-gradient(135deg, #26c5ff, #128eff); }
.button-accent { margin-top: 14px; color: #07161f; background: linear-gradient(135deg, #8cf092, #44c55a); }
.button-secondary { border-color: var(--line); background: var(--surface-3); }
.button-ghost { border-color: var(--line); background: transparent; }

.mini-help {
  margin-top: 14px;
  padding: 13px;
  border-left: 3px solid var(--cyan);
  border-radius: 4px 11px 11px 4px;
  background: rgba(25, 186, 242, 0.07);
}

.mini-help p { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

.canvas-panel { overflow: hidden; }

.canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  padding: 14px 17px;
  border-bottom: 1px solid var(--line);
}

.toolbar-actions { display: flex; gap: 8px; }

.icon-button {
  min-height: 36px;
  padding: 7px 10px;
  border-color: var(--line);
  background: var(--surface-2);
  font-size: 12px;
}

.icon-button.danger:not(:disabled) { color: #ffc0c5; border-color: rgba(255, 91, 104, 0.4); }
.icon-button[aria-pressed="true"] { color: #00131e; border-color: #8ee4ff; background: #dff7ff; }
.icon-button:disabled { opacity: 0.4; cursor: not-allowed; }

.canvas-wrap { position: relative; padding: 10px; }
.brand-watermark { mix-blend-mode: screen; }

#rig-canvas.white-background .canvas-background { fill: #f7fbfd; }
#rig-canvas.white-background .canvas-grid { opacity: 0.45; }
#rig-canvas.white-background .brand-watermark { mix-blend-mode: multiply; opacity: 1; }
#rig-canvas.white-background #algofish-watermark text { fill: #08719d; fill-opacity: 0.105; }
#rig-canvas.white-background .rig-edge.mainline { stroke: #167aa8; }
#rig-canvas.white-background .rig-edge.leader { stroke: #b66d00; }
#rig-canvas.white-background .rig-edge.branch { stroke: #547d8e; }
#rig-canvas.white-background .rig-edge-shadow { stroke: rgba(20, 145, 190, 0.18); }
#rig-canvas.white-background .node-callout { stroke: rgba(10, 96, 132, 0.72); }
#rig-canvas.white-background .free-rail { fill: rgba(25, 186, 242, 0.045); stroke: rgba(18, 119, 158, 0.32); }

#rig-canvas {
  display: block;
  width: 100%;
  max-height: none;
  min-height: 620px;
  touch-action: none;
  user-select: none;
}

.canvas-hint {
  position: absolute;
  right: 24px;
  bottom: 22px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  font-size: 11px;
  pointer-events: none;
}

.rig-edge { fill: none; stroke-linecap: round; }
.rig-edge.mainline { stroke: #c8f3ff; stroke-width: 4; }
.rig-edge.leader { stroke: #f2c162; stroke-width: 3; }
.rig-edge.branch { stroke: #b8d6df; stroke-width: 4; }
.rig-edge-shadow { fill: none; stroke: rgba(21, 187, 241, 0.28); stroke-width: 10; stroke-linecap: round; }
.rig-node { cursor: grab; }
.rig-node:active { cursor: grabbing; }
.node-hit { fill: transparent; }
.selection-ring { fill: none; stroke: #21c4ff; stroke-width: 3; stroke-dasharray: 8 5; filter: url(#glow); }
.rig-asset { pointer-events: none; filter: drop-shadow(0 7px 7px rgba(0, 0, 0, 0.46)); }
.snap-halo { fill: rgba(25, 186, 242, 0.12); stroke: #63dcff; stroke-width: 4; stroke-dasharray: 9 6; filter: url(#glow); pointer-events: none; }
.snap-link { fill: none; stroke: #63dcff; stroke-width: 4; stroke-dasharray: 10 7; pointer-events: none; }
.free-rail { fill: rgba(25, 186, 242, 0.035); stroke: rgba(99, 220, 255, 0.24); stroke-width: 2; stroke-dasharray: 12 10; pointer-events: none; }
.potential-drop-edge { fill: none; stroke: var(--drop-color); stroke-width: 14; stroke-linecap: round; stroke-dasharray: 10 9; opacity: 0.58; filter: url(#glow); pointer-events: none; }
.potential-drop-node { fill: color-mix(in srgb, var(--drop-color) 16%, transparent); stroke: var(--drop-color); stroke-width: 4; stroke-dasharray: 9 6; opacity: 0.9; filter: url(#glow); pointer-events: none; }
.potential-drop-legend { fill: #e5f8ff; font: 800 13px Inter, Arial, sans-serif; paint-order: stroke; stroke: #052033; stroke-width: 6; pointer-events: none; }
.node-label rect { fill: rgba(4, 22, 33, 0.92); stroke: rgba(51, 198, 247, 0.7); stroke-width: 1.5; }
.node-label text { fill: #eefaff; font-family: Inter, Arial, sans-serif; font-size: 16px; font-weight: 700; }
.node-label .node-detail { fill: #98bdcf; font-size: 13px; font-weight: 500; }
.node-callout { fill: none; stroke: rgba(127, 219, 250, 0.7); stroke-width: 1.5; stroke-dasharray: 5 4; }
.node-number circle { stroke: rgba(255, 255, 255, 0.8); stroke-width: 2; }
.node-number text { fill: #fff; font: 800 14px Inter, Arial, sans-serif; text-anchor: middle; dominant-baseline: central; }
.wire-source-halo { fill: rgba(25, 186, 242, 0.12); stroke: #28c7ff; stroke-width: 4; stroke-dasharray: 9 7; }
.wire-source-label { fill: #d7f6ff; font: 800 13px Inter, Arial, sans-serif; text-anchor: middle; paint-order: stroke; stroke: #062335; stroke-width: 5; }

.selection-empty {
  display: grid;
  min-height: 150px;
  place-items: center;
  padding: 20px;
  border: 1px dashed rgba(107, 196, 228, 0.28);
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
}

.selection-empty span {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  color: var(--cyan);
  background: rgba(25, 186, 242, 0.1);
  font-size: 25px;
}

.selection-empty p { margin: 8px 0 0; font-size: 12px; line-height: 1.5; }

.rig-context {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
  padding: 10px;
  border: 1px solid rgba(25, 186, 242, 0.26);
  border-radius: 10px;
  background: rgba(25, 186, 242, 0.07);
}

.rig-context span { color: var(--muted); font-size: 11px; font-weight: 700; }
.rig-context strong { color: var(--cyan-soft); font-size: 12px; line-height: 1.45; }

.component-role {
  display: grid;
  gap: 5px;
  margin-bottom: 14px;
  padding: 10px;
  border: 1px solid rgba(25, 186, 242, 0.26);
  border-radius: 10px;
  background: rgba(25, 186, 242, 0.07);
}

.component-role span { color: var(--muted); font-size: 11px; font-weight: 700; }
.component-role strong { color: var(--cyan-soft); font-size: 12px; line-height: 1.4; }

.component-ports {
  display: grid;
  gap: 7px;
  margin: -4px 0 14px;
  padding: 10px;
  border: 1px solid rgba(128, 204, 230, 0.18);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
}

.component-ports > div { display: grid; gap: 3px; }
.component-ports span { color: var(--muted); font-size: 11px; font-weight: 700; }
.component-ports strong { color: var(--text); font-size: 12px; }
.component-ports ul { display: grid; gap: 5px; margin: 0; padding: 0; list-style: none; }
.component-ports li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text);
  font-size: 11px;
}
.component-ports li small { color: var(--muted); }
.component-ports li[data-connected="true"] small { color: #79e39a; }

#cage-mount-context {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
}

select:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

form label,
.settings-group label {
  display: grid;
  gap: 7px;
  margin-bottom: 13px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 39px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: var(--surface);
  padding: 8px 10px;
}

.input-with-unit {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.input-with-unit input { border: 0; background: transparent; }
.input-with-unit span { padding-right: 10px; color: var(--cyan-soft); }

.coordinates {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.coordinates output { color: var(--text); }

hr { height: 1px; margin: 18px 0; border: 0; background: var(--line); }
.settings-group h3 { margin-bottom: 13px; font-size: 14px; }
.settings-group h3 span { color: var(--muted); font-size: 11px; font-weight: 600; }
.settings-group select { width: 100%; }
.file-actions { display: grid; gap: 9px; }
.export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.data-preview {
  display: grid;
  grid-template-columns: minmax(260px, 0.72fr) minmax(360px, 1.28fr);
  gap: 28px;
  margin-top: 16px;
  padding: 24px;
}

.data-preview > div > p:last-child { margin-bottom: 0; color: var(--muted); line-height: 1.55; }

pre {
  max-height: 230px;
  margin: 0;
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--cyan-soft);
  background: var(--surface);
  font: 12px/1.55 "Cascadia Code", Consolas, monospace;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 50;
  max-width: min(390px, calc(100% - 44px));
  padding: 12px 15px;
  border: 1px solid rgba(71, 208, 255, 0.52);
  border-radius: 12px;
  color: var(--text);
  background: var(--surface-3);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(255, 91, 104, 0.72); background: #3a1921; }

@media (max-width: 1120px) {
  .workspace { grid-template-columns: 220px minmax(460px, 1fr); }
  .inspector-panel { position: static; grid-column: 1 / -1; }
  .inspector-panel { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; }
  .inspector-panel .panel-heading { grid-column: 1 / -1; margin-bottom: 0; }
  .inspector-panel hr { display: none; }
}

@media (max-width: 800px) {
  .prototype-badge { display: none; }
  .top-actions .button-ghost { display: none; }
  main { width: min(100% - 20px, 720px); padding-top: 28px; }
  .intro { display: grid; align-items: start; }
  .mode-bar { align-items: stretch; flex-direction: column; }
  .account-rigs-panel { grid-template-columns: 1fr auto auto auto; }
  .account-rigs-panel > div { grid-column: 1 / -1; }
  .mode-switch { display: grid; grid-template-columns: 1fr 1fr; }
  .magnet-controls { align-items: stretch; flex-direction: column; }
  .magnet-controls label { justify-content: space-between; }
  .status-card { min-width: 0; }
  .workspace { grid-template-columns: 1fr; }
  .panel { position: static; }
  .library-panel { order: 2; }
  .canvas-panel { order: 1; }
  .inspector-panel { order: 3; grid-column: auto; display: block; }
  .inspector-panel hr { display: block; }
  #rig-canvas { min-height: 520px; max-height: none; }
  .data-preview { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .topbar { padding: 10px 12px; }
  .brand { font-size: 19px; }
  .brand-mark { width: 38px; height: 38px; }
  .top-actions .button { padding-inline: 10px; font-size: 12px; }
  h1 { font-size: 34px; }
  .canvas-toolbar { align-items: start; }
  .toolbar-actions { flex-direction: column; }
  .canvas-wrap { padding: 5px; }
  #rig-canvas { min-height: 470px; }
  .canvas-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
