/* The downloads tab is nested in Settings: size it to its panel, not the viewport. */
.settings-layout,
.settings-panel,
.downloads-page,
.download-services-admin { min-width: 0; }
.downloads-page { container: downloads / inline-size; }
.downloads-page .download-heading { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px 20px; }
.download-heading > div { flex: 1 1 220px; min-width: 0; }
.download-heading h2 { margin: 0 0 7px; font-size: clamp(23px, 2.7vw, 31px); line-height: 1.15; overflow-wrap: anywhere; }
.download-heading .muted { margin: 0; max-width: 40ch; line-height: 1.5; }
.download-heading .button { flex: none; margin-left: auto; white-space: nowrap; }
.download-section-title { margin: 26px 0 0; font-size: 15px; letter-spacing: -.01em; }
.download-service-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: 12px; margin: 14px 0 16px; }
.download-service-card { display: grid; grid-template-columns: 46px minmax(0, 1fr) 18px; align-items: center; gap: 14px; width: 100%; min-width: 0; min-height: 94px; padding: 15px; border: 1px solid #e9e3eb; border-radius: 18px; background: linear-gradient(145deg, #fff, #faf7fb); box-shadow: 0 7px 20px #3e25490d; text-align: left; color: #24212a; cursor: pointer; transition: transform .2s, box-shadow .2s, border-color .2s; }
.download-service-card:hover, .download-service-card:focus-visible { transform: translateY(-2px); border-color: #eab6c6; box-shadow: 0 13px 28px #3e25491a; }
.download-service-card > span:nth-child(2) { display: grid; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
.download-service-card strong { display: block; font-size: 14px; line-height: 1.2; }
.download-service-card small { display: block; color: #797280; font-size: 11px; line-height: 1.35; }
.download-service-card em { display: block; color: #817588; font-size: 10px; line-height: 1.3; font-style: normal; }
.download-service-card em.online { color: #287a5b; }
.download-service-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: #f3e6ef; color: #a33c67; font-size: 23px; }
.download-service-arrow { color: #998d9e; font-size: 18px; }
.download-help { margin: 10px 0 24px; padding: 12px 15px; border: 1px solid #eee8ed; border-radius: 13px; background: #fcfafc; }
.download-help summary { color: #6d596d; font-size: 11px; font-weight: 650; cursor: pointer; }
.download-help p { margin: 10px 0 0; color: #746c77; font-size: 11px; line-height: 1.55; overflow-wrap: anywhere; }
.download-torrent-summary { display: grid; gap: 8px; margin-bottom: 18px; }
.download-torrent-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 12px 14px; border: 1px solid #eae7ec; border-radius: 12px; background: #fff; }
.download-torrent-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.download-torrent-row span { color: #807687; font-size: 11px; }
.download-tool-panel:not([hidden]) { position: fixed; z-index: 60; inset: clamp(12px, 2.5vw, 34px); display: flex; flex-direction: column; min-width: 0; overflow: hidden; border: 1px solid #e7e0e9; border-radius: 20px; background: #fff; box-shadow: 0 0 0 100vmax #17111caa, 0 25px 80px #17111c50; }
.download-tool-head { display: flex; flex: none; align-items: center; justify-content: space-between; gap: 12px; min-height: 61px; padding: 12px 18px; border-bottom: 1px solid #eee9ef; }
.download-tool-head h2 { min-width: 0; margin: 0; font-size: 17px; overflow-wrap: anywhere; }
.download-tool-head .button { flex: none; }
.download-tool-panel iframe { display: block; flex: 1; width: 100%; min-height: 0; border: 0; background: #fff; }
body.downloads-tool-open { overflow: hidden; }
@container downloads (max-width: 620px) {
  .download-service-grid { grid-template-columns: 1fr; }
}
@container downloads (min-width: 621px) and (max-width: 790px) {
  .download-service-card:last-child { grid-column: 1 / -1; }
}
@media (max-width: 1220px) {
  .settings-layout, body.tv-mode .settings-layout { grid-template-columns: minmax(0, 1fr); gap: 13px; }
  .settings-nav, body.tv-mode .settings-nav { display: flex; flex-wrap: wrap; gap: 6px; overflow: visible; }
  .settings-tab { white-space: nowrap; }
}
@media (max-width: 760px) {
  .download-service-grid { grid-template-columns: 1fr; gap: 9px; }
  .download-service-card { min-height: 80px; padding: 11px 13px; }
  .download-heading .button { min-height: 40px; }
  .download-tool-panel:not([hidden]) { inset: 0; border: 0; border-radius: 0; }
  .download-tool-head { padding-top: max(12px, env(safe-area-inset-top)); }
}
body.tv-mode .download-service-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
body.tv-mode .download-service-card { min-height: 105px; }
body.tv-mode .download-service-card strong { font-size: 17px; }
body.tv-mode .download-service-card small { font-size: 13px; }
body.tv-mode .download-service-card em { font-size: 12px; }
body.tv-mode .download-help summary { font-size: 14px; }
@container downloads (max-width: 570px) {
  body.tv-mode .download-service-grid { grid-template-columns: 1fr; }
}
@container downloads (min-width: 571px) and (max-width: 860px) {
  body.tv-mode .download-service-card:last-child { grid-column: 1 / -1; }
}
.youtube-music-tool { margin: 20px 0 24px; padding: clamp(18px, 3vw, 28px); border: 1px solid #ebe5eb; border-radius: 24px; background: linear-gradient(145deg, #fff, #fbf8fb); box-shadow: 0 12px 35px #361a3e0c; }
.youtube-music-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.youtube-music-heading > div { min-width: 0; }
.youtube-music-heading h3 { margin: 5px 0 7px; color: #26212a; font-size: clamp(20px, 2.2vw, 27px); letter-spacing: -.035em; }
.youtube-music-heading .muted { max-width: 54ch; margin: 0; line-height: 1.5; }
.youtube-audio-badge { flex: none; padding: 7px 10px; border: 1px solid #f2d8e3; border-radius: 999px; background: #fff5f8; color: #a52f5c; font-size: 11px; font-weight: 700; }
.youtube-preview-form { margin-top: 22px; }
.youtube-preview-form > label, .youtube-destination-dialog label { display: block; margin-bottom: 8px; color: #514a55; font-size: 12px; font-weight: 700; }
.youtube-search-row { display: flex; gap: 10px; }
.youtube-search-row input, .youtube-destination-dialog select { width: 100%; min-width: 0; min-height: 45px; padding: 0 14px; border: 1px solid #ded7e0; border-radius: 13px; background: #fff; color: #26212a; font: inherit; }
.youtube-search-row input:focus-visible, .youtube-destination-dialog select:focus-visible { outline: 2px solid #ba5178; outline-offset: 2px; }
.youtube-search-row .button { flex: none; }
.youtube-status { min-height: 1.3em; margin: 11px 0 0; font-size: 12px; }
.youtube-preview-card:not([hidden]) { display: grid; grid-template-columns: clamp(82px, 15vw, 132px) minmax(0, 1fr); gap: 17px; align-items: start; margin-top: 14px; padding: 14px; border: 1px solid #ebe5eb; border-radius: 18px; background: #fff; }
.youtube-preview-card > img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; background: #eee; }
.youtube-preview-info { display: grid; min-width: 0; gap: 5px; }
.youtube-preview-info strong { overflow-wrap: anywhere; color: #252029; font-size: 16px; }
.youtube-preview-info span, .youtube-preview-info small { color: #776d7b; font-size: 12px; }
.youtube-preview-info audio { width: 100%; min-width: 0; height: 42px; margin-top: 6px; }
.youtube-download-button { justify-self: start; margin-top: 6px; }
.youtube-download-progress:not([hidden]) { display: grid; gap: 5px; margin-top: 16px; padding: 13px 15px; border: 1px solid #ebd7e2; border-radius: 14px; background: #fff8fb; color: #463541; font-size: 12px; line-height: 1.45; }
.youtube-download-progress:not([hidden]) { position: relative; padding-right: 48px; }
.youtube-notice-close { position: absolute; top: 8px; right: 8px; display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 1px solid #d8c8d0; border-radius: 50%; background: #ffffffb8; color: #674350; font-size: 22px; line-height: 1; cursor: pointer; }
.youtube-notice-close:hover { background: #fff; }
.youtube-notice-close:focus-visible { outline: 2px solid #ba5178; outline-offset: 2px; }
.youtube-download-progress a { color: #a32b60; font-weight: 700; }
.youtube-destination-dialog { width: min(430px, calc(100vw - 28px)); max-height: calc(100dvh - 28px); padding: 25px; border: 1px solid #e9dfe8; border-radius: 22px; background: #fff; color: #26212a; box-shadow: 0 24px 70px #1b111b55; }
.youtube-destination-dialog::backdrop { background: #150d16a8; backdrop-filter: blur(5px); }
.youtube-destination-dialog h3 { margin: 6px 0 10px; font-size: 24px; letter-spacing: -.035em; }
.youtube-destination-dialog #youtube-destination-track { overflow-wrap: anywhere; margin: 0 0 22px; }
.youtube-destination-dialog #youtube-destination-help { margin: 14px 0 0; font-size: 11px; line-height: 1.5; }
.youtube-destination-dialog #youtube-destination-help.youtube-destination-warning { padding: 10px 12px; border: 1px solid #e7ad5e; border-radius: 11px; background: #fff3df; color: #6a390d; font-size: 13px; font-weight: 650; }
.youtube-destination-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 23px; }
@media (max-width: 590px) {
  .youtube-music-tool { padding: 17px; border-radius: 19px; }
  .youtube-music-heading { display: block; }
  .youtube-audio-badge { display: inline-block; margin-top: 12px; }
  .youtube-search-row { display: grid; }
  .youtube-search-row .button { width: 100%; }
  .youtube-preview-card:not([hidden]) { grid-template-columns: 80px minmax(0, 1fr); gap: 11px; }
  .youtube-preview-info audio, .youtube-download-button { grid-column: 1 / -1; }
  .youtube-preview-info audio { width: calc(100% + 91px); margin-left: -91px; margin-top: 10px; }
  .youtube-download-button { width: calc(100% + 91px); margin-left: -91px; }
}
/* Settings navigation stays above every panel on desktop and television. */
.settings-layout, body.tv-mode .settings-layout { display: block; grid-template-columns: none; margin-top: 23px; }
.settings-nav, body.tv-mode .settings-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; width: 100%; min-width: 0; margin-bottom: 16px; padding: 0 0 13px; border-bottom: 1px solid #e9e3e9; overflow: visible; }
.settings-nav .settings-tab { flex: none; min-width: 0; white-space: nowrap; text-align: center; }
.settings-panel { width: 100%; min-width: 0; }
@media (max-width: 760px) {
  .settings-nav, body.tv-mode .settings-nav { flex-wrap: nowrap; gap: 5px; padding-bottom: 9px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; scroll-snap-type: x proximity; }
  .settings-nav::-webkit-scrollbar { display: none; }
  .settings-nav .settings-tab { scroll-snap-align: start; }
}

.download-tool-panel iframe[hidden], .download-tool-panel [hidden] { display:none!important; }
.download-tool-loading { flex:1; display:grid; align-content:center; justify-items:center; gap:18px; min-height:180px; padding:24px; color:var(--ink,#24212a); text-align:center; }
.download-tool-loading p { max-width:44ch; line-height:1.6; }
#download-tool-recovery { display:flex; justify-content:center; flex-wrap:wrap; gap:10px; }
