:root {
  color-scheme: dark;
  --bg: #0d1117;
  --surface: #111822;
  --surface-2: #151e2b;
  --surface-3: #1b2636;
  --line: #54667d;
  --line-strong: #35455b;
  --text: #e7edf5;
  --muted: #91a0b5;
  --subtle: #637086;
  --accent: #5eead4;
  --accent-strong: #22d3ee;
  --danger: #f87171;
  --warning: #facc15;
  --panel-width: 381px;
  --panel-height: 420px;
  --panel-overlay-width: var(--panel-width);
  --panel-overlay-height: var(--panel-height);
  --canvas-reserved-width: var(--panel-width);
  --canvas-reserved-height: var(--panel-height);
  --panel-collapsed-width: 76px;
  --panel-collapsed-height: 122px;
  --panel-snap-threshold: 50px;
  --panel-bottom-collapse-threshold: 200px;
  --toolbar-height: 58px;
  --status-height: 34px;
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

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

button {
  color: inherit;
}

.app-shell {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: var(--toolbar-height) minmax(0, 1fr);
  background: var(--bg);
}

.top-toolbar {
  display: grid;
  grid-template-columns: minmax(150px, max-content) minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  overflow: hidden;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(17, 24, 34, 0.96);
  backdrop-filter: blur(12px);
  z-index: 20;
}

.brand-lockup {
  min-width: 0;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.brand-lockup > div {
  min-width: 0;
}

.brand-lockup h1 {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.1;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0;
}

#workspace-status,
.alpha-control span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.toolbar-group,
.section-toolbar {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.view-actions {
  flex: 0 0 auto;
  justify-content: flex-end;
}

.toolbar-divider {
  width: 1px;
  height: 28px;
  background: var(--line);
}

.section-toolbar {
  gap: 4px;
  font-size: 12px;
}

.section-toolbar .chip-button {
  padding: 0 8px;
}

.primary-actions {
  justify-self: stretch;
  justify-content: flex-end;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.primary-actions::-webkit-scrollbar {
  display: none;
}

#file-input {
  display: none;
}

.tool-button,
.chip-button,
.icon-button,
.unit-toggle,
.panel-tab {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

.tool-button,
.chip-button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  border-radius: 7px;
  white-space: nowrap;
}

.tool-button.primary {
  border-color: rgba(94, 234, 212, 0.45);
  background: #14313a;
}

.chip-button {
  min-height: 32px;
  min-width: 0;
  flex: 1;
  padding: 0 10px;
  color: var(--muted);
}

.chip-button.danger {
  border-color: rgba(248, 113, 113, 0.35);
  color: #fecaca;
}

.icon-button.danger {
  border-color: rgba(248, 113, 113, 0.58);
  background: #7f1d1d;
  color: #fee2e2;
}

.icon-button {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border-radius: 7px;
}

.unit-toggle {
  width: 42px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-transform: uppercase;
}

@media (hover: hover) and (pointer: fine) {
  .tool-button:hover,
  .chip-button:hover,
  .icon-button:hover,
  .unit-toggle:hover,
  .panel-tab:hover {
    border-color: var(--line-strong);
    background: var(--surface-3);
  }
}

.tool-button:disabled,
.chip-button:disabled,
.icon-button:disabled,
.unit-toggle:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

@media (hover: hover) and (pointer: fine) {
  .tool-button.primary:hover {
    border-color: rgba(94, 234, 212, 0.7);
    background: #173b45;
  }

  .icon-button.danger:hover {
    border-color: rgba(248, 113, 113, 0.8);
    background: #991b1b;
  }
}

.icon-button[aria-pressed="true"],
.icon-button[aria-pressed="true"]:hover {
  border-color: rgba(94, 234, 212, 0.54);
  background: #14313a;
  color: var(--text);
}

.app-shell svg {
  width: 17px;
  height: 17px;
  stroke-width: 1.8;
}

.workspace {
  width: 100%;
  height: 100%;
  min-height: 0;
  min-width: 0;
  position: relative;
  display: block;
  overflow: hidden;
}

.viewer-surface {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: #020617;
}

.viewer-surface.canvas-light {
  background: #f8fafc;
}

.viewer-surface canvas {
  display: block;
  width: calc(100% - var(--canvas-reserved-width));
  height: 100%;
  cursor: grab;
  touch-action: none;
}

.viewer-surface canvas:active {
  cursor: grabbing;
}

.app-shell.ruler-active .viewer-surface canvas,
.app-shell.ruler-active .viewer-surface canvas:active {
  cursor: crosshair;
}

.app-shell .measurement-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(100% - var(--canvas-reserved-width));
  height: 100%;
  pointer-events: none;
  z-index: 4;
}

.measurement-overlay .measurement-line-outline {
  stroke: #000;
  stroke-width: 4px;
  vector-effect: non-scaling-stroke;
}

.measurement-overlay .measurement-line {
  stroke: #fff;
  stroke-width: 2px;
  vector-effect: non-scaling-stroke;
}

.measurement-overlay circle {
  fill: #fff;
  stroke: #000;
  stroke-width: 1px;
  vector-effect: non-scaling-stroke;
}

.measurement-overlay text {
  fill: #fff;
  stroke: #000;
  stroke-width: 2px;
  paint-order: stroke;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  pointer-events: none;
  color: var(--muted);
}

.empty-state.is-hidden {
  display: none;
}

.empty-state .tool-button {
  pointer-events: auto;
}

.empty-state strong {
  color: var(--text);
  font-size: 18px;
}

.empty-state-note {
  margin-top: -8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.empty-state-icon {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(17, 24, 34, 0.72);
}

.empty-state-icon svg {
  width: 24px;
  height: 24px;
}

.drop-overlay {
  position: absolute;
  inset: 18px;
  display: none;
  place-content: center;
  justify-items: center;
  gap: 12px;
  border: 1px dashed rgba(94, 234, 212, 0.8);
  border-radius: var(--radius);
  background: rgba(3, 7, 18, 0.78);
  color: var(--accent);
  font-weight: 700;
  z-index: 8;
}

.app-shell.drag-active .drop-overlay {
  display: grid;
}

.viewport-hud {
  position: absolute;
  left: 12px;
  top: 12px;
  display: flex;
  gap: 8px;
  z-index: 5;
}

.metric-pill,
.canvas-status {
  border: 1px solid rgba(38, 51, 69, 0.86);
  background: rgba(13, 17, 23, 0.72);
  color: var(--muted);
  backdrop-filter: blur(10px);
}

.canvas-light .metric-pill,
.canvas-light .canvas-status {
  border-color: rgba(148, 163, 184, 0.62);
  background: rgba(248, 250, 252, 0.78);
  color: #475569;
}

.metric-pill {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.canvas-status {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: var(--status-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  z-index: 5;
}

.workspace:has(.side-panel:not(.collapsed)) .empty-state,
.workspace:has(.side-panel:not(.collapsed)) .canvas-status {
  right: var(--panel-overlay-width);
}

.workspace.panel-open .empty-state,
.workspace.panel-open .canvas-status {
  right: var(--panel-overlay-width);
}

.workspace:has(.side-panel.collapsed) .empty-state,
.workspace:has(.side-panel.collapsed) .canvas-status {
  right: var(--panel-collapsed-width);
}

.workspace.panel-collapsed .empty-state,
.workspace.panel-collapsed .canvas-status {
  right: var(--panel-collapsed-width);
}

.side-panel {
  width: var(--panel-width);
  min-width: 0;
  min-height: 0;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  container-type: inline-size;
  border-left: 1px solid var(--line);
  background: var(--surface);
  transform: translateX(0);
  transition: transform 180ms ease;
  z-index: 30;
}

.side-panel.collapsed {
  min-width: 0;
  overflow: hidden;
  pointer-events: auto;
  transform: translateX(calc(100% - var(--panel-collapsed-width)));
}

.side-panel.resizing {
  transition: none;
}

.side-panel.resizing {
  user-select: none;
}

.side-panel.collapsed .panel-tabs,
.side-panel.collapsed .layer-list-scroll {
  display: none;
}

.side-panel.collapsed .panel-section {
  display: none;
}

.side-panel.collapsed .panel-content {
  width: var(--panel-collapsed-width);
}

.side-panel.collapsed .panel-section[data-panel="layers"] {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 10px;
}

.side-panel.collapsed .layer-panel-controls {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.side-panel.collapsed .section-toolbar {
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
}

.side-panel.collapsed .section-toolbar .chip-button {
  display: inline-flex;
  flex: 0 0 auto;
  width: 40px;
  height: 36px;
  min-width: 0;
  padding: 0;
}

.side-panel.collapsed .section-toolbar .chip-button:nth-child(n + 4) {
  display: none;
}

.side-panel.collapsed .section-toolbar .chip-button span {
  display: none;
}

.side-panel.collapsed .alpha-control {
  width: 44px;
  min-height: 168px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 4px;
}

.side-panel.collapsed .alpha-control .field-row {
  display: flex;
  justify-content: center;
  width: 100%;
}

.side-panel.collapsed .alpha-control .field-row span {
  display: none;
}

.side-panel.collapsed .alpha-control .field-row strong {
  min-width: 0;
  text-align: right;
}

.side-panel.collapsed #alpha-slider {
  width: 20px;
  height: 118px;
  writing-mode: vertical-lr;
  direction: rtl;
}

.resize-handle {
  position: absolute;
  left: -4px;
  top: 0;
  bottom: 0;
  width: 8px;
  cursor: ew-resize;
  touch-action: none;
  z-index: 7;
}

.resize-handle:hover {
  background: rgba(94, 234, 212, 0.22);
}

.panel-tabs {
  display: flex;
  gap: 6px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.panel-tab {
  flex: 1 1 0;
  min-width: 0;
  height: 48px;
  display: grid;
  place-items: center;
  gap: 3px;
  position: relative;
  padding: 4px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 11px;
}

.panel-tab.active {
  border-color: rgba(94, 234, 212, 0.42);
  background: rgba(20, 49, 58, 0.86);
  color: var(--text);
}

.tab-badge {
  position: absolute;
  top: 5px;
  right: 7px;
  min-width: 17px;
  height: 17px;
  display: grid;
  place-items: center;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(248, 113, 113, 0.18);
  color: #fecaca;
  font-size: 10px;
}

.panel-content {
  min-height: 0;
  overflow: hidden;
}

.panel-section {
  display: none;
  height: 100%;
  min-height: 0;
  padding: 12px;
  overflow: hidden;
}

.panel-section.active {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-section:not([data-panel="layers"]) {
  overflow-y: auto;
}

.layer-panel-controls {
  display: grid;
  gap: 12px;
  flex: 0 0 auto;
}

.diagnostic-toolbar {
  justify-content: flex-end;
}

.diagnostic-toolbar .chip-button {
  flex: 0 0 auto;
}

@container (max-width: 380px) {
  .panel-tab,
  .layer-panel-controls .chip-button,
  .filter-actions .chip-button {
    padding: 0;
  }

  .panel-tab span:not(.tab-badge),
  .layer-panel-controls .chip-button span,
  .filter-actions .chip-button span {
    display: none;
  }
}

.alpha-control {
  display: grid;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
}

.alpha-control[hidden],
.side-panel.collapsed .alpha-control[hidden] {
  display: none;
}

.outline-source-control {
  display: grid;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
}

.outline-source-control span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}

.outline-source-status {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 500;
}

.outline-source-control select {
  width: 100%;
  min-width: 0;
  height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #0f1724;
  color: #f8fafc;
  font: inherit;
  font-weight: 650;
  outline: none;
  padding: 0 12px;
}

.outline-source-control select:focus {
  border-color: rgba(94, 234, 212, 0.62);
  box-shadow: 0 0 0 1px rgba(94, 234, 212, 0.18);
}

.outline-source-control option {
  background: #0f1724;
  color: #f8fafc;
}

.side-panel.collapsed .outline-source-control {
  display: none;
}

.layer-list-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.layer-list,
.diagnostic-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.layer-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 6px 0;
}

.layer-item {
  position: relative;
  display: grid;
  grid-template-columns: 28px 24px minmax(0, 1fr) 32px;
  align-items: center;
  gap: 8px;
  min-height: 50px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
}

.layer-group-heading {
  padding: 8px 2px 2px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.drill-layer-item .layer-label span {
  line-height: 1.45;
  white-space: pre-line;
}

.layer-item[draggable="true"] {
  cursor: grab;
  -webkit-touch-callout: none;
  user-select: none;
}

.layer-item.dragging {
  opacity: 0.45;
}

.layer-item.touch-dragging {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(94, 234, 212, 0.55);
}

.layer-item.drop-before::before,
.layer-item.drop-after::after {
  content: "";
  position: absolute;
  left: 6px;
  right: 6px;
  height: 3px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow:
    0 0 0 1px rgba(13, 17, 23, 0.9),
    0 0 12px rgba(94, 234, 212, 0.62);
  pointer-events: none;
  z-index: 2;
}

.layer-item.drop-before::before {
  top: -6px;
}

.layer-item.drop-after::after {
  bottom: -6px;
}

.layer-item:hover {
  border-color: var(--line-strong);
  background: var(--surface-3);
}

.layer-empty-item {
  cursor: pointer;
}

.layer-empty-item[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.layer-empty-item:focus-visible {
  outline: 2px solid rgba(94, 234, 212, 0.72);
  outline-offset: 2px;
}

.layer-color-picker {
  position: relative;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background:
    linear-gradient(
      rgb(var(--layer-color-rgb, 0 255 0) / var(--layer-alpha, 1)),
      rgb(var(--layer-color-rgb, 0 255 0) / var(--layer-alpha, 1))
    ),
    linear-gradient(45deg, #ffffff 25%, transparent 25%),
    linear-gradient(-45deg, #ffffff 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ffffff 75%),
    linear-gradient(-45deg, transparent 75%, #ffffff 75%);
  background-color: #94a3b8;
  background-position:
    0 0,
    0 0,
    0 6px,
    6px -6px,
    -6px 0;
  background-size:
    auto,
    12px 12px,
    12px 12px,
    12px 12px,
    12px 12px;
  cursor: pointer;
}

.layer-color-picker:focus-visible {
  outline: 2px solid rgba(94, 234, 212, 0.72);
  outline-offset: 2px;
}

.layer-color-picker.has-alpha-override::after {
  content: "";
  position: absolute;
  top: -2px;
  right: -2px;
  width: 5px;
  height: 5px;
  border: 1px solid var(--surface-2);
  border-radius: 999px;
  background: #ef4444;
  box-shadow: 0 0 0 1px rgba(3, 7, 18, 0.72);
}

.layer-checkbox {
  width: 18px;
  height: 18px;
  accent-color: #3b82f6;
  cursor: pointer;
}

.layer-item-inverted .layer-checkbox {
  accent-color: #ea580c;
}

.pcr-app.layer-color-pickr {
  z-index: 60;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}

.pcr-app.layer-color-pickr .pcr-selection,
.pcr-app.layer-color-pickr .pcr-interaction {
  background: var(--surface);
}

.pcr-app.layer-color-pickr .pcr-result {
  border: 1px solid var(--line-strong);
  background: #0f1724;
  color: var(--text);
}

.pcr-app.layer-color-pickr .pcr-save {
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
}

.pcr-app.layer-color-pickr .pcr-save {
  border-color: rgba(94, 234, 212, 0.45);
  background: #14313a;
}

.pcr-app.layer-color-pickr .pcr-layer-alpha-override {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0.8em 0;
  color: #e7edf5;
  font-size: 12px;
  font-weight: 650;
  user-select: none;
}

.pcr-app.layer-color-pickr .pcr-layer-alpha-override input {
  appearance: auto;
  width: 16px;
  height: 16px;
  min-width: 16px;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
  opacity: 1;
  cursor: pointer;
}

.layer-label {
  min-width: 0;
  display: grid;
  gap: 3px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.layer-label strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 650;
}

.layer-label span,
.diagnostic-list span {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.layer-menu-btn {
  color: var(--muted);
}

.layer-menu-btn:hover,
.layer-menu-btn:focus-visible {
  color: var(--text);
}

.layer-context-menu {
  position: fixed;
  z-index: 80;
  min-width: 178px;
  padding: 5px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface-2);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.36);
}

.layer-context-menu[hidden] {
  display: none;
}

.layer-context-menu-item {
  width: 100%;
  min-height: 32px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 6px 9px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}

.layer-context-menu-item svg {
  width: 16px;
  height: 16px;
}

.layer-context-menu-item:hover,
.layer-context-menu-item:focus-visible {
  outline: none;
  background: var(--surface-3);
}

.layer-context-menu-item.danger {
  color: #fecaca;
}

.layer-context-menu-item.active {
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.14);
}

.layer-context-menu-item:disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.52;
}

.layer-context-menu-separator {
  height: 1px;
  margin: 5px 4px;
  background: var(--line);
}

.options-section,
.filter-form,
.notification,
.diagnostic-list li {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
}

.screenshot-dialog {
  width: min(380px, calc(100vw - 24px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

.screenshot-dialog::backdrop {
  background: rgba(3, 7, 18, 0.62);
  backdrop-filter: blur(4px);
}

.screenshot-form {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.screenshot-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.screenshot-dialog-header strong {
  font-size: 14px;
}

.screenshot-option-row {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
}

.screenshot-option-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.screenshot-option-row strong {
  font-size: 13px;
}

.screenshot-option-row small,
.screenshot-progress {
  color: var(--muted);
  font-size: 12px;
}

.screenshot-option-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.screenshot-option-row select {
  width: 86px;
  flex: 0 0 86px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0f1724;
  color: var(--text);
  outline: none;
}

.screenshot-option-row select:focus {
  border-color: rgba(94, 234, 212, 0.62);
}

.screenshot-progress {
  display: none;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(94, 234, 212, 0.34);
  border-radius: 7px;
  background: rgba(20, 49, 58, 0.46);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.screenshot-form.is-exporting .screenshot-progress {
  display: grid;
}

.screenshot-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.screenshot-progress-header span {
  min-width: 0;
  color: var(--text);
}

.screenshot-progress-header strong {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.screenshot-progress-bar {
  width: 100%;
  height: 8px;
  overflow: hidden;
  appearance: none;
  border: 1px solid rgba(94, 234, 212, 0.28);
  border-radius: 999px;
  background: rgba(15, 23, 36, 0.82);
}

.screenshot-progress-bar::-webkit-progress-bar {
  border-radius: 999px;
  background: rgba(15, 23, 36, 0.82);
}

.screenshot-progress-bar::-webkit-progress-value {
  border-radius: 999px;
  background: var(--accent);
}

.screenshot-progress-bar::-moz-progress-bar {
  border-radius: 999px;
  background: var(--accent);
}

.loading-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(3, 7, 18, 0.62);
  backdrop-filter: blur(4px);
}

.loading-modal[hidden] {
  display: none;
}

.loading-panel {
  width: min(420px, calc(100vw - 32px));
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

.loading-header,
.loading-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.loading-header > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.loading-header strong {
  font-size: 14px;
}

.loading-header span,
.loading-file span,
.loading-progress-header {
  color: var(--muted);
  font-size: 12px;
}

.loading-header svg {
  width: 22px;
  height: 22px;
  color: var(--accent);
  animation: loading-spin 900ms linear infinite;
}

.loading-file {
  min-width: 0;
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
}

.loading-file strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loading-progress-header strong {
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
}

.loading-progress-bar {
  width: 100%;
  height: 9px;
  overflow: hidden;
  appearance: none;
  border: 1px solid rgba(94, 234, 212, 0.28);
  border-radius: 999px;
  background: rgba(15, 23, 36, 0.82);
}

.loading-progress-bar::-webkit-progress-bar {
  border-radius: 999px;
  background: rgba(15, 23, 36, 0.82);
}

.loading-progress-bar::-webkit-progress-value {
  border-radius: 999px;
  background: var(--accent);
}

.loading-progress-bar::-moz-progress-bar {
  border-radius: 999px;
  background: var(--accent);
}

@keyframes loading-spin {
  to {
    transform: rotate(360deg);
  }
}

.screenshot-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.screenshot-actions .chip-button,
.screenshot-actions .tool-button {
  flex: 0 0 auto;
  min-width: 82px;
}

.options-form {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.options-section,
.filter-form {
  padding: 12px;
}

.options-section {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.options-section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.options-section-heading strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.options-section-heading span,
.option-row > span,
.option-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.option-row {
  display: grid;
  grid-template-columns: minmax(80px, 0.5fr) minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
  overflow: hidden;
}

.option-row > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.option-outline {
  display: grid;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0f1724;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}

.segmented-control.three-up {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.segmented-control.four-up {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.segmented-control.five-up {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.segmented-control label {
  min-width: 0;
  overflow: hidden;
}

.segmented-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-control span {
  height: 28px;
  display: grid;
  place-items: center;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  font-size: 12px;
}

.segmented-control input:checked + span {
  border-color: rgba(94, 234, 212, 0.52);
  background: rgba(20, 49, 58, 0.86);
  color: var(--text);
}

.segmented-control input:disabled + span {
  cursor: not-allowed;
  opacity: 0.55;
}

.option-number-control {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}

.option-number-control > input {
  width: 100%;
  min-width: 0;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  padding: 0 8px;
}

.option-number-control > input:focus {
  border-color: rgba(94, 234, 212, 0.62);
  box-shadow: 0 0 0 1px rgba(94, 234, 212, 0.18);
}

.option-number-control > input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.option-number-control > input::-webkit-outer-spin-button,
.option-number-control > input::-webkit-inner-spin-button {
  appearance: none;
  margin: 0;
}

.option-number-control > input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

.option-unit-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
}

.option-unit-choice {
  position: relative;
  display: block;
  min-width: 0;
}

.option-unit-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.option-unit-choice span {
  height: 28px;
  display: grid;
  place-items: center;
  min-width: 42px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  font-size: 12px;
}

.option-unit-choice input:checked + span {
  border-color: rgba(94, 234, 212, 0.52);
  background: rgba(20, 49, 58, 0.86);
  color: var(--text);
}

.option-unit-choice input:focus-visible + span {
  border-color: rgba(94, 234, 212, 0.72);
  box-shadow: 0 0 0 1px rgba(94, 234, 212, 0.26);
}

.option-unit-choice input:disabled + span {
  cursor: not-allowed;
  opacity: 0.55;
}

@container (max-width: 300px) {
  .option-row-stack-narrow {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
}

.option-note {
  display: grid;
  gap: 3px;
  min-width: 0;
  overflow: hidden;
}

.option-note span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.diagnostic-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.diagnostic-list li {
  display: grid;
  gap: 3px;
  padding: 10px;
}

.filter-form {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.filter-actions {
  display: flex;
  gap: 6px;
  min-width: 0;
}

.filter-actions .chip-button {
  flex: 1;
  min-width: 0;
}

.filter-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.filter-field span,
.filter-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.filter-field textarea {
  width: 100%;
  min-width: 0;
  min-height: 148px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0f1724;
  color: var(--text);
  outline: none;
  resize: vertical;
  line-height: 1.45;
  font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.filter-field textarea:focus {
  border-color: rgba(94, 234, 212, 0.62);
}

.filter-note {
  margin: 0;
}

.filter-note span {
  display: block;
}

.notification {
  display: none;
  position: fixed;
  bottom: calc(var(--status-height) + 12px);
  right: calc(var(--panel-width) + 12px);
  width: min(460px, calc(100vw - var(--panel-width) - 24px));
  max-height: min(48vh, 320px);
  grid-template-columns: minmax(0, 1fr) 32px;
  gap: 8px;
  padding: 10px;
  border-color: rgba(250, 204, 21, 0.38);
  background: rgba(113, 63, 18, 0.24);
  overflow: auto;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.32);
  z-index: 60;
}

.notification.show {
  display: grid;
}

.app-shell:has(.side-panel.collapsed) .notification {
  right: 12px;
  width: min(460px, calc(100vw - 24px));
}

.notification.danger {
  border-color: rgba(248, 113, 113, 0.42);
  background: rgba(127, 29, 29, 0.26);
}

.notification ul {
  margin: 7px 0 0;
  padding-left: 18px;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

.field-row strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

#alpha-slider {
  width: 100%;
  accent-color: var(--accent);
}

@media (max-width: 760px) {
  :root {
    --toolbar-height: 56px;
    --status-height: 30px;
  }

  .top-toolbar {
    grid-template-columns: minmax(0, 1fr) auto auto;
    padding: 8px;
    gap: 6px;
  }

  .brand-lockup {
    display: none;
  }

  .toolbar-divider {
    height: 24px;
  }

  #drawer-toggle {
    display: none;
  }

  #workspace-status {
    display: none;
  }

  .tool-button {
    min-width: 38px;
    padding: 0 10px;
  }

  .tool-button span,
  .chip-button span {
    display: none;
  }

  .workspace {
    overflow: hidden;
  }

  .viewer-surface canvas,
  .app-shell .measurement-overlay {
    width: 100%;
    height: calc(100% - var(--canvas-reserved-height));
  }

  .workspace:has(.side-panel:not(.collapsed)) .empty-state {
    right: 0;
    bottom: var(--panel-overlay-height);
  }

  .workspace:has(.side-panel:not(.collapsed)) .canvas-status {
    right: 0;
    bottom: var(--panel-overlay-height);
  }

  .workspace.panel-open .empty-state,
  .workspace.panel-open .canvas-status {
    right: 0;
    bottom: var(--panel-overlay-height);
  }

  .workspace:has(.side-panel.collapsed) .empty-state,
  .workspace:has(.side-panel.collapsed) .canvas-status {
    right: 0;
    bottom: var(--panel-collapsed-height);
  }

  .workspace.panel-collapsed .empty-state,
  .workspace.panel-collapsed .canvas-status {
    right: 0;
    bottom: var(--panel-collapsed-height);
  }

  .side-panel {
    position: fixed;
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    width: auto !important;
    height: var(--panel-height);
    max-height: min(72vh, 560px);
    max-height: min(72dvh, 560px);
    padding-bottom: var(--safe-area-bottom);
    z-index: 30;
    border-left: 0;
    border-top: 1px solid var(--line);
    box-shadow: 0 -18px 42px rgba(0, 0, 0, 0.34);
    transform: translateY(0);
  }

  .panel-tabs {
    gap: 4px;
    padding: 6px 8px;
  }

  .panel-tab {
    height: 38px;
    gap: 2px;
    padding: 3px;
  }

  .panel-section {
    padding: 8px 10px;
  }

  .panel-section.active,
  .layer-panel-controls {
    gap: 8px;
  }

  .alpha-control {
    gap: 6px;
    padding: 5px 10px;
  }

  .options-section,
  .filter-form {
    padding: 8px;
  }

  .options-form,
  .filter-form {
    gap: 8px;
  }

  .side-panel.collapsed {
    width: auto;
    transform: translateY(calc(100% - var(--panel-collapsed-height)));
    overflow: hidden;
    pointer-events: auto;
    border-top: 1px solid var(--line);
  }

  .side-panel.collapsed .panel-section[data-panel="layers"] {
    gap: 8px;
    padding: 8px 10px;
  }

  .side-panel.collapsed .panel-content {
    width: auto;
  }

  .side-panel.collapsed .layer-panel-controls {
    height: auto;
    display: grid;
    align-items: stretch;
    gap: 8px;
  }

  .side-panel.collapsed .section-toolbar {
    flex-direction: row;
    align-items: center;
    gap: 4px;
    margin-top: 7px;
  }

  .side-panel.collapsed .section-toolbar .chip-button {
    flex: 1;
    width: auto;
    height: 42px;
    padding: 0 6px;
  }

  .side-panel.collapsed .section-toolbar .chip-button span {
    display: inline;
  }

  .side-panel.collapsed .alpha-control {
    width: auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
  }

  .side-panel.collapsed .alpha-control .field-row {
    display: contents;
  }

  .side-panel.collapsed .alpha-control .field-row span {
    display: none;
  }

  .side-panel.collapsed .alpha-control .field-row strong {
    grid-column: 2;
    grid-row: 1;
    min-width: 38px;
    text-align: right;
  }

  .side-panel.collapsed #alpha-slider {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    height: auto;
    writing-mode: horizontal-tb;
    direction: ltr;
  }

  .resize-handle {
    left: 0;
    right: 0;
    top: -5px;
    bottom: auto;
    width: auto;
    height: 20px;
    cursor: ns-resize;
  }

  .resize-handle::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 4px;
    width: 44px;
    height: 3px;
    border-radius: 999px;
    background: var(--line);
    transform: translateX(-50%);
  }

  .panel-tabs {
    padding: 8px;
  }

  .panel-tab {
    height: 42px;
  }

  .viewport-hud {
    left: 8px;
    top: 8px;
    flex-direction: column;
  }

  .canvas-status {
    padding: 0 8px;
  }

  .notification {
    bottom: calc(var(--status-height) + 8px);
    left: 8px;
    right: 8px;
    width: auto;
    max-height: min(38vh, 260px);
  }
}
