@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

:root {
  --bg: #0c0f14;
  --bg-2: #12151d;
  --surface: rgba(18, 22, 31, 0.72);
  --surface-strong: rgba(23, 28, 39, 0.92);
  --surface-soft: rgba(255, 255, 255, 0.055);
  --ink: #f8fafc;
  --muted: #9aa4b2;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.16);
  --accent: #ea580c;
  --accent-2: #2563eb;
  --run: #22c55e;
  --gold: #f59e0b;
  --bad: #ef4444;
  --code: #e5edf7;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.38);
  --shadow-soft: 0 16px 42px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% 12%, rgba(234, 88, 12, 0.18), transparent 28%),
    radial-gradient(circle at 86% 4%, rgba(37, 99, 235, 0.22), transparent 30%),
    radial-gradient(circle at 65% 96%, rgba(34, 197, 94, 0.12), transparent 34%),
    linear-gradient(180deg, #0a0d12 0%, #10131b 48%, #0c0f14 100%);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.72), transparent 82%);
}

svg {
  display: block;
}

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

button {
  cursor: pointer;
  touch-action: manipulation;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease,
    color 180ms ease,
    box-shadow 180ms ease,
    filter 180ms ease;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(234, 88, 12, 0.5);
  outline-offset: 2px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  min-height: 80px;
  padding: 14px max(20px, calc((100vw - 1520px) / 2 + 28px));
  border-bottom: 1px solid var(--line);
  background: rgba(8, 11, 16, 0.82);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(22px) saturate(140%);
}

.brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  color: #fff;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(234, 88, 12, 0.94), rgba(37, 99, 235, 0.86)),
    rgba(255, 255, 255, 0.1);
  color: #fff;
  box-shadow: 0 18px 42px rgba(234, 88, 12, 0.2);
  transition:
    transform 180ms ease,
    box-shadow 180ms ease;
}

.brand:hover .brand-mark {
  transform: translateY(-1px) scale(1.03);
  box-shadow: 0 22px 54px rgba(37, 99, 235, 0.26);
}

.brand-mark svg {
  width: 28px;
  height: 28px;
}

.brand-mark path {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.brand-text {
  font-size: 24px;
  font-weight: 800;
}

.search {
  display: flex;
  flex: 1;
  max-width: 560px;
  min-width: 220px;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  padding: 0 13px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 12px 32px rgba(0, 0, 0, 0.18);
}

.search svg {
  width: 20px;
  height: 20px;
}

.search path {
  fill: none;
  stroke: rgba(255, 255, 255, 0.68);
  stroke-linecap: round;
  stroke-width: 2;
}

.search input {
  width: 100%;
  min-height: 46px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #fff;
}

.search input::placeholder {
  color: rgba(255, 255, 255, 0.56);
}

.layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  gap: 22px;
  width: min(1520px, 100%);
  margin: 0 auto;
  padding: 24px 28px 34px;
}

.sidebar {
  position: sticky;
  top: 104px;
  align-self: start;
  max-height: calc(100dvh - 128px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(24, 29, 40, 0.86), rgba(13, 17, 25, 0.88)),
    rgba(255, 255, 255, 0.04);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(22px) saturate(135%);
}

.category-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.category-button {
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  color: rgba(255, 255, 255, 0.72);
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.category-button:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}

.category-button.active {
  border-color: rgba(234, 88, 12, 0.8);
  background: linear-gradient(135deg, rgba(234, 88, 12, 0.92), rgba(37, 99, 235, 0.78));
  color: #fff;
  box-shadow: 0 16px 32px rgba(234, 88, 12, 0.18);
}

.tool-nav {
  display: grid;
  gap: 5px;
  padding: 10px;
}

.tool-link {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  padding: 6px 9px;
  text-align: left;
}

.tool-link:hover {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  transform: translateX(2px);
}

.tool-link.active {
  border-color: rgba(245, 158, 11, 0.24);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--gold);
}

.tool-icon {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #fbbf24;
  font-size: 12px;
  font-weight: 800;
}

.workspace {
  min-width: 0;
}

.workbench {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(23, 28, 39, 0.92), rgba(14, 18, 27, 0.9)),
    rgba(255, 255, 255, 0.04);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(135%);
}

.tool-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0;
  padding: 24px 26px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(234, 88, 12, 0.13), transparent 38%),
    linear-gradient(90deg, rgba(37, 99, 235, 0.11), transparent 46%),
    rgba(255, 255, 255, 0.02);
}

.eyebrow {
  margin: 0 0 7px;
  color: #fb923c;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.tool-titlebar h1 {
  margin: 0;
  color: #fff;
  font-size: clamp(28px, 3.1vw, 42px);
  font-weight: 800;
  line-height: 1.06;
}

.title-actions {
  display: flex;
  gap: 10px;
}

.icon-button {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.075);
  color: #f8fafc;
  box-shadow: var(--shadow-soft);
}

.icon-button:hover {
  border-color: rgba(234, 88, 12, 0.72);
  background: rgba(234, 88, 12, 0.14);
  color: #fff;
  transform: translateY(-1px);
}

.icon-button svg {
  width: 21px;
  height: 21px;
}

.icon-button path {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.tool-host {
  min-height: 604px;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0;
}

.tool-grid.three {
  grid-template-columns: minmax(0, 0.88fr) minmax(0, 1.12fr);
}

.tool-pane {
  min-width: 0;
  padding: 24px;
  background: rgba(255, 255, 255, 0.028);
}

.tool-pane:first-child {
  border-right: 1px solid var(--line);
}

.tool-pane.full {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  border-right: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.02)),
    rgba(255, 255, 255, 0.02);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 0;
}

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

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}

.field {
  display: grid;
  gap: 7px;
  min-width: 150px;
}

.field.wide {
  flex: 1 1 280px;
}

.field label,
.editor-label {
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 700;
}

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025)),
    rgba(7, 10, 15, 0.62);
  color: var(--ink);
  outline: 0;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 10px 28px rgba(0, 0, 0, 0.16);
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease;
}

.input,
.select {
  min-height: 46px;
  padding: 9px 12px;
}

.select option {
  color: #111827;
  background: #fff;
}

.textarea {
  min-height: 340px;
  resize: vertical;
  padding: 16px;
  color: var(--code);
  font-family: Consolas, "SFMono-Regular", "Courier New", monospace;
  font-size: 14px;
  line-height: 1.6;
}

.textarea.short {
  min-height: 170px;
}

.textarea.medium {
  min-height: 245px;
}

.textarea[readonly] {
  background:
    linear-gradient(180deg, rgba(37, 99, 235, 0.08), rgba(255, 255, 255, 0.025)),
    rgba(7, 10, 15, 0.56);
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: rgba(234, 88, 12, 0.84);
  box-shadow:
    0 0 0 4px rgba(234, 88, 12, 0.13),
    0 16px 34px rgba(0, 0, 0, 0.24);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  border: 1px solid rgba(234, 88, 12, 0.68);
  border-radius: 8px;
  background: linear-gradient(135deg, #ea580c, #f97316);
  color: #fff;
  padding: 10px 16px;
  font-weight: 800;
  box-shadow: 0 16px 34px rgba(234, 88, 12, 0.22);
}

.button.secondary {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.075);
  color: #f8fafc;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
}

.button.warn {
  border-color: rgba(239, 68, 68, 0.68);
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

.button:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.055);
}

.segmented button {
  min-height: 42px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: #f8fafc;
  padding: 8px 12px;
}

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

.segmented button.active {
  background: linear-gradient(135deg, #ea580c, #f97316);
  color: #fff;
}

.checkbox {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  min-height: 44px;
  color: #cbd5e1;
  font-weight: 650;
}

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

.result-box {
  min-height: 44px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025)),
    rgba(7, 10, 15, 0.56);
  color: var(--code);
  padding: 13px;
  line-height: 1.6;
}

.result-box.code,
pre.code {
  color: var(--code);
  font-family: Consolas, "SFMono-Regular", "Courier New", monospace;
  font-size: 13px;
  white-space: pre-wrap;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
  gap: 10px;
}

.metrics.compact {
  margin: 14px 0;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
}

.metric {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.03)),
    rgba(255, 255, 255, 0.035);
  padding: 13px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.metric strong {
  display: block;
  margin-top: 4px;
  color: #fff;
  font-size: 24px;
}

.tree {
  max-height: 560px;
  overflow: auto;
  font-family: Consolas, "SFMono-Regular", "Courier New", monospace;
  font-size: 13px;
}

.tree details {
  padding-left: 16px;
}

.tree summary {
  cursor: pointer;
}

.diff-line {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 10px;
  padding: 2px 8px;
  border-left: 3px solid transparent;
  font-family: Consolas, "SFMono-Regular", "Courier New", monospace;
  font-size: 13px;
}

.diff-line.add {
  border-left-color: var(--run);
  background: rgba(34, 197, 94, 0.12);
}

.diff-line.remove {
  border-left-color: var(--bad);
  background: rgba(239, 68, 68, 0.12);
}

.diff-line.same {
  color: var(--muted);
}

.diff-table {
  display: grid;
  gap: 10px;
  max-height: 430px;
}

.diff-card {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) 82px minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  padding: 10px;
}

.diff-card.add {
  border-left-color: var(--run);
}

.diff-card.remove {
  border-left-color: var(--bad);
}

.diff-card.change {
  border-left-color: var(--gold);
}

.diff-card strong {
  overflow-wrap: anywhere;
  color: #fff;
  font-family: Consolas, "SFMono-Regular", "Courier New", monospace;
  font-size: 13px;
}

.diff-card span {
  display: inline-grid;
  min-height: 28px;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 800;
}

.diff-card code {
  min-height: 38px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 10, 15, 0.5);
  padding: 8px;
  color: var(--code);
  font-family: Consolas, "SFMono-Regular", "Courier New", monospace;
  font-size: 12px;
  white-space: pre-wrap;
}

.empty-state {
  display: grid;
  min-height: 120px;
  place-items: center;
  color: var(--muted);
  font-weight: 750;
}

.swatch {
  width: 100%;
  min-height: 160px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}

.preview-stage {
  display: grid;
  min-height: 260px;
  place-items: center;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.055) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.055) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.055) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.055) 75%);
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

.shadow-sample {
  width: min(260px, 72%);
  aspect-ratio: 1.45;
  border-radius: 8px;
  background: #fff;
}

.flex-canvas {
  display: flex;
  gap: 10px;
  min-height: 240px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(7, 10, 15, 0.44);
  padding: 14px;
}

.flex-item {
  display: grid;
  min-width: 54px;
  min-height: 54px;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #ea580c, #2563eb);
  color: #fff;
  font-weight: 800;
}

.image-preview {
  max-width: 100%;
  max-height: 340px;
  border-radius: 8px;
}

.toast {
  min-height: 22px;
  margin: 14px 2px 0;
  color: #cbd5e1;
  font-size: 14px;
}

.toast.error {
  color: #fecaca;
  font-weight: 700;
}

.hidden {
  display: none !important;
}

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

@media (max-width: 1080px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .sidebar {
    position: static;
    max-height: none;
  }

  .category-nav {
    display: flex;
    overflow: auto;
  }

  .category-button {
    flex: 0 0 auto;
    min-width: 78px;
  }

  .tool-nav {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .layout {
    padding: 14px;
  }

  .tool-titlebar {
    align-items: flex-start;
    flex-direction: column;
    padding: 22px;
  }

  .tool-grid,
  .tool-grid.three {
    grid-template-columns: 1fr;
  }

  .tool-pane:first-child {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .tool-pane {
    padding: 18px;
  }

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