/* Port Rec — página do vídeo */
:root {
  color-scheme: light dark;
  --bg: #F5F5F6;
  --surface: #FFFFFF;
  --surface-2: #F0F0F2;
  --border: #E4E4E8;
  --text: #17171A;
  --muted: #6B6B75;
  --faint: #9A9AA3;
  --accent: #E5484D;
  --accent-hover: #D63B41;
  --accent-soft: #FDEBEC;
  --accent-text: #C2272D;
  --ok: #138A47;
  --focus: #3B82F6;
  --mark: #FFE58A;
  --shadow: 0 1px 2px rgba(16, 16, 20, .05), 0 10px 30px rgba(16, 16, 20, .06);
  --radius: 16px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --header: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0D0D0F;
    --surface: #16161A;
    --surface-2: #202025;
    --border: #2A2A31;
    --text: #F4F4F5;
    --muted: #A1A1AA;
    --faint: #71717A;
    --accent-soft: rgba(229, 72, 77, .16);
    --accent-text: #FF8E92;
    --ok: #3DD68C;
    --mark: rgba(255, 214, 10, .35);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

svg.i {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
svg.f { fill: currentColor; stroke: none; }

/* ---------- topo ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: var(--header);
  padding: 0 max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -.01em;
  text-decoration: none;
}
.logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #16161A;
  display: grid;
  place-items: center;
  flex: none;
}
.logo::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2.5px #16161A, 0 0 0 4.2px #fff;
}
.logo.big { width: 56px; height: 56px; border-radius: 16px; }
.logo.big::before { width: 26px; height: 26px; box-shadow: 0 0 0 4px #16161A, 0 0 0 7px #fff; }
.top-actions { display: flex; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 24px;
  max-width: 1480px;
  margin: 0 auto;
  padding: 24px max(20px, env(safe-area-inset-right)) 48px max(20px, env(safe-area-inset-left));
}
.stage { min-width: 0; }

/* ---------- player ---------- */
.player {
  position: relative;
  width: 100%;
  aspect-ratio: var(--ar, 16 / 9);
  max-height: calc(100vh - var(--header) - 200px);
  min-height: 220px;
  margin: 0 auto;
  border-radius: var(--radius);
  background: #0B0B0D;
  overflow: hidden;
  box-shadow: var(--shadow);
  isolation: isolate;
}
.player video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  cursor: pointer;
}
.player:fullscreen { border-radius: 0; max-height: none; aspect-ratio: auto; }

.big-play {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  margin: -42px 0 0 -42px;
  border: 0;
  border-radius: 50%;
  background: rgba(229, 72, 77, .95);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 12px 40px rgba(229, 72, 77, .45);
  transition: transform .15s ease, opacity .2s ease;
}
.big-play:hover { transform: scale(1.06); }
.big-play svg { width: 34px; height: 34px; margin-left: 4px; }
.player.playing .big-play { opacity: 0; pointer-events: none; transform: scale(.9); }

.spinner-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .2);
  border-top-color: #fff;
  animation: spin .8s linear infinite;
  display: none;
}
.player.waiting .spinner-ring { display: block; }

.controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  padding: 36px 16px 12px;
  background: linear-gradient(to top, rgba(0, 0, 0, .78), rgba(0, 0, 0, .35) 60%, transparent);
  color: #fff;
  opacity: 1;
  transition: opacity .25s ease;
}
.player.playing.idle .controls { opacity: 0; }
.player.playing.idle { cursor: none; }
.player.playing.idle video { cursor: none; }

.progress {
  position: relative;
  height: 18px;
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: none;
}
.progress .track {
  position: relative;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .25);
  overflow: hidden;
  transition: height .15s ease;
}
.progress:hover .track, .progress.dragging .track { height: 6px; }
.progress .buffered, .progress .played {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
}
.progress .buffered { background: rgba(255, 255, 255, .35); }
.progress .played { background: var(--accent); }
.progress .knob {
  position: absolute;
  top: 50%;
  left: 0;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .4);
  transform: scale(0);
  transition: transform .15s ease;
}
.progress:hover .knob, .progress.dragging .knob { transform: scale(1); }
.progress .hover-time {
  position: absolute;
  bottom: 22px;
  left: 0;
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(0, 0, 0, .85);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transform: translateX(-50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity .1s;
}
.progress:hover .hover-time, .progress.dragging .hover-time { opacity: 1; }

.bar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}
.ctl {
  display: inline-grid;
  place-items: center;
  min-width: 38px;
  height: 38px;
  padding: 0 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.ctl:hover { background: rgba(255, 255, 255, .14); }
.ctl svg { width: 20px; height: 20px; }
.time {
  margin: 0 8px;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, .92);
  white-space: nowrap;
}
.spacer { flex: 1; }
.volume {
  width: 0;
  opacity: 0;
  accent-color: #fff;
  transition: width .2s ease, opacity .2s ease;
}
.vol-wrap { display: flex; align-items: center; }
.vol-wrap:hover .volume, .volume:focus-visible { width: 80px; opacity: 1; margin-right: 6px; }

/* ---------- processando ---------- */
.processing {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  color: #fff;
  text-align: center;
  background:
    radial-gradient(60% 80% at 20% 20%, rgba(229, 72, 77, .35), transparent 60%),
    radial-gradient(60% 80% at 80% 80%, rgba(99, 102, 241, .28), transparent 60%),
    #0F0F12;
  background-size: 140% 140%;
  animation: drift 9s ease-in-out infinite alternate;
}
.processing-card { max-width: 420px; }
.processing .orb {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .15);
  border-top-color: #fff;
  animation: spin 1s linear infinite;
}
.processing h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: -.02em; }
.processing p { margin: 0; color: rgba(255, 255, 255, .72); font-size: 14px; }
.steps {
  display: inline-flex;
  flex-direction: column;
  gap: 8px;
  margin: 18px auto 0;
  padding: 14px 18px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .07);
  text-align: left;
  font-size: 14px;
}
.step { display: flex; align-items: center; gap: 10px; color: rgba(255, 255, 255, .6); }
.step .dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .3);
  flex: none;
}
.step.active { color: #fff; }
.step.active .dot { border-color: rgba(255, 255, 255, .25); border-top-color: #fff; animation: spin .8s linear infinite; }
.step.done { color: #fff; }
.step.done .dot {
  border: 0;
  background: #3DD68C url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23062b17' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 12px no-repeat;
}
.processing.failed .orb { animation: none; border-color: var(--accent); }

/* ---------- informações ---------- */
.info { padding: 20px 2px 0; }
.info h1 {
  margin: 0;
  font-size: clamp(20px, 2.2vw, 26px);
  line-height: 1.25;
  letter-spacing: -.02em;
}
.byline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
}
.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex: none;
}
.byline .who { color: var(--text); font-weight: 600; }
.byline .sep { width: 3px; height: 3px; border-radius: 50%; background: var(--faint); }
.desc-wrap {
  margin-top: 16px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}
.desc { margin: 0; font-size: 15px; line-height: 1.6; white-space: pre-wrap; }
.desc:empty { display: none; }
.desc-wrap:has(.desc:empty):has(.ai-note[hidden]) { display: none; }
.ai-note {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 10px 0 0;
  color: var(--faint);
  font-size: 12px;
}
.desc:empty + .ai-note { margin-top: 0; }
.ai-note svg.i { width: 14px; height: 14px; }

/* ---------- transcrição ---------- */
.side {
  position: sticky;
  top: calc(var(--header) + 24px);
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header) - 48px);
  min-height: 360px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px 10px 18px;
}
.side-head h2 { margin: 0; font-size: 15px; letter-spacing: -.01em; }
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 14px 8px;
  padding: 0 10px;
  height: 36px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
}
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 14px;
  color: var(--text);
}
.search svg.i { width: 16px; height: 16px; }
.segments {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 16px;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}
.seg {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background .12s;
}
.seg:hover { background: var(--surface-2); }
.seg .t {
  padding-top: 1px;
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.seg .x { font-size: 14px; line-height: 1.5; color: var(--muted); }
.seg.active { background: var(--accent-soft); }
.seg.active .x { color: var(--text); }
.seg.past .x { color: var(--text); }
.seg mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
.seg.hide { display: none; }
.side-msg {
  display: grid;
  place-items: center;
  gap: 10px;
  height: 100%;
  min-height: 200px;
  padding: 24px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}
.side-msg svg.i { width: 28px; height: 28px; color: var(--faint); }
.skeleton { padding: 8px 10px; }
.skeleton div {
  height: 12px;
  margin: 12px 0;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2), color-mix(in srgb, var(--surface-2) 40%, var(--border)), var(--surface-2));
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.skeleton .note { height: auto; background: none; animation: none; color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.mini-spin {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  padding: 10px 16px;
  border-radius: 12px;
  background: #17171A;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- páginas de mensagem ---------- */
.message { display: grid; place-items: center; min-height: calc(100vh - var(--header)); padding: 24px; }
.message-card { max-width: 420px; text-align: center; }
.message-card h1 { margin: 18px 0 6px; font-size: 24px; letter-spacing: -.02em; }
.message-card p { margin: 0; color: var(--muted); }
.message-card .logo { margin: 0 auto; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes drift { from { background-position: 0% 0%; } to { background-position: 100% 100%; } }

/* ---------- celular / tablet ---------- */
@media (max-width: 1024px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 20px; padding-top: 16px; }
  .side { position: static; height: auto; max-height: 70vh; min-height: 0; }
  .player { max-height: none; }
}
@media (max-width: 600px) {
  :root { --header: 56px; }
  .layout { padding-left: 0; padding-right: 0; padding-top: 0; }
  .player { border-radius: 0; box-shadow: none; }
  .info, .side { margin: 0 16px; }
  .info { padding-top: 16px; }
  .side { border-radius: 14px; }
  .top-actions .btn span { display: none; }
  .top-actions .btn { width: 38px; padding: 0; }
  .time { margin: 0 4px; font-size: 12px; }
  .ctl.hide-sm { display: none; }
  .big-play { width: 68px; height: 68px; margin: -34px 0 0 -34px; }
  .processing h2 { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
