:root {
  color-scheme: dark;
  --root: #171a21;
  --panel: #202630;
  --elevated: #252c36;
  --border: #343c48;
  --hover: #667384;
  --text: #f3f6fb;
  --muted: #afbac8;
  --accent: #1686ff;
  --accent-dark: #1e477a;
  --success: #7fe39a;
  --warning: #f5c95c;
  --failure: #f06f6f;
  font: 15px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--root); color: var(--text); }
a { color: #8ec4ff; text-decoration: none; }
a:hover { color: white; }
.topbar { height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 max(24px, calc((100vw - 1080px)/2)); border-bottom: 1px solid var(--border); background: #171a21; }
.brand { color: var(--text); font-weight: 700; font-size: 17px; letter-spacing: .01em; }
.brand span { color: var(--muted); font-weight: 500; }
nav { display: flex; align-items: center; gap: 20px; }
nav form { margin: 0; }
.page { width: min(1080px, calc(100% - 40px)); margin: 42px auto 80px; }
.page.narrow { width: min(460px, calc(100% - 32px)); margin-top: 9vh; }
h1 { margin: 0 0 20px; font-size: clamp(26px, 4vw, 34px); line-height: 1.2; letter-spacing: -.025em; }
h2 { margin: 26px 0 12px; font-size: 18px; }
p { margin: 0 0 14px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-heading h1 { margin: 0; }
.eyebrow { margin: 0 0 8px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .13em; }
.muted, .hint, dt { color: var(--muted); }
.small { font-size: 12px; }
.panel { overflow: hidden; border: 1px solid var(--border); border-radius: 11px; background: var(--panel); box-shadow: 0 18px 50px rgba(0,0,0,.24); }
.auth-panel, .form-panel, .detail-panel { padding: 26px; }
.auth-panel h1 { margin-bottom: 8px; }
.stack { display: grid; gap: 10px; margin-top: 22px; }
label { color: var(--text); font-size: 13px; font-weight: 600; }
input, select { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--elevated); color: var(--text); font: inherit; outline: none; }
input[type=file] { min-height: 48px; padding: 8px; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(22,134,255,.18); }
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--elevated); color: var(--text); font: inherit; cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
button:hover, .button:hover { border-color: var(--hover); background: #333e4d; color: white; }
.primary { border-color: var(--accent); background: var(--accent-dark); color: var(--text); }
.primary:hover { border-color: var(--accent); background: #245995; }
.link-button { min-height: auto; padding: 0; border: 0; background: transparent; color: var(--muted); }
.link-button:hover { border: 0; background: transparent; color: white; }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 12px; }
.hint { margin: -4px 0 6px; font-size: 12px; }
.errorlist { margin: 0; padding: 0; color: var(--failure); list-style: none; font-size: 13px; }
.alert { padding: 11px 13px; border: 1px solid rgba(240,111,111,.35); border-radius: 8px; background: rgba(240,111,111,.1); color: #ff9a9a; }
.notice { padding: 12px 14px; border: 1px solid rgba(22,134,255,.28); border-radius: 8px; background: rgba(22,134,255,.09); color: #b8d9ff; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 13px 16px; border-bottom: 1px solid var(--border); text-align: left; }
th { background: var(--elevated); color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255,255,255,.025); }
.status { display: inline-flex; align-items: center; min-height: 25px; padding: 3px 9px; border: 1px solid var(--border); border-radius: 999px; background: var(--elevated); font-size: 12px; white-space: nowrap; }
.status-queued { color: var(--warning); }
.status-processing { color: #8ec4ff; border-color: rgba(22,134,255,.4); }
.status-done { color: var(--success); }
.status-error { color: var(--failure); }
.empty { padding: 56px 20px; text-align: center; }
.empty-icon { display: grid; width: 48px; height: 48px; margin: 0 auto 15px; place-items: center; border: 1px solid var(--border); border-radius: 12px; background: var(--elevated); color: var(--accent); font-size: 24px; }
.empty h2 { margin: 0 0 7px; }
.empty .button { margin-top: 12px; }
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin: 0; padding-bottom: 22px; border-bottom: 1px solid var(--border); }
.facts dt { margin-bottom: 3px; font-size: 12px; }
.facts dd { margin: 0; }
.result-list { margin: 0; padding: 0; list-style: none; }
.result-list li { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--border); overflow-wrap: anywhere; }
.small-button { min-height: 32px; padding: 5px 11px; font-size: 13px; }
.back-link { color: var(--muted); }
.workspace-heading { margin-bottom: 24px; }
.workspace-heading h1 { margin-bottom: 6px; }
.workspace-heading > div > p:last-child { margin: 0; }
.upload-panel { margin-bottom: 36px; }
.upload-form { display: grid; gap: 28px; padding: 26px; }
.media-fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.media-fieldset legend, .upload-label-row > label { margin-bottom: 12px; font-size: 15px; font-weight: 700; }
.media-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.media-tile { position: relative; display: flex; min-height: 104px; align-items: center; gap: 16px; padding: 18px; border: 1px solid var(--border); border-radius: 11px; background: var(--elevated); cursor: pointer; transition: border-color .15s, background .15s, box-shadow .15s; }
.media-tile:hover { border-color: #526176; background: #252c37; }
.media-tile:has(input:checked) { border-color: var(--accent); background: rgba(22,134,255,.12); box-shadow: 0 0 0 1px var(--accent); }
.media-tile:has(input:focus-visible) { outline: 3px solid rgba(22,134,255,.45); outline-offset: 2px; }
.media-tile input { position: absolute; width: 1px; min-height: 0; padding: 0; opacity: 0; }
.media-tile-icon { display: grid; width: 52px; height: 52px; flex: 0 0 52px; place-items: center; border-radius: 10px; background: #303a48; color: #a8cfff; font-size: 28px; }
.media-tile-copy { display: grid; gap: 3px; }
.media-tile-copy strong { font-size: 17px; }
.media-tile-copy small { color: var(--muted); font-size: 12px; font-weight: 400; }
.upload-section { display: grid; gap: 10px; }
.upload-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.upload-label-row > label { margin: 0; }
.file-input { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); }
.drop-zone { display: grid; min-height: 154px; align-content: center; justify-items: center; gap: 5px; border: 1px dashed #536275; border-radius: 10px; background: rgba(255,255,255,.018); cursor: pointer; }
.drop-zone:hover, .drop-zone.drag-over, .file-input:focus-visible + .drop-zone { border-color: var(--accent); background: rgba(22,134,255,.07); outline: none; }
.drop-icon { display: grid; width: 36px; height: 36px; margin-bottom: 4px; place-items: center; border-radius: 9px; background: rgba(22,134,255,.13); color: #a8cfff; font-size: 23px; }
.drop-zone strong { font-size: 14px; }
.drop-zone > span:last-child { font-size: 12px; }
.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
.preview-card { position: relative; overflow: hidden; min-width: 0; border: 1px solid var(--border); border-radius: 9px; background: var(--elevated); }
.preview-card img, .preview-card video { display: block; width: 100%; height: 100px; object-fit: cover; background: #0f1116; }
.preview-name { overflow: hidden; padding: 7px 9px; color: var(--text); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.remove-file { position: absolute; top: 6px; right: 6px; width: 27px; min-height: 27px; padding: 0; border-color: rgba(255,255,255,.28); border-radius: 50%; background: rgba(10,12,16,.8); color: white; font-size: 17px; line-height: 1; }
.preview-message { grid-column: 1 / -1; margin: 0; color: var(--failure); font-size: 13px; }
.upload-section .hint { margin: 0; }
.upload-footer { display: flex; align-items: end; justify-content: space-between; gap: 20px; padding-top: 20px; border-top: 1px solid var(--border); }
.copies-field { display: grid; min-width: min(100%, 300px); gap: 7px; }
.copies-field > label { font-size: 13px; }
.copies-control { display: flex; align-items: center; gap: 10px; }
.copies-control input { width: 84px; }
.submit-upload { min-height: 46px; padding: 10px 18px; }
.jobs-heading { display: flex; align-items: end; margin: 0 0 12px; }
.jobs-heading .eyebrow { margin-bottom: 2px; }
.jobs-heading h2 { margin: 0; font-size: 21px; }
.jobs-panel { min-height: 74px; }
.jobs-panel .empty { padding: 25px 20px; }
@media (max-width: 650px) {
  .upload-form { gap: 22px; padding: 19px; }
  .media-choices { gap: 9px; }
  .media-tile { min-height: 86px; gap: 10px; padding: 12px; }
  .media-tile-icon { width: 40px; height: 40px; flex-basis: 40px; font-size: 23px; }
  .media-tile-copy strong { font-size: 15px; }
  .upload-label-row { align-items: flex-start; flex-direction: column; gap: 3px; }
  .upload-footer { align-items: stretch; flex-direction: column; }
  .submit-upload { width: 100%; }
  .preview-grid { grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); }
}
@media (max-width: 650px) {
  .topbar { padding: 0 16px; }
  nav { gap: 12px; font-size: 13px; }
  .page { width: calc(100% - 24px); margin-top: 26px; }
  .page-heading { align-items: flex-start; }
  .page-heading .button { flex-shrink: 0; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth-panel, .form-panel, .detail-panel { padding: 19px; }
}
