:root {
  color-scheme: light;
  --ink: #1e211d;
  --muted: #6b7067;
  --paper: #f4f1e8;
  --panel: #fffcf2;
  --line: #d9d1c0;
  --accent: #e6512f;
  --accent-2: #1f8f7a;
  --field: #ece5d7;
  --shadow: 0 18px 55px rgba(54, 45, 31, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(31, 143, 122, 0.08), transparent 36%),
    repeating-linear-gradient(0deg, rgba(30, 33, 29, 0.035) 0 1px, transparent 1px 28px),
    var(--paper);
  color: var(--ink);
  font-family: "Segoe UI", "Malgun Gothic", sans-serif;
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.shell {
  display: grid;
  grid-template-columns: minmax(330px, 390px) minmax(0, 1fr);
  height: 100%;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px 20px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel), white 12%);
  overflow: auto;
}

.version-badge {
  margin-top: auto;
  padding-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 56px;
}

.mark {
  width: 42px;
  height: 42px;
  background:
    linear-gradient(45deg, transparent 0 42%, var(--accent) 42% 58%, transparent 58%),
    linear-gradient(135deg, #151515 0 45%, #f6f1e6 45% 56%, #f59b31 56%);
  border: 1px solid #1e211d;
  transform: rotate(-8deg);
}

h1,
h2,
p {
  margin: 0;
}

.brand h1 {
  font-size: 25px;
  line-height: 1;
  letter-spacing: 0;
}

.brand p,
#modelKicker,
.notes span {
  color: var(--muted);
  font-size: 13px;
}

.dropzone {
  display: grid;
  gap: 7px;
  padding: 16px;
  border: 1px dashed color-mix(in srgb, var(--accent), black 18%);
  background: color-mix(in srgb, var(--accent), white 91%);
}

.dropzone input {
  display: none;
}

.dropzone span {
  color: var(--accent);
  font-weight: 700;
}

.dropzone strong {
  font-size: 14px;
  overflow-wrap: anywhere;
}

.actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 10px;
}

.primary,
.ghost,
.download,
.view-tools button {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--panel);
  transition: transform 140ms ease, background 140ms ease;
}

.primary:hover,
.download:hover,
.view-tools button:hover {
  transform: translateY(-1px);
  background: #30362f;
}

.ghost {
  background: transparent;
  color: var(--ink);
}

.status-strip {
  min-height: 34px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-left: 4px solid var(--accent-2);
  background: color-mix(in srgb, var(--accent-2), white 88%);
  color: #0e5145;
  font-size: 13px;
  font-weight: 700;
}

.status-strip.error {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent), white 88%);
  color: #7a1f10;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  border: 1px solid var(--line);
}

.metric {
  padding: 12px;
  min-width: 0;
}

.metric:nth-child(odd) {
  border-right: 1px solid var(--line);
}

.metric:nth-child(n + 3) {
  border-top: 1px solid var(--line);
}

.metric strong {
  display: block;
  font-size: 21px;
}

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

.controls,
.settings {
  display: grid;
  gap: 10px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

h2 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.text-button {
  background: transparent;
  color: var(--accent-2);
  font-weight: 700;
}

.color-list,
.component-list {
  display: grid;
  gap: 7px;
}

.component-list {
  max-height: 275px;
  overflow: auto;
  padding-right: 2px;
}

.color-row,
.component-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.34);
}

.color-row.readonly {
  cursor: default;
}

.color-row.active,
.component-row.active {
  border-color: var(--ink);
  background: #fff8df;
}

.swatch {
  width: 22px;
  height: 22px;
  border: 1px solid rgba(0, 0, 0, 0.25);
}

.row-main {
  min-width: 0;
}

.row-main strong {
  display: block;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-main span,
.row-count {
  color: var(--muted);
  font-size: 12px;
}

.empty-selection {
  min-height: 68px;
  display: flex;
  align-items: center;
  padding: 12px;
  border: 1px dashed var(--line);
  color: var(--muted);
  font-size: 13px;
}

.settings label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.settings input,
.settings select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--ink);
  padding: 0 10px;
}

.readout {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.34);
}

.readout strong {
  font-size: 13px;
}

.readout span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.download-pair {
  display: grid;
  gap: 8px;
}

.download {
  width: 100%;
  margin-top: 4px;
  background: var(--accent);
  border-color: #a9351d;
}

.download.secondary {
  background: var(--ink);
  border-color: var(--ink);
}

.download:disabled,
.text-button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 28px 16px;
  border-bottom: 1px solid var(--line);
}

#modelTitle {
  margin-top: 3px;
  font-size: clamp(24px, 3vw, 40px);
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.view-tools {
  display: flex;
  gap: 8px;
  align-items: center;
}

.view-tools button {
  min-width: 58px;
  background: transparent;
  color: var(--ink);
}

.viewer {
  position: relative;
  min-width: 0;
  min-height: 0;
}

.viewer.can-pick canvas {
  cursor: pointer;
}

.viewer canvas {
  display: block;
}

.hover-badge {
  position: absolute;
  z-index: 3;
  max-width: min(280px, calc(100% - 28px));
  padding: 8px 10px;
  border: 1px solid var(--ink);
  background: color-mix(in srgb, var(--panel), white 8%);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.hover-badge.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.split-action {
  position: absolute;
  right: 22px;
  bottom: 22px;
  z-index: 4;
  min-width: 118px;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid #a9351d;
  background: var(--accent);
  color: var(--panel);
  font-weight: 800;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.split-action.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.split-action:hover {
  transform: translateY(-1px);
  background: #d94627;
}

.notes {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 18px;
  padding: 14px 28px 20px;
  border-top: 1px solid var(--line);
}

.notes div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.notes strong {
  font-size: 12px;
  text-transform: uppercase;
}

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

  .shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100%;
  }

  .panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: none;
  }

  .stage {
    min-height: 72vh;
  }

  .topbar,
  .notes {
    padding-inline: 18px;
  }

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