:root {
  color-scheme: light;
  --paper: #fbf6ea;
  --ink: #17130d;
  --muted: #6c6254;
  --line: #e7d7bf;
  --panel: #fffdf8;
  --accent: #b94d16;
  --accent-dark: #a73b09;
  font-family:
    Avenir Next,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    Segoe UI,
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  padding: 0 16px;
  cursor: pointer;
  transition:
    transform 140ms ease,
    background-color 140ms ease,
    opacity 140ms ease;
  touch-action: manipulation;
}

button:active {
  transform: scale(0.96);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid rgb(231 101 26 / 35%);
  outline-offset: 2px;
}

.shell {
  width: 100%;
  margin: 0 auto;
  padding: 3px;
}

.drop {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
  align-items: center;
  min-height: 310px;
  padding: 30px 24px;
  border: 2px dashed #d9c5a8;
  border-radius: 12px;
  background: var(--panel);
  text-align: center;
}

.drop.dragging {
  border-color: var(--accent);
  background: #fff0dc;
}

.drop.has-files {
  min-height: 0;
  padding: 16px;
  gap: 12px;
  border-style: solid;
}

.has-files .drop-copy {
  max-width: 100%;
}

.has-files h1 {
  font-size: 18px;
}

.has-files .muted {
  display: none;
}

#selectedFiles {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.has-files .actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 10px;
}

.has-files #browse {
  min-height: 42px;
  min-width: 0;
  padding: 8px 16px;
  font-size: 15px;
  box-shadow: none;
}

.has-files #limits {
  order: 1;
  flex-basis: 100%;
}

.target-warning {
  margin-top: 12px;
  padding: 12px;
  border-left: 3px solid var(--accent);
  background: #fff0dc;
  font-size: 14px;
}

.target-warning strong {
  color: var(--accent-dark);
}

.target-warning p {
  margin: 6px 0 10px;
  line-height: 1.5;
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.muted {
  max-width: 58ch;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  text-wrap: pretty;
}

.actions,
.controls,
.target,
.advanced,
.status,
.result {
  display: grid;
  gap: 10px;
}

.actions input,
.target input,
.target select,
.advanced select {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

.actions {
  justify-items: center;
  width: min(480px, 100%);
  gap: 14px;
}

#browse {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 58px;
  min-width: 230px;
  max-width: 100%;
  padding: 12px 28px;
  background: var(--accent);
  font-size: 20px;
  font-weight: 650;
  box-shadow: 0 3px 0 #8c3710;
}

.url-import {
  display: flex;
  width: min(390px, 100%);
  gap: 8px;
}

.url-import input {
  min-width: 0;
  flex: 1;
  font-size: 14px;
}

#importUrl {
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-size: 14px;
}

.controls {
  grid-template-columns: minmax(0, 1fr) minmax(230px, 300px);
  align-items: center;
  gap: 18px;
  padding: 22px 4px 18px;
  border-bottom: 1px solid var(--line);
}

.mode {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: flex-start;
}

.mode button {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 0 14px;
  background: transparent;
  border: 1px solid var(--line);
  line-height: 1.1;
  color: var(--ink);
}

.mode button.selected {
  background: #fff0dc;
  border-color: var(--accent);
  color: var(--accent-dark);
}

.target {
  position: relative;
  grid-template-columns: auto repeat(2, minmax(0, 1fr));
  align-items: center;
  font-size: 14px;
}

.target input:disabled {
  background: #f2ede4;
  color: var(--muted);
}

#proBadge {
  position: absolute;
  top: -8px;
  right: 8px;
  border-radius: 4px;
  background: #25170d;
  color: #fff;
  padding: 2px 8px;
  font-size: 12px;
}

.advanced {
  grid-column: 1 / -1;
}

summary {
  cursor: pointer;
  color: var(--accent-dark);
  font-weight: 500;
  font-size: 14px;
  min-height: 24px;
}

.advanced label {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 360px;
  margin-top: 12px;
}

.advanced label span {
  flex: 0 0 100px;
  font-size: 14px;
}

.status {
  margin: 10px 0;
}

#limits {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  text-wrap: balance;
}

.bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #eedcc2;
}

.bar span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
}

.results {
  display: grid;
  gap: 10px;
}

.result {
  align-items: center;
  padding: 12px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.result p {
  margin: 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.zip {
  margin-top: 14px;
  background: var(--accent);
}

.source {
  margin: 14px 0 0;
  text-align: right;
}

.source a {
  color: #9a3412;
  font-size: 0.86rem;
}

.queue-actions,
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.shell:not(:has(.result)) :is(.queue-actions, .bar, .zip) {
  display: none;
}

#compressNow {
  background: var(--accent);
}

#cancelJob,
#resetRows {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

#message {
  min-height: 1.4em;
  margin: 0;
  color: var(--accent-dark);
  font-weight: 700;
}

#message:empty {
  display: none;
}

.result {
  grid-template-columns: minmax(160px, 260px) 1fr auto;
}

.previews {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.previews figure {
  margin: 0;
}

.previews img {
  width: 100%;
  min-height: 88px;
  max-height: 140px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.previews figcaption {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.row-actions a {
  display: inline-grid;
  min-height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  padding: 0 16px;
  text-decoration: none;
}

@media (max-width: 760px) {
  .drop {
    min-height: 300px;
    gap: 20px;
    padding: 24px 16px;
  }

  h1 {
    font-size: 22px;
  }

  .muted {
    margin-top: 8px;
    font-size: 14px;
    line-height: 1.42;
  }

  .controls {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 18px 2px;
  }

  .mode button {
    flex: 1 1 90px;
    padding: 8px;
    font-size: 13px;
  }

  .result {
    grid-template-columns: 1fr;
  }
}

@media (hover: hover) {
  #browse:hover,
  #compressNow:hover {
    background: var(--accent-dark);
  }

  #importUrl:hover {
    background: var(--paper);
  }
}

@media (prefers-reduced-motion: reduce) {
  button {
    transition: none;
  }
}
