:root {
  color-scheme: dark;
  --bg: #0c0e15;
  --surface: #141722;
  --raised: #1a1e2b;
  --line: #2c3041;
  --text: #f3f4fc;
  --muted: #a4acc2;
  --accent: #cafa8c;
  --violet: #b9a5ff;
  --error: #ffaaa8;
  font-family: "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: radial-gradient(ellipse 70rem 36rem at 78% -8rem, #272145, transparent), var(--bg);
}
button, input, select { font: inherit; }
a { color: inherit; text-decoration: none; }
button, a.button, select { cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 2px solid var(--violet); outline-offset: 4px; }
h1, h2, p { margin: 0; }
.topbar { border-bottom: 1px solid var(--line); background: #10121be8; }
.top-inner, .workspace { max-width: 1272px; margin: auto; padding-inline: clamp(20px, 5vw, 64px); }
.top-inner { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.brand { display: inline-flex; align-items: center; font-size: 1.28rem; font-weight: 800; letter-spacing: -.06em; }
.brand > span:last-child { color: var(--accent); }
.mark {
  background: var(--accent);
  width: 25px;
  height: 25px;
  display: inline-block;
  position: relative;
  margin-right: 9px;
  border-radius: 7px;
  flex: 0 0 auto;
}
.mark::before, .mark::after { content: ""; position: absolute; width: 55%; height: 18%; left: 22%; border-radius: 2px; background: #232d28; transform: rotate(-34deg); }
.mark::before { top: 31%; }
.mark::after { top: 51%; }
.mark.large { width: 42px; height: 42px; border-radius: 13px; margin-bottom: 21px; }
.top-actions, .filters, .dialog-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.domain, .eyebrow, .hint, .stat > span { font-family: ui-monospace, monospace; }
.domain { color: var(--muted); font-size: .82rem; }
.workspace { padding-block: clamp(34px, 8vh, 72px); }
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 30px; }
.eyebrow { color: var(--violet); font-size: .76rem; font-weight: 650; letter-spacing: .15em; text-transform: uppercase; margin-bottom: 12px; }
h1 { font-size: clamp(2.25rem, 6vw, 4.35rem); line-height: 1.03; letter-spacing: -.07em; margin-bottom: 12px; }
.hero h1 > span { color: var(--accent); }
h2 { font-size: 1.28rem; letter-spacing: -.035em; }
.muted, .hint { color: var(--muted); line-height: 1.5; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat { background: linear-gradient(150deg, #191c2b, var(--surface)); border: 1px solid var(--line); padding: 17px 20px; border-radius: 14px; display: grid; gap: 7px; align-content: start; }
.stat > span { color: var(--muted); font-size: .76rem; }
.stat strong { font-size: clamp(1.05rem, 2.5vw, 1.55rem); letter-spacing: -.035em; overflow-wrap: anywhere; }
progress { width: 100%; max-width: 230px; height: 5px; accent-color: var(--accent); }
.upload-panel {
  margin-top: 20px;
  padding: 12px;
  border: 1px solid #37354b;
  border-radius: 22px;
  background: linear-gradient(155deg, #211d35 0%, #171927 58%, #141722 100%);
  box-shadow: 0 14px 34px #080a1459;
}
.drop-zone {
  min-height: 144px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(14px, 2.5vw, 24px);
  padding: clamp(16px, 3vw, 30px);
  border: 1px dashed #615581;
  border-radius: 14px;
  background: radial-gradient(ellipse at 12% 8%, #3a2b59 0%, transparent 65%), #1c1b30;
  transition: border-color .18s ease, background-color .18s ease;
}
.drop-zone.dragging { border-color: var(--accent); background: radial-gradient(ellipse at 12% 8%, #344833 0%, transparent 74%), #222d24; }
.upload-icon {
  width: clamp(44px, 6vw, 64px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid #8270b3;
  border-radius: 17px;
  background: linear-gradient(145deg, #514172, #34294f);
  color: #e1d7ff;
}
.upload-icon > span {
  position: relative;
  width: 23px;
  height: 10px;
  margin-top: 13px;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 0 0 5px 5px;
}
.upload-icon > span::before, .upload-icon > span::after { content: ""; position: absolute; left: 50%; }
.upload-icon > span::before { top: -12px; width: 2px; height: 14px; background: currentColor; transform: translateX(-50%); }
.upload-icon > span::after { top: -12px; width: 8px; height: 8px; border-top: 2px solid currentColor; border-left: 2px solid currentColor; transform: translateX(-50%) rotate(45deg); }
.drop-copy { display: grid; gap: 4px; }
.drop-copy h2 { font-size: clamp(1.25rem, 3vw, 1.6rem); }
.drop-copy p { color: #d7d0e8; }
.drop-copy span, .toolbar p, .image-details { color: var(--muted); font-size: .84rem; }
#pick { min-height: 45px; padding-inline: 17px; box-shadow: 0 4px 16px #cafa8c21; }
.library-actions, .queue-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.upload-controls { display: grid; gap: 7px; }
.upload-controls label { color: #d7d0e8; font-size: .78rem; }
.upload-queue {
  display: grid;
  grid-template-rows: 1fr;
  padding-inline: 8px;
  opacity: 1;
  transition: grid-template-rows .3s ease, opacity .25s ease;
}
.upload-queue.closing { grid-template-rows: 0fr; opacity: 0; }
.queue-content { min-height: 0; overflow: hidden; }
.queue-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.queue-heading:first-child { margin-top: 16px; }
.queue-heading h3 { margin: 0; font-size: 1rem; }
.queue-actions .button { min-height: 30px; padding: 4px 8px; }
.upload-percent, .upload-file-status, .upload-file-size { font-size: .78rem; font-variant-numeric: tabular-nums; }
.upload-percent { color: var(--accent); }
.upload-progress, .upload-file-progress { display: block; max-width: none; border: 0; overflow: hidden; border-radius: 99px; background: #302b43; }
.upload-progress { height: 10px; margin-bottom: 8px; }
.upload-file-progress { grid-column: 1 / -1; height: 4px; }
.upload-progress::-webkit-progress-bar, .upload-file-progress::-webkit-progress-bar { border-radius: 99px; background: #302b43; }
.upload-progress::-webkit-progress-value, .upload-file-progress::-webkit-progress-value { border-radius: 99px; background: linear-gradient(90deg, #a693f0, #cafa8c); }
.upload-progress::-moz-progress-bar, .upload-file-progress::-moz-progress-bar { border-radius: 99px; background: linear-gradient(90deg, #a693f0, #cafa8c); }
#upload-status { font-size: .82rem; }
.upload-files { display: grid; gap: 6px; max-height: 268px; overflow: auto; margin: 12px 0 4px; padding: 0; list-style: none; }
.upload-file {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 7px 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #11131f;
}
.upload-file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .84rem; }
.upload-file-size { color: var(--muted); }
.upload-file-status { color: var(--violet); }
.upload-file[data-state="processing"] .upload-file-status { color: #e1d7ff; }
.upload-file[data-state="done"] .upload-file-status { color: var(--accent); }
.upload-file[data-state="done"] { grid-template-columns: auto minmax(0, 1fr) auto auto; }
.upload-file[data-state="done"] .upload-file-progress { display: none; }
.upload-preview { width: 34px; height: 28px; object-fit: cover; border-radius: 5px; background: var(--raised); }
.upload-file[data-state="failed"] .upload-file-status, .upload-file-error { color: var(--error); }
.upload-file[data-state="failed"] .upload-file-progress { display: none; }
.upload-file[data-state="cancelled"] .upload-file-progress { display: none; }
.upload-file-error { grid-column: 1 / -1; font-size: .8rem; overflow-wrap: anywhere; }
.upload-file-note { color: var(--muted); }
.upload-file-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; }
.upload-file-actions .button { min-height: 28px; padding: 4px 8px; font-size: .78rem; }
.button { border: 1px solid transparent; border-radius: 9px; padding: 9px 13px; min-height: 40px; display: inline-flex; justify-content: center; align-items: center; font-size: .88rem; font-weight: 650; }
.primary { background: var(--accent); color: #1a291b; }
.primary:hover:not(:disabled) { background: #e0ffb7; }
.secondary { background: var(--raised); color: var(--text); border-color: var(--line); }
.ghost { background: transparent; color: var(--muted); }
.secondary:hover:not(:disabled), .ghost:hover:not(:disabled) { background: #2a2b3c; color: var(--text); }
.danger { color: var(--error); border-color: #74484e; background: #36242c; }
.danger:hover:not(:disabled) { background: #492f39; }
.collection { margin-top: 36px; }
.toolbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.selection-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; padding: 10px 12px; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-size: .85rem; }
#quick-actions { margin-left: auto; }
input, select { background: #10121b; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; color: var(--text); min-height: 40px; min-width: 0; }
input::placeholder { color: #9da3b8; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 14px; }
.card { position: relative; background: var(--surface); border: 1px solid var(--line); overflow: hidden; border-radius: 14px; min-width: 0; transition: border-color .18s ease; }
.card:focus-within, .card:hover { border-color: #665b88; }
.card:has(.card-select input:checked) { border-color: var(--violet); }
.card-select { position: absolute; top: 9px; left: 9px; display: grid; place-content: center; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 9px; background: #151722ee; cursor: pointer; }
.card-select input { width: 16px; height: 16px; min-height: 0; margin: 0; accent-color: var(--accent); cursor: pointer; }
.thumbnail { padding: 0; border: 0; width: 100%; aspect-ratio: 16 / 10; display: grid; place-items: center; overflow: hidden; }
.thumbnail, .preview {
  background-color: #151722;
  background-image: conic-gradient(#1c1e2b 25%, #151722 0 50%, #1c1e2b 0 75%, #151722 0);
  background-size: 20px 20px;
}
.thumbnail:focus-visible { outline-offset: -4px; }
.thumbnail img { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: contain; }
.card-body { padding: 13px; }
.image-name, .image-alias { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.image-name { font-weight: 700; }
.image-details { margin-top: 4px; }
.category-chip { display: inline-block; max-width: 100%; margin-top: 7px; padding: 3px 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-radius: 6px; background: #262139; color: #ded3ff; font-size: .72rem; vertical-align: middle; }
.image-alias { color: var(--violet); font-family: ui-monospace, monospace; font-size: .75rem; margin-top: 5px; min-height: 1.1rem; }
.card-actions { display: flex; gap: 7px; margin-top: 11px; }
.card-actions .button:first-child { flex: 1; }
.empty, .feedback { border: 1px solid var(--line); border-radius: 13px; background: var(--surface); color: var(--muted); padding: 17px 20px; overflow-wrap: anywhere; }
.empty { grid-column: 1 / -1; text-align: center; padding: 38px 20px; }
.feedback { margin-top: 10px; }
.feedback ul { margin: 8px 0 0; padding-left: 20px; }
.pagination { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 18px; color: var(--muted); }
.startup { text-align: center; color: var(--muted); padding: 80px 20px; }
.login-shell { padding: 10vh 20px 52px; display: grid; place-items: center; }
.login-card { background: radial-gradient(ellipse at 8% 0%, #29213e, transparent 66%), var(--surface); border: 1px solid #39334d; width: min(100%, 440px); padding: clamp(26px, 7vw, 42px); border-radius: 23px; box-shadow: 0 22px 80px #090a11; }
.login-card h1 { font-size: clamp(2.1rem, 8vw, 3.1rem); }
form { margin-top: 20px; display: grid; gap: 14px; }
form label { display: grid; gap: 6px; font-weight: 650; font-size: .9rem; }
.login-card button { margin-top: 5px; }
.error { color: var(--error); font-size: .88rem; overflow-wrap: anywhere; }
dialog { width: min(calc(100% - 32px), 610px); max-height: calc(100% - 32px); overflow: auto; padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--text); }
dialog::backdrop { background: #080811c9; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.editor-panel { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.editor-panel summary { color: var(--text); font-weight: 650; cursor: pointer; }
.editor-panel > .muted, .editor-panel > .error { margin-top: 8px; font-size: .82rem; }
#share-form { display: flex; align-items: flex-end; flex-wrap: wrap; margin-top: 12px; }
#share-form label { flex: 1 1 130px; }
.tool-list { display: grid; gap: 7px; list-style: none; padding: 0; margin: 12px 0 0; }
.tool-list:empty { display: none; }
.tool-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; background: #11131f; padding: 8px 10px; border-radius: 8px; font-size: .85rem; }
.tool-description { display: grid; gap: 4px; flex: 1 1 160px; min-width: 0; overflow-wrap: anywhere; }
.tool-description span { color: var(--muted); }
.tool-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.tool-row .button { min-height: 32px; padding: 5px 8px; font-size: .8rem; }
#bulk-confirm-field { padding: 12px; border: 1px solid #74484e; border-radius: 9px; color: var(--error); }
.preview { border-radius: 10px; display: grid; place-items: center; height: min(34vh, 300px); overflow: hidden; }
.preview img { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
#image-meta { margin-top: 8px; font-size: .85rem; }
.alias-input { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.alias-input input { flex: 1; }
.hint { font-size: .75rem; }
.visibility { display: flex; align-items: center; gap: 8px; }
.visibility input { min-height: auto; accent-color: var(--accent); }
.image-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.dialog-actions { justify-content: flex-end; }
.dialog-actions .danger:first-child { margin-right: auto; }
.toast { position: fixed; bottom: 20px; right: 20px; max-width: min(390px, calc(100% - 40px)); z-index: 3; border: 1px solid #536045; background: #242c25; padding: 12px 16px; border-radius: 10px; overflow-wrap: anywhere; }
.sr-only { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
@media (max-width: 550px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .domain { display: none; }
  .drop-zone { grid-template-columns: auto minmax(0, 1fr); }
  .upload-controls { grid-column: 1 / -1; }
  .upload-file { gap: 7px 8px; }
  .filters, .filters label:first-child, .filters input { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .drop-zone, .card, .upload-queue { transition: none; }
}
