:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-2: #eef2ef;
  --text: #17201b;
  --muted: #657169;
  --border: #d7ded8;
  --accent: #176b5b;
  --accent-2: #b9432f;
  --accent-3: #d6a039;
  --danger: #aa2f2f;
  --shadow: 0 10px 30px rgba(24, 38, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

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

.topbar,
.panelHeader,
.uploadToolbar,
.submitRow,
.topActions,
.filters,
.imageMeta,
.jobMeta,
.jobFooter {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.15;
}

h2 {
  font-size: 16px;
  line-height: 1.2;
}

#serverStatus {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

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

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.composer,
.sidePanel,
.jobsPanel {
  padding: 16px;
}

.jobsPanel {
  margin-top: 16px;
}

.panelHeader {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(2, 72px);
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: block;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.segmented input:checked + span {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 6px rgba(15, 30, 20, 0.1);
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

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

textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--text);
  outline: none;
}

textarea {
  min-height: 88px;
  padding: 10px 12px;
  resize: vertical;
}

select {
  height: 38px;
  padding: 0 10px;
}

textarea:focus,
select:focus,
.dropZone:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 107, 91, 0.14);
}

.gridFields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.dropZone {
  display: grid;
  place-items: center;
  min-height: 138px;
  border: 1.5px dashed #9fb0a6;
  border-radius: 8px;
  background: #f9fbf9;
  outline: none;
  cursor: pointer;
}

.dropZone.isDragging {
  border-color: var(--accent);
  background: #edf7f4;
}

.dropMain {
  font-size: 15px;
  font-weight: 700;
}

.dropSub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.uploadToolbar {
  justify-content: space-between;
  gap: 8px;
  margin: 12px 0;
}

.topActions,
.filters {
  gap: 8px;
  flex-wrap: wrap;
}

.primaryButton,
.textButton,
.ghostButton,
.iconButton,
.chip {
  min-height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
}

.primaryButton {
  min-width: 132px;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.textButton,
.ghostButton,
.chip {
  padding: 0 12px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ghostButton {
  color: var(--muted);
}

.iconButton {
  width: 34px;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  display: inline-grid;
  place-items: center;
}

.iconButton.small {
  width: 26px;
  min-height: 26px;
  border-radius: 6px;
  color: var(--danger);
}

.chip {
  min-height: 30px;
  color: var(--muted);
  font-size: 12px;
}

.chip.isActive {
  border-color: var(--accent);
  color: var(--accent);
  background: #edf7f4;
}

.primaryButton:disabled,
.textButton:disabled,
.ghostButton:disabled,
.iconButton:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.imageGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(144px, 1fr));
  gap: 10px;
}

.imageGrid.compact {
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  max-height: 520px;
  overflow: auto;
  padding-right: 2px;
}

.imageCard {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfb;
}

.imageCard img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--surface-2);
}

.imageMeta {
  justify-content: space-between;
  gap: 8px;
  padding: 7px 8px;
}

code {
  overflow: hidden;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.submitRow {
  justify-content: flex-start;
  gap: 12px;
  margin-top: 16px;
}

.inlineStatus {
  color: var(--muted);
  font-size: 13px;
}

.jobList {
  display: grid;
  gap: 10px;
}

.jobCard {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfb;
}

.jobMeta,
.jobFooter {
  justify-content: space-between;
  gap: 12px;
}

.jobMeta {
  margin-bottom: 8px;
}

.status {
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  background: var(--surface-2);
  color: var(--muted);
}

.status.pending {
  background: #fff3d8;
  color: #7a5200;
}

.status.running {
  background: #e8f1ff;
  color: #1b4e8a;
}

.status.completed {
  background: #e7f6ed;
  color: #18633b;
}

.status.failed {
  background: #fde9e7;
  color: #9a3025;
}

.jobPrompt {
  display: -webkit-box;
  overflow: hidden;
  margin-bottom: 10px;
  color: #2b342f;
  font-size: 13px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

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

.emptyState {
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 920px) {
  .shell {
    width: min(100vw - 20px, 760px);
    padding-top: 12px;
  }

  .topbar,
  .workspace {
    display: grid;
    grid-template-columns: 1fr;
  }

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

  .sidePanel {
    order: 2;
  }
}
