:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-strong: #eef3f7;
  --ink: #121820;
  --muted: #687382;
  --line: #d7dee8;
  --accent: #05668d;
  --accent-dark: #034965;
  --accent-soft: #dff2f8;
  --danger: #c03243;
  --ok: #0a7f5a;
  --warn: #a15c00;
  --shadow: 0 18px 60px rgba(23, 34, 46, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.app-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 0 0 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: 1.05rem;
  letter-spacing: 0;
}

.header-metrics {
  display: grid;
  min-width: min(100%, 330px);
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.header-metrics span {
  min-width: 0;
  padding: 14px 12px;
  border-right: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
}

.header-metrics span:last-child {
  border-right: 0;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.tool-panel,
.queue-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.tool-panel {
  position: sticky;
  top: 16px;
  overflow: hidden;
}

.drop-zone {
  position: relative;
  display: grid;
  min-height: 250px;
  place-items: center;
  padding: 24px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(5, 102, 141, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(5, 102, 141, 0.08) 1px, transparent 1px),
    var(--panel-strong);
  background-size: 28px 28px;
  text-align: center;
}

.drop-zone.dragover {
  outline: 3px solid var(--accent);
  outline-offset: -8px;
}

.drop-zone input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.drop-zone h2 {
  margin: 8px 0 14px;
  font-size: 1.45rem;
}

.drop-mark {
  display: grid;
  width: 60px;
  height: 60px;
  place-items: center;
  border: 2px dashed var(--accent);
  border-radius: 50%;
  color: var(--accent);
  font-size: 2rem;
  font-weight: 700;
}

.settings {
  display: grid;
  gap: 18px;
  padding: 18px;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend,
.settings label > span,
.range-row span,
.check-row span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

.segmented label {
  min-width: 0;
  margin: 0;
}

.segmented input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.segmented span {
  display: grid;
  min-width: 0;
  min-height: 36px;
  place-items: center;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
}

.segmented input:checked + span {
  background: var(--accent);
  color: #ffffff;
}

.range-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 3ch;
  gap: 12px;
  align-items: center;
}

.range-row span {
  margin-bottom: 0;
}

.range-row output {
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 800;
  text-align: right;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

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

input[type="number"],
input[type="text"] {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  padding: 10px 11px;
}

input[type="number"]:focus,
input[type="text"]:focus,
.drop-zone:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(5, 102, 141, 0.16);
}

.check-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.check-row span {
  margin: 0;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 18px 18px;
}

.actions .ghost {
  grid-column: 1 / -1;
}

.button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
}

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

.primary {
  background: var(--accent);
  color: #ffffff;
}

.primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

.secondary {
  border-color: var(--line);
  background: #ffffff;
  color: var(--ink);
}

.secondary:hover:not(:disabled),
.ghost:hover:not(:disabled) {
  border-color: var(--accent);
}

.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.queue-panel {
  min-height: 620px;
  overflow: hidden;
}

.queue-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px;
  gap: 18px;
  align-items: center;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.queue-toolbar h2 {
  margin-bottom: 2px;
}

.queue-toolbar p,
.empty-state p {
  margin-bottom: 0;
  color: var(--muted);
}

progress {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--line);
}

progress::-webkit-progress-bar {
  background: var(--line);
}

progress::-webkit-progress-value {
  background: var(--accent);
}

progress::-moz-progress-bar {
  background: var(--accent);
}

.empty-state {
  display: grid;
  min-height: 450px;
  place-items: center;
  align-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
}

.empty-icon {
  width: 80px;
  height: 56px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, transparent 50%, rgba(5, 102, 141, 0.2) 51%),
    linear-gradient(45deg, transparent 58%, rgba(192, 50, 67, 0.18) 59%),
    #ffffff;
}

.queue-list {
  display: grid;
}

.queue-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) minmax(108px, 0.22fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.queue-item:last-child {
  border-bottom: 0;
}

.thumb {
  width: 72px;
  height: 54px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-meta {
  min-width: 0;
}

.file-name {
  overflow: hidden;
  margin-bottom: 5px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-submeta,
.savings {
  color: var(--muted);
  font-size: 0.86rem;
}

.status {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.status.queued {
  background: var(--panel-strong);
  color: var(--muted);
}

.status.processing {
  background: #fff1d8;
  color: var(--warn);
}

.status.done {
  background: #ddf6ec;
  color: var(--ok);
}

.status.error {
  background: #fde2e6;
  color: var(--danger);
}

.row-actions {
  display: flex;
  gap: 6px;
}

.icon-button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 900;
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.error-text {
  margin-top: 4px;
  color: var(--danger);
  font-size: 0.82rem;
}

@media (max-width: 920px) {
  .app-header {
    align-items: stretch;
    flex-direction: column;
  }

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

  .tool-panel {
    position: static;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  h1 {
    font-size: 2.2rem;
  }

  .header-metrics {
    grid-template-columns: 1fr;
  }

  .header-metrics span {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .header-metrics span:last-child {
    border-bottom: 0;
  }

  .grid-two,
  .actions,
  .queue-toolbar,
  .queue-item {
    grid-template-columns: 1fr;
  }

  .queue-toolbar {
    gap: 10px;
  }

  .thumb {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }

  .row-actions {
    width: 100%;
  }

  .row-actions .icon-button {
    width: 44px;
  }
}
