:root {
  --bg: #0b0d12;
  --panel: #141821;
  --panel-2: #1b2030;
  --line: #262d3d;
  --text: #e6eaf2;
  --muted: #8b95ab;
  --accent: #4d9fff;
  --ok: #35d07f;
  --bad: #ff5f56;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 20% -10%, #182034 0%, var(--bg) 60%);
  color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button {
  font: inherit; color: var(--text); cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 14px;
  transition: background .15s, border-color .15s, opacity .15s;
}
button:hover:not(:disabled) { background: #232a3c; border-color: #34405a; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #04121f; font-weight: 600; }
button.primary:hover:not(:disabled) { background: #6bb0ff; border-color: #6bb0ff; }
.quiet { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
select, input {
  width: 100%; min-width: 0; max-width: 100%;
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
}
select:focus, input:focus { outline: 2px solid #2c5b96; outline-offset: 0; }
label { display: block; color: var(--muted); font-size: 12px; }
label select, label input { display: block; margin-top: 5px; }
h1, h2, p { margin: 0; }
h2 { font-size: 17px; }
.topbar {
  max-width: 1144px; margin: 24px auto 22px; padding-bottom: 18px;
  display: flex; align-items: center; gap: 14px;
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 19px; letter-spacing: .3px; }
.spacer { flex: 1; }
.tag {
  display: inline-block; font-size: 12px; font-weight: 400; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px;
  white-space: nowrap;
}
#workspace { max-width: 1180px; margin: 0 auto; padding: 0 18px 40px; }
.card {
  background: linear-gradient(180deg, var(--panel) 0%, #11151d 100%);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 18px;
}
.tools { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 18px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tool { font-size: 13px; padding: 7px 12px; }
.tool.active { background: #163254; border-color: #2c5b96; color: #a6cfff; }
.settings-grid { display: grid; grid-template-columns: minmax(190px, 1.5fr) repeat(3, minmax(110px, 1fr)); gap: 12px; }
.settings-grid.upscaling { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.details-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px; margin-top: 14px; }
details { min-width: 0; flex: 0 1 420px; font-size: 13px; color: var(--muted); }
summary { cursor: pointer; width: fit-content; }
.field-row { display: flex; gap: 12px; margin-top: 12px; }
.field-row label { flex: 1; min-width: 0; }
.help { margin-top: 10px; font-size: 12px; line-height: 1.6; }
.dropzone {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--panel-2); border: 1px dashed #3a4560; border-radius: 10px;
  padding: 18px; margin-top: 20px;
}
.dropzone.dragging { background: #163254; border-color: var(--accent); }
.dropzone h2 { font-size: 15px; font-weight: 500; }
.dropzone p { font-size: 12px; color: var(--muted); margin-top: 4px; }
.dropzone button { flex-shrink: 0; }
.formats-note { font-size: 12px; color: var(--muted); margin-top: 8px; }
.batch-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 18px; }
.batch-actions span { color: var(--muted); font-size: 12px; }
.section-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-line h2 { display: flex; align-items: center; gap: 8px; }
#local-section .section-line { margin-top: 20px; }
.file-list { display: flex; flex-direction: column; gap: 8px; }
.file-row {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); padding: 10px 12px;
}
.file-badge {
  flex: 0 0 40px; display: grid; place-items: center; height: 34px; overflow: hidden;
  background: #111723; border: 1px solid var(--line); border-radius: 6px;
  color: var(--muted); font-size: 10px; font-weight: 600; text-transform: uppercase;
}
.file-body { flex: 1; min-width: 0; }
.file-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { font-size: 12px; color: var(--muted); margin-top: 3px; overflow-wrap: anywhere; }
.file-meta.error { color: #ffb1ad; }
.file-meta.success { color: var(--ok); }
.file-arrow { color: var(--muted); }
.file-target { width: 94px; padding: 5px 8px; font-size: 13px; }
.row-action { padding: 4px 9px; font-size: 18px; line-height: 1.2; border-radius: 8px; color: var(--muted); }
.download { padding: 5px 10px; font-size: 13px; border: 1px solid #2c5b96; border-radius: 8px; background: #163254; white-space: nowrap; }
.download:hover { background: #1d3f68; text-decoration: none; }
.progress-track { height: 6px; border-radius: 999px; background: #0d111a; overflow: hidden; margin-top: 7px; }
.progress-fill { height: 100%; width: 0; border-radius: 999px; background: var(--accent); transition: width .4s; }
footer { font-size: 12px; color: var(--muted); }
.login-view { max-width: 380px; margin: 14vh auto; text-align: center; padding: 0 12px; }
.login-view .card { padding: 26px; }
.login-view h1 { font-size: 20px; margin-bottom: 6px; }
.login-view > .card > p { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.login-view label { text-align: left; }
.login-view input { margin-bottom: 12px; text-align: center; }
.login-view .primary { width: 100%; }
.error { min-height: 18px; color: #ffb1ad; font-size: 13px; margin-top: 10px; }
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #0f1520; border: 1px solid var(--line); border-radius: 12px; padding: 11px 16px;
  max-width: 90vw; box-shadow: 0 10px 30px rgba(0,0,0,.5); font-size: 13px;
}
@media (max-width: 1180px) { .topbar { margin-left: 18px; margin-right: 18px; } }
@media (max-width: 720px) { .settings-grid, .settings-grid.upscaling { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 460px) {
  .topbar { flex-wrap: wrap; gap: 10px; margin-top: 18px; padding-bottom: 14px; }
  .topbar h1 { flex: 1; }
  .topbar .spacer { display: none; }
  .topbar .tag { order: 3; flex-basis: 100%; width: fit-content; border: 0; padding: 0; }
  #workspace { padding: 0 12px 30px; }
  .topbar { margin-left: 12px; margin-right: 12px; }
  .card { padding: 14px; }
  .tools { gap: 6px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tool { padding: 7px 8px; }
  #upscale-tool { grid-column: span 2; }
  .dropzone { padding: 14px; align-items: flex-start; flex-direction: column; gap: 12px; }
  .dropzone button { align-self: flex-start; }
  .batch-actions { align-items: flex-end; }
  .batch-actions span { max-width: 155px; font-size: 11px; }
  .batch-actions .primary { font-size: 13px; padding: 8px 10px; }
  .file-row { gap: 8px; padding: 9px 8px; flex-wrap: wrap; }
  .file-badge { flex-basis: 32px; font-size: 9px; }
  .file-name { font-size: 12px; }
  .file-meta { font-size: 11px; }
  .file-target { width: 76px; font-size: 12px; }
  .file-arrow { display: none; }
  .download { font-size: 12px; padding: 5px 8px; }
  .row-action { padding: 4px 7px; }
  .section-line h2 { font-size: 15px; }
  .section-line .quiet { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
