:root {
  color-scheme: light;
  --bg: #f5f6f2;
  --surface: #ffffff;
  --ink: #151719;
  --muted: #5d646d;
  --line: #d9ddd8;
  --accent: #146c63;
  --accent-2: #b44534;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

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

button,
select,
input {
  font: inherit;
}

.app-shell {
  width: min(1500px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

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

.kicker {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 54px);
  line-height: 0.95;
  letter-spacing: 0;
}

.source-note {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.source-note a {
  color: var(--accent);
  font-weight: 800;
}

.workspace {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

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

.controls {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef1ec;
}

.mode-button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
  cursor: pointer;
}

.mode-button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 8px rgba(15, 23, 42, 0.1);
}

.control-group {
  display: none;
  gap: 16px;
}

.control-group.active {
  display: grid;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

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

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

.button-row.single {
  grid-template-columns: 1fr;
}

.button-row button,
.download-row a {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.button-row button:nth-child(2) {
  background: var(--accent-2);
}

.button-row button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.meta-grid {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 4px;
}

.meta-grid div {
  display: grid;
  gap: 2px;
}

.meta-grid span {
  color: var(--muted);
  font-size: 12px;
}

.meta-grid strong {
  font-size: 15px;
}

.status-text {
  min-height: 42px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.viewer-section {
  min-width: 0;
}

.compare-viewer,
.wipe-viewer,
.sequence-viewer {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #101417;
  border-radius: 8px;
  box-shadow: var(--shadow);
  user-select: none;
  touch-action: none;
}

.compare-viewer {
  display: none;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
  background: var(--line);
}

.compare-viewer.active {
  display: grid;
}

.compare-viewer figure {
  position: relative;
  margin: 0;
  min-width: 0;
  background: #101417;
}

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

.compare-viewer figcaption {
  position: absolute;
  left: 14px;
  bottom: 14px;
  max-width: calc(100% - 28px);
  padding: 7px 10px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.wipe-viewer,
.sequence-viewer {
  display: none;
}

.wipe-viewer.active,
.sequence-viewer.active {
  display: block;
}

.wipe-viewer img,
.sequence-viewer img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.wipe-compare-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  clip-path: inset(0 50% 0 0);
}

.wipe-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 3px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 0 20px rgba(0, 0, 0, 0.55);
}

.wipe-handle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 42px;
  height: 42px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: rgba(20, 108, 99, 0.86);
  transform: translate(-50%, -50%);
}

.viewer-label {
  position: absolute;
  bottom: 14px;
  max-width: min(42%, 420px);
  padding: 7px 10px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.viewer-label.left {
  left: 14px;
}

.viewer-label.right {
  right: 14px;
  text-align: right;
}

.filmstrip-section {
  margin-top: 18px;
  padding-bottom: 8px;
}

.filmstrip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 156px;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 0 12px;
}

.thumb {
  display: grid;
  gap: 7px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: #fff;
  padding: 7px;
  cursor: pointer;
  text-align: left;
}

.thumb.active {
  border-color: var(--accent);
}

.thumb img {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 5px;
  object-fit: cover;
}

.thumb span {
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100vw - 20px, 720px);
    padding-top: 14px;
  }

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

  .source-note {
    justify-content: space-between;
  }

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

  .controls {
    order: 2;
  }

  .filmstrip {
    grid-auto-columns: 132px;
  }
}
