:root {
  color-scheme: dark;
  --bg: #101110;
  --panel: #1b1f1d;
  --panel-2: #252a27;
  --line: #39413d;
  --text: #f3f6f2;
  --muted: #a5aea8;
  --accent: #42d392;
  --accent-2: #6ec8ff;
  --warn: #f4b860;
  --danger: #ff7b8a;
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

button,
.button-link,
input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.button-link:hover,
input[type="submit"]:hover {
  border-color: var(--accent-2);
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary {
  border-color: transparent;
  background: var(--accent);
  color: #062017;
  font-weight: 800;
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 18px;
}

h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.05;
}

p {
  margin: 8px 0 0;
  color: var(--muted);
}

.start-grid {
  display: grid;
  grid-template-columns: minmax(320px, 520px) minmax(280px, 1fr);
  gap: 16px;
  align-items: start;
}

.workspace {
  display: grid;
  grid-template-columns: 310px 1fr;
  gap: 16px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.panel-title {
  min-height: 42px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.upload-panel {
  padding-bottom: 14px;
  position: sticky;
  top: 16px;
}

.upload-form {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.file-field {
  display: grid;
  gap: 8px;
  min-height: 112px;
  padding: 16px;
  border: 1px dashed #5a6861;
  border-radius: 8px;
  background: #141614;
}

.file-field span {
  font-size: 18px;
  font-weight: 800;
}

.file-field input {
  width: 100%;
  color: var(--muted);
}

.status {
  min-height: 68px;
  margin: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #141614;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.status.error {
  border-color: var(--danger);
  color: #ffd9de;
}

.sound-note,
.tone-note,
.empty-note,
.retention-note {
  padding: 12px;
  border: 1px solid #46534d;
  border-radius: 6px;
  background: #141a17;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.sound-note {
  margin: 0;
}

.tone-note {
  margin: 14px 14px 0;
}

.retention-note {
  margin: 14px 14px 0;
}

.tone-note.active {
  border-color: #5c7a54;
  background: #152017;
  color: #c2dfc1;
}

.empty-note {
  margin: 14px;
}

.privacy-copy {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.privacy-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.main-panel {
  display: grid;
  gap: 16px;
}

.video-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.viewer {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #070807;
}

.viewer-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  padding: 12px 14px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
}

video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #050605;
}

.analysis-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(360px, 1.4fr);
  gap: 16px;
}

.recommendation p,
.metrics {
  padding: 0 14px;
}

.big-number {
  padding: 20px 14px 4px;
  color: var(--accent);
  font-size: 52px;
  font-weight: 850;
  line-height: 1;
}

.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 14px;
}

.metrics span {
  padding: 7px 9px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
}

.controls {
  padding-bottom: 14px;
}

.controls > button {
  width: calc(100% - 28px);
  margin: 14px 14px 0;
}

.controls label {
  display: grid;
  grid-template-columns: 170px 1fr 92px;
  gap: 12px;
  align-items: center;
  padding: 14px 14px 0;
  color: var(--muted);
  font-size: 13px;
}

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

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

output {
  color: var(--text);
  text-align: right;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 14px 14px 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.segmented button {
  border: 0;
  border-radius: 0;
  background: transparent;
}

.segmented button.active {
  background: var(--accent-2);
  color: #03141b;
  font-weight: 800;
}

.toggle {
  grid-template-columns: 20px 1fr !important;
}

.progress-wrap {
  margin: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #141614;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

progress {
  width: 100%;
  height: 14px;
  accent-color: var(--accent);
}

.frame-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 10px;
  padding: 14px;
}

.frame-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #111311;
}

.frame-card img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.frame-card span {
  display: block;
  padding: 7px 8px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.output-panel {
  padding-bottom: 14px;
}

.output-panel video {
  border-bottom: 1px solid var(--line);
}

.download-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  margin: 14px 14px 0;
  padding: 0 14px;
  border-radius: 6px;
  background: var(--accent-2);
  color: #03141b;
  font-weight: 800;
  text-decoration: none;
}

@media (max-width: 980px) {
  .topbar,
  .workspace,
  .video-grid,
  .analysis-grid,
  .start-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .upload-panel {
    position: static;
  }

  .controls label {
    grid-template-columns: 1fr;
  }

  output {
    text-align: left;
  }
}
