:root {
  --bg: #f6f7fb;
  --text: #16202a;
  --muted: #647286;
  --line: #d9e0ea;
  --panel: #ffffff;
  --accent: #0f8b8d;
  --accent-dark: #0a6668;
  --danger: #c2410c;
  --happy: #f5b700;
  --neutral: #7c8a9a;
  --moved: #a855f7;
  --angry: #ef4444;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

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

.upload-hero {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.75fr);
  align-items: center;
  gap: 44px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-dark);
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: 48px;
}

h2 {
  font-size: 22px;
}

.lead {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.75;
}

.notice {
  margin-top: 24px;
  padding-left: 14px;
  border-left: 4px solid var(--accent);
  color: #334155;
  line-height: 1.7;
}

.upload-panel,
.summary-panel,
.video-panel,
.download-section,
.json-section,
.timeline-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 50px rgba(22, 32, 42, 0.08);
}

.upload-panel {
  padding: 28px;
}

input[type="file"] {
  width: 1px;
  height: 1px;
  opacity: 0;
  position: absolute;
}

.file-picker {
  display: flex;
  min-height: 142px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px dashed #9aa8ba;
  border-radius: 8px;
  background: #f8fafc;
  cursor: pointer;
  text-align: center;
}

.file-title {
  font-size: 20px;
  font-weight: 700;
}

.file-subtitle,
.status-text,
.section-title span {
  color: var(--muted);
}

button,
.secondary-button,
.secondary-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  background: var(--accent);
  color: white;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

button {
  width: 100%;
  margin-top: 18px;
}

.secondary-button {
  background: #334155;
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.progress-shell {
  height: 10px;
  margin-top: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7edf5;
}

.progress-bar {
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 0.2s ease;
}

.status-text {
  min-height: 22px;
  margin: 12px 0 0;
}

.result-shell {
  padding: 34px 0 48px;
}

.result-header,
.section-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.result-header {
  margin-bottom: 26px;
}

.result-header h1 {
  font-size: 34px;
  overflow-wrap: anywhere;
}

.media-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(310px, 0.75fr);
  gap: 20px;
}

.video-panel {
  padding: 14px;
}

video {
  display: block;
  width: 100%;
  max-height: 520px;
  border-radius: 6px;
  background: #0f172a;
}

.summary-panel {
  padding: 20px;
}

.summary-grid {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.summary-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}

.summary-card strong {
  font-size: 15px;
}

.summary-card span,
.segment-card span {
  color: var(--muted);
  font-size: 13px;
}

.timeline-section,
.download-section,
.json-section {
  margin-top: 22px;
  padding: 20px;
}

.download-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.download-card,
.download-empty,
.backend-note {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #fbfdff;
}

.download-card {
  display: grid;
  gap: 6px;
  color: var(--text);
  text-decoration: none;
}

.download-card:hover {
  border-color: var(--accent);
}

.download-card span,
.download-empty,
.backend-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.backend-note {
  grid-column: 1 / -1;
}

.timeline-track {
  display: flex;
  height: 36px;
  margin-top: 18px;
  overflow: hidden;
  border-radius: 6px;
  background: #e8eef6;
}

.timeline-block {
  min-width: 6px;
  height: 100%;
}

.segment-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.segment-card {
  border: 1px solid var(--line);
  border-left: 5px solid var(--neutral);
  border-radius: 6px;
  padding: 12px;
  background: #fbfdff;
}

.segment-card strong {
  display: block;
  margin-bottom: 8px;
}

pre {
  max-height: 360px;
  overflow: auto;
  margin: 18px 0 0;
  border-radius: 6px;
  padding: 16px;
  background: #101827;
  color: #e2e8f0;
  white-space: pre-wrap;
}

.timeline-block.emotion-happy { background: var(--happy); }
.timeline-block.emotion-neutral { background: var(--neutral); }
.timeline-block.emotion-moved { background: var(--moved); }
.timeline-block.emotion-angry { background: var(--angry); }

.segment-card.emotion-happy { border-left-color: var(--happy); }
.segment-card.emotion-neutral { border-left-color: var(--neutral); }
.segment-card.emotion-moved { border-left-color: var(--moved); }
.segment-card.emotion-angry { border-left-color: var(--angry); }

@media (max-width: 860px) {
  .upload-hero,
  .media-layout {
    grid-template-columns: 1fr;
  }

  .upload-hero {
    min-height: auto;
    padding: 36px 0;
  }

  h1 {
    font-size: 34px;
  }

  .result-header,
  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }
}

.watch-body {
  background: #101827;
}

.watch-screen {
  min-height: 100vh;
  color: white;
}

.player-stage {
  position: relative;
  height: calc(100vh - 118px);
  min-height: 620px;
  background: #050914;
}

.main-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0;
  background: #050914;
}

.camera-pip {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: clamp(132px, 12vw, 170px);
  z-index: 20;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  overflow: hidden;
  background: #0f172a;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.42);
}

.camera-pip video {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  transform: scaleX(-1);
  border-radius: 0;
}

.camera-pip canvas {
  display: none;
}

.camera-status {
  display: grid;
  gap: 2px;
  padding: 7px 9px;
  background: rgba(15, 23, 42, 0.92);
}

.camera-status span {
  color: #cbd5e1;
  font-size: 11px;
}

.camera-status strong {
  font-size: 13px;
}

.watch-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 18px;
  align-items: center;
  padding: 12px clamp(18px, 4vw, 40px);
  background: #f6f7fb;
  color: var(--text);
}

.watch-toolbar h1 {
  font-size: 24px;
  overflow-wrap: anywhere;
}

.watch-toolbar .lead {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.55;
}

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

.watch-actions button,
.watch-actions .secondary-link {
  width: 100%;
  margin: 0;
}

.watch-status {
  margin: 0;
  padding: 8px clamp(18px, 4vw, 40px) 10px;
  color: #d7dee9;
  background: #101827;
}

.rating-modal[hidden] {
  display: none;
}

.rating-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 9, 20, 0.72);
}

.rating-dialog {
  width: min(420px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 24px;
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
}

.rating-dialog h2 {
  font-size: 22px;
}

.rating-dialog p {
  margin: 12px 0 18px;
  color: var(--muted);
  line-height: 1.6;
}

.rating-buttons {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.rating-buttons button {
  min-height: 46px;
  margin: 0;
  padding: 0;
  font-size: 18px;
}

@media (max-width: 760px) {
  .player-stage {
    min-height: 460px;
    height: calc(100vh - 190px);
  }

  .camera-pip {
    right: 10px;
    bottom: 10px;
    width: clamp(112px, 30vw, 140px);
  }

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