:root {
  color-scheme: light;

  /* A quiet technical workbench: one cool neutral family, one interaction signal, one measurement signal. */
  --workbench: #ededeb;
  --surface: #fbfbfa;
  --surface-sunken: #f4f4f2;
  --canvas: #ffffff;
  --ink: #17191b;
  --ink-soft: #494e51;
  --ink-muted: #707678;
  --hairline: #d9d9d4;
  --hairline-strong: #bdbcba;
  --signal: #2f5fe0;
  --signal-hover: #214dc4;
  --signal-tint: #eaefff;
  --measure: #c7351b;
  --measure-tint: #fcebe7;
  --success: #23684a;
  --success-tint: #e6f1ea;
  --error: #a8291d;

  --radius-xs: 3px;
  --radius-sm: 5px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --control-height: 30px;

  --font-ui: "Avenir Next", "Seravek", "Noto Sans SC", "Source Han Sans SC", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei UI", "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", "SFMono-Regular", "Cascadia Code", "JetBrains Mono", "IBM Plex Mono", "Menlo", monospace;
  --motion: 160ms cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out-soft: cubic-bezier(0.22, 1, 0.36, 1);
  --motion-panel: 260ms var(--ease-out-soft);
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--workbench);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.45;
  letter-spacing: 0;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}

button,
textarea {
  font: inherit;
}

button {
  min-height: var(--control-height);
  padding: 5px 10px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-xs);
  background: var(--canvas);
  color: var(--ink);
  cursor: pointer;
  transition: color var(--motion), background-color var(--motion), border-color var(--motion), transform var(--motion);
}

button:hover {
  border-color: #8f9089;
  background: #fff;
}

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

button:disabled {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
  transform: none;
}

button:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}

.primary-action {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
  font-weight: 650;
}

.primary-action:hover {
  border-color: #000;
  background: #000;
}

.workbench-bar {
  position: relative;
  z-index: 50;
  height: 56px;
  padding: 0 var(--space-5);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  border-bottom: 1px solid var(--hairline);
  background: rgba(251, 251, 250, 0.88);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
}

.bar-side {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.bar-side-right {
  justify-self: end;
}

.viewport-panel {
  justify-self: center;
  min-width: 0;
}

.brand {
  margin: 0;
  line-height: 1;
  justify-self: start;
  display: flex;
  align-items: center;
}

.brand-wordmark,
#brandWordmark {
  display: block;
  max-height: 36px;
  max-width: 150px;
  object-fit: contain;
  object-position: left center;
  filter: drop-shadow(0 1px 1px rgba(23, 25, 27, 0.06));
}

.brand-fallback,
#brandFallback:not([hidden]) {
  color: var(--ink);
  font-size: 19px;
  font-weight: 700;
}

.bar-tools,
.source-actions,
.viewport-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.custom-width-input {
  width: 62px;
  min-height: 24px;
  padding: 3px 6px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-xs);
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  outline: none;
  display: none;
  -moz-appearance: textfield;
  appearance: textfield;
}

.custom-width-input::-webkit-outer-spin-button,
.custom-width-input::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.custom-width-input.visible {
  display: block;
}

.custom-width-input:focus {
  border-color: var(--signal);
  box-shadow: 0 0 0 1px var(--signal);
}

.tool-button {
  color: var(--ink-soft);
}

.tool-button.active {
  border-color: rgba(47, 95, 224, 0.48);
  background: var(--signal-tint);
  color: #184bc0;
  font-weight: 650;
}

.viewport-group {
  padding: 2px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
}

.viewport {
  min-height: 24px;
  padding: 3px 8px;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.viewport:hover {
  border: 0;
  background: rgba(23, 25, 27, 0.05);
  color: var(--ink);
}

.viewport.active {
  border: 1px solid rgba(47, 95, 224, 0.48);
  background: var(--signal-tint);
  color: #184bc0;
  font-weight: 650;
}

.workspace {
  position: relative;
  min-width: 0;
  height: calc(100% - 56px);
  display: grid;
  grid-template-columns: 280px 6px minmax(0, 1fr) 6px 310px;
  grid-template-rows: minmax(0, 1fr);
  transition: grid-template-columns var(--motion-panel);
}

.workspace.no-anim {
  transition: none;
}

.workspace.no-anim .collapse-button {
  transition: none;
}

/* Explicit placement: a hidden (display: none) resizer must not reflow the panels. */
.source-panel {
  grid-column: 1;
}

#sourceResizer {
  grid-column: 2;
}

.preview-panel {
  grid-column: 3;
}

#inspectorResizer {
  grid-column: 4;
}

.inspector-panel {
  grid-column: 5;
}

.panel-resizer {
  position: relative;
  min-width: 0;
  cursor: col-resize;
  background: transparent;
}

.panel-resizer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: var(--hairline);
  transform: translateX(-50%);
  opacity: 1;
  transition: opacity var(--motion), background-color var(--motion), width var(--motion);
}

.panel-resizer:hover::after,
.panel-resizer.active::after {
  width: 2px;
  background: var(--signal);
  opacity: 1;
}

/* Orbital dot: the collapse handle that sits on the panel seams. */
.collapse-button {
  position: absolute;
  top: 50%;
  z-index: 40;
  width: 22px;
  height: 22px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--hairline-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-muted);
  box-shadow:
    0 1px 3px rgba(23, 25, 27, 0.1),
    0 0 0 1px rgba(251, 251, 250, 0.7);
  transform: translateY(-50%);
  transition:
    color var(--motion),
    background-color var(--motion),
    border-color var(--motion),
    box-shadow var(--motion),
    left var(--motion-panel),
    right var(--motion-panel);
}

.collapse-button:hover {
  border-color: #8f9089;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(23, 25, 27, 0.16), 0 0 0 1px rgba(251, 251, 250, 0.7);
}

.collapse-button:active {
  transform: translateY(-50%) scale(0.94);
}

.collapse-button:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 1px;
}

.collapse-button svg {
  pointer-events: none;
  transition: transform var(--motion);
}

#sourceCollapse svg {
  transform: rotate(180deg);
}

#sourceCollapse.collapsed svg {
  transform: rotate(0deg);
}

#inspectorCollapse.collapsed svg {
  transform: rotate(180deg);
}

.collapse-button.collapsed {
  background: #fff;
}

.panel-resizer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: var(--hairline);
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity var(--motion), background-color var(--motion), width var(--motion);
}

.panel-resizer:hover::after,
.panel-resizer.active::after {
  width: 2px;
  background: var(--signal);
  opacity: 1;
}

body.resizing-panels {
  cursor: col-resize;
  user-select: none;
}

.source-panel,
.inspector-panel {
  min-width: 0;
  overflow: hidden;
  background: var(--surface);
}

.source-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: var(--space-3);
  padding: var(--space-3);
  border-right: 1px solid var(--hairline);
  transition: opacity var(--motion-panel);
}

.source-panel.panel-motion,
.inspector-panel.panel-motion {
  opacity: 0;
}

[hidden] {
  display: none !important;
}

.panel-head,
.inspector-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.panel-head {
  align-items: center;
  min-height: var(--control-height);
}

.panel-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
}

.source-actions button {
  min-height: 24px;
  padding: 3px 8px;
  color: var(--ink-soft);
  font-size: 12px;
}

.drop-zone {
  min-height: 58px;
  padding: var(--space-3);
  display: grid;
  align-content: center;
  justify-items: start;
  border: 1px dashed var(--hairline-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  color: var(--ink-muted);
  cursor: pointer;
}

.drop-zone:hover {
  border-color: var(--ink);
  background: #fff;
}

.drop-zone.dragover {
  border-color: var(--signal);
  background: var(--signal-tint);
  color: #184bc0;
}

.drop-title {
  color: var(--ink);
  font-size: 12px;
  font-weight: 650;
}

.drop-sub {
  margin-top: 2px;
  font-size: 11px;
}

.source-editor {
  min-height: 0;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-sm);
  background: var(--canvas);
  overflow: hidden;
}

.editor-gutter {
  min-height: 0;
  padding: var(--space-3) var(--space-2) var(--space-4) 0;
  overflow: hidden;
  border-right: 1px solid var(--hairline);
  background: var(--surface-sunken);
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  text-align: right;
  white-space: pre;
  user-select: none;
}

.editor-surface {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.editor-highlight {
  position: absolute;
  inset: 0;
  z-index: 1;
  margin: 0;
  padding: var(--space-3);
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre;
  pointer-events: none;
}

.editor-highlight code {
  display: block;
  min-width: max-content;
}

.token-tag {
  color: #174ea6;
}

.token-name {
  color: #174ea6;
  font-weight: 650;
}

.token-attr {
  color: #7a5400;
}

.token-string {
  color: #23684a;
}

.token-comment,
.token-doctype {
  color: var(--ink-muted);
  font-style: italic;
}

#htmlSource {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  padding: var(--space-3);
  resize: none;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: transparent;
  caret-color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre;
  overflow-wrap: normal;
  outline: none;
}

#htmlSource:focus {
  box-shadow: inset 0 0 0 2px rgba(47, 95, 224, 0.48);
}

#htmlSource::placeholder {
  color: transparent;
}

#htmlSource::selection {
  background: rgba(47, 95, 224, 0.24);
  color: transparent;
}

.preview-panel {
  min-width: 0;
  min-height: 0;
  padding: var(--space-4);
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  background: var(--workbench);
}

.preview-stage {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  justify-content: center;
  overflow: auto;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-sm);
  background: var(--canvas);
}

#previewFrame {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-width: 0;
  border: 0;
  background: #fff;
}

#previewFrame.fixed-width {
  flex: 0 0 auto;
}

.inspector-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: var(--space-3);
  padding: var(--space-3);
  border-left: 1px solid var(--hairline);
  transition: opacity var(--motion-panel);
}

.inspector-body {
  min-height: 0;
  display: grid;
}

.property-groups,
.inspector-empty {
  grid-area: 1 / 1;
  min-height: 0;
}

.inspector-empty {
  display: grid;
  place-content: center;
  justify-items: center;
  padding: var(--space-5);
  text-align: center;
  color: var(--ink-muted);
}

.inspector-empty svg {
  margin-bottom: var(--space-4);
  color: #a9aba6;
}

.inspector-empty .empty-title {
  margin: 0 0 4px;
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 650;
}

.inspector-empty .empty-sub {
  max-width: 210px;
  margin: 0;
  color: var(--ink-muted);
  font-size: 11.5px;
  line-height: 1.55;
}

.inspector-head {
  align-items: flex-start;
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--hairline);
}

.selection-meta {
  min-width: 0;
}

.section-label {
  display: block;
  margin-bottom: 3px;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0;
  text-transform: uppercase;
}

#selectorLabel {
  margin: 0 0 var(--space-1);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

#dimensionLabel {
  margin: 0;
  color: var(--ink);
  font-size: 19px;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

#copyButton {
  flex: none;
}

.breadcrumb {
  min-height: 20px;
  display: flex;
  align-items: center;
  gap: 5px;
  overflow-x: auto;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  white-space: nowrap;
  scrollbar-width: none;
}

.breadcrumb::-webkit-scrollbar {
  display: none;
}

.breadcrumb span {
  cursor: pointer;
}

.breadcrumb span:hover {
  color: var(--signal);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.property-groups {
  min-width: 0;
  overflow: auto;
  scrollbar-gutter: stable;
}

.property-group {
  padding: var(--space-3) 0 var(--space-4);
  border-bottom: 1px solid var(--hairline);
}

.property-group:last-child {
  border-bottom: 0;
}

.group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}

.property-group h3 {
  margin: 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.copy-group {
  min-height: 22px;
  padding: 2px 5px;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--ink-muted);
  font-size: 11px;
}

.copy-group:hover {
  border: 0;
  background: rgba(23, 25, 27, 0.05);
  color: var(--ink);
}

.copy-group.copied,
.copy-value.copied {
  background: var(--success-tint);
  color: var(--success);
}

.property {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: var(--space-3);
  padding: 5px 0;
  align-items: start;
}

.property-name {
  padding-top: 2px;
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 1.3;
}

.property-name small {
  display: block;
  margin-top: 1px;
  color: #93989a;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0;
}

.property-value {
  width: 100%;
  min-width: 0;
  min-height: 0;
  padding: 2px 3px;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.45;
  text-align: left;
  font-variant-numeric: tabular-nums;
  cursor: copy;
  overflow-wrap: anywhere;
}

button.property-value:hover {
  background: var(--signal-tint);
  color: #184bc0;
}

.property-value.text-content {
  padding: 5px 6px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-xs);
  background: var(--surface-sunken);
  cursor: copy;
}

.property-value.text-content:hover {
  border-color: rgba(47, 95, 224, 0.4);
  background: var(--signal-tint);
}

.text-content-clamp {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  white-space: pre-wrap;
}

.color-chip {
  width: 10px;
  height: 10px;
  margin-right: 6px;
  display: inline-block;
  vertical-align: 0;
  border: 1px solid rgba(0, 0, 0, 0.22);
  border-radius: var(--radius-xs);
  background: transparent;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 2147483647;
  min-height: 30px;
  padding: 6px 11px;
  border: 1px solid var(--success);
  border-radius: var(--radius-xs);
  background: var(--success-tint);
  color: var(--success);
  font-size: 12px;
  transform: translate(-50%, 8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--motion), transform var(--motion);
}

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

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 99px;
  background: #c3c4bf;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background-color: #a3a49e;
}

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

  .workbench-bar {
    height: auto;
    padding: var(--space-3);
    align-items: flex-start;
    flex-direction: column;
    gap: var(--space-3);
  }

  .workspace {
    height: auto;
    display: block;
    transition: none;
  }

  .panel-resizer,
  .collapse-button {
    display: none;
  }

  .source-panel,
  .preview-panel,
  .inspector-panel {
    border: 0;
    border-bottom: 1px solid var(--hairline);
  }

  .source-panel {
    grid-template-rows: auto auto 360px;
  }

  .preview-stage {
    height: 540px;
  }

  .property-groups {
    overflow: visible;
  }
}

@media (prefers-reduced-motion: reduce) {
  button,
  #toast,
  .workspace,
  .collapse-button,
  .source-panel,
  .inspector-panel,
  .panel-resizer::after {
    transition: none;
  }

  button:active {
    transform: none;
  }
}
