:root {
  color-scheme: light;
  --bg: #f6f8f7;
  --surface: #ffffff;
  --surface-strong: #fdfcf8;
  --ink: #17211f;
  --muted: #60706b;
  --line: #dce5df;
  --teal: #008f83;
  --teal-dark: #006f66;
  --coral: #ef6f5e;
  --lime: #c8e85b;
  --shadow: 0 18px 50px rgba(25, 44, 40, 0.12);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.app {
  min-height: 100vh;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1480px;
  margin: 0 auto 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #b8ddd4;
  border-radius: var(--radius);
  background: #e9fbf7;
  color: var(--teal-dark);
}

.brand h1,
.brand p,
.panel-head h2,
.settings-head h2 {
  margin: 0;
}

.brand h1 {
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: 0;
}

.brand p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.status-dot::before {
  width: 8px;
  height: 8px;
  content: "";
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 0 3px rgba(200, 232, 91, 0.32);
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(250px, 0.78fr) minmax(420px, 1.55fr) minmax(270px, 0.82fr);
  gap: 16px;
  max-width: 1480px;
  margin: 0 auto;
}

.queue-panel,
.preview-panel,
.settings-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.queue-panel,
.settings-panel {
  padding: 16px;
}

.preview-panel {
  padding: 18px;
}

.drop-zone {
  display: grid;
  min-height: 210px;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 22px;
  border: 1.5px dashed #9dcfc5;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #f1fffc 0%, #fffdfa 100%);
  color: var(--muted);
  text-align: center;
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.drop-zone.dragover {
  border-color: var(--teal);
  background: #e8fbf8;
  transform: translateY(-1px);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.drop-zone strong {
  color: var(--ink);
  font-size: 18px;
}

.drop-zone span:last-child {
  max-width: 260px;
  font-size: 13px;
  line-height: 1.45;
}

.drop-icon {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--teal);
  color: #ffffff;
}

.queue-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.file-list {
  display: grid;
  max-height: 430px;
  overflow: auto;
  gap: 8px;
  padding-right: 2px;
}

.file-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  text-align: left;
}

.file-item.active {
  border-color: #8fd1c8;
  background: #effbf8;
}

.file-thumb {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  background: #eef2f0;
}

.file-item > span:nth-child(2) {
  min-width: 0;
  overflow: hidden;
}

.file-name {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.file-save {
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
  position: relative;
  z-index: 1;
  background: inherit;
}

.panel-head,
.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head > div {
  min-width: 0;
}

.eyeless-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.panel-head h2,
.settings-head h2 {
  font-size: 20px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.settings-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.secondary-button,
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 800;
}

.secondary-button {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  padding: 0 13px;
}

.primary-button {
  width: 100%;
  border: 0;
  background: var(--teal);
  color: #ffffff;
  padding: 0 16px;
}

.comparison {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 430px;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(45deg, #edf2ef 25%, transparent 25%),
    linear-gradient(-45deg, #edf2ef 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #edf2ef 75%),
    linear-gradient(-45deg, transparent 75%, #edf2ef 75%);
  background-color: #ffffff;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

.comparison.empty .image-frame {
  display: none;
}

.comparison:not(.empty) .empty-state {
  display: none;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  color: var(--muted);
  text-align: center;
}

.empty-state svg {
  width: 52px;
  height: 52px;
  color: var(--teal);
}

.empty-state p {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.image-frame {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid rgba(23, 33, 31, 0.08);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
}

.image-frame figcaption {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(23, 33, 31, 0.08);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.image-frame img {
  width: 100%;
  height: 100%;
  min-height: 280px;
  object-fit: contain;
  padding: 10px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.metrics div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metrics strong {
  display: block;
  margin-top: 5px;
  font-size: 20px;
  line-height: 1.15;
}

.metrics .savings {
  border-color: #bcd779;
  background: #f8ffe0;
}

.control-group {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.control-group label,
.control-row label {
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

#qualityValue {
  color: var(--teal-dark);
  font-size: 26px;
  font-weight: 900;
}

input[type="range"] {
  width: 100%;
  height: 34px;
  margin: 4px 0 0;
  accent-color: var(--teal);
}

.scale {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select,
input[type="number"] {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
  padding: 0 12px;
  font-size: 14px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 18px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 750;
}

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

.support-note {
  margin-top: 16px;
  padding: 14px;
  border-left: 4px solid var(--coral);
  border-radius: var(--radius);
  background: #fff5f1;
}

.support-note strong {
  font-size: 13px;
}

.support-note p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .file-list {
    max-height: 260px;
  }
}

@media (max-width: 680px) {
  .app {
    padding: 12px;
  }

  .topbar,
  .panel-head,
  .settings-head {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    justify-content: space-between;
  }

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

  .comparison {
    min-height: 620px;
  }

  .image-frame img {
    min-height: 220px;
  }

  .secondary-button {
    width: 100%;
  }
}
