:root {
  color-scheme: dark;
  --ink: #08090b;
  --panel: #101115;
  --cream: #e7e3d8;
  --muted: #aaa79f;
  --line: #34333a;
  --mint: #9de3c2;
  --violet: #a78bfa;
  --gutter: clamp(20px, 4vw, 64px);
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--ink); color: var(--cream); font: 1rem/1.55 "DM Sans", system-ui, sans-serif; }
main, footer { width: min(100%, 1264px); margin: 0 auto; padding-inline: var(--gutter); }
main { padding-block: clamp(18px, 2.6vw, 34px) 48px; }
footer { display: flex; flex-wrap: wrap; gap: 8px 20px; padding-bottom: 28px; color: var(--muted); font-size: .875rem; }
h1, h2, h3, p, figure, fieldset { margin: 0; }
h1 { font-size: clamp(1.9rem, 3.2vw, 2.6rem); font-weight: 300; letter-spacing: -.05em; line-height: 1.05; margin-bottom: 4px; }
h2 { font-size: 1.55rem; font-weight: 500; letter-spacing: -.035em; line-height: 1.2; }
h3 { font-size: 1rem; font-weight: 500; }
a { color: inherit; text-underline-offset: .2em; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 2px solid var(--violet); outline-offset: 4px; }
.intro { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.intro > div > p { color: var(--muted); }
.account { flex-shrink: 0; }
.account-row { display: flex; align-items: center; gap: 14px; }
.account-menu { position: relative; }
.account-menu summary { max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .875rem; color: var(--muted); cursor: pointer; list-style: none; }
.account-menu summary::-webkit-details-marker { display: none; }
.account-menu summary::after { content: " \25BE"; }
.account-menu-body { position: absolute; right: 0; top: calc(100% + 8px); z-index: 5; display: grid; gap: 6px; justify-items: start; padding: 10px 14px; border: 1px solid var(--line); background: var(--panel); white-space: nowrap; }
.balance { color: var(--mint); font: 1rem/1.6 var(--mono); }
.text-button { color: var(--cream); padding: 2px 0; border: 0; background: none; text-decoration: underline; text-underline-offset: .2em; font-size: .875rem; }
.button, .offer button { display: inline-block; padding: 10px 15px; border: 1px solid var(--line); border-radius: 3px; background: transparent; color: var(--cream); text-decoration: none; font-size: .875rem; white-space: nowrap; }
.button:hover, .offer button:hover:enabled { border-color: var(--mint); color: var(--mint); }
.button.primary { border-color: var(--mint); background: var(--mint); color: var(--ink); font-weight: 500; }
.button.primary:hover:enabled { background: #c5f1dc; }
.notice { border-left: 2px solid var(--violet); padding: 9px 13px; margin-top: 20px; background: var(--panel); overflow-wrap: anywhere; }
.notice.error { border-color: #efa5a5; }
.workspace { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(330px, 1fr); gap: 22px; margin-top: 22px; align-items: start; }
.stage { display: grid; gap: 12px; min-width: 0; }
.settings { display: grid; gap: 16px; padding: clamp(16px, 2vw, 22px); background: var(--panel); border: 1px solid var(--line); min-width: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); padding: clamp(17px, 3vw, 30px); }
.drop-zone { position: relative; display: grid; justify-items: center; align-content: center; gap: 10px; min-height: clamp(240px, 56vh, 540px); margin: 0; padding: 14px; border: 1px dashed #706778; background: var(--panel); color: var(--cream); text-align: center; cursor: pointer; overflow-wrap: anywhere; }
.drop-zone:hover, .drop-zone:focus-within, .drop-zone.dragging { border-color: var(--violet); background: #1a1624; }
.drop-zone input { position: absolute; inline-size: 1px; block-size: 1px; clip-path: inset(50%); overflow: hidden; }
.muted, small, .offer p { color: var(--muted); font-size: .875rem; }
.drop-empty { display: grid; justify-items: center; gap: 10px; }
.file-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; font-size: .875rem; }
.file-row .change { color: var(--violet); text-decoration: underline; text-underline-offset: .2em; }
fieldset { display: grid; gap: 6px; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 6px; }
#upload-help { font-size: .8rem; }
.offer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-block: 13px; border-bottom: 1px solid var(--line); }
.offer:last-child { padding-bottom: 0; border-bottom: 0; }
.membership button { border-color: #567f6b; color: var(--mint); }
.jobs { margin-top: 35px; }
.jobs-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 18px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
#jobs-empty { margin-top: 14px; }
#jobs-list { padding: 0; list-style: none; }
#jobs-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 18px; margin: 18px 0 0; }
.job { display: grid; align-content: start; background: var(--panel); border: 1px solid var(--line); }
.job-image { position: relative; display: grid; place-items: center; aspect-ratio: 4 / 3; overflow: hidden; background: #0c0d10; border-bottom: 1px solid var(--line); }
.job-image > img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; }
.job-image > img.pending { opacity: .45; filter: saturate(.5); }
.job-original { position: absolute; left: 10px; bottom: 10px; width: 64px; height: 48px; border: 1px solid var(--line); background: var(--ink); }
.job-original img { display: block; width: 100%; height: 100%; object-fit: cover; }
.job-heading { display: grid; gap: 2px; padding: 12px 14px 0; }
.job-heading h3 { font-size: .95rem; }
.job-actions { padding: 12px 14px 14px; }
.job-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; font-size: .85rem; }
.job-state { font: .8rem var(--mono); color: var(--violet); }
.job[data-status="done"] .job-state { color: var(--mint); }
.job[data-status="failed"] .job-state { color: #efa5a5; }
#file-preview { display: block; max-width: 100%; max-height: clamp(200px, 50vh, 480px); object-fit: contain; }
.drop-zone.has-file { min-height: 0; }
.progress-card { display: flex; gap: 14px; align-items: center; padding: 12px; border: 1px solid var(--line); background: #15141a; }
.progress-thumb { position: relative; flex: 0 0 96px; height: 96px; overflow: hidden; border: 1px solid var(--line); background: var(--ink); }
.progress-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.progress-card[data-state="working"] .progress-thumb img { filter: saturate(.6) blur(1px); }
.shimmer { position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(167,139,250,.35) 50%, transparent 70%); background-size: 250% 100%; animation: shimmer 1.6s linear infinite; }
.progress-card:not([data-state="working"]) .shimmer { display: none; }
.progress-body { display: grid; gap: 4px; min-width: 0; flex: 1; }
.bar { height: 3px; background: var(--line); overflow: hidden; margin-top: 4px; }
.bar span { display: block; height: 100%; width: 35%; background: var(--violet); animation: slide 1.4s ease-in-out infinite; }
.progress-card:not([data-state="working"]) .bar { display: none; }
.progress-card[data-state="failed"] #progress-title { color: #efa5a5; }
.progress-card[data-state="done"] #progress-title { color: var(--mint); }
#progress-download { justify-self: start; margin-top: 6px; }
.job[data-status="queued"] .job-state::before, .job[data-status="running"] .job-state::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: var(--violet); animation: pulse 1s ease-in-out infinite; }
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -100% 0; } }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .shimmer, .bar span, .job-state::before { animation: none !important; } }
@media (max-width: 860px) {
  .workspace { grid-template-columns: 1fr; }
  .drop-zone { min-height: 190px; }
  #file-preview { max-height: 260px; }
}
@media (max-width: 640px) {
  .intro { align-items: start; flex-direction: column; gap: 10px; }
  .intro > div > p { font-size: .9rem; }
  .account-menu-body { right: auto; left: 0; }
}

.focus-editor { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); background: #0c0d10; }
.focus-editor canvas, #fade-canvas { display: block; width: 100%; height: auto; max-height: 60vh; object-fit: contain; background: #18171c; }
.focus-editor canvas { cursor: crosshair; touch-action: manipulation; }
.slider { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 12px; font-size: .875rem; }
.slider input { accent-color: var(--violet); width: 100%; }
#fade-dialog { width: min(920px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: clamp(16px, 3vw, 26px); border: 1px solid var(--line); background: var(--panel); color: var(--cream); }
#fade-dialog::backdrop { background: rgba(8, 9, 11, .78); }
#fade-dialog > * + * { margin-top: 12px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.job-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 3px; font-size: .875rem; cursor: pointer; }
.chip:has(input:checked) { border-color: var(--violet); background: #18171c; }
.chip input { margin: 0; accent-color: var(--violet); }
#card-dialog { width: min(1000px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: clamp(16px, 3vw, 26px); border: 1px solid var(--line); background: var(--panel); color: var(--cream); }
.card-head { display: flex; justify-content: space-between; align-items: start; gap: 16px; }
.card-head h2 { margin: 0 0 4px; }
#card-dialog::backdrop { background: rgba(8, 9, 11, .78); }
#card-dialog > * + * { margin-top: 12px; }
.field { display: grid; gap: 6px; font-size: .875rem; }
.field input, .field select { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 3px; background: var(--ink); color: var(--cream); font: inherit; font-size: 1rem; }
.field input:focus, .field select:focus { border-color: var(--violet); }

/* Settings: compact segmented choices with one note for the selected option. */
legend { font-weight: 500; }
.group-label { margin-top: 4px; color: var(--muted); font: .7rem var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.segments { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.segments.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.seg { position: relative; display: block; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 40px; padding: 8px 6px; border: 1px solid var(--line); border-radius: 3px; font-size: .9rem; text-align: center; line-height: 1.25; }
.seg:hover span { border-color: #5a5566; }
.seg input:checked + span { border-color: var(--violet); background: #1a1624; color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--violet); outline-offset: 2px; }
.note { min-height: 1.4em; color: var(--muted); font-size: .825rem; line-height: 1.4; margin-top: 2px; }
.extras { border: 1px solid var(--line); border-radius: 3px; }
.extras summary { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 12px; cursor: pointer; font-weight: 500; list-style: none; }
.extras summary::-webkit-details-marker { display: none; }
.extras summary > span:first-child::before { content: "+ "; color: var(--violet); }
.extras[open] summary > span:first-child::before { content: "\2013  "; }
.extras-summary { color: var(--muted); font-weight: 400; font-size: .8rem; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.extras fieldset { padding: 0 12px 12px; }
.extras fieldset legend { float: left; width: 100%; font-weight: 400; color: var(--muted); font-size: .85rem; }
.action { display: flex; gap: 8px; }
.action .primary { flex: 1; text-align: center; padding-block: 13px; font-size: .95rem; }
#credits-dialog { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: clamp(18px, 3vw, 28px); border: 1px solid var(--line); background: var(--panel); color: var(--cream); }
#credits-dialog::backdrop { background: rgba(8, 9, 11, .78); }
.dialog-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; }
#credits-dialog .membership { margin-top: 10px; }
#credits-error { margin-top: 12px; }
.drop-icon { width: 56px; height: 56px; color: var(--violet); opacity: .8; }
