:root {
  color-scheme: light;
  --paper: #f7f4ee;
  --ink: #22262a;
  --muted: #66707a;
  --line: #d6d0c7;
  --panel: #fffdfa;
  --teal: #177b76;
  --teal-deep: #0d504d;
  --coral: #d86149;
  --amber: #e2a941;
  --charcoal: #27313a;
  --shadow: 0 18px 48px rgba(33, 37, 41, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter, "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(23, 123, 118, 0.08), transparent 360px),
    var(--paper);
}

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

button {
  border: 0;
  cursor: pointer;
}

.shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  align-items: end;
  gap: 20px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
}

h2 {
  font-size: 24px;
}

.api-panel,
.panel {
  background: rgba(255, 253, 250, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.api-panel {
  padding: 14px;
}

.api-panel label,
.flow label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.api-row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #c9c1b5;
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
}

input,
select {
  min-height: 40px;
  padding: 0 10px;
}

textarea {
  resize: vertical;
  padding: 12px;
  line-height: 1.6;
}

.icon-btn,
.primary-btn,
.full-btn,
.quick-prompts button,
.tabs button,
.panel-title button,
.download-link {
  border-radius: 6px;
  font-weight: 800;
  transition:
    transform 0.16s ease,
    background 0.16s ease,
    border-color 0.16s ease;
}

.icon-btn {
  width: 72px;
  color: #fff;
  background: var(--charcoal);
}

.fine-print {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 460px) minmax(0, 1fr);
  gap: 20px;
  align-items: stretch;
}

.control-pane {
  display: grid;
  gap: 14px;
  align-content: start;
}

.panel {
  padding: 16px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  font-weight: 900;
}

.panel-title button {
  min-height: 34px;
  padding: 0 12px;
  color: var(--teal-deep);
  background: #e5f0ed;
}

.primary-btn {
  min-height: 38px;
  padding: 0 16px;
  color: #fff;
  background: var(--teal);
}

.quick-prompts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.quick-prompts button {
  min-height: 36px;
  padding: 0 8px;
  color: var(--charcoal);
  background: #f0e7d9;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.tab {
  min-height: 42px;
  color: var(--muted);
  background: #ede8e0;
  border: 1px solid transparent;
}

.tab.active {
  color: #fff;
  background: var(--charcoal);
}

.flow {
  display: none;
}

.flow.active {
  display: grid;
  gap: 14px;
}

.switch-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.switch-grid label {
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: #f6f1e8;
  border: 1px solid #e3d8c9;
  border-radius: 6px;
}

.switch-grid input {
  width: auto;
  min-height: auto;
}

.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.full-btn {
  min-height: 46px;
  padding: 0 14px;
  color: #fff;
  background: var(--teal);
}

.full-btn.secondary {
  color: var(--teal-deep);
  background: #dcece8;
}

.full-btn:disabled {
  cursor: not-allowed;
  color: #879098;
  background: #e4e2dc;
}

.catalog-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.catalog-card {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.catalog-card.active {
  border-color: var(--teal);
  box-shadow: inset 4px 0 0 var(--teal);
}

.catalog-icon {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--charcoal);
  font-size: 22px;
  font-weight: 900;
}

.catalog-card h3 {
  margin: 0 0 3px;
  font-size: 15px;
}

.catalog-card p,
.match-summary {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.catalog-card button {
  min-height: 34px;
  padding: 0 10px;
  color: var(--teal-deep);
  background: #e5f0ed;
  border-radius: 6px;
  font-weight: 800;
}

.slider-grid {
  display: grid;
  gap: 10px;
}

.slider-grid label {
  display: grid;
  grid-template-columns: 92px 1fr;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

input[type="range"] {
  accent-color: var(--teal);
}

.log-panel {
  max-height: 260px;
  overflow: hidden;
}

#statusLog {
  display: grid;
  gap: 8px;
  max-height: 190px;
  margin: 0;
  padding-left: 20px;
  overflow: auto;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.preview-pane {
  display: grid;
  grid-template-rows: auto minmax(420px, 1fr) auto;
  min-height: calc(100vh - 170px);
  overflow: hidden;
  background: #171d22;
  border: 1px solid #252d34;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.viewer-toolbar,
.handoff {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  color: #f7f4ee;
}

.viewer-toolbar {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.viewer-toolbar .eyebrow {
  color: #85d2c7;
}

.metric-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.metric-strip span {
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  color: #f7f4ee;
  background: rgba(255, 255, 255, 0.08);
  font-size: 12px;
  font-weight: 800;
}

.viewer {
  position: relative;
  min-height: 420px;
}

.viewer canvas {
  display: block;
}

.handoff {
  align-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: #20272d;
}

.handoff p {
  margin: 4px 0 0;
  color: #c5ccd2;
  font-size: 13px;
}

.download-link {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  color: #1a1e22;
  background: var(--amber);
  text-decoration: none;
  white-space: nowrap;
}

.hidden {
  display: none;
}

button:hover,
.download-link:hover {
  transform: translateY(-1px);
}

button:active,
.download-link:active {
  transform: translateY(0);
}

@media (max-width: 980px) {
  .topbar,
  .workspace {
    grid-template-columns: 1fr;
  }

  .preview-pane {
    min-height: 620px;
  }
}

@media (max-width: 620px) {
  .shell {
    width: min(100vw - 20px, 1480px);
    padding-top: 14px;
  }

  .quick-prompts,
  .two-cols,
  .switch-grid {
    grid-template-columns: 1fr;
  }

  .viewer-toolbar,
  .handoff {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-strip {
    justify-content: flex-start;
  }
}
