:root {
  --media-accent: #176b5d;
  --media-accent-dark: #0f4e44;
  --media-soft: #dff1eb;
  --media-ink: #191918;
  --media-muted: #69675f;
  --media-line: #d9d2c7;
  --media-surface: rgba(255, 253, 248, .9);
  --media-radius: 22px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  margin: 0;
}

button, input, select { font: inherit; }
button { color: inherit; }

.media-shell {
  width: min(1480px, calc(100% - 48px));
  margin: 0 auto;
  padding: 78px 0 56px;
}

.media-hero {
  margin-bottom: 16px;
}

.media-hero h1 {
  margin: 0;
  font-family: "Manrope", "Inter", system-ui, sans-serif;
  font-size: clamp(1.65rem, 3.5vw, 2.35rem);
  font-weight: 760;
  letter-spacing: -.065em;
  line-height: 1;
}

.media-subtitle {
  max-width: 630px;
  margin: 15px 0 0;
  color: var(--media-muted);
  font-size: .92rem;
  line-height: 1.65;
}

.media-panel {
  overflow: hidden;
  border: 1px solid var(--media-line);
  border-radius: var(--media-radius);
  background: var(--media-surface);
  box-shadow: 0 22px 60px rgba(48, 42, 31, .075);
  backdrop-filter: blur(14px);
}

.media-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(285px, .6fr);
  min-height: 590px;
}

.media-main { min-width: 0; padding: 18px; }

.media-sidebar {
  min-width: 0;
  padding: 24px;
  border-left: 1px solid var(--media-line);
  background: rgba(248, 245, 238, .62);
}

.dropzone {
  position: relative;
  display: grid;
  min-height: 520px;
  place-items: center;
  overflow: hidden;
  padding: 28px;
  border: 1.5px dashed #bdb5a9;
  border-radius: 17px;
  background:
    radial-gradient(circle at 50% 43%, color-mix(in srgb, var(--media-accent) 8%, transparent), transparent 17rem),
    rgba(250, 247, 241, .7);
  cursor: pointer;
}

.dropzone.is-dragging {
  border-color: var(--media-accent);
  background-color: color-mix(in srgb, var(--media-soft) 28%, white);
  transform: translateY(-1px);
}

/* Hover looks only where there is a hover. A finger leaves :hover behind after
   a tap, so on a phone the button just used would stay lifted and recoloured. */
@media (hover: hover) {
  .dropzone:hover {
    border-color: var(--media-accent);
    background-color: color-mix(in srgb, var(--media-soft) 28%, white);
    transform: translateY(-1px);
  }

  .btn:hover:not(:disabled) { border-color: #aca397; transform: translateY(-1px); }
  .btn-primary:hover:not(:disabled) { border-color: var(--media-accent); background: var(--media-accent); }
}

.dropzone-inner { max-width: 410px; text-align: center; }

.drop-icon {
  display: grid;
  width: 72px;
  height: 72px;
  margin: 0 auto 22px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--media-accent) 25%, var(--media-line));
  border-radius: 22px;
  color: var(--media-accent);
  background: color-mix(in srgb, var(--media-soft) 78%, white);
  box-shadow: 0 12px 28px rgba(30, 84, 72, .11);
  transform: rotate(-3deg);
}

.drop-icon svg { width: 31px; height: 31px; }

.dropzone h2 { margin: 0; font-size: 1.28rem; letter-spacing: -.035em; }
.dropzone p { margin: 9px 0 20px; color: var(--media-muted); font-size: .82rem; line-height: 1.55; }

.btn {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
  border: 1px solid var(--media-line);
  border-radius: 11px;
  background: #fffdf8;
  cursor: pointer;
  font-size: .78rem;
  font-weight: 700;
}

.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary {
  border-color: var(--media-ink);
  color: white;
  background: var(--media-ink);
  box-shadow: 0 8px 18px rgba(25, 25, 24, .14);
}

.btn-block { width: 100%; }
.btn svg { width: 16px; height: 16px; }
.stack-gap { margin-top: 10px; }
.subdued-count { color: #8b867d; font-weight: 500; }

.control-section + .control-section {
  margin-top: 23px;
  padding-top: 22px;
  border-top: 1px solid var(--media-line);
}

.control-label,
.control-section > label:first-child {
  display: block;
  margin: 0 0 9px;
  color: #56534d;
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: .63rem;
  font-weight: 600;
  letter-spacing: .085em;
  text-transform: uppercase;
}

.control-help { margin: 7px 0 0; color: #878278; font-size: .69rem; line-height: 1.45; }

.media-select,
.media-input {
  width: 100%;
  min-height: 43px;
  padding: 0 12px;
  border: 1px solid var(--media-line);
  border-radius: 10px;
  outline: 0;
  background: #fffdf8;
  font-size: .78rem;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--media-line);
  border-radius: 12px;
  background: #ece7de;
}

.quality-options { grid-template-columns: repeat(4, 1fr); }

.segmented button {
  min-width: 0;
  height: 35px;
  padding: 0 7px;
  border: 0;
  border-radius: 8px;
  color: #6c685f;
  background: transparent;
  cursor: pointer;
  font-size: .68rem;
  font-weight: 700;
}

.segmented button[aria-pressed="true"] {
  color: var(--media-ink);
  background: #fffdf8;
  box-shadow: 0 2px 9px rgba(43, 38, 29, .1);
}

.range-head { display: flex; justify-content: space-between; gap: 10px; }
.range-value { color: var(--media-accent-dark); font-family: "DM Mono", monospace; font-size: .66rem; }
input[type="range"] { width: 100%; accent-color: var(--media-accent); }

.status-card {
  padding: 13px;
  border: 1px solid var(--media-line);
  border-radius: 12px;
  background: rgba(255,253,248,.7);
}

.status-row { display: flex; align-items: center; gap: 10px; }
.status-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: #aaa59b; }
.status-card.is-working .status-dot { background: var(--media-accent); box-shadow: 0 0 0 5px color-mix(in srgb, var(--media-accent) 13%, transparent); animation: pulse 1.35s infinite; }
.status-card.is-done .status-dot { background: #2d9b63; }
.status-card.is-error .status-dot { background: #cb4d3c; }
.status-copy { min-width: 0; }
.status-title { margin: 0; font-size: .74rem; font-weight: 750; }
.status-detail { margin: 3px 0 0; overflow-wrap: anywhere; color: #817d74; font-size: .65rem; line-height: 1.4; }

.progress-track { height: 5px; margin-top: 11px; overflow: hidden; border-radius: 9px; background: #e4ded4; }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: var(--media-accent); transition: width .25s ease; }

.viewer {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: auto;
  margin-inline: auto;
  aspect-ratio: var(--viewer-aspect, 4 / 3);
  min-height: 0;
  overflow: hidden;
  border-radius: 17px;
  background: #e7e2d9;
}

.viewer-pane { position: absolute; inset: 0; display: grid; place-items: center; }
.viewer-pane img { display: block; width: 100%; height: 100%; object-fit: contain; object-position: center; user-select: none; -webkit-user-drag: none; }
.viewer-after { clip-path: inset(0 calc(100% - var(--split, 50%)) 0 0); }
.checkerboard {
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #dedede 25%, transparent 25%),
    linear-gradient(-45deg, #dedede 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #dedede 75%),
    linear-gradient(-45deg, transparent 75%, #dedede 75%);
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

.split-line { position: absolute; top: 0; bottom: 0; left: var(--split, 50%); width: 2px; background: white; box-shadow: 0 0 0 1px rgba(0,0,0,.12); transform: translateX(-1px); pointer-events: none; }
.split-handle { position: absolute; top: 50%; left: var(--split, 50%); display: grid; width: 38px; height: 38px; place-items: center; border: 2px solid white; border-radius: 50%; color: white; background: rgba(25,25,24,.7); box-shadow: 0 4px 16px rgba(0,0,0,.2); transform: translate(-50%, -50%); pointer-events: none; }
.split-range { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: ew-resize; }
.viewer-tag { position: absolute; top: 13px; z-index: 4; padding: 6px 9px; border-radius: 8px; color: white; background: rgba(25,25,24,.66); backdrop-filter: blur(8px); font-family: "DM Mono", monospace; font-size: .59rem; letter-spacing: .06em; text-transform: uppercase; pointer-events: none; }
.viewer-tag.before { left: 13px; }
.viewer-tag.after { right: 13px; }

.viewer-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.file-summary { min-width: 0; color: var(--media-muted); font-size: .71rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toolbar-actions { display: flex; flex: 0 0 auto; gap: 7px; }

.batch-tray { margin-top: 13px; padding: 13px; border: 1px solid var(--media-line); border-radius: 14px; background: rgba(248,245,238,.68); }
.batch-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.batch-head strong { font-size: .7rem; }
.batch-head span { color: #888278; font-size: .62rem; }
.batch-list { display: grid; grid-auto-columns: minmax(132px, 1fr); grid-auto-flow: column; gap: 7px; overflow-x: auto; padding-bottom: 2px; }
.batch-item { display: grid; grid-template-columns: 37px minmax(0, 1fr); gap: 8px; align-items: center; min-width: 0; padding: 7px; border: 1px solid transparent; border-radius: 10px; color: inherit; background: rgba(255,253,248,.72); cursor: pointer; text-align: left; }
@media (hover: hover) { .batch-item:hover { border-color: #bbb3a7; } }
.batch-item.is-selected { border-color: var(--media-accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--media-accent) 9%, transparent); }
.batch-thumb { position: relative; width: 37px; height: 37px; overflow: hidden; border-radius: 8px; background: #e7e2d9; }
.batch-thumb img { width: 100%; height: 100%; object-fit: cover; }
.batch-state { position: absolute; right: 2px; bottom: 2px; display: grid; width: 13px; height: 13px; place-items: center; border: 1.5px solid #fff; border-radius: 50%; color: #fff; background: #aaa59b; font-size: 8px; line-height: 1; }
.batch-item.is-working .batch-state { background: var(--media-accent); animation: pulse 1.35s infinite; }
.batch-item.is-done .batch-state { background: #2d9b63; }
.batch-item.is-error .batch-state { background: #cb4d3c; }
.batch-name { overflow: hidden; margin: 0; font-size: .64rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.batch-meta { margin: 2px 0 0; color: #8a857c; font-size: .56rem; }

.working-overlay { position: absolute; inset: 0; z-index: 8; display: grid; place-items: center; padding: 30px; background: rgba(244,240,232,.86); backdrop-filter: blur(10px); text-align: center; }
.working-overlay[hidden] { display: none; }
.spinner { width: 43px; height: 43px; margin: 0 auto 17px; border: 3px solid color-mix(in srgb, var(--media-accent) 18%, transparent); border-top-color: var(--media-accent); border-radius: 50%; animation: spin .85s linear infinite; }
.working-overlay strong { display: block; font-size: .95rem; }
.working-overlay p { margin: 7px 0 0; color: var(--media-muted); font-size: .72rem; line-height: 1.5; }

.color-control { display: flex; gap: 8px; }
.color-control input[type="color"] { width: 43px; height: 43px; flex: 0 0 auto; padding: 3px; border: 1px solid var(--media-line); border-radius: 10px; background: #fffdf8; }

/* Converter */
.converter-panel { padding: 18px; }
.converter-drop { min-height: 260px; }
.converter-grid { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 18px; margin-top: 18px; }
.converter-card { min-width: 0; padding: 20px; border: 1px solid var(--media-line); border-radius: 17px; background: rgba(255,253,248,.72); }
.converter-card h2 { margin: 0 0 16px; font-size: .95rem; letter-spacing: -.025em; }

.file-list { display: grid; gap: 8px; }
.file-list:empty::after { display: block; padding: 34px 12px; border: 1px dashed var(--media-line); border-radius: 12px; color: #89847a; content: "Your files will appear here"; font-size: .72rem; text-align: center; }
.file-item { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 11px; align-items: center; padding: 10px; border: 1px solid var(--media-line); border-radius: 12px; background: #fffdf8; }
.file-thumb { display: grid; width: 42px; height: 42px; place-items: center; overflow: hidden; border-radius: 9px; color: var(--media-accent-dark); background: var(--media-soft); font-family: "DM Mono", monospace; font-size: .57rem; font-weight: 600; text-transform: uppercase; }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-name { overflow: hidden; margin: 0; font-size: .72rem; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { margin: 3px 0 0; color: #8b867d; font-size: .62rem; }
.icon-btn { display: grid; width: 32px; height: 32px; place-items: center; border: 1px solid transparent; border-radius: 8px; color: #858078; background: transparent; cursor: pointer; }
@media (hover: hover) { .icon-btn:hover { border-color: var(--media-line); color: #b73f31; background: #fff; } }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field label { display: block; margin-bottom: 7px; color: #625f58; font-size: .66rem; font-weight: 700; }
.field.span-2 { grid-column: 1 / -1; }
.inline-check { display: flex; align-items: center; gap: 8px; color: #625f58; font-size: .7rem; }
.inline-check input { accent-color: var(--media-accent); }
.conversion-note { margin: 12px 0 0; padding: 10px 11px; border-radius: 9px; color: #6f6b62; background: #eee9e0; font-size: .65rem; line-height: 1.5; }

.results-section { margin-top: 18px; }
.results-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.results-head h2 { margin: 0; font-size: .95rem; }
.result-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.result-item { display: flex; min-width: 0; align-items: center; gap: 10px; padding: 11px; border: 1px solid var(--media-line); border-radius: 12px; background: #fffdf8; }
.result-info { min-width: 0; flex: 1; }
.result-name { overflow: hidden; margin: 0; font-size: .69rem; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.result-meta { margin: 3px 0 0; color: #8b867d; font-size: .59rem; }
.result-download { min-height: 32px; padding: 0 10px; font-size: .64rem; text-decoration: none; }

[hidden] { display: none !important; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--media-accent) 4%, transparent); } }

@media (max-width: 840px) {
  .media-shell { width: min(100% - 24px, 720px); padding-top: 70px; }
  .media-workspace, .converter-grid { grid-template-columns: 1fr; }
  .media-sidebar { border-top: 1px solid var(--media-line); border-left: 0; }
  .dropzone { min-height: 430px; }
  .result-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 540px) {
  .media-shell { width: min(100% - 16px, 720px); }
  .media-main, .converter-panel { padding: 10px; }
  .media-sidebar { padding: 18px; }
  .dropzone { min-height: 370px; padding: 20px; }
  .viewer-toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-actions .btn { flex: 1; }
  .settings-grid { grid-template-columns: 1fr; }
  .field.span-2 { grid-column: auto; }
  .result-list { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
