:root {
  color-scheme: light;
  --accent: #087f8c;
  --accent-dark: #045b62;
  --bg: #f6f8f7;
  --border: #d8dedb;
  --danger: #c7364a;
  --ink: #18211f;
  --muted: #66736f;
  --panel: #ffffff;
  --soft: #edf2f0;
  --sun: #f3b33d;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

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

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

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

.home-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.home-link:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.05;
}

h2 {
  font-size: 18px;
}

.top-status,
.summary {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) 340px;
  gap: 16px;
  max-width: 1180px;
  margin: 0 auto;
}

.panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.file-panel,
.settings-panel,
.results-panel {
  padding: 18px;
}

.settings-panel {
  align-self: start;
  position: sticky;
  grid-column: 2;
  grid-row: 1 / span 2;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}

.results-panel {
  grid-column: 1;
}

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

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: end;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 750;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    opacity 160ms ease;
}

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

.button.primary {
  width: 100%;
  margin-top: 16px;
  background: var(--accent);
  color: #ffffff;
}

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

.button.secondary {
  width: 100%;
  margin-top: 8px;
  border-color: #f1cf8f;
  background: #fff8e8;
  color: #61410a;
}

.button.ghost {
  border-color: var(--border);
  background: #ffffff;
  color: var(--ink);
}

.button.ghost:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.button.subtle {
  background: var(--soft);
  color: var(--muted);
}

.dropzone {
  position: relative;
  display: grid;
  min-height: 178px;
  place-items: center;
  border: 1px dashed #9aaeaa;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(8, 127, 140, 0.08), rgba(243, 179, 61, 0.1)),
    #fbfcfc;
  text-align: center;
}

.dropzone.is-dragging {
  border-color: var(--accent);
  background: #eef8f8;
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.drop-copy {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.drop-copy strong {
  font-size: 20px;
}

.drop-copy span {
  color: var(--muted);
  font-size: 13px;
}

.file-list,
.results-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.empty-state {
  display: grid;
  min-height: 72px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
}

.file-row,
.result-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #ffffff;
}

.file-main,
.result-main {
  min-width: 0;
}

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

.file-name,
.result-name {
  overflow: hidden;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta,
.result-meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.file-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
}

.file-estimate {
  color: var(--accent-dark);
  font-weight: 750;
}

.file-actual {
  color: var(--accent-dark);
  font-weight: 750;
}

.file-state {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.file-progress {
  height: 4px;
  margin-top: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--soft);
}

.file-progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 140ms ease;
}

.file-row.is-uploading,
.file-row.is-converting {
  border-color: rgba(8, 127, 140, 0.48);
  background: #fbfefe;
}

.file-row.is-uploading .file-state,
.file-row.is-converting .file-state {
  color: var(--accent-dark);
}

.file-row.is-converting .file-progress-bar {
  width: 100% !important;
  background: linear-gradient(90deg, var(--accent), #41b6b4, var(--accent));
  background-size: 200% 100%;
  animation: progress-shimmer 1.1s linear infinite;
}

.file-row.is-done .file-progress-bar {
  width: 100% !important;
}

.file-row.is-failed .file-progress-bar {
  width: 100% !important;
  background: var(--danger);
}

.file-row.is-failed .file-state {
  color: var(--danger);
}

.row-action {
  min-width: 86px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
  min-height: 34px;
  padding: 0 10px;
}

.row-action:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.result-row.failed {
  border-color: #efb3bd;
  background: #fff7f8;
}

.result-row.failed .result-name {
  color: var(--danger);
}

.result-actions {
  display: flex;
  gap: 7px;
}

.compare-action {
  border-color: rgba(8, 127, 140, .34);
  background: #e7f5f4;
  color: var(--accent-dark);
  font-weight: 800;
}

.compare-action:hover {
  border-color: var(--accent);
  background: #d7efed;
}

.watermark-fieldset {
  margin: 16px 0 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.watermark-fieldset .switch-field {
  margin: 0;
}

.watermark-controls {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.watermark-controls .format-field:last-of-type,
.watermark-controls .range-field:last-child {
  margin-bottom: 0;
}

.watermark-controls input[type="text"] {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
}

.comparison-panel {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

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

.comparison-head h3 {
  margin: 0;
  font-size: 19px;
}

.comparison-frame {
  --comparison-split: 50%;
  position: relative;
  height: clamp(260px, 52vw, 560px);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: repeating-conic-gradient(#edf1f4 0 25%, #fff 0 50%) 0 / 20px 20px;
}

.comparison-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.comparison-before {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  clip-path: inset(0 calc(100% - var(--comparison-split)) 0 0);
}

.comparison-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--comparison-split);
  z-index: 3;
  width: 3px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .35);
  transform: translateX(-50%);
}

.comparison-label {
  position: absolute;
  top: 12px;
  z-index: 4;
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(18, 27, 36, .78);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.comparison-label.is-before { left: 12px; }
.comparison-label.is-after { right: 12px; }

.comparison-range {
  display: grid;
  gap: 7px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.range-field {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.range-field > span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-weight: 750;
}

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

.range-field.is-disabled {
  color: var(--muted);
  opacity: 0.64;
}

.switch-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  margin-bottom: 16px;
  font-weight: 750;
}

.switch-field input {
  position: absolute;
  opacity: 0;
}

.switch-ui {
  position: relative;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: #cad4d1;
  transition: background 160ms ease;
}

.switch-ui::after {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  content: "";
  transition: transform 160ms ease;
}

.switch-field input:checked + .switch-ui {
  background: var(--accent);
}

.switch-field input:checked + .switch-ui::after {
  transform: translateX(20px);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field-grid input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
}

.preset-field {
  min-width: 0;
  margin: 0 0 16px;
  border: 0;
  padding: 0;
}

.preset-field legend {
  margin-bottom: 7px;
  padding: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

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

.preset-button {
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 7px;
  background: var(--soft);
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.2;
}

.preset-button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.preset-button.is-active {
  border-color: var(--accent);
  background: #e7f5f4;
  color: var(--accent-dark);
  box-shadow: inset 0 0 0 1px rgba(8, 127, 140, 0.16);
}

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

.format-field {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.format-field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  background: #ffffff;
  color: var(--ink);
}

.format-field select:focus-visible,
.field-grid input:focus-visible {
  border-color: var(--accent);
  outline: 2px solid rgba(8, 127, 140, 0.18);
  outline-offset: 1px;
}

.estimate-card {
  margin-top: 16px;
  border: 1px solid #cce0dd;
  border-radius: 8px;
  padding: 12px;
  background: #f3f9f8;
}

.estimate-head,
.progress-head,
.progress-detail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.estimate-head {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 750;
}

.estimate-head strong {
  color: var(--ink);
  font-size: 17px;
}

.estimate-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.conversion-progress {
  margin-top: 16px;
}

.progress-head {
  font-size: 13px;
}

.progress-head span,
.progress-detail {
  color: var(--muted);
}

.progress-shell {
  height: 8px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--soft);
}

.progress-bar {
  width: 0;
  height: 100%;
  background: var(--sun);
  transition: width 180ms ease;
}

.progress-shell.is-indeterminate .progress-bar {
  background: linear-gradient(90deg, var(--accent), #48bcb8, var(--accent));
  background-size: 200% 100%;
  animation: progress-shimmer 1.1s linear infinite;
}

.progress-detail {
  margin-top: 7px;
  font-size: 12px;
}

.progress-detail span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-detail span:last-child {
  flex: 0 0 auto;
}

@keyframes progress-shimmer {
  to {
    background-position: -200% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .file-row.is-converting .file-progress-bar,
  .progress-shell.is-indeterminate .progress-bar {
    animation: none;
  }
}

@media (max-width: 880px) {
  .app-shell {
    padding: 16px;
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .top-actions {
    flex-wrap: wrap;
  }

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

  .settings-panel {
    position: static;
    grid-column: auto;
    grid-row: auto;
    max-height: none;
    overflow-y: visible;
  }

  .results-panel {
    grid-column: auto;
  }

  .panel-head {
    align-items: start;
    flex-direction: column;
  }

  .button-row {
    justify-content: start;
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 27px;
  }

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

  .file-line,
  .progress-detail {
    align-items: start;
  }

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

  .button-row .button {
    flex: 1 1 110px;
  }
}

.field-grid.is-ico {
  grid-template-columns: 1fr;
}
