:root {
  color-scheme: dark;
  --bg: #111312;
  --panel: #181b19;
  --panel-2: #20231f;
  --line: #343932;
  --line-strong: #4a5148;
  --text: #ebece7;
  --muted: #a8ada3;
  --accent: #4c9b6f;
  --accent-strong: #67b884;
  --danger: #b94e4e;
  --danger-strong: #d36767;
  --warn: #d0a85c;
  --input: #101210;
  --focus: #8cc99f;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  height: 100vh;
  min-height: 640px;
}

.topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #141614;
}

.brand {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0;
}

.status-line {
  min-width: 0;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.controls {
  display: grid;
  grid-template-columns: auto minmax(360px, 1fr) auto;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.control-band {
  display: flex;
  align-items: end;
  gap: 8px;
  min-width: 0;
}

.settings-band {
  flex-wrap: wrap;
}

.action-band {
  justify-content: end;
  flex-wrap: wrap;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--text);
  background: #252923;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.button:hover {
  border-color: var(--focus);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.button.primary,
.button.accent {
  border-color: #3f7f5a;
  background: var(--accent);
  color: #07110b;
  font-weight: 700;
}

.button.primary:hover,
.button.accent:hover {
  background: var(--accent-strong);
}

.button.danger {
  border-color: #874141;
  background: var(--danger);
  color: #fff5f5;
}

.button.danger:hover {
  background: var(--danger-strong);
}

.button.secondary {
  background: #242821;
}

.button.compact {
  min-height: 30px;
  padding: 0 10px;
}

.field {
  display: grid;
  gap: 3px;
  min-width: 126px;
}

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

.field.wide {
  min-width: 240px;
  flex: 1 1 260px;
}

.field.tight {
  min-width: 94px;
}

.field.full {
  width: 100%;
}

input,
select {
  min-height: 34px;
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 6px 9px;
  background: var(--input);
  color: var(--text);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 2px rgba(140, 201, 159, 0.14);
}

input:disabled {
  color: var(--muted);
  opacity: 0.8;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding-bottom: 6px;
  white-space: nowrap;
}

.check input {
  width: 16px;
  height: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 380px);
  min-height: 0;
}

.table-wrap {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  border-right: 1px solid var(--line);
}

.image-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  table-layout: fixed;
}

.image-table th,
.image-table td {
  border-bottom: 1px solid var(--line);
  padding: 6px 8px;
  text-align: left;
  vertical-align: middle;
}

.image-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 34px;
  background: #1a1d1a;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.image-table tr {
  height: 44px;
}

.image-table tbody tr {
  background: #141714;
}

.image-table tbody tr:nth-child(even) {
  background: #171a16;
}

.image-table tbody tr.active {
  outline: 2px solid rgba(140, 201, 159, 0.4);
  outline-offset: -2px;
}

.image-table tbody tr:hover {
  background: #20241f;
}

.select-col {
  width: 42px;
}

.image-table th:nth-child(2) {
  width: 210px;
}

.image-table th:nth-child(3) {
  width: 155px;
}

.image-table th:nth-child(4) {
  width: 230px;
}

.image-table th:nth-child(5) {
  width: 260px;
}

.image-table th:nth-child(6) {
  width: 150px;
}

.image-table th:nth-child(7) {
  width: 145px;
}

.row-check {
  width: 16px;
  height: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.cell-input {
  min-height: 30px;
  padding: 4px 7px;
  border-color: transparent;
  background: #10120f;
}

.cell-input:hover,
.cell-input:focus {
  border-color: var(--focus);
}

.status-pill {
  display: inline-flex;
  max-width: 100%;
  min-height: 24px;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  background: #292e28;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill.proposed,
.status-pill.edited,
.status-pill.included_in_zip {
  color: #dff4e5;
  background: #254532;
}

.status-pill.describing,
.status-pill.uploading {
  color: #fff3cf;
  background: #4e4023;
}

.status-pill.error {
  color: #ffe3e3;
  background: #573030;
}

.empty {
  height: 120px;
  text-align: center;
  color: var(--muted);
}

.preview-pane {
  display: grid;
  grid-template-rows: minmax(240px, 1fr) auto auto auto;
  min-width: 0;
  min-height: 0;
  gap: 10px;
  padding: 10px;
  background: var(--panel-2);
}

.preview-frame {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 220px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0d0f0d;
}

.preview-frame img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.preview-frame.has-image img {
  display: block;
}

.preview-frame.has-image .preview-empty {
  display: none;
}

.preview-empty {
  color: var(--muted);
}

.preview-meta {
  min-height: 42px;
  display: grid;
  gap: 2px;
}

.preview-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

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

.edit-panel {
  display: grid;
  gap: 8px;
}

.full-button {
  width: 100%;
}

.problem-list {
  display: grid;
  gap: 5px;
  max-height: 120px;
  overflow: auto;
  color: #ffd8d8;
  font-size: 12px;
}

.problem-list div {
  padding: 6px 8px;
  border: 1px solid #6d3d3d;
  border-radius: 6px;
  background: #321f1f;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.login-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  background: #111312;
}

.login-panel {
  width: min(380px, calc(100vw - 32px));
  display: grid;
  gap: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.login-panel h1 {
  margin: 0;
  font-size: 24px;
}

.login-panel form {
  display: grid;
  gap: 14px;
}

.login-error {
  color: #ffd8d8;
}

@media (max-width: 1120px) {
  .controls {
    grid-template-columns: 1fr;
  }

  .action-band {
    justify-content: start;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(330px, 1fr) minmax(300px, 42vh);
  }

  .table-wrap {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .preview-pane {
    grid-template-columns: minmax(220px, 1fr) minmax(260px, 360px);
    grid-template-rows: minmax(220px, 1fr) auto;
  }

  .preview-frame {
    grid-row: 1 / 3;
  }
}

@media (max-width: 700px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .status-line {
    grid-column: 1 / 3;
  }

  .control-band,
  .settings-band,
  .action-band {
    align-items: stretch;
  }

  .button,
  .source-band label {
    flex: 1 1 auto;
  }

  .workspace {
    grid-template-rows: minmax(300px, 1fr) minmax(360px, 45vh);
  }

  .preview-pane {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(180px, 1fr) auto auto auto;
  }

  .preview-frame {
    grid-row: auto;
  }
}

