:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --ink: #1d2320;
  --muted: #68736c;
  --line: #d9dfd8;
  --accent: #196f6a;
  --accent-strong: #124f4d;
  --warm: #b86b2b;
  --shadow: 0 18px 45px rgba(32, 42, 38, 0.1);
}

* {
  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;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  gap: 24px;
}

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

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  padding: 4px;
}

.nav-links a {
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
  padding: 8px 12px;
}

.nav-links a.active {
  background: var(--ink);
  color: #fff;
}

.page-head {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  align-items: end;
  gap: 42px;
  padding: 58px 0 36px;
}

.page-head.compact {
  padding-top: 28px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--warm);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  max-width: 820px;
  margin-bottom: 0;
  font-size: clamp(34px, 5vw, 68px);
  line-height: 0.98;
  letter-spacing: 0;
}

.page-head p:not(.eyebrow) {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding-bottom: 56px;
}

.tool-card {
  min-height: 230px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 22px;
  box-shadow: var(--shadow);
}

.tool-card.primary {
  background: #fefefe;
  border-color: rgba(25, 111, 106, 0.28);
}

.tool-card.muted {
  opacity: 0.72;
}

.tool-kicker {
  display: inline-block;
  margin-bottom: 22px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.tool-card h2 {
  margin-bottom: 12px;
  font-size: 24px;
  line-height: 1.15;
}

.tool-card p {
  color: var(--muted);
  line-height: 1.55;
}

.tool-action {
  display: inline-block;
  margin-top: 22px;
  color: var(--accent-strong);
  font-weight: 800;
}

.compare-app {
  width: calc(100vw - 16px);
  max-width: none;
  padding-bottom: 36px;
}

.compare-app .page-head.compact {
  grid-template-columns: minmax(0, auto) minmax(360px, 1fr);
  gap: 22px;
  padding: 12px 0 14px;
}

.compare-app .page-head h1 {
  max-width: none;
  font-size: clamp(26px, 2.2vw, 40px);
  line-height: 1.05;
}

.compare-app .page-head .eyebrow {
  margin-bottom: 6px;
}

.compare-app .page-head p:not(.eyebrow) {
  font-size: 14px;
  line-height: 1.45;
}

.compare-toolbar,
.video-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.compare-toolbar {
  display: grid;
  grid-template-columns: auto auto minmax(220px, 1fr) auto minmax(104px, 130px) auto;
  align-items: end;
  gap: 12px;
  margin-bottom: 10px;
  padding: 10px;
}

.icon-button,
.text-button,
.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 750;
}

.icon-button {
  width: 42px;
  font-size: 18px;
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.text-button {
  padding: 0 14px;
  white-space: nowrap;
}

.compact-button {
  min-height: 40px;
  padding: 0 12px;
}

.control {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.control span,
.check-control,
.panel-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.control input,
.control select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

.control input[type="range"] {
  padding: 0;
}

.time-readout {
  min-width: 154px;
  padding-bottom: 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-weight: 760;
  text-align: right;
}

.video-grid {
  display: grid;
  grid-template-columns: minmax(260px, var(--left-panel, 1fr)) 12px minmax(260px, var(--right-panel, 1fr));
  gap: 10px;
  align-items: stretch;
}

.video-panel {
  min-width: 0;
  overflow: hidden;
}

.splitter {
  width: 12px;
  min-height: 100%;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(90deg, transparent 0 3px, var(--line) 3px 5px, transparent 5px 7px, var(--line) 7px 9px, transparent 9px);
  cursor: col-resize;
}

.splitter:hover,
.splitter.dragging {
  background: var(--accent);
}

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

.panel-head strong {
  display: block;
  max-width: 42vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-button {
  position: relative;
  min-width: 76px;
  padding: 0 14px;
}

.file-button input {
  position: absolute;
  inset: 0;
  cursor: pointer;
  opacity: 0;
}

.drop-zone {
  position: relative;
  display: grid;
  min-height: clamp(440px, calc(100vh - 280px), 900px);
  place-items: center;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #111816;
  overflow: hidden;
}

.drop-zone.dragging {
  outline: 3px solid rgba(25, 111, 106, 0.45);
  outline-offset: -6px;
}

video {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 16 / 9;
  background: #0d1211;
  object-fit: contain;
  transform: translate(var(--pan-x, 0px), var(--pan-y, 0px)) scale(var(--zoom, 1));
  transform-origin: center;
  transition: transform 120ms ease;
  will-change: transform;
}

.video-viewport {
  display: none;
  width: 100%;
  height: clamp(440px, calc(100vh - 280px), 900px);
  min-height: 440px;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}

.has-video .video-viewport {
  display: block;
}

.video-viewport.dragging {
  cursor: grabbing;
}

.video-viewport.dragging video {
  transition: none;
}

.empty-state {
  color: rgba(255, 255, 255, 0.72);
  font-weight: 760;
}

.has-video .empty-state {
  display: none;
}

.panel-controls {
  flex-wrap: wrap;
}

.panel-controls .control {
  width: min(170px, 52%);
}

.panel-controls .zoom-control {
  flex: 1 1 180px;
  width: auto;
}

.check-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
}

@media (max-width: 920px) {
  .page-head,
  .tool-grid,
  .video-grid {
    grid-template-columns: 1fr;
  }

  .page-head {
    gap: 20px;
    padding-top: 34px;
  }

  .compare-app .page-head.compact {
    grid-template-columns: 1fr;
    gap: 8px;
    padding-top: 10px;
  }

  .tool-grid {
    padding-bottom: 34px;
  }

  .compare-toolbar {
    grid-template-columns: auto auto 1fr;
  }

  .control.wide,
  .time-readout,
  .control.small,
  .text-button {
    grid-column: 1 / -1;
  }

  .time-readout {
    padding-bottom: 0;
    text-align: left;
  }

  .panel-head strong {
    max-width: 66vw;
  }

  .splitter {
    display: none;
  }

  .drop-zone,
  .video-viewport {
    height: min(58vh, 560px);
    min-height: 320px;
  }
}

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

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 0;
  }

  .nav-links {
    width: 100%;
  }

  .nav-links a {
    flex: 1;
    text-align: center;
  }

  h1 {
    font-size: 36px;
  }

  .drop-zone {
    min-height: 260px;
  }

  .video-viewport {
    height: min(52vh, 420px);
    min-height: 260px;
  }
}
