/* ---------- Dialogs ---------- */

body:has(dialog[open]:not(.player-minimized)) {
  overflow: hidden;
}

.modal {
  width: min(560px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100vh - 40px);
  margin: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  overflow: visible;
}

.modal.modal-wide {
  width: min(760px, calc(100vw - 32px));
}

.modal::backdrop {
  background: rgba(3, 6, 15, 0.74);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}

.modal-card {
  max-height: calc(100vh - 40px);
  padding: 24px;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  background: #0e1526;
  box-shadow: 0 40px 110px rgba(0, 0, 0, 0.65);
  animation: modal-in 0.18s ease-out;
}

.modal-card::-webkit-scrollbar {
  width: 6px;
}

.modal-card::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.13);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(9px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.modal-head h2 {
  margin-top: 4px;
  font-size: 22px;
  font-weight: 800;
}

.modal-head .small {
  max-width: 460px;
  margin-top: 5px;
}

.modal-head .icon-btn {
  flex: 0 0 auto;
}

.modal .field {
  margin-bottom: 14px;
}

.modal .field-row {
  gap: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.modal-actions .btn {
  min-width: 100px;
}

.modal-divider {
  height: 1px;
  margin: 24px 0 19px;
  border: 0;
  background: var(--line);
}

.modal-subtitle {
  font-size: 15px;
  font-weight: 700;
}

.modal .hint {
  margin-top: 4px;
  color: var(--muted-2);
  font-size: 11.5px;
  line-height: 1.55;
}

.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 13px;
}

.data-actions .btn {
  min-height: 35px;
  padding: 6px 12px;
  font-size: 11.5px;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 17px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}

/* ---------- Swatches ---------- */

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding-top: 3px;
}

.swatch {
  position: relative;
  display: block;
  cursor: pointer;
}

.swatch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.swatch span {
  display: block;
  width: 31px;
  height: 31px;
  border: 2px solid transparent;
  border-radius: 10px;
  background: var(--sc);
  transition: transform 0.15s ease, outline-color 0.15s ease;
}

.swatch:hover span {
  transform: scale(1.08);
}

.swatch input:checked + span {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.swatch input:focus-visible + span {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

/* ---------- Quick mark ---------- */

.quick-controls {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 17px;
}

.quick-controls .field {
  margin: 0;
}

.quick-date-field {
  width: 160px;
  flex: 0 0 auto;
}

.quick-controls .grow {
  flex: 1;
  min-width: 210px;
}

.quick-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 45vh;
  overflow-y: auto;
  padding-right: 5px;
}

.quick-group h4 {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 5px;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.quick-group h4 .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pc);
}

.quick-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 9px;
}

.quick-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.quick-item .q-info {
  min-width: 0;
  flex: 1;
}

.quick-item .q-title {
  display: block;
  overflow: hidden;
  color: var(--text-soft);
  font-size: 12.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-item .q-meta {
  color: var(--muted-2);
  font-size: 9.5px;
  font-weight: 600;
}

.quick-item .btn {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 10.5px;
}

.quick-empty {
  padding: 38px 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
  text-align: center;
}

.quick-empty strong {
  display: block;
  margin-bottom: 3px;
  color: var(--text-soft);
  font-size: 14px;
}

/* ---------- Confirm ---------- */

.confirm-card {
  text-align: center;
}

.confirm-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin: 2px auto 14px;
  border: 1px solid rgba(251, 113, 133, 0.25);
  border-radius: 50%;
  background: rgba(251, 113, 133, 0.1);
  color: #fda4af;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
}

.confirm-card h2 {
  font-size: 20px;
}

.confirm-card p {
  max-width: 380px;
  margin: 8px auto 0;
  font-size: 12.5px;
  line-height: 1.6;
}

.confirm-card .modal-actions {
  justify-content: center;
}

/* ---------- Toast ---------- */

.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(340px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 15px;
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--green);
  border-radius: 12px;
  background: #141c31;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.24s ease-out;
}

.toast.leaving {
  animation: toast-out 0.22s ease-in forwards;
}

.toast .toast-icon {
  flex: 0 0 auto;
  font-size: 14px;
  line-height: 1.3;
}

.toast strong {
  color: var(--text);
  font-weight: 800;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(5px) scale(0.98);
  }
}

/* ---------- Confetti ---------- */

.confetti {
  position: fixed;
  inset: 0;
  z-index: 200;
  overflow: hidden;
  pointer-events: none;
}

.confetti i {
  position: absolute;
  top: -20px;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  animation: confetti-fall 2s cubic-bezier(0.2, 0.65, 0.4, 1) forwards;
}

@keyframes confetti-fall {
  0% {
    opacity: 1;
    transform: translate3d(0, -10px, 0) rotate(0deg);
  }
  100% {
    opacity: 0.9;
    transform: translate3d(var(--drift, 0px), 105vh, 0) rotate(760deg);
  }
}

/* ---------- Settings: flexible goals ---------- */

.settings-section {
  margin-bottom: 22px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.settings-section:last-of-type {
  margin-bottom: 8px;
  padding-bottom: 0;
  border-bottom: 0;
}

.settings-section > .modal-subtitle {
  margin-bottom: 11px;
}

.switch-line {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 10px;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.switch-line input {
  width: 17px;
  height: 17px;
  accent-color: var(--violet);
  cursor: pointer;
}

.day-goals {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.day-goal {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
}

.day-name {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.day-goal .input {
  min-height: 31px;
  padding: 4px 7px;
  font-size: 11.5px;
}

.rest-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.rest-check input {
  width: 13px;
  height: 13px;
  accent-color: var(--violet);
}

.freeze-row {
  align-items: end;
  margin-top: 13px;
}

.freeze-row .switch-line {
  margin-top: 0;
  padding-bottom: 10px;
}

/* ---------- YouTube import ---------- */

.modal.modal-wide {
  width: min(780px, calc(100vw - 32px));
}

.yt-url-row {
  display: flex;
  gap: 8px;
}

.yt-url-row .input {
  flex: 1;
  min-width: 0;
}

.yt-url-row .btn {
  flex: 0 0 auto;
}

.yt-status {
  margin-top: 13px;
  padding: 10px 13px;
  border: 1px solid rgba(34, 211, 238, 0.2);
  border-radius: 10px;
  background: rgba(34, 211, 238, 0.06);
  color: #a5f3fc;
  font-size: 11.5px;
  line-height: 1.55;
}

.yt-status.error {
  border-color: rgba(251, 113, 133, 0.26);
  background: rgba(251, 113, 133, 0.07);
  color: #fda4af;
}

.yt-status.loading {
  display: flex;
  align-items: center;
  gap: 9px;
  border-color: rgba(139, 92, 246, 0.25);
  background: rgba(139, 92, 246, 0.07);
  color: #ddd1ff;
}

.yt-status code {
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.25);
  font-size: 10.5px;
}

.spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-top-color: #c4b5fd;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.yt-preview-head {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: 17px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.03);
}

.yt-preview-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 11px;
  background: rgba(244, 63, 94, 0.11);
  color: #fda4af;
}

.yt-preview-icon svg {
  width: 21px;
  height: 21px;
}

.yt-preview-title {
  min-width: 0;
  flex: 1;
}

.yt-preview-title strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.yt-preview-title p {
  overflow: hidden;
  margin-top: 2px;
  color: var(--muted-2);
  font-size: 10px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.yt-video-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 250px;
  margin-top: 12px;
  overflow-y: auto;
  padding-right: 4px;
}

.yt-video-list::-webkit-scrollbar {
  width: 5px;
}

.yt-video-list::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.12);
}

.yt-video-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 7px;
  border-radius: 7px;
}

.yt-video-item:hover {
  background: rgba(255, 255, 255, 0.035);
}

.yt-video-index {
  width: 22px;
  flex: 0 0 auto;
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 800;
  text-align: right;
}

.yt-video-title {
  overflow: hidden;
  flex: 1;
  color: var(--text-soft);
  font-size: 11.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.yt-video-duration {
  flex: 0 0 auto;
  color: var(--muted-2);
  font-size: 9.5px;
  font-weight: 700;
}

.yt-preview .field-row,
#yt-preview .field-row {
  margin-top: 14px;
}

.yt-removed-note {
  margin-top: 10px;
}

/* ---------- Player ---------- */

.modal.modal-player {
  width: min(900px, calc(100vw - 32px));
}

.player-card {
  padding: 22px;
}

.player-card .modal-head {
  margin-bottom: 14px;
}

.player-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 14px;
  background: #03060e;
  box-shadow: 0 18px 45px -22px #000;
}

.player-frame iframe,
.player-frame > div,
#yt-player {
  width: 100% !important;
  height: 100% !important;
}

.player-frame iframe {
  display: block;
  border: 0;
}

/* Modo apenas áudio: o iframe continua no DOM para o YouTube seguir tocando,
   mas fica visualmente oculto atrás de uma superfície de áudio. */
.player-frame.audio-mode #yt-player,
.player-frame.audio-mode iframe {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.player-audio {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.25fr);
  align-items: center;
  gap: clamp(18px, 4vw, 36px);
  padding: clamp(20px, 4vw, 38px);
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(139, 92, 246, 0.34), transparent 58%),
    radial-gradient(110% 140% at 100% 100%, rgba(34, 211, 238, 0.18), transparent 62%),
    linear-gradient(135deg, #080d19 0%, #111a2e 52%, #081120 100%);
  color: #f8fafc;
}

.player-frame.audio-mode .player-audio {
  display: grid;
}

.audio-cover {
  position: relative;
  width: 100%;
  max-width: 250px;
  aspect-ratio: 1;
  justify-self: center;
  overflow: hidden;
  border-radius: 24px;
  background-color: #0b1222;
  background-position: center;
  background-size: cover;
  box-shadow: 0 28px 60px -24px rgba(0, 0, 0, 0.9), inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.audio-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(8, 13, 25, 0.05) 0%, rgba(8, 13, 25, 0.35) 55%, rgba(8, 13, 25, 0.88) 100%);
}

.audio-cover-icon {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.72);
}

.audio-cover-icon svg {
  width: 34%;
  height: 34%;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.55));
}

.audio-equalizer {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 24px;
  transform: translateX(-50%);
}

.audio-equalizer i {
  width: 3px;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(180deg, #67e8f9, #8b5cf6);
  transform-origin: bottom;
  animation: audio-bar 1.05s ease-in-out infinite;
  animation-play-state: paused;
  opacity: 0.8;
}

.audio-equalizer i:nth-child(2) { animation-delay: 0.12s; }
.audio-equalizer i:nth-child(3) { animation-delay: 0.24s; }
.audio-equalizer i:nth-child(4) { animation-delay: 0.36s; }
.audio-equalizer i:nth-child(5) { animation-delay: 0.48s; }

.player-frame.audio-playing .audio-equalizer i {
  animation-play-state: running;
}

@keyframes audio-bar {
  0%, 100% { transform: scaleY(0.24); }
  50% { transform: scaleY(1); }
}

.audio-panel {
  min-width: 0;
}

.audio-eyebrow {
  color: #67e8f9;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.audio-title {
  margin-top: 7px;
  display: -webkit-box;
  overflow: hidden;
  color: #fff;
  font-family: var(--font-display);
  font-size: clamp(19px, 2.5vw, 29px);
  line-height: 1.18;
  letter-spacing: -0.025em;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.audio-sub {
  margin-top: 7px;
  overflow: hidden;
  color: rgba(226, 232, 240, 0.68);
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audio-progress {
  height: 5px;
  margin-top: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
}

.audio-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #8b5cf6, #22d3ee);
  transition: width 0.35s linear;
}

.audio-time-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 7px;
  color: rgba(226, 232, 240, 0.58);
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.audio-time-row #audio-saved {
  color: #6ee7b7;
}

.audio-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 15px;
}

.audio-btn {
  min-height: 34px;
  padding: 6px 11px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  font-size: 11px;
  font-weight: 800;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.audio-btn:hover {
  border-color: rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.12);
}

.audio-btn:active {
  transform: scale(0.97);
}

.audio-btn.play {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: linear-gradient(135deg, #8b5cf6, #22d3ee);
  color: #fff;
  box-shadow: 0 12px 28px -12px rgba(34, 211, 238, 0.75);
}

.audio-btn.play svg {
  width: 18px;
  height: 18px;
}

.audio-volume {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 110px;
  flex: 1;
  color: rgba(226, 232, 240, 0.62);
}

.audio-volume svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.audio-volume input {
  width: 100%;
  min-width: 0;
  accent-color: #22d3ee;
  cursor: pointer;
}

.audio-speed {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
}

.audio-speed select {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  outline: none;
}

.audio-speed select option {
  background: #0f172a;
  color: #e2e8f0;
}

.audio-btn.exit {
  margin-left: auto;
}

.audio-hint {
  margin-top: 12px;
  color: rgba(226, 232, 240, 0.48);
  font-size: 10.5px;
  line-height: 1.5;
}

.player-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 13px;
}

.player-progress {
  min-width: 0;
  flex: 1;
}

.player-progress .bar {
  margin-top: 0;
  height: 6px;
}

.player-progress-labels {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
  color: var(--muted-2);
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.player-status {
  flex: 0 0 auto;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 800;
}

.player-status.good {
  background: rgba(52, 211, 153, 0.1);
  color: #6ee7b7;
}

.player-status.live::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: currentColor;
  vertical-align: 1px;
  animation: status-pulse 1.4s ease-in-out infinite;
}

@keyframes status-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.15); }
}

.player-status.warn {
  background: rgba(251, 191, 36, 0.1);
  color: #fcd34d;
}

.player-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.player-actions .btn {
  min-height: 37px;
  padding: 7px 13px;
  font-size: 12px;
}

.player-speed {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  min-height: 37px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.player-speed select {
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  outline: none;
}

.player-speed select option {
  background: #0f172a;
  color: #e2e8f0;
}

.player-card > .hint {
  margin-top: 10px;
}

@media (max-width: 620px) {
  .player-card {
    padding: 16px;
  }

  .player-actions .btn {
    flex: 1 1 auto;
  }

  .player-speed {
    flex: 1 1 auto;
    justify-content: space-between;
  }

  .player-speed select {
    min-width: 72px;
  }
}

/* ---------- Player em segundo plano ---------- */

.player-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

dialog#dlg-player.player-minimized {
  position: fixed;
  top: -10000px;
  left: -10000px;
  width: 2px;
  height: 2px;
  max-height: 2px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.mini-audio {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 90;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: min(620px, calc(100vw - 24px));
  padding: 10px 12px 13px;
  transform: translateX(-50%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 17px;
  background: rgba(8, 13, 25, 0.96);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.62);
  color: #f8fafc;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  animation: mini-audio-in 0.22s ease-out;
}

.mini-audio[hidden] {
  display: none;
}

@keyframes mini-audio-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.mini-audio-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.mini-audio-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.35), rgba(34, 211, 238, 0.2));
  color: #c4b5fd;
}

.mini-audio-icon svg {
  width: 19px;
  height: 19px;
}

.mini-audio-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.mini-audio-copy strong {
  overflow: hidden;
  font-size: 12.5px;
  font-weight: 800;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.mini-audio-copy span {
  overflow: hidden;
  color: rgba(226, 232, 240, 0.66);
  font-size: 10.5px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.mini-audio-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.mini-audio-btn {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  font-size: 10.5px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.16s ease, transform 0.16s ease;
}

.mini-audio-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.mini-audio-btn:active {
  transform: scale(0.96);
}

.mini-audio-btn.play {
  border-color: transparent;
  background: linear-gradient(135deg, #8b5cf6, #22d3ee);
  color: #fff;
}

.mini-audio-btn.play svg {
  width: 14px;
  height: 14px;
}

.mini-audio-speed {
  display: inline-grid;
  place-items: center;
  height: 34px;
  padding: 0 5px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
}

.mini-audio-speed select {
  border: 0;
  background: transparent;
  color: #e2e8f0;
  font-size: 10.5px;
  font-weight: 800;
  cursor: pointer;
  outline: none;
}

.mini-audio-speed select option {
  background: #0f172a;
  color: #e2e8f0;
}

.mini-audio-btn.stop {
  color: #fca5a5;
}

.mini-audio-btn.stop svg {
  width: 12px;
  height: 12px;
}

.mini-audio-progress {
  position: absolute;
  right: 12px;
  bottom: 6px;
  left: 12px;
  height: 3px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
}

.mini-audio-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #8b5cf6, #22d3ee);
  transition: width 0.3s linear;
}

body:has(.mini-audio:not([hidden])) .page {
  padding-bottom: 110px;
}

/* ---------- Sincronização ---------- */

.sync-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font: inherit;
  font-size: 10.5px;
  font-weight: 800;
  cursor: pointer;
  transition: color 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.sync-indicator:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

.sync-indicator[hidden] {
  display: none;
}

.sync-indicator-icon {
  display: inline-flex;
}

.sync-indicator-icon svg {
  width: 14px;
  height: 14px;
}

.sync-indicator.is-synced {
  color: var(--green);
  border-color: rgba(52, 211, 153, 0.28);
}

.sync-indicator.is-syncing {
  color: var(--amber);
  border-color: rgba(251, 191, 36, 0.28);
}

.sync-indicator.is-syncing .sync-indicator-icon {
  animation: sync-spin 1s linear infinite;
}

.sync-indicator.is-error {
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.32);
}

@keyframes sync-spin {
  to { transform: rotate(360deg); }
}

.exam-date-hint.warn {
  color: var(--amber);
}

.sync-code-row {
  align-items: flex-end;
}

.sync-code-row .field {
  flex: 1 1 180px;
}

.sync-code-row .btn {
  margin-bottom: 14px;
  white-space: nowrap;
}

.sync-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.sync-status {
  color: var(--muted-2);
  font-size: 11.5px;
  font-weight: 700;
}

.sync-status.good {
  color: var(--green);
}

.sync-status.warn {
  color: var(--amber);
}

.sync-status.error {
  color: #fca5a5;
}

.sync-link {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.025);
}

.sync-link-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sync-link code {
  min-width: 0;
  padding: 3px 7px;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--text);
  font-size: 11.5px;
  word-break: break-all;
}

.sync-link .hint {
  margin-top: 6px;
}

/* ---------- Player de arquivo offline ---------- */

#offline-player {
  display: block;
  width: 100% !important;
  height: 100% !important;
  background: #000;
  object-fit: contain;
}

.player-frame.audio-mode #offline-player {
  opacity: 0;
  pointer-events: none;
}

/* O atributo hidden precisa vencer o display dos botões. */
.player-actions .btn[hidden] {
  display: none;
}
