:root {
  --bg: #f4f8fe;
  --panel: #ffffff;
  --ink: #071d3d;
  --muted: #586a82;
  --line: #d5e1f0;
  --blue: #276ef1;
  --blue-soft: #edf4ff;
  --teal: #0aaaa6;
  --amber: #b86900;
  --red: #d92d3a;
  --shadow: 0 18px 48px rgba(34, 72, 126, 0.10);
  --shadow-soft: 0 8px 24px rgba(34, 72, 126, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(69, 126, 205, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(69, 126, 205, 0.055) 1px, transparent 1px),
    radial-gradient(circle at 12% 0%, rgba(39, 110, 241, 0.09), transparent 32rem);
  background-size: 48px 48px, 48px 48px, auto;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button,
.file-button,
.top-link {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

button:hover,
.file-button:hover,
.top-link:hover {
  border-color: #9ab9eb;
  background: var(--blue-soft);
  color: #1759d1;
}

.top-link {
  text-decoration: none;
}

button:active {
  transform: translateY(1px);
}

button.active {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-soft);
}

.button-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.button-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-only {
  width: 34px;
  padding: 0;
}

.icon-only .button-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

input,
textarea {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #ffffff;
  color: var(--ink);
}

textarea {
  resize: none;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  padding: 10px;
}

.topbar {
  position: relative;
  z-index: 20;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 18px;
  background: rgba(250, 253, 255, 0.88);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 28px rgba(34, 72, 126, 0.06);
  backdrop-filter: blur(16px);
}

.topbar h1 {
  margin: 0;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.1;
  letter-spacing: -0.035em;
  font-weight: 800;
}

.brand-mark {
  color: var(--blue);
  background: linear-gradient(135deg, #145ce8 0%, #3a86ff 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13.5px;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: nowrap;
  padding: 0;
}

.primary-action {
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
  font-weight: 700;
}

.primary-action:hover {
  border-color: #155ed8;
  background: #155ed8;
  color: #ffffff;
}

.action-menu,
.toolbar-menu {
  position: relative;
}

.action-menu > summary,
.toolbar-menu > summary {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  padding: 0 11px;
  font-size: 13px;
  font-weight: 650;
  list-style: none;
  white-space: nowrap;
}

.action-menu > summary::-webkit-details-marker,
.toolbar-menu > summary::-webkit-details-marker {
  display: none;
}

.action-menu > summary::after,
.toolbar-menu > summary::after {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
}

.action-menu[open] > summary,
.toolbar-menu[open] > summary {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
}

.action-menu[open] > summary::after,
.toolbar-menu[open] > summary::after {
  transform: rotate(225deg) translate(-1px, -1px);
}

.menu-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  min-width: 220px;
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 20px 55px rgba(18, 52, 96, 0.20);
  padding: 10px;
}

.export-menu button,
.menu-button-stack button {
  width: 100%;
  justify-content: flex-start;
}

.options-menu {
  min-width: 290px;
}

.menu-links {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.menu-links a {
  min-height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #2359c4;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.menu-links a:hover {
  background: var(--blue-soft);
}

.page-menu .menu-links {
  min-width: 280px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 0;
  padding: 10px;
}

.page-menu .menu-links a {
  justify-content: start;
  padding: 0 10px;
}

.page-menu .menu-links a[aria-current="page"] {
  background: var(--blue-soft);
  color: var(--blue);
}

.file-button input {
  display: none;
}

.background-control,
.export-scale-control {
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.options-menu .background-control {
  height: auto;
  display: grid;
  grid-template-columns: 1fr auto;
  white-space: normal;
}

.options-menu .background-control > span:first-child {
  grid-column: 1 / -1;
  color: var(--ink);
  font-weight: 700;
}

.options-menu .background-control > .color-picker {
  grid-column: 1 / -1;
}

.options-menu .background-control > input[type="range"] {
  width: 100%;
}

.color-picker {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 2px 4px 2px 2px;
}

.color-picker:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(39, 110, 241, 0.11);
}

.color-picker input[type="color"] {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  overflow: hidden;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.color-picker input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-picker input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 6px;
}

.color-picker input[type="color"]::-moz-color-swatch {
  border: 0;
  border-radius: 6px;
}

.color-hex-input {
  width: 62px;
  min-width: 0;
  height: 28px;
  border: 0;
  border-radius: 5px;
  padding: 0 2px;
  color: var(--ink);
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  text-transform: lowercase;
}

.color-hex-input:focus {
  outline: 0;
  background: var(--blue-soft);
}

.background-control > input[type="color"] {
  width: 34px;
  height: 32px;
  padding: 2px;
  cursor: pointer;
}

.background-control > input[type="range"] {
  width: 86px;
  accent-color: var(--blue);
}

.background-control output,
.alpha-color output {
  min-width: 34px;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.export-scale-control select {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 8px;
}

.app-shell {
  height: calc(100vh - 70px);
  min-height: 620px;
  display: grid;
  grid-template-columns: clamp(270px, 21vw, 340px) minmax(0, 1fr) clamp(320px, 24vw, 420px);
  /* A definite row keeps tall panel content scrolling inside the shell
     instead of overflowing it (and colliding with the footer below). */
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "source work inspector";
  gap: 14px;
  padding: 14px;
}

.source-panel {
  grid-area: source;
}

.work-area {
  grid-area: work;
}

.inspector-panel {
  grid-area: inspector;
}

.app-shell.hide-source {
  grid-template-columns: minmax(0, 1fr) clamp(320px, 24vw, 420px);
  grid-template-areas: "work inspector";
}

.app-shell.hide-inspector {
  grid-template-columns: clamp(270px, 21vw, 340px) minmax(0, 1fr);
  grid-template-areas: "source work";
}

.app-shell.hide-source.hide-inspector {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "work";
}

.app-shell.hide-source .source-panel,
.app-shell.hide-inspector .inspector-panel {
  display: none;
}

.panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.panel-tabs {
  flex: 0 0 auto;
  min-height: 48px;
  display: flex;
  align-items: stretch;
  gap: 4px;
  padding: 6px 7px 0;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fbfdff, #f6f9fe);
}

.panel-tab {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  min-height: 41px;
  border: 0;
  border-radius: 9px 9px 0 0;
  background: transparent;
  color: var(--muted);
  padding: 0 10px;
  font-size: 12.5px;
  font-weight: 700;
}

.panel-tab::after {
  content: "";
  position: absolute;
  right: 8px;
  bottom: -1px;
  left: 8px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: transparent;
}

.panel-tab:hover {
  border-color: transparent;
  background: rgba(237, 244, 255, 0.72);
  color: #1759d1;
}

.panel-tab.active,
.panel-tab[aria-selected="true"] {
  border-color: transparent;
  background: #ffffff;
  color: var(--blue);
  box-shadow: 0 -1px 0 #ffffff, 0 0 18px rgba(39, 110, 241, 0.07);
}

.panel-tab.active::after,
.panel-tab[aria-selected="true"]::after {
  background: var(--blue);
}

.panel-tab:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -3px;
}

.tab-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.tab-panel[hidden] {
  display: none;
}

.source-tab-panel {
  display: flex;
  flex-direction: column;
}

.source-tab-panel .source-block {
  flex: 1 1 auto;
}

.local-status {
  flex: 0 0 auto;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 14px;
  border-top: 1px solid var(--line);
  background: #fbfdff;
  color: var(--muted);
  font-size: 12px;
}

.status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 4px rgba(10, 170, 166, 0.10);
}

.panel-block {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  padding: 14px;
}

.panel-block:last-child {
  border-bottom: 0;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

h2 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.2;
  letter-spacing: 0.01em;
  font-weight: 750;
}

.section-head h2 {
  margin: 0;
}

.source-block {
  min-height: 360px;
  display: flex;
  flex-direction: column;
}

#svgInput {
  flex: 1;
  min-height: 260px;
}

.status-line {
  min-height: 22px;
  padding-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.status-line.error {
  color: var(--red);
}

.layers-block {
  min-height: 220px;
}

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

.layer-item {
  width: 100%;
  min-width: 0;
  justify-content: flex-start;
  text-align: left;
  min-height: 40px;
  padding: 7px 9px;
  background: #fbfdff;
}

.layer-item.active {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.layer-item.primary {
  box-shadow: 0 0 0 1px var(--blue) inset;
}

.layer-tag {
  flex: none;
  font-weight: 700;
  color: var(--blue);
}

.layer-meta {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

.ad-slot {
  min-height: 250px;
  display: block;
  gap: 5px;
  margin-top: 16px;
  border: 1px solid #d9e3ef;
  border-radius: 11px;
  background: #f9fbff;
  color: #7a8da6;
  text-align: center;
  padding: 8px;
  overflow: hidden;
}

.ad-slot span {
  display: block;
  margin-bottom: 6px;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.ad-slot .adsbygoogle {
  width: 100%;
  min-height: 220px;
}

.ad-slot-compact {
  min-height: 250px;
  margin-top: 2px;
}

.tab-ad-slot {
  margin: 14px;
}

.work-area {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.canvas-toolbar {
  min-height: 44px;
  position: sticky;
  top: 0;
  z-index: 4;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 7px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(12px);
  flex-wrap: wrap;
}

.canvas-popover {
  right: auto;
  left: 0;
  min-width: 250px;
}

.canvas-popover .segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.canvas-popover .segmented button {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.canvas-popover .segmented button:nth-child(3n) {
  border-right: 0;
}

.canvas-popover .segmented button:nth-last-child(-n + 3) {
  border-bottom: 0;
}

.menu-button-stack {
  min-width: 190px;
}

.segmented {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.segmented button {
  border: 0;
  border-radius: 0;
  border-right: 1px solid var(--line);
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  color: #ffffff;
  background: var(--blue);
}

.zoom-control,
.snap-control {
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.zoom-control input {
  width: 72px;
  height: 32px;
  padding: 0 7px;
}

.snap-control input {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}

.stage {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background-color: #fbfdff;
  background-image:
    linear-gradient(rgba(74, 129, 204, 0.10) 1px, transparent 1px),
    linear-gradient(90deg, rgba(74, 129, 204, 0.10) 1px, transparent 1px);
  background-size: 48px 48px;
  border: 1px solid var(--line);
  border-radius: 16px;
  position: relative;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.precision-hud {
  position: sticky;
  top: 10px;
  left: 10px;
  z-index: 3;
  width: max-content;
  min-width: 112px;
  margin: 10px 0 -36px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  line-height: 1;
  padding: 7px 8px;
  pointer-events: none;
  box-shadow: var(--shadow-soft);
}

.svg-mount {
  width: max-content;
  min-width: 100%;
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 180px;
}

.svg-mount svg {
  display: block;
  overflow: visible;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 24px 60px rgba(34, 72, 126, 0.16);
}

.selected-name {
  color: var(--muted);
  font-size: 12px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.control-grid label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.alpha-color {
  display: grid;
  grid-template-columns: minmax(98px, 0.9fr) minmax(74px, 1fr) 34px;
  gap: 6px;
  align-items: center;
}

.alpha-color input[type="range"] {
  min-width: 0;
  accent-color: var(--blue);
}

.control-grid input {
  width: 100%;
  min-width: 0;
  height: 32px;
  padding: 0 8px;
}

.control-grid input[type="range"] {
  padding: 0;
}

.control-grid .color-hex-input {
  width: 62px;
  height: 28px;
  padding: 0 2px;
}

.alpha-color input[type="range"],
.background-control > input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  height: 20px;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.alpha-color input[type="range"]::-webkit-slider-runnable-track,
.background-control > input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: #dce6f3;
}

.alpha-color input[type="range"]::-webkit-slider-thumb,
.background-control > input[type="range"]::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  margin-top: -5px;
  appearance: none;
  -webkit-appearance: none;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 1px rgba(39, 110, 241, 0.35), 0 2px 6px rgba(22, 66, 126, 0.18);
}

.alpha-color input[type="range"]::-moz-range-track,
.background-control > input[type="range"]::-moz-range-track {
  height: 4px;
  border: 0;
  border-radius: 999px;
  background: #dce6f3;
}

.alpha-color input[type="range"]::-moz-range-thumb,
.background-control > input[type="range"]::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 1px rgba(39, 110, 241, 0.35), 0 2px 6px rgba(22, 66, 126, 0.18);
}

.alpha-color input[type="range"]:focus-visible,
.background-control > input[type="range"]:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.inspector-actions {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.action-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f8fbff;
}

.action-group button {
  min-width: 0;
  min-height: 31px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  padding: 0 7px;
  color: #40536d;
  font-size: 11.5px;
}

.action-group button:last-child {
  border-right: 0;
}

.action-group button:hover {
  background: var(--blue-soft);
  color: var(--blue);
}

.action-group .button-icon {
  width: 14px;
  height: 14px;
  flex-basis: 14px;
}

.wide-button {
  width: 100%;
  margin-top: 8px;
}

#pathInput {
  width: 100%;
  min-height: 92px;
}

.path-table {
  margin-top: 8px;
  display: grid;
  gap: 6px;
  max-height: 230px;
  overflow: auto;
}

.path-row {
  display: grid;
  grid-template-columns: 34px repeat(7, minmax(48px, 1fr));
  gap: 5px;
  align-items: center;
}

.path-row strong {
  text-align: center;
  color: var(--teal);
}

.path-row input {
  width: 100%;
  min-width: 0;
  height: 28px;
  padding: 0 6px;
  font-size: 12px;
}

.path-row input[aria-invalid="true"] {
  border-color: #c94848;
  background: #fff5f5;
  box-shadow: 0 0 0 2px rgba(201, 72, 72, 0.12);
}

.attr-list {
  display: grid;
  gap: 6px;
  max-height: 200px;
  overflow: auto;
}

.attr-row {
  display: grid;
  grid-template-columns: 86px 1fr 28px;
  gap: 5px;
  align-items: center;
}

.attr-row input {
  width: 100%;
  min-width: 0;
  height: 30px;
  padding: 0 7px;
  font-size: 12px;
}

.attr-row span {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attr-row button {
  min-height: 30px;
  padding: 0;
}

.attr-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 6px;
  margin-top: 8px;
}

.attr-editor input {
  min-width: 0;
  height: 32px;
  padding: 0 8px;
}

.learn-panel {
  color: #334155;
  font-size: 13px;
  line-height: 1.45;
}

.learn-panel code {
  color: var(--amber);
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

.lab-overlay {
  pointer-events: none;
}

.lab-overlay-box {
  fill: none;
  stroke: var(--blue);
  stroke-width: 0.45;
  stroke-dasharray: 5 4;
  opacity: 0.62;
  vector-effect: non-scaling-stroke;
}

.lab-handle-spoke {
  stroke: var(--blue);
  stroke-width: 0.35;
  opacity: 0.24;
  vector-effect: non-scaling-stroke;
}

.lab-handle-line {
  stroke: var(--teal);
  stroke-width: 0.4;
  opacity: 0.34;
  vector-effect: non-scaling-stroke;
}

.lab-handle {
  fill: rgba(255, 255, 255, 0.52);
  stroke: var(--teal);
  stroke-width: 0.75;
  vector-effect: non-scaling-stroke;
  pointer-events: all;
  cursor: grab;
}

.lab-handle.active {
  fill: rgba(255, 255, 255, 0.88);
  stroke: var(--red);
}

.lab-handle.end {
  stroke: var(--blue);
}

.lab-handle.control {
  stroke: var(--teal);
}

.lab-handle:active {
  cursor: grabbing;
}

.lab-snap-guide {
  fill: none;
  stroke: var(--red);
  stroke-width: 0.85;
  opacity: 0.9;
  vector-effect: non-scaling-stroke;
}

.lab-resize-handle {
  fill: #ffffff;
  stroke: var(--blue);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  pointer-events: all;
}

.lab-rotate-handle {
  fill: #ffffff;
  stroke: var(--teal);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  pointer-events: all;
  cursor: grab;
}

.lab-rotate-handle:active {
  cursor: grabbing;
}

.lab-rotate-line {
  stroke: var(--teal);
  stroke-width: 0.6;
  opacity: 0.5;
  vector-effect: non-scaling-stroke;
}

.rubber-band {
  position: fixed;
  z-index: 50;
  border: 1px dashed var(--blue);
  background: rgba(47, 111, 237, 0.08);
  pointer-events: none;
}

.stage.pan-ready {
  cursor: grab;
}

.stage.panning-active {
  cursor: grabbing;
}

.noscript-note {
  margin: 24px auto;
  max-width: 720px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: rgba(250, 253, 255, 0.92);
  padding: 18px 20px;
}

.footer-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: grid;
  gap: 12px;
}

.footer-nav,
.content-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.footer-nav {
  padding: 0;
  border: 0;
}

.footer-bar {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 20px;
}

.footer-bar > p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.footer-disclosure {
  border-top: 1px solid var(--line);
}

.footer-disclosure > summary {
  width: max-content;
  min-height: 40px;
  display: flex;
  align-items: center;
  color: #2359c4;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  list-style: none;
}

.footer-disclosure > summary::-webkit-details-marker {
  display: none;
}

.footer-disclosure > summary::after {
  content: "+";
  margin-left: 7px;
  font-size: 16px;
}

.footer-disclosure[open] > summary::after {
  content: "−";
}

.footer-expanded {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  padding: 18px 0 8px;
}

.footer-expanded .footer-note {
  grid-column: 1 / -1;
}

.footer-nav a,
.content-nav a,
.content-main a {
  color: #2359c4;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.footer-nav a,
.content-nav a {
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
}

.footer-nav a:hover,
.content-nav a:hover,
.content-main a:hover {
  color: #174398;
  text-decoration: underline;
}

/* Standalone information and guide pages */
.content-page {
  min-height: 100%;
  background:
    linear-gradient(rgba(69, 126, 205, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(69, 126, 205, 0.055) 1px, transparent 1px),
    radial-gradient(circle at top right, rgba(39, 110, 241, 0.12), transparent 34rem),
    var(--bg);
  background-size: 48px 48px, 48px 48px, auto, auto;
}

.content-header {
  background: rgba(250, 253, 255, 0.88);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 28px rgba(34, 72, 126, 0.06);
  backdrop-filter: blur(16px);
}

.content-header-inner {
  width: min(1080px, calc(100% - 40px));
  margin: 0 auto;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.site-brand {
  color: #0b2d61;
  font-size: 18px;
  font-weight: 780;
  text-decoration: none;
  white-space: nowrap;
}

.content-main {
  width: min(900px, calc(100% - 40px));
  margin: 0 auto;
  padding: 64px 0 80px;
}

.content-main.wide {
  width: min(1080px, calc(100% - 40px));
}

.content-hero {
  margin-bottom: 40px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.content-main h1 {
  max-width: 780px;
  margin: 0;
  font-size: clamp(34px, 7vw, 58px);
  line-height: 1.02;
  letter-spacing: -0.04em;
}

.content-main h2 {
  margin: 38px 0 12px;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.content-main h3 {
  margin: 24px 0 8px;
  font-size: 18px;
}

.lede {
  max-width: 740px;
  margin: 18px 0 0;
  color: #405164;
  font-size: 19px;
  line-height: 1.65;
}

.content-main p,
.content-main li {
  color: #334155;
  font-size: 16px;
  line-height: 1.75;
}

.content-main p {
  margin: 0 0 16px;
}

.content-main ul,
.content-main ol {
  margin: 12px 0 22px;
  padding-left: 24px;
}

.content-main li {
  margin-bottom: 8px;
}

.content-main code {
  color: #8a4f00;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.9em;
}

.content-main pre {
  overflow-x: auto;
  margin: 18px 0 24px;
  border: 1px solid #26364a;
  border-radius: 12px;
  background: #152033;
  color: #ecf3ff;
  padding: 18px;
}

.content-main pre code {
  color: inherit;
}

.info-card,
.guide-card,
.callout {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.info-card,
.callout {
  padding: 22px;
}

.callout {
  margin: 28px 0;
  border-left: 4px solid var(--blue);
}

.callout p:last-child,
.info-card p:last-child {
  margin-bottom: 0;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.guide-card {
  display: block;
  padding: 24px;
  color: inherit;
  text-decoration: none;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.guide-card:hover {
  transform: translateY(-2px);
  border-color: #9fb9eb;
  box-shadow: 0 16px 36px rgba(25, 38, 54, 0.12);
  text-decoration: none !important;
}

.guide-card h2,
.guide-card h3 {
  margin: 0 0 8px;
  color: var(--ink);
}

.guide-card p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.breadcrumbs {
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 14px;
}

.breadcrumbs a {
  color: inherit;
}

.article-meta {
  margin-top: 16px;
  color: var(--muted);
  font-size: 14px;
}

.step-list {
  counter-reset: guide-step;
  list-style: none;
  padding-left: 0 !important;
}

.step-list > li {
  counter-increment: guide-step;
  position: relative;
  min-height: 44px;
  padding-left: 56px;
  margin-bottom: 22px;
}

.step-list > li::before {
  content: counter(guide-step);
  position: absolute;
  top: 1px;
  left: 0;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-weight: 750;
}

.page-footer {
  border-top: 1px solid var(--line);
  background: rgba(250, 253, 255, 0.92);
  padding: 18px 20px;
}

.page-footer-inner {
  width: min(1080px, 100%);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.page-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 720px) {
  .content-header-inner {
    width: min(100% - 28px, 1080px);
    padding: 14px 0;
    align-items: center;
    flex-direction: row;
    gap: 12px;
  }

  .content-nav {
    min-width: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px 14px;
  }

  .content-main,
  .content-main.wide {
    width: min(100% - 28px, 900px);
    padding: 44px 0 60px;
  }

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

  .footer-expanded {
    grid-template-columns: 1fr;
  }

  .footer-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .footer-nav {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
  }
}

.site-footer h2 {
  margin: 0 0 10px;
  font-size: 17px;
}

.site-footer p,
.site-footer li {
  margin: 0 0 10px;
  color: #334155;
  font-size: 14px;
  line-height: 1.6;
}

.site-footer .footer-bar > p {
  margin: 0;
}

.site-footer ul {
  margin: 0;
  padding-left: 20px;
}

.site-footer li {
  margin-bottom: 5px;
}

.site-footer code {
  color: var(--amber);
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
}

.footer-expanded details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px 14px;
  margin-bottom: 8px;
}

.footer-expanded summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
}

.footer-expanded details p {
  margin: 10px 0 2px;
}

.footer-note {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  margin: 0;
}

@media (max-width: 1280px) {
  .app-shell {
    grid-template-columns: 250px minmax(0, 1fr) 300px;
  }
}

@media (max-width: 1120px) {
  .app-shell {
    height: calc(100vh - 70px);
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    /* Row minimums must sum below the shell's min-height (620px) or the
       grid overflows its own box and spills under the footer. */
    grid-template-rows: minmax(300px, 1fr) minmax(200px, 0.55fr);
    grid-template-areas:
      "work work"
      "source inspector";
  }

  .app-shell.hide-source {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "work"
      "inspector";
    grid-template-rows: minmax(300px, 1fr) minmax(200px, 0.5fr);
  }

  .app-shell.hide-inspector {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "work"
      "source";
    grid-template-rows: minmax(300px, 1fr) minmax(200px, 0.5fr);
  }

  .app-shell.hide-source.hide-inspector {
    grid-template-areas: "work";
    grid-template-rows: minmax(300px, 1fr);
  }

  .inspector-panel {
    display: flex;
    overflow: hidden;
  }

  .source-panel,
  .inspector-panel {
    min-height: 0;
  }

  .source-block {
    min-height: 0;
    flex: 1;
  }
}

@media (max-width: 760px) {
  .topbar {
    position: relative;
    z-index: 20;
    height: auto;
    min-height: 0;
    align-items: flex-start;
    flex-direction: column;
    padding: 12px;
    gap: 12px;
  }

  .top-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    overflow: visible;
  }

  .top-actions > button,
  .top-actions > .file-button,
  .action-menu > summary,
  .toolbar-menu > summary {
    min-height: 44px;
  }

  .action-menu,
  .toolbar-menu {
    position: static;
  }

  .action-menu .menu-popover {
    top: calc(100% - 4px);
    right: 12px;
    left: 12px;
    min-width: 0;
  }

  .app-shell {
    height: auto;
    min-height: calc(100vh - 126px);
    grid-template-columns: 1fr;
    grid-template-rows: minmax(58vh, 1fr) auto auto;
    grid-template-areas:
      "work"
      "source"
      "inspector";
    padding: 8px;
    gap: 8px;
  }

  .app-shell.hide-source {
    grid-template-columns: 1fr;
    grid-template-areas:
      "work"
      "inspector";
    grid-template-rows: minmax(72vh, 1fr) auto;
  }

  .app-shell.hide-inspector {
    grid-template-columns: 1fr;
    grid-template-areas:
      "work"
      "source";
    grid-template-rows: minmax(72vh, 1fr) auto;
  }

  .app-shell.hide-source.hide-inspector {
    grid-template-columns: 1fr;
    grid-template-areas: "work";
    grid-template-rows: minmax(72vh, 1fr);
  }

  .work-area {
    min-height: 0;
  }

  .canvas-toolbar {
    position: relative;
    flex-wrap: wrap;
    overflow: visible;
    justify-content: flex-start;
    padding: 7px;
  }

  .canvas-popover {
    top: calc(100% + 7px);
    right: 7px;
    left: 7px;
    min-width: 0;
  }

  .source-block {
    min-height: 250px;
  }

  .inspector-panel {
    display: flex;
  }

  .inspector-panel,
  .source-panel {
    max-height: none;
  }

  .control-grid,
  .inspector-panel {
    grid-template-columns: 1fr;
  }

  .alpha-color {
    grid-template-columns: minmax(98px, 0.9fr) minmax(80px, 1fr) 34px;
  }

  .ad-slot {
    min-height: 250px;
  }

  .svg-mount {
    padding: 110px;
  }
}
