:root {
  color-scheme: light;
  --bg: #ead8c9;
  --surface: #fff8ef;
  --surface-strong: #fffdf8;
  --text: #2a173c;
  --muted: #7a6a75;
  --line: rgba(55, 28, 63, 0.14);
  --accent: #e52d5a;
  --accent-2: #ffb92e;
  --accent-3: #ee5b8c;
  --deep: #37184f;
  --shadow: 0 22px 54px rgba(70, 38, 52, 0.14);
}

body.dark {
  color-scheme: dark;
  --bg: #24152a;
  --surface: #2f1b39;
  --surface-strong: #3a2247;
  --text: #fff7ec;
  --muted: #d5c2cb;
  --line: rgba(255, 247, 236, 0.14);
  --accent: #f24c78;
  --accent-2: #ffc145;
  --accent-3: #ff79a2;
  --deep: #180c25;
  --shadow: 0 22px 54px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
}

body {
  min-width: 0;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

a {
  color: var(--accent);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 282px minmax(0, 1fr);
  border: 1px solid var(--line);
  background: var(--surface);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.78);
  display: flex;
  flex-direction: column;
  gap: 22px;
}

body.dark .sidebar {
  background: rgba(47, 27, 57, 0.92);
}

.brand {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-2);
  font-weight: 900;
  font-size: 25px;
  box-shadow: inset 0 0 0 12px rgba(255, 255, 255, 0.08);
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.18;
}

.brand p,
.sidebar-card p,
.panel-heading p,
.content-panel p,
.search-summary {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-btn,
.soft-btn,
.swatch-btn {
  border: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
}

.nav-btn {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 6px;
  background: transparent;
  text-align: left;
  font-weight: 800;
}

.nav-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff9f1;
  box-shadow: 0 10px 24px rgba(229, 45, 90, 0.22);
}

.sidebar-card {
  margin-top: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-strong);
}

.sidebar-card span {
  color: var(--muted);
  font-size: 13px;
}

.sidebar-card strong {
  display: block;
  margin-top: 4px;
  color: var(--deep);
  font-size: 30px;
}

body.dark .sidebar-card strong {
  color: var(--accent-2);
}

.workspace {
  min-width: 0;
  padding: clamp(16px, 2vw, 30px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-weight: 900;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar h2 {
  margin: 0;
  font-size: clamp(26px, 3vw, 40px);
  line-height: 1;
}

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

.soft-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 6px;
  background: var(--surface-strong);
  text-decoration: none;
  font-weight: 800;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.tool-grid {
  display: grid;
  gap: 16px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 248, 239, 0.92);
  box-shadow: var(--shadow);
}

body.dark .panel {
  background: rgba(47, 27, 57, 0.92);
}

.filters-panel,
.content-panel {
  padding: 18px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.panel-heading.compact {
  margin: 0;
  padding: 16px 18px 12px;
}

.panel-heading h3,
.content-panel h3 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.pill {
  white-space: nowrap;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(255, 185, 46, 0.22);
  color: var(--deep);
  font-weight: 900;
  font-size: 13px;
}

body.dark .pill {
  color: var(--text);
}

.filter-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(120px, 150px) minmax(120px, 150px);
  gap: 10px;
}

.text-input,
.select-input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: var(--surface-strong);
  color: var(--text);
}

.palette-layout {
  display: grid;
  grid-template-columns: minmax(240px, 340px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.palette-column {
  min-height: 0;
  max-height: calc(100vh - 180px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.palette-grid {
  min-height: 0;
  overflow: auto;
  padding: 0 14px 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 8px;
}

.swatch-btn {
  min-height: 76px;
  border-radius: 6px;
  padding: 7px;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 7px;
  background: var(--surface-strong);
  text-align: left;
}

.swatch-btn.is-active {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
}

.swatch-color {
  min-height: 32px;
  border-radius: 5px;
  border: 1px solid rgba(42, 23, 60, 0.22);
}

.swatch-meta {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  font-weight: 900;
}

.swatch-meta span:last-child {
  color: var(--muted);
  font-weight: 800;
}

.inspector {
  min-width: 0;
  padding: 14px;
}

.inspector-hero {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.big-swatch {
  width: 78px;
  height: 78px;
  border-radius: 6px;
  border: 1px solid rgba(42, 23, 60, 0.24);
}

.inspector h3 {
  margin: 0;
  font-size: 34px;
  line-height: 1;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.meta-item {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-strong);
}

.meta-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.meta-item strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  line-height: 1.3;
}

.position-image {
  display: block;
  width: 100%;
  max-width: 1280px;
  max-height: min(72vh, 720px);
  margin: 0 auto;
  object-fit: contain;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #9d7415;
}

.image-actions {
  display: grid;
  margin-top: 10px;
}

.image-actions a {
  justify-content: center;
}

.empty-state {
  min-height: 260px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 18px;
}

.content-panel {
  max-width: 980px;
}

.compare-grid {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.compare-controls,
.compare-table-panel {
  padding: 18px;
}

.compare-controls {
  position: sticky;
  top: 18px;
}

.compare-selects {
  display: grid;
  gap: 12px;
}

.select-card {
  display: grid;
  gap: 7px;
  font-weight: 900;
}

.select-card span {
  color: var(--muted);
  font-size: 13px;
}

.swap-btn {
  background: var(--accent-2);
  color: var(--deep);
}

.compare-swatches {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.compare-swatch-card {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-strong);
}

.compare-swatch {
  height: 58px;
  border-radius: 6px;
  border: 1px solid rgba(42, 23, 60, 0.25);
}

.compare-swatch-card strong,
.compare-swatch-card span {
  display: block;
}

.compare-swatch-card span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.compare-visual-panel {
  overflow: hidden;
}

.compare-canvas {
  display: block;
  width: 100%;
  height: auto;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface-strong);
}

.direction-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 14px;
}

.direction-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-strong);
}

.direction-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.direction-card strong {
  display: block;
  margin-top: 5px;
  line-height: 1.35;
}

.compare-table-panel {
  grid-column: 2;
}

.compare-table {
  display: grid;
  gap: 8px;
}

.compare-row {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1.2fr 1.2fr;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-strong);
}

.compare-row.head {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  background: transparent;
}

.compare-row strong {
  color: var(--accent);
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 16px 0 28px;
}

.steps > div {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-strong);
}

pre {
  overflow: auto;
  padding: 16px;
  border-radius: 6px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (min-width: 1680px) {
  .palette-layout {
    grid-template-columns: 360px minmax(0, 1fr);
  }

  .palette-grid {
    grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  }
}

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

  .sidebar {
    padding: 18px;
  }

  .palette-layout,
  .compare-grid {
    grid-template-columns: 1fr;
  }

  .palette-column {
    max-height: none;
  }

  .palette-grid {
    max-height: 300px;
  }

  .compare-controls {
    position: static;
  }

  .compare-table-panel {
    grid-column: auto;
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .nav-btn {
    text-align: center;
    padding: 0 8px;
  }

  .sidebar-card {
    display: none;
  }

  .filter-row,
  .steps {
    grid-template-columns: 1fr;
  }

  .meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .direction-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 620px) {
  .workspace {
    padding: 14px;
  }

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

  .topbar-actions {
    width: 100%;
  }

  .soft-btn {
    flex: 1;
  }

  .brand {
    grid-template-columns: 48px 1fr;
  }

  .brand-mark {
    width: 48px;
    height: 48px;
    font-size: 21px;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel-heading {
    flex-direction: column;
  }

  .palette-grid {
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    max-height: 260px;
  }

  .inspector-hero {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .big-swatch {
    width: 64px;
    height: 64px;
  }

  .meta-grid,
  .direction-grid,
  .compare-row {
    grid-template-columns: 1fr;
  }

  .position-image {
    max-height: none;
  }
}
