/* MiyaTube: compact approved App Shell, preserving existing scroll chrome. */
:root { --refined-header-height: 60px; }
.app-header { min-height: 0; padding: calc(8px + env(safe-area-inset-top)) 16px 8px; gap: 8px; }
.app-header .brand-lockup { gap: 10px; min-width: 0; }
.app-header .brand-icon { width: 38px; height: 38px; flex-basis: 38px; border-radius: 12px; }
.app-header .brand-play { border-top-width: 8px; border-bottom-width: 8px; border-left-width: 13px; margin-left: 3px; }
.app-header .brand-lockup h1 { font-size: 19px; line-height: 1.08; }
.app-header .brand-lockup p { max-width: none; margin-top: 3px; font-size: clamp(10px,2.9vw,12px); line-height: 1.18; white-space: nowrap; }
.explore-overview-footer { display: block; width: 100%; min-height: 48px; margin: 24px 0 8px; border: 1px solid #dce6f0; border-radius: 14px; background: #f1f5fa; color: #173355; font: inherit; font-size: 14px; font-weight: 800; }
.extract-view .page-heading h2 { font-size: clamp(25px, 6.8vw, 31px); }
.extract-empty-help { padding: 12px 14px; margin-top: 17px; }
.extract-main-action { min-height: 56px; font-size: 17px; }
.extract-processing-card .processing-steps { grid-template-columns: repeat(3,minmax(0,1fr)); }
.extract-processing-card .processing-steps::before { left: calc(16.7% + 9px); right: calc(16.7% + 9px); }
@media (max-width: 380px) { .app-header .brand-lockup p { font-size: 10px; } }

.overview-premium > .dimension-section { margin: 14px 0 20px; }
.explore-view #exploreSearch { min-height: 46px; font-size: 16px; }
.cloud-section + .dimension-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid #e1e7f0; }
.term-cloud { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 9px; padding: 18px 10px; background: #f4f7fc; border: 1px solid #e0e8f0; border-radius: 18px; }
.term-cloud-item { min-height: 44px; padding: 8px 12px; background: #fff; color: #173355; border: 1px solid #dae4ee; border-radius: 11px; font: inherit; font-weight: 800; }
.term-cloud-item.is-small { font-size: 13px; }
.term-cloud-item.is-medium { font-size: 17px; }
.term-cloud-item.is-large { font-size: 21px; }
.term-cloud-item small { display: inline-block; padding: 2px 5px; margin-left: 5px; font-size: 11px; background: #e9eff8; border-radius: 12px; color: #647895; vertical-align: top; }
.term-cloud-item.is-active { background: #173355; color: #fff; }
.cloud-match-title { margin: 15px 2px 8px; font-size: 15px; }

.library-other-views { font-size: 12px; color: #607693; }
.library-other-views summary { padding: 5px 2px; cursor: pointer; min-height: 38px; }
.library-other-views .library-view-row { margin-top: 6px; }
.library-auto-layout { display: block; }
.library-auto-section { margin: 15px 0 24px; }
.library-auto-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 1px 12px; }
.library-auto-heading strong { font-size: 17px; color: #112f56; }
.library-auto-heading span { color: #6d7f96; font-size: 11px; text-align: right; }
.library-auto-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px 10px; }
.library-auto-card { min-width: 0; position: relative; }
.library-auto-open { display: block; width: 100%; min-width: 0; background: transparent; border: 0; text-align: left; padding: 0; font: inherit; color: #163256; }
.library-auto-open strong { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-size: 13px; line-height: 1.3; margin-top: 6px; padding-right: 30px; }
.library-auto-open > span:last-child { display: block; margin-top: 3px; color: #657b96; font-size: 12px; }
.library-auto-thumb { display: block; position: relative; aspect-ratio:16/9; border-radius: 11px; overflow:hidden; background: #17345a; }
.library-auto-thumb img { display:block; width:100%; height:100%; object-fit:cover; }
.library-auto-thumb small { position:absolute; right:5px; bottom:5px; background:#102037e8; color:white; border-radius:4px; padding:2px 4px; font-size:11px; }
.library-auto-more { position:absolute; bottom:10px; right:0; width:32px; height:40px; background:#eef3f9; border:0; border-radius:9px; color:#39587c; font-size:16px; }
.library-auto-groups { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
.library-auto-group { display:flex; flex-direction:column; justify-content:center; gap:5px; min-height:90px; padding:12px; text-align:left; background:#f3f6fb; color:#173355; border:1px solid #dae4ef; border-radius:15px; font:inherit; }
.library-auto-group strong { font-size:14px; line-height:1.2; }
.library-auto-group small { color:#637996; font-size:12px; }
.library-auto-back { display:block; margin-bottom:14px; min-height:44px; border:0; background:none; color:#173355; font-weight:800; }
.library-view-row { overflow-x:auto; scrollbar-width:none; }
.library-view-row .library-view { flex: 0 0 auto; min-height: 44px; }

.example-source-note { margin: 8px 0 0; color: #657992; font-size: 12px; line-height: 1.4; }

/* Nuvem v3: typographic word cloud, without pills or badges. All terms
 * remain accessible native buttons with at least 44px of tap height. */
.cloud-section .term-cloud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  align-content: center;
  justify-content: center;
  gap: 2px 11px;
  min-height: 176px;
  padding: 17px 12px 19px;
  background: #f5f7fb;
  border: 1px solid #e7ebf1;
  border-radius: 18px;
}
.cloud-section .term-cloud-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  max-width: 100%;
  padding: 4px 5px;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: center;
  font: inherit;
  line-height: 1.12;
  letter-spacing: -.025em;
  transition: color .15s ease;
}
.cloud-section .term-cloud-item.is-large {
  padding: 4px 7px;
  border: 0;
  background: transparent;
  color: #142f58;
  font-size: clamp(26px, 8vw, 36px);
  font-weight: 850;
}
.cloud-section .term-cloud-item.is-medium {
  border: 0;
  background: transparent;
  color: #a47a27;
  font-size: clamp(21px, 6.2vw, 28px);
  font-weight: 780;
}
.cloud-section .term-cloud-item.is-small {
  border: 0;
  background: transparent;
  color: #4e647f;
  font-size: clamp(16px, 4.7vw, 20px);
  font-weight: 700;
}
.cloud-section .term-cloud-item:nth-child(4n+3) { color: #395877; }
.cloud-section .term-cloud-item:nth-child(6n+4) { color: #99752f; }
.cloud-section .term-cloud-item.is-active {
  background: transparent;
  border: 0;
  box-shadow: inset 0 -3px 0 #c29439;
  border-radius: 0;
  color: #122d54;
}
.cloud-section .term-cloud-item:focus-visible,
.cloud-section .term-list-item:focus-visible,
.occurrence-row button:focus-visible {
  outline: 3px solid #c29439;
  outline-offset: 2px;
}
.term-cloud-alternative { margin-top: 12px; color: #49637f; font-size: 13px; }
.term-cloud-alternative summary { display: inline-flex; align-items: center; min-height: 44px; cursor: pointer; font-weight: 700; }
.term-list { display: flex; flex-wrap: wrap; gap: 7px; padding: 8px 0 14px; }
.term-list-item {
  display: inline-flex; gap: 8px; align-items: center;
  min-height: 44px; padding: 8px 12px; border: 1px solid #dce5ef;
  border-radius: 10px; background: #fff; color: #18365d; font: inherit; font-weight: 700;
}
.term-list-item span { color: #667a94; font-size: 12px; }
.term-list-item.is-active { border-color: #ba8c39; background: #fff8e9; }
.occurrence-results { margin-top: 16px; }
.cloud-match-title { margin: 0; padding: 7px 0 10px; font-size: 16px; font-weight: 800; color: #172f53; }
.occurrence-list {
  list-style: none;
  margin: 0; padding: 0;
  border-top: 1px solid #e1e7f0;
}
.occurrence-row {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 13px 0; border-bottom: 1px solid #e1e7f0;
}
.occurrence-play {
  display: flex; flex: 0 0 64px; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  min-height: 54px; padding: 6px 4px;
  border: 0; border-radius: 11px;
  background: #fff1cf; color: #805c13;
  font: inherit; font-size: 12px; font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.occurrence-play > span:first-child { font-size: 14px; }
.occurrence-content { flex: 1; min-width: 0; }
.occurrence-context-trigger {
  display: block; width: 100%; min-height: 52px;
  padding: 2px 0; border: 0; background: transparent;
  text-align: left; font: inherit; color: #31455f;
  font-size: 15px; line-height: 1.54;
}
.occurrence-preview {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden; line-clamp: 2;
}
.occurrence-full { display: block; line-height: 1.54; }
.occurrence-preview[hidden], .occurrence-full[hidden], .occurrence-details[hidden] { display: none !important; }
.occurrence-mark {
  border-radius: 3px; background: #f5e2b2;
  color: #182f52; font-weight: 800; padding: 0 1px;
}
.occurrence-details { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 5px; }
.occurrence-details button {
  border: 0; border-radius: 8px; background: #edf2f8;
  color: #365579; font: inherit; font-size: 13px; font-weight: 700;
  min-height: 44px; padding: 8px 12px;
}
@media (prefers-reduced-motion: reduce) {
  .cloud-section .term-cloud-item { transition: none; }
}

/* Unaligned, deterministic word packing replaces centered flex rows. */
.cloud-section .term-cloud.is-packed {
  position: relative;
  display: block;
  overflow: hidden;
  padding: 0;
  min-height: 160px;
}
.cloud-section .term-cloud.is-packed .term-cloud-item {
  position: absolute;
  display: inline-flex;
  margin: 0;
  transform: none;
  height: auto;
  white-space: nowrap;
}
/* Map summary is navigation, not inert analytics. */
button.map-stat {
  width: 100%; font: inherit; text-align: left; color: inherit;
  cursor: pointer; transition: border-color .14s ease, background-color .14s ease;
}
button.map-stat:hover { border-color: #bf984d; background: #fffaf1; }
button.map-stat:focus-visible, button.overview-topic-row:focus-visible {
  outline: 3px solid #c29439;
  outline-offset: 2px;
}
button.overview-topic-row {
  width: 100%; font: inherit; text-align: left; color: inherit;
  border: 0; border-bottom: 1px solid #e5eaf1;
  background: transparent; cursor: pointer;
}
button.overview-topic-row:hover { background: #f7f9fd; }
@media (prefers-reduced-motion: reduce) {
  button.map-stat { transition: none; }
}

/* Honest elapsed timer anchored to the durable job start, never an ETA. */
.processing-elapsed {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0;
  padding: 11px 14px;
  border: 1px solid #e5e9ef;
  border-radius: 12px;
  background: #f7f9fc;
  color: #3c5876;
}
.processing-elapsed[hidden] { display: none !important; }
.processing-elapsed-caption { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; font-weight: 600; }
.processing-elapsed strong { color: #132c51; font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .025em; }

/* Visibly distinguish a saved incomplete language variant from translated success. */
.language-notice.is-language-warning {
  background: #fff6e4;
  border: 1px solid #e8cf98;
  color: #71521d;
}


/* Personal highlights + related library + adaptive video summary */
.transcript-highlight-button {
  align-self: start;
  min-height: 36px;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  color: var(--premium-muted);
  padding: 4px 6px;
}
.transcript-highlight-button.is-saved { color: var(--premium-navy); }

.personal-highlights-panel,
.related-library-panel,
.video-summary-shell {
  border: 1px solid var(--premium-line);
  border-radius: 20px;
  background: var(--premium-surface);
  padding: 14px;
}
.personal-highlight-list,
.related-video-list { display: grid; gap: 10px; }
.personal-highlight-card {
  border: 1px solid var(--premium-line);
  border-radius: 16px;
  padding: 12px;
  background: #fff;
}
.personal-highlight-card > p { margin: 8px 0; line-height: 1.48; }
.personal-highlight-card aside {
  margin-top: 8px;
  border-left: 3px solid var(--premium-gold);
  padding: 7px 10px;
  background: var(--premium-soft);
  border-radius: 0 10px 10px 0;
  font-size: 13px;
}
.personal-highlight-card > small { display: block; margin-top: 8px; color: var(--premium-muted); }
.personal-highlight-top,
.personal-highlight-actions,
.video-summary-head,
.video-summary-progress,
.personal-note-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.personal-highlight-time,
.personal-highlight-actions button,
.video-summary-full {
  min-height: 36px;
  border: 1px solid var(--premium-line);
  border-radius: 12px;
  background: #fff;
  color: var(--premium-navy);
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  padding: 0 10px;
}
.personal-highlight-actions button { border: 0; padding: 0 5px; background: transparent; }

.related-video-card {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--premium-line);
  border-radius: 16px;
  background: #fff;
  padding: 8px;
  text-align: left;
  color: inherit;
}
.related-video-card img {
  width: 88px;
  aspect-ratio: 16 / 9;
  border-radius: 11px;
  object-fit: cover;
}
.related-video-card span { min-width: 0; display: grid; gap: 3px; }
.related-video-card strong { font-size: 13px; line-height: 1.25; }
.related-video-card small,
.related-video-card em { font-size: 11px; color: var(--premium-muted); font-style: normal; }

.app-maintenance { display: grid; justify-items: start; gap: 8px; padding: 10px 4px 3px; }
.app-maintenance p { margin: 0; color: var(--premium-navy); font-size: 13px; font-weight: 750; }
.app-maintenance small { color: var(--premium-muted); font-size: 12px; line-height: 1.4; }
.app-maintenance button { min-height: 44px; }

/* Keep the iPhone summary header vertical even when the base .video-compact
   flex style is used. The native YouTube iframe must not compete for a row
   with the summary controls and video metadata. */
.explore-view #exploreVideoHeader.has-video-player {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  min-width: 0;
}
.explore-view #exploreVideoHeader.has-video-player > .video-start-player {
  /* +24px remains the safe fallback for installed PWAs with cached CSS. */
  width: var(--miyatube-player-width, calc(100% + 24px));
  max-width: none;
  margin-inline: var(--miyatube-player-margin, -12px);
  flex: 0 0 auto;
  aspect-ratio: 16 / 9;
}
.explore-view #exploreVideoHeader.has-video-player > .video-start-player iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}
.explore-view #exploreVideoHeader.has-video-player > .video-summary-shell,
.explore-view #exploreVideoHeader.has-video-player > .video-copy {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  flex: 0 0 auto;
}

/* Three native YouTube embeds share the widest safe iPhone presentation.
   Preserve 16:9, native controls, and an 8px viewport gutter; do not change
   playback, timestamps, summary card navigation, or persisted data. */
@media (max-width: 619px) {
  /* The older responsive layer clips both ancestors: allow only the outer
     Navegue view to show this safe 8px video breakout. Its knowledge panels
     keep their own existing overflow clips. */
  .explore-view,
  .explore-view #exploreContent {
    overflow-x: visible;
  }
  .explore-view #exploreVideoHeader.has-video-player > .video-start-player {
    /* Center the breakout rather than pushing the neighboring summary cards. */
    --miyatube-player-width: min(calc(100vw - 16px), calc(100% + 56px));
    --miyatube-player-margin: 0;
    --miyatube-player-left: 50%;
    --miyatube-player-transform: translateX(-50%);
  }
  #transcriptSheet .transcript-inline-player {
    width: calc(100% + 32px);
    max-width: calc(100vw - 16px);
    margin-inline: -16px;
  }
  #playerSheet .player-media {
    width: calc(100% + 16px);
    max-width: calc(100vw - 16px);
    margin-inline: -8px;
  }
}

.video-summary-shell { margin: 10px 0 12px; }
.video-summary-head > div { display: grid; gap: 2px; }
.video-summary-head strong { color: var(--premium-navy); }
.video-summary-head span,
.video-summary-progress span { color: var(--premium-muted); font-size: 12px; }
.video-summary-progress { margin-top: 10px; font-size: 12px; }
.video-summary-nav {
  margin-top: 10px;
  overflow: hidden;
}
.video-summary-moments {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 0 10px 3px 0;
}
.video-summary-moments::-webkit-scrollbar { display: none; }
.video-summary-moment {
  scroll-snap-align: start;
  flex: 0 0 min(78vw, 310px);
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 3px 8px;
  align-items: center;
  min-height: 62px;
  border: 1px solid var(--premium-line);
  border-radius: 14px;
  background: #fff;
  color: var(--premium-navy);
  padding: 8px 10px;
  text-align: left;
}
.video-summary-moment > span {
  grid-row: 1 / 3;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--premium-soft);
  font-weight: 800;
}
.video-summary-moment strong { font-size: 12px; line-height: 1.25; }
.video-summary-moment small { color: var(--premium-muted); font-size: 10px; }
.video-summary-moment.is-active { border-color: var(--premium-gold); }
.video-summary-moment.is-active > span { background: var(--premium-navy); color: #fff; }

.personal-note-panel { max-width: 560px; }
.personal-note-quote {
  margin: 0 0 14px;
  padding: 12px;
  border-radius: 14px;
  background: var(--premium-soft);
  line-height: 1.45;
}
.personal-note-field { display: grid; gap: 7px; }
.personal-note-field span { font-size: 12px; font-weight: 800; color: var(--premium-navy); }
.personal-note-field textarea {
  width: 100%;
  resize: vertical;
  min-height: 118px;
  border: 1px solid var(--premium-line);
  border-radius: 14px;
  padding: 11px;
  font: inherit;
  color: var(--premium-navy);
  background: #fff;
}
.personal-note-actions { margin-top: 14px; }

@media (max-width: 430px) {
  .related-video-card { grid-template-columns: 78px minmax(0, 1fr) auto; }
  .related-video-card img { width: 78px; }
}
