:root {
  color-scheme: light;
  --bg: #f6f5ef;
  --ink: #1f2528;
  --muted: #667176;
  --line: #d8d8ce;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: #dff3ef;
  --warn: #9b5d00;
  --shadow: 0 18px 48px rgba(31, 37, 40, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

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

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 700;
}

button:hover:not(:disabled) {
  background: var(--accent-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

button.secondary:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.workspace {
  max-width: 1280px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 8px 0 22px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.03;
  letter-spacing: 0;
}

.topbar p {
  max-width: 680px;
  margin: 10px 0 0;
  color: var(--muted);
}

.runtime-pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.control-pane,
.image-pane {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.control-pane {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.field {
  display: grid;
  gap: 7px;
}

.selected-model {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfb;
}

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

.selected-model span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.selected-model strong,
.selected-model small {
  overflow-wrap: anywhere;
}

.selected-model strong {
  font-size: 15px;
}

.selected-model small {
  color: var(--muted);
  font-size: 12px;
}

.field span,
.custom-model summary {
  color: #3a4347;
  font-size: 13px;
  font-weight: 800;
}

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

.field input,
.field select {
  min-height: 42px;
  padding: 0 10px;
}

.field input[type="range"] {
  padding: 0;
}

.model-meta {
  display: grid;
  gap: 8px;
  border-left: 3px solid var(--accent);
  padding: 2px 0 2px 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.custom-model {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.custom-model summary {
  cursor: pointer;
}

.custom-model[open] {
  display: grid;
  gap: 12px;
}

.button-row,
.action-strip,
.result-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.button-row button {
  flex: 1;
}

progress {
  width: 100%;
  height: 10px;
  accent-color: var(--accent);
}

.status-line,
#inferenceStatus {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.image-pane {
  padding: 18px;
}

.drop-zone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 430px;
  border: 1px dashed #aab4b8;
  border-radius: 8px;
  background: #fafafa;
  overflow: hidden;
}

.drop-zone.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}

#imageInput {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

#previewCanvas {
  width: min(448px, 92vw);
  max-width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  background: white;
}

.drop-copy {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 4px;
  width: min(92%, 460px);
  padding: 10px 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--muted);
  text-align: center;
  pointer-events: none;
}

.drop-copy strong {
  color: var(--ink);
}

.action-strip {
  justify-content: space-between;
  margin: 16px 0;
}

.results {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.result-head {
  justify-content: space-between;
}

.result-head h2 {
  margin: 0;
  font-size: 20px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 46px;
  margin: 14px 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: #fff;
  font-size: 13px;
}

.tag b {
  color: var(--accent-strong);
}

textarea {
  min-height: 130px;
  resize: vertical;
  padding: 12px;
  line-height: 1.45;
}

.model-dialog {
  width: min(960px, calc(100vw - 28px));
  max-height: min(760px, calc(100vh - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
}

.model-dialog::backdrop {
  background: rgba(20, 27, 30, 0.48);
}

.dialog-surface {
  display: grid;
  gap: 18px;
  max-height: inherit;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.dialog-head,
.dialog-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.dialog-head h2 {
  margin: 0;
  font-size: 24px;
}

.dialog-head p {
  margin: 5px 0 0;
  color: var(--muted);
}

.picker-grid {
  display: grid;
  grid-template-columns: minmax(250px, 0.9fr) minmax(280px, 1.1fr);
  gap: 16px;
}

.picker-grid h3 {
  margin: 0 0 10px;
  color: #3a4347;
  font-size: 13px;
  text-transform: uppercase;
}

.family-list,
.variant-list {
  display: grid;
  gap: 10px;
}

.family-card,
.variant-card {
  display: grid;
  gap: 7px;
  width: 100%;
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.family-card:hover,
.variant-card:hover,
.family-card.active,
.variant-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.family-card strong,
.variant-card strong {
  font-size: 15px;
}

.family-card span,
.variant-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.card-meta b {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 7px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--accent-strong);
  font-size: 11px;
}

.dialog-actions {
  align-items: center;
  justify-content: flex-end;
}

@media (max-width: 860px) {
  .app-shell {
    padding: 16px;
  }

  .topbar,
  .layout,
  .action-strip {
    display: grid;
  }

  .runtime-pill {
    justify-self: start;
  }

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

  .drop-zone {
    min-height: 360px;
  }

  .picker-grid,
  .dialog-head,
  .dialog-actions {
    display: grid;
  }

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