/* CLIPAR: botão claquete aceso, janela com as abas "Novo clipe" e "Clipes da chamada", aviso de clipe novo. */
#stage-controls .sc-btn.clipping { background: var(--brand); color: #fff; box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 30%, transparent); }
/* Ao clipar (e ao abrir a janela), a claquete bate. A animação "clap" fica no motion.css. */
#stage-controls .sc-btn.clipping .clap, .clip-badge .clap { animation: clap .7s ease-in-out; }
.clip-badge .clap { animation-delay: .12s; }

/* Barra de cima da chamada: escolha de grade ou destaque à direita. */
.stage-actions { position: relative; display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* ---------- Janela ---------- */
.clip-card {
  position: relative; width: min(760px, 100%); max-height: calc(100dvh - 32px); padding: 0; display: flex; flex-direction: column;
  background: var(--bg-main); border: 1px solid var(--divider); border-radius: 18px; box-shadow: 0 24px 80px rgba(0, 0, 0, .6);
}
/* Um brilho da cor da marca atrás do título. */
.clip-card::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 140px; pointer-events: none;
  background: radial-gradient(120% 100% at 0% 0%, color-mix(in srgb, var(--brand) 22%, transparent), transparent 70%);
}
.clip-card [hidden] { display: none !important; }
.clip-card p { padding: 0; line-height: 1.35; }
.clip-head { position: relative; display: flex; align-items: center; gap: 12px; padding: 18px 20px 0; }
.clip-badge {
  display: grid; place-items: center; width: 40px; height: 40px; flex-shrink: 0; border-radius: 12px; color: #fff;
  background: var(--brand-gradient, var(--brand)); box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 40%, transparent);
}
.clip-head-text { flex: 1; min-width: 0; }
.clip-card .clip-head h2 { margin: 0; padding: 0; font-size: 18px; line-height: 1.2; color: var(--text-strong); }
.clip-card .clip-sub { margin: 2px 0 0; color: var(--text-muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clip-close {
  display: grid; place-items: center; width: 32px; height: 32px; flex-shrink: 0; align-self: flex-start; border: 0; border-radius: 50%;
  background: transparent; color: var(--text-muted); cursor: pointer; transition: transform .2s;
}
.clip-close:hover { background: var(--hover-strong); color: var(--text); transform: rotate(90deg); }

/* Abas: controle segmentado. */
.clip-tabs { position: relative; display: flex; gap: 4px; margin: 16px 20px 0; padding: 4px; border-radius: 12px; background: var(--bg-panel); border: 1px solid var(--divider); }
.clip-tab {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 34px; padding: 0 12px; border: 0; border-radius: 9px;
  background: transparent; color: var(--text-muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: none;
}
.clip-tab > span { white-space: nowrap; }
.clip-tab:hover:not(:disabled):not(.active) { color: var(--text); background: var(--hover); }
.clip-tab.active { background: var(--bg-main); color: var(--text-strong); box-shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 2px 8px rgba(0, 0, 0, .3); }
.clip-tab.active svg { color: var(--brand); }
.clip-tab:disabled { opacity: .45; cursor: not-allowed; }
.clip-tab:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.clip-tab-count {
  min-width: 20px; height: 20px; padding: 0 6px; box-sizing: border-box; border-radius: 10px; background: var(--hover-strong); color: var(--text);
  font-size: 11px; font-weight: 700; line-height: 20px; font-variant-numeric: tabular-nums;
}
.clip-tab.active .clip-tab-count { background: var(--brand); color: #fff; }

.clip-panel { position: relative; display: flex; flex-direction: column; gap: 14px; padding: 16px 20px; min-height: 0; }

/* ---------- Aba "Novo clipe" ---------- */
.clip-cutter { overflow-y: auto; }
.clip-stage { flex-shrink: 0; align-self: center; width: min(100%, max(320px, (100dvh - 600px) * 16 / 9)); border-radius: 14px; overflow: hidden; background: #0d0b12; aspect-ratio: 16 / 9; border: 1px solid var(--divider); box-shadow: 0 8px 24px rgba(0, 0, 0, .35); }
.clip-preview { display: block; width: 100%; height: 100%; }

.clip-timeline { display: flex; flex-direction: column; gap: 6px; }
.clip-wave { position: relative; height: 68px; border-radius: 12px; background: var(--bg-panel); border: 1px solid var(--divider); overflow: hidden; }
.clip-wave-bars { position: absolute; inset: 0; width: 100%; height: 100%; }
.clip-shade { position: absolute; top: 0; bottom: 0; background: rgba(0, 0, 0, .5); pointer-events: none; }
.clip-shade.left { left: 0; }
.clip-shade.right { right: 0; }
.clip-window {
  position: absolute; top: 0; bottom: 0; border: 2px solid var(--brand); border-radius: 10px; pointer-events: none;
  background: color-mix(in srgb, var(--brand) 8%, transparent); box-shadow: 0 0 0 1px rgba(0, 0, 0, .3), 0 0 18px color-mix(in srgb, var(--brand) 35%, transparent);
}
.clip-playhead { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #fff; pointer-events: none; box-shadow: 0 0 6px rgba(255, 255, 255, .6); }
.clip-playhead.hidden { display: none; }
/* As duas alças são sliders sobrepostos: só o pegador recebe o mouse, o trilho deixa passar.
   Seletores mais fortes que o input[type=range] global dos controles. */
.clip-wave input.clip-handle[type=range] { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; background: none; pointer-events: none; -webkit-appearance: none; appearance: none; cursor: default; }
.clip-wave input.clip-handle[type=range]:focus { outline: none; }
.clip-wave input.clip-handle[type=range]::-webkit-slider-runnable-track { height: 100%; background: none; border: 0; }
.clip-wave input.clip-handle[type=range]::-moz-range-track { height: 100%; background: none; }
.clip-wave input.clip-handle[type=range]::-moz-range-progress { background: none; }
.clip-wave input.clip-handle[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; pointer-events: auto; width: 14px; height: 100%; margin-top: 0; border: 0; border-radius: 7px; cursor: ew-resize;
  background: linear-gradient(#fff, #fff) center / 2px 20px no-repeat, var(--brand); box-shadow: 0 0 0 2px rgba(0, 0, 0, .35); transition: transform .12s;
}
.clip-wave input.clip-handle[type=range]::-moz-range-thumb {
  pointer-events: auto; width: 14px; height: 66px; border: 0; border-radius: 7px; cursor: ew-resize;
  background: linear-gradient(#fff, #fff) center / 2px 20px no-repeat, var(--brand); box-shadow: 0 0 0 2px rgba(0, 0, 0, .35);
}
.clip-wave input.clip-handle[type=range]:hover::-webkit-slider-thumb { transform: scaleX(1.2); }
.clip-wave input.clip-handle[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 2px #fff, 0 0 0 5px color-mix(in srgb, var(--brand) 45%, transparent); }
.clip-wave input.clip-handle[type=range]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 2px #fff, 0 0 0 5px color-mix(in srgb, var(--brand) 45%, transparent); }
.clip-ruler { position: relative; height: 14px; margin: 0 2px; font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.clip-ruler span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.clip-ruler span:first-child { transform: none; }
.clip-ruler span:last-child { transform: translateX(-100%); }

.clip-info { display: flex; align-items: center; gap: 14px; }
.clip-span {
  flex-shrink: 0; padding: 8px 12px; border-radius: 10px; font-size: 20px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums;
  color: var(--text-strong); background: color-mix(in srgb, var(--brand) 18%, var(--bg-panel)); border: 1px solid color-mix(in srgb, var(--brand) 40%, transparent);
}
.clip-info-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.clip-card .clip-selection { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); font-size: 13px; }
.clip-who-row { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--text-muted); }
.clip-who-row svg { flex-shrink: 0; }
.clip-card .clip-who { margin: 0; color: var(--text-muted); font-size: 12px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Título do clipe (opcional): uma linha entre a prévia e a onda do som. */
.clip-title-box {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0; height: 40px; padding: 0 12px; border-radius: 10px; cursor: text;
  background: var(--bg-input); border: 1px solid var(--divider); transition: border-color .15s, box-shadow .15s;
}
.clip-title-box svg { flex-shrink: 0; color: var(--text-muted); transition: color .15s; }
.clip-title-box:focus-within svg { color: var(--brand); }
.clip-title-box:hover { border-color: color-mix(in srgb, var(--brand) 35%, var(--divider)); }
.clip-title-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
.clip-title-field { flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; outline: 0; background: transparent; color: var(--text-strong); font: inherit; font-size: 14px; font-weight: 600; }
.clip-card .clip-title-field:focus-visible { outline: none; } /* o contorno roxo é da caixa inteira */
.clip-title-field::placeholder { color: var(--text-muted); font-weight: 500; }
.clip-title-count { flex-shrink: 0; font-size: 11px; font-variant-numeric: tabular-nums; color: var(--text-muted); opacity: 0; transition: opacity .15s; }
.clip-title-box:focus-within .clip-title-count, .clip-title-count.full { opacity: 1; }
.clip-title-count.full { color: var(--brand); }

.clip-card .clip-actions { display: flex; align-items: center; gap: 8px; margin: 0; padding: 14px 20px; background: var(--bg-sidebar); border-top: 1px solid var(--divider); border-radius: 0 0 17px 17px; }
.clip-actions .clip-spacer { flex: 1; }
.clip-listen { display: inline-flex; align-items: center; gap: 6px; border-radius: 9px; }
.clip-card .clip-listen.playing { color: var(--brand); }
.clip-release { border-radius: 10px; }
.clip-release:disabled { opacity: .7; cursor: progress; }

/* ---------- Aba "Clipes da chamada" ---------- */
.clip-library { min-height: 300px; max-height: min(62dvh, 560px); overflow-y: auto; padding-bottom: 20px; }
.clip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.clip-item {
  display: flex; flex-direction: column; border-radius: 14px; overflow: hidden; background: var(--bg-panel); border: 1px solid var(--divider);
  transition: transform .15s var(--spring, ease-out);
}
.clip-item:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--brand) 55%, var(--divider)); box-shadow: 0 10px 28px rgba(0, 0, 0, .35); }
.clip-item-media { position: relative; aspect-ratio: 16 / 9; background: #0d0b12; }
.clip-item-thumb { display: block; width: 100%; height: 100%; object-fit: cover; }
.clip-item-length {
  position: absolute; right: 8px; bottom: 8px; padding: 2px 7px; border-radius: 6px; background: rgba(0, 0, 0, .72); color: #fff;
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.clip-item-body { display: flex; flex-direction: column; gap: 4px; padding: 10px 10px 10px 12px; }
.clip-item-title {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere;
  font-size: 14px; font-weight: 600; line-height: 1.3; color: var(--text);
}
.clip-item-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.clip-item-row small { flex: 1; min-width: 0; font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clip-item-title.named { color: var(--text-strong); font-weight: 700; }
.clip-item-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.clip-rename {
  display: grid; place-items: center; width: 32px; height: 32px; flex-shrink: 0; border: 0; border-radius: 9px;
  background: transparent; color: var(--text-muted); cursor: pointer; transition: background .12s, color .12s;
}
.clip-rename:hover { background: var(--hover-strong); color: var(--text-strong); }
.clip-rename:focus-visible, .clip-title-input:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.clip-title-input {
  width: 100%; min-width: 0; height: 30px; padding: 0 8px; border-radius: 7px; border: 1px solid var(--brand);
  background: var(--bg-input); color: var(--text-strong); font: inherit; font-size: 14px; font-weight: 700;
}
.clip-notice-text strong.clip-notice-title { color: var(--text-strong); }
.clip-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; flex: 1; padding: 40px 16px; text-align: center; }
.clip-empty-icon {
  display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: 6px; border-radius: 18px;
  color: var(--brand); background: color-mix(in srgb, var(--brand) 14%, var(--bg-panel)); border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent);
}
.clip-empty strong { color: var(--text-strong); font-size: 15px; }
.clip-empty small { color: var(--text-muted); font-size: 13px; max-width: 320px; }

/* "Pode clipar meu áudio", nas duas abas. */
.clip-privacy {
  display: flex; align-items: center; gap: 12px; margin: 0 20px 16px; padding: 10px 12px; border-radius: 12px; cursor: pointer;
  background: var(--bg-panel); border: 1px solid var(--divider); transition: none;
}
.clip-privacy:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--divider)); }
.clip-privacy-icon { display: grid; place-items: center; width: 32px; height: 32px; flex-shrink: 0; border-radius: 10px; color: var(--brand); background: color-mix(in srgb, var(--brand) 14%, transparent); }
.clip-privacy:has(input:not(:checked)) .clip-privacy-icon { color: var(--text-muted); background: var(--hover); }
.clip-privacy-text { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.clip-privacy-text strong { font-size: 13px; color: var(--text-strong); }
.clip-privacy-text small { font-size: 12px; color: var(--text-muted); }
.clip-card[data-tab=list] .clip-library { padding-bottom: 12px; }

/* ---------- Aviso de clipe novo: canto de baixo, acima da barra da chamada. ---------- */
#clip-notices { position: fixed; right: 20px; bottom: 96px; z-index: 46; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.clip-notice {
  display: flex; align-items: center; gap: 12px;
  pointer-events: auto; width: min(400px, calc(100vw - 32px)); padding: 10px; border: 1px solid var(--divider); border-radius: 14px;
  background: var(--bg-floating); box-shadow: var(--elev-2), var(--edge-light); animation: clip-in .28s var(--ease-enter);
}
.clip-notice.leaving { animation: clip-out .2s ease-in forwards; }
@keyframes clip-in { from { opacity: 0; transform: translateY(12px) scale(.97); } }
@keyframes clip-out { to { opacity: 0; transform: translateY(8px); } }
.clip-thumb { width: 80px; height: 45px; flex-shrink: 0; border-radius: 8px; object-fit: cover; background: #0d0b12; border: 1px solid var(--divider); }
.clip-notice-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.clip-notice-text strong { font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clip-notice-text small { font-size: 12px; line-height: 1.35; color: var(--text-muted); }
.clip-download {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; flex-shrink: 0; border: 0; border-radius: 9px;
  background: var(--hover-strong); color: var(--text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: transform .12s;
}
.clip-download.primary { background: var(--brand); color: #fff; }
.clip-download:hover { background: var(--hover); }
.clip-item .clip-download:hover { background: var(--brand); color: #fff; }
.clip-download.primary:hover { background: var(--brand-hover); }
.clip-download:active { transform: scale(.96); }
.clip-notice-close { display: grid; place-items: center; width: 24px; height: 24px; flex-shrink: 0; border: 0; border-radius: 50%; background: transparent; color: var(--text-muted); cursor: pointer; }
.clip-notice-close:hover { background: var(--hover-strong); color: var(--text); }

:root[data-reduce-motion=true] :is(.clip-notice, #stage-controls .sc-btn.clipping .clap, .clip-badge .clap) { animation: none; }
:root[data-reduce-motion=true] .clip-item:hover { transform: none; }

@media (max-width: 640px) {
  .clip-head { padding: 14px 14px 0; }
  .clip-card .clip-sub { white-space: normal; text-wrap: pretty; }
  .clip-tabs { margin: 12px 14px 0; }
  .clip-tab { padding: 0 8px; gap: 6px; }
  .clip-tab-extra { display: none; }
  .clip-panel { padding: 12px 14px; gap: 12px; }
  .clip-privacy { margin: 0 14px 12px; }
  .clip-card .clip-actions { padding: 12px 14px; flex-wrap: wrap; }
  .clip-actions .clip-spacer { display: none; }
  .clip-actions button { flex: 1; justify-content: center; white-space: nowrap; }
  .clip-actions .clip-release { flex-basis: 100%; order: -1; }
  .clip-span { font-size: 17px; padding: 7px 10px; }
  .clip-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .clip-item-body { gap: 6px; padding: 8px; }
  .clip-item-row { flex-wrap: wrap; }
  .clip-item-row small { flex-basis: 100%; }
  .clip-item-actions { flex: 1; }
  .clip-item .clip-download { justify-content: center; }
  .clip-item-actions .clip-download { flex: 1; }
  .clip-title-field { font-size: 16px; } /* menos de 16 px faz o iPhone dar zoom ao tocar */
  .clip-title-input { font-size: 16px; }
  #clip-notices { right: 16px; left: 16px; bottom: 84px; }
  .clip-notice { width: 100%; }
}
