:root {
  color-scheme: dark;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #ededed;
  background: #141414;
  --card: #1f1f1f;
  --surface: #181818;
  --border: #2d2d2d;
  --strong-border: #3d3d3d;
  --muted: #aaa;
  --accent: #e11d48;
  --accent-hover: #f43f5e;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent-hover); outline-offset: 3px; }
body { margin: 0; }
main { width: min(100%, 1100px); margin: auto; padding: 40px 24px; }
h1, h2, p { margin: 0; }
h1 { font-size: 1.75rem; letter-spacing: -.03em; margin-top: 6px; }
h2 { font-size: 1.1rem; letter-spacing: -.02em; }
button, input, select { font: inherit; }

.page-header, .panel-heading, .queue-heading, .control-title, .toggle-row, .progress-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.page-header { margin-bottom: 22px; flex-wrap: wrap; }
.project { color: var(--muted); font-size: .85rem; text-underline-offset: 3px; }
.project:hover { color: #fff; }
.model-status, .muted { color: var(--muted); font-size: .82rem; }
.model-status.unavailable { color: #fb7185; }
.workspace { display: grid; grid-template-columns: 1.35fr 1fr; align-items: start; gap: 16px; }
.panel, dialog {
  min-width: 0;
  padding: 22px;
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 2px solid var(--accent);
}
.panel-heading { margin-bottom: 16px; }

.drop-zone {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 10px;
  min-height: 172px;
  padding: 16px;
  position: relative;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--strong-border);
  cursor: pointer;
}
.drop-zone:is(:hover, :focus-within, .dragging) { border-color: var(--accent-hover); background: #202020; }
.drop-zone input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.drop-zone input:disabled { cursor: wait; }
.drop-zone small, .fine-print, .hint, .range-labels { color: var(--muted); font-size: .78rem; line-height: 1.5; }
.upload-icon { font-size: 1.5rem; color: var(--muted); }
.queue-heading { margin: 16px 0 4px; }
.queue { list-style: none; padding: 0; margin: 0; max-height: 290px; overflow: auto; }
.queue li { display: flex; align-items: center; gap: 10px; padding: 6px 2px; border-bottom: 1px solid var(--border); }
.queue .empty { color: var(--muted); font-size: .85rem; padding: 14px 0; }
.file-name { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: .85rem; }
.file-size, .file-icon { color: var(--muted); font-size: .75rem; white-space: nowrap; }
.fine-print { margin-top: 14px; }

.button, .text-button, .remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  min-height: 36px;
  border: 1px solid var(--strong-border);
  color: #ededed;
  background: #252525;
  font-size: .85rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.button { min-height: 48px; }
:is(.secondary, .text-button, .remove):hover:not(:disabled) { background: #2e2e2e; border-color: #484848; color: #fff; }
:is(.button, .text-button, .remove):active:not(:disabled) { transform: scale(.985); }
:is(.button, .text-button, .remove):disabled { color: var(--muted); cursor: not-allowed; opacity: .55; }
.remove { padding: 0 10px; font-size: 1.05rem; }
.primary { width: 100%; margin-top: 16px; background: var(--accent); border-color: var(--accent-hover); color: #fff; }
.primary:hover:not(:disabled) { background: #be123c; }
.primary:disabled { background: #201a1c; border-color: #2e2226; }

fieldset { min-width: 0; padding: 0; margin: 0; border: 0; }
fieldset label, summary { font-size: .88rem; font-weight: 600; }
select { width: 100%; margin-top: 8px; padding: 10px; background: var(--surface); color: inherit; border: 1px solid var(--strong-border); }
.hint, .range-labels { margin-top: 6px; }
.advanced { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
summary { cursor: pointer; }
.control-title, .toggle-row { margin-top: 16px; }
output { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.range-labels { display: flex; justify-content: space-between; gap: 8px; }
input[type="range"], progress { width: 100%; margin: 8px 0 0; accent-color: var(--accent); }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
.toggle-row small { display: block; color: var(--muted); font-weight: 400; }
.progress-area { margin-top: 14px; }
.progress-title { font-size: .85rem; color: var(--muted); }
.progress-area button { margin-top: 6px; }

.results { margin-top: 16px; }
.result-heading { flex-wrap: wrap; }
.result-heading p { margin-top: 5px; }
.notice, .error { background: var(--surface); padding: 10px 12px; font-size: .85rem; line-height: 1.5; color: var(--muted); }
.error { margin-top: 12px; background: #221215; color: #fb7185; overflow-wrap: anywhere; }
.result-grid { list-style: none; padding: 0; margin: 14px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); gap: 12px; }
.result-grid:empty { display: none; }
.result-grid li { display: flex; flex-direction: column; gap: 7px; padding: 10px; border: 1px solid var(--strong-border); min-width: 0; }
.photo-preview { position: relative; width: 100%; padding: 0; border: 1px solid var(--border); background: var(--surface); aspect-ratio: 4 / 3; cursor: zoom-in; }
.photo-preview:hover { border-color: var(--accent-hover); }
.photo-preview img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.result-grid strong, #preview-title { overflow-wrap: anywhere; }
.result-grid span, .rejected-files { color: var(--muted); font-size: .8rem; overflow-wrap: anywhere; }
.result-grid .review { color: #fcd38a; }
.result-grid .button { margin-top: auto; min-height: 40px; }
dialog { width: min(960px, calc(100% - 24px)); color: inherit; }
dialog::backdrop { background: #000c; }
dialog img { display: block; max-width: 100%; max-height: 68vh; margin: 0 auto 12px; object-fit: contain; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.header-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.logout .button { min-height: 36px; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-panel { width: min(100%, 400px); padding: 26px; }
.login-form { display: grid; gap: 10px; margin-top: 22px; }
.login-form label { font-size: .88rem; font-weight: 600; }
.login-form input {
  min-width: 0;
  min-height: 48px;
  padding: 0 12px;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--strong-border);
}
.login-form .primary { margin-top: 6px; }
.login-error { margin-top: 0; }
.login-error:empty { display: none; }

@media (max-width: 680px) {
  main { padding: 24px 12px; }
  .workspace { grid-template-columns: 1fr; }
  .panel, dialog { padding: 16px; }
}
