/* ========= Base reset ========= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: 'Montserrat', sans-serif;
  background: var(--app-bg);
  color: var(--text-color);
  overflow: hidden;
  touch-action: pan-y;
  -webkit-text-size-adjust: 100%;
  padding-top: 0 !important;
}

:root {
  --tg-top: 0px;
  --tg-right: 0px;
  --tg-bottom: 0px;
  --tg-left: 0px;
  --bg-color: #F7FBFF;
  --tg-header-color: color-mix(in srgb, var(--bg-color) 92%, var(--accent-color) 8%);
  --text-color: #0B1220;
  --accent-color: #4F8DFF;
  --accent-text: #fff;
  --brand-cyan: #2EE9D1;
  --brand-blue: #4F8DFF;
  --brand-purple: #8B5CF6;
  --accent-grad: linear-gradient(135deg, var(--brand-cyan) 0%, var(--brand-blue) 55%, var(--brand-purple) 100%);
  --nav-surface: rgba(255,255,255,.75);
  --nav-border: rgba(0,0,0,.08);
  --nav-shadow: 0 8px 28px rgba(0,0,0,.12);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --app-top-gap: 0px;
  --kb-offset: 0px;
  --player-h: 0px;
  --glass-blur: 4px;
  --island-bg: rgba(255,255,255,.40);
  --island-border: rgba(0,0,0,.08);
  --island-blur: 4px;
  --topbar-1: rgba(255,255,255,.92);
  --topbar-2: rgba(255,255,255,.60);
  --bg-gradient-bottom: color-mix(in srgb, var(--bg-color) 92%, var(--accent-color) 8%);
  --bg-solid-stop: calc(var(--tg-top, 0px) + 96px);
  --bg-fade-stop:  calc(var(--tg-top, 0px) + 240px);
  --bg-gradient-mid: color-mix(in srgb, var(--tg-header-color) 70%, var(--bg-gradient-bottom) 30%);
  --app-bg: linear-gradient(180deg,
    var(--tg-header-color) 0px,
    var(--tg-header-color) var(--bg-solid-stop),
    var(--bg-gradient-mid) var(--bg-fade-stop),
    var(--bg-gradient-bottom) 100%);
}

@media (prefers-color-scheme: dark){
  :root{
    --island-bg: rgba(30,30,30,.40);
    --island-border: rgba(255,255,255,.08);
    --topbar-1: rgba(30,30,30,.92);
    --topbar-2: rgba(30,30,30,.58);
    --nav-surface: rgba(30,30,30,.72);
    --nav-border: rgba(255,255,255,.08);
    --nav-shadow: 0 8px 28px rgba(0,0,0,.6);
    --tg-header-color: color-mix(in srgb, var(--bg-color) 92%, var(--accent-color) 8%);
  }
}

body {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

button {
  background: var(--accent-grad);
  color: var(--accent-text);
}

/* ========= App layout ========= */
.screen{
  height: 100svh;
  min-height: 100svh;
  box-sizing: border-box;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  padding-top: 0;
  padding-bottom: 0;
}

.hidden { display: none !important; }

#search-tab{
  display: flex;
  flex-direction: column;
  height: 100svh;
  overflow: hidden;
  padding: 0 16px 16px;
  padding-bottom: 0;
}

#home-results-mount{
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#home-results{
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 0 12px;
  padding-bottom: calc(12px + var(--tg-bottom, 0px) + var(--player-h, 0px));
  --home-islands-h: 56px;
  padding-top: calc(4px + var(--home-islands-h));
  margin-top: calc(-1 * var(--home-islands-h));
  scroll-padding-top: calc(4px + var(--home-islands-h));
}

#home-results::-webkit-scrollbar,
.search-results::-webkit-scrollbar,
.sheet-content::-webkit-scrollbar{
  width: 0 !important;
  height: 0 !important;
  display: none !important;
}

/* ========= Home appbar ========= */
.search-controls{
  box-shadow: none !important;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  -webkit-mask-image: none !important;
  mask-image: none !important;
  padding: 10px calc(var(--tg-ui-pad-x, 16px) + var(--tg-right, 0px))
           10px calc(var(--tg-ui-pad-x, 16px) + var(--tg-left, 0px));
  padding-top: calc(var(--tg-top, 0px) + 10px);
}

.home-appbar{
  position: relative;
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap: 10px;
  min-height: 44px;
}

/* Home hero header */
.home-hero{
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 8px 4px 10px;
  margin: 0 0 2px;
  background: linear-gradient(
    to bottom,
    var(--hero-grad-1, rgba(0,0,0,.65)),
    var(--hero-grad-2, rgba(0,0,0,0))
  );
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
}

.home-hero-title{
  font-weight: 900;
  font-size: 44px;
  line-height: 1.0;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}

.home-hero-sub{
  font-weight: 600;
  font-size: 14px;
  line-height: 1.3;
  color: var(--tg-hint-color);
  opacity: .95;
  margin: 0;
}

.home-heading{
  font-weight: 900;
  font-size: 26px;
  line-height: 1.05;
  margin: 10px 2px 10px;
}

.home-intro{
  padding: 12px 12px 0;
}

.home-intro--spacer{
  min-height: 22px;
}

.home-heading--spacer{
  min-height: 28px;
}

.home-heading--recent{
  margin-top: 16px;
  margin-bottom: 6px;
}

.home-intro-sub{
  font-weight: 700;
  font-size: 18px;
  line-height: 1.2;
  color: var(--tg-hint-color);
  opacity: .95;
}

.home-appbar-right{
  display:flex;
  align-items:center;
  gap: 10px;
  margin-left:auto;
  pointer-events: auto;
}

.home-search-icon{
  appearance: none;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: none;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  color: inherit;
  flex: 0 0 auto;
}

.home-search-icon svg{
  width: 22px;
  height: 22px;
  display: block;
  fill: var(--text-color);
  opacity: 0.85;
}

.home-search-icon:active{
  opacity: 0.6;
}

.home-search-pill:active{ transform: scale(.99); }

.home-search-text{display:none !important;}

.home-search-ico{ line-height: 0; }

.account-btn{
  appearance: none;
  width: 44px;
  height: 44px;
  background: transparent;
  border: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  display: grid;
  place-items: center;
  padding: 0;
  flex: 0 0 auto;
}

.account-btn img{
  width:36px;
  height:36px;
  border-radius:50%;
  object-fit:cover;
  display:block;
}

#account-avatar-fallback{
  width:36px;
  height:36px;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:50%;
  font-weight:700;
}

/* ========= Icons ========= */
.icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* ========= Settings UI ========= */
.setting-item {
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  font-size: 16px;
  padding: 12px 16px;
  cursor: default;
}

.setting-row span { flex-grow: 1; }

.setting-select,
.setting-button {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding: 6px 12px;
  background-color: var(--accent-color);
  border: none;
  border-radius: 4px;
  color: white;
  font-size: 14px;
  cursor: pointer;
  min-width: 100px;
  text-align: center;
}

.setting-button--secondary{
  background: transparent;
  color: var(--accent-color);
  border: 1px solid color-mix(in srgb, var(--accent-color) 55%, transparent);
}

.setting-select:hover, .setting-button:hover { background-color: var(--accent-color); }
.setting-select::-ms-expand { display: none; }

.setting-select{
  text-align: center;
  text-align-last: center;
  padding-left: 12px;
  padding-right: 12px;
}
.setting-select option{ text-align: center; }

.switch-toggle {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
}

.switch-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-toggle .slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0;
  right: 0; bottom: 0;
  background-color: #ccc;
  transition: 0.4s;
  border-radius: 24px;
}

.switch-toggle .slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}

.switch-toggle input:checked + .slider {
  background-color: var(--accent-color);
}

.switch-toggle input:checked + .slider::before {
  transform: translateX(18px);
}

/* ========= Profile header ========= */
.tg-profile-header{
  position: relative;
  margin: 14px;
  border-radius: 22px;
  overflow: hidden;
  padding: 18px 16px 16px;
  border: 1px solid var(--nav-border, rgba(0,0,0,.08));
  background: radial-gradient(120% 140% at 20% 0%,
    color-mix(in srgb, var(--accent-color) 65%, #ffffff 35%) 0%,
    color-mix(in srgb, var(--accent-color) 35%, var(--tg-secondary-bg-color, #f5f5f5) 65%) 55%,
    var(--tg-secondary-bg-color, #f5f5f5) 100%);
}

.tg-profile-header::after{
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 12px 12px, rgba(255,255,255,.25) 0 2px, transparent 3px);
  opacity: .22;
  pointer-events: none;
}

.tg-profile-center{
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  position: relative;
  z-index: 1;
}

.tg-avatar{
  width: 92px;
  height: 92px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid rgba(255,255,255,.65);
  background: rgba(255,255,255,.25);
  display: grid;
  place-items: center;
}

.tg-avatar img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tg-avatar-fallback{
  width: 100%;
  height: 100%;
  display: none;
  place-items: center;
  font-weight: 900;
  font-size: 34px;
  color: rgba(255,255,255,.95);
  background: linear-gradient(180deg, rgba(0,0,0,.18), rgba(0,0,0,.06));
}

.tg-name-row{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.tg-display-name{
  font-size: 34px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.tg-subline{
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
  color: color-mix(in srgb, var(--tg-text-color, #000) 70%, transparent);
  font-weight: 700;
}

.tg-id-label{ opacity: .8; }
.tg-id-value{ font-weight: 900; }

.tg-id-wrap{
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.tg-username{
  text-decoration: none;
  color: color-mix(in srgb, var(--accent-color) 75%, var(--tg-text-color, #000) 25%);
  font-weight: 800;
}

.tg-id-value-clickable{
  cursor: pointer;
  user-select: none;
}
.tg-id-value-clickable:active{
  opacity: .65;
}

/* ========= Sheet (account) ========= */
.sheet{
  position: fixed;
  inset: 0;
  z-index: 2000;
  pointer-events: none;
}

.sheet-backdrop{
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.35);
  opacity: 0;
  transition: opacity .2s ease;
}

.sheet-panel{
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(86vh, 720px);
  background: var(--bg-color);
  color: var(--text-color);
  border-radius: 18px 18px 0 0;
  transform: translateY(100%);
  transition: transform .25s ease;
  box-shadow: 0 18px 50px rgba(0,0,0,.25);
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}

.sheet.is-open{ pointer-events: auto; }
.sheet-backdrop.is-open{ opacity: 1; }
.sheet.is-open .sheet-panel{ transform: translateY(0); }
.sheet.is-dragging .sheet-panel{ transition: none; }

.sheet-grabber{
  width: 44px;
  height: 5px;
  border-radius: 999px;
  background: rgba(0,0,0,.18);
  margin: 10px auto 6px;
}

.sheet-content{
  overflow: auto;
  max-height: calc(min(86vh, 720px) - 24px);
  -webkit-overflow-scrolling: touch;
}

.account-profile{
  padding: 14px 14px 6px;
}

#account-sheet.is-open ~ #mini-player{
  z-index: 1900;
}

/* ========= Search sheet ========= */
.search-sheet{
  position: fixed;
  inset: 0;
  z-index: 2500;
  pointer-events: none;
}

.search-sheet-backdrop{
  position:absolute;
  inset:0;
  background: rgba(0,0,0,.35);
  opacity: 0;
  transition: opacity .18s ease;
}

.search-sheet-panel{
  position:absolute;
  inset: 0;
  background: var(--bg-color);
  color: var(--text-color);
  transform: translateY(100%);
  transition: transform .22s ease;
  display:flex;
  flex-direction: column;
  padding-top: calc(env(safe-area-inset-top, 0px));
}

.search-sheet.is-open{ pointer-events: auto; }
.search-sheet.is-open .search-sheet-backdrop{ opacity: 1; }
.search-sheet.is-open .search-sheet-panel{ transform: translateY(0); }

.search-sheet-top{
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 12px 12px;
  padding-top: calc(var(--tg-top, var(--safe-top, 0px)) + 8px);
  border-bottom: none;
}

.search-sheet-top.no-back{
  padding-left: 16px;
}
.search-sheet-top.no-back .search-sheet-back{
  display: none;
}

.search-sheet-back,
.search-sheet-voice{
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 0;
  background: transparent;
  font-size: 0;
  color: var(--text-color);
  position: relative;
  display: grid;
  place-items: center;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.search-sheet-voice svg{
  width: 22px;
  height: 22px;
  display: block;
  fill: currentColor;
  opacity: .85;
}

.search-sheet-voice.is-disabled{
  opacity: .45;
}

.search-sheet-voice.is-listening{
  color: var(--accent-color);
}

.search-sheet-voice.is-listening::after{
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--accent-color) 35%, transparent);
  animation: mgPulse 1.1s ease-in-out infinite;
  pointer-events: none;
}

@keyframes mgPulse{
  0%,100%{ opacity:.35; transform: scale(1); }
  50%{ opacity:.75; transform: scale(1.04); }
}

.search-sheet-box{
  flex: 1;
  min-width: 0;
  position: relative;
}

#search-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  padding: 0 44px 0 12px;
  padding-right: 46px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,.10);
  background: var(--tg-secondary-bg-color, #f5f5f5);
  color: var(--tg-text-color, #000);
  width: 100%;
  outline: none;
  box-sizing: border-box;
  font-size: 16px;
  line-height: 20px;
}

#search-input:focus{
  border-color: color-mix(in srgb, var(--accent-color) 60%, rgba(0,0,0,.10));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-color) 20%, transparent);
}

#search-input::-webkit-search-cancel-button,
#search-input::-webkit-search-decoration{
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

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

.search-action{
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: 0;
  background: transparent;
  color: var(--tg-hint-color, #888);
  display: grid;
  place-items: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.search-action:active{
  transform: translateY(-50%) scale(0.96);
}

.search-action svg{
  width: 18px;
  height: 18px;
  display: block;
  fill: currentColor;
}

.search-action.is-loading svg{ animation: spin 0.9s linear infinite; }

.search-sheet-body{
  flex: 1;
  min-height: 0;
  overflow: auto;
  display:flex;
  flex-direction: column;
  padding-bottom: calc(var(--safe-bottom) + 12px);
  -webkit-overflow-scrolling: touch;
}

.search-sheet-content{
  padding: 12px 16px 0;
  flex: 1;
  min-height: 0;
}

#search-results{
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: auto;
  padding: 8px 0 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom) + var(--player-h, 0px));
}

/* ========= Results list ========= */
.search-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px;
  margin: 8px 0;
  cursor: pointer;
  position: relative;

  border-radius: 18px;
  border: 1px solid color-mix(in srgb, var(--text-color) 10%, transparent);
  background: color-mix(in srgb, var(--tg-secondary-bg-color, var(--secondary-bg-color, #f5f5f5)) 85%, transparent);

  box-shadow: 0 1px 0 rgba(0,0,0,0.04);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);

  transition: transform 0.08s ease, background 0.2s ease, border-color 0.2s ease;
}

.search-item:hover { background: color-mix(in srgb, var(--tg-secondary-bg-color, var(--secondary-bg-color, #f5f5f5)) 92%, transparent); }
.search-item:active { transform: scale(0.995); }


.search-item:hover { background: rgba(127,127,127,0.08); }
.search-item:active { transform: scale(0.995); }

.thumb {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 999px;
  flex: 0 0 52px;
  background: color-mix(in srgb, var(--tg-secondary-bg-color, #f5f5f5) 70%, transparent);
}

.track-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.track-title {
  font-weight: 700;
  font-size: 14px;
  line-height: 1.2;
  margin-bottom: 2px;
  color: var(--tg-link-color, var(--accent-color));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-artist {
  color: var(--tg-hint-color, #888);
  font-size: 12px;
  opacity: 0.95;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-duration {
  font-size: 11px;
  opacity: 0.85;
  color: var(--tg-hint-color, #888);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-duration:empty {
  display: none;
}
.src-ico{
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 16px;
  line-height: 0;
}

.src-ico svg{
  width: 100%;
  height: 100%;
  display: block;
}

.track-actions{
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.track-source-right{
  width: 18px;
  height: 18px;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius: 0;
  border: none;
  background: transparent;
  flex: 0 0 18px;
  opacity: 0.85;
}

.track-source-right svg{
  width: 100%;
  height: 100%;
  display:block;
}

.track-more{
  appearance: none;
  background: transparent;
  border: none;
  padding: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.track-more svg{
  width: 20px;
  height: 20px;
  fill: var(--tg-hint-color);
  opacity: 0.8;
}

.track-more:active{
  opacity: 0.6;
}

.history-link{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 6px 4px 10px;
  padding: 10px 10px;
  border: none;
  background: transparent;
  color: var(--tg-link-color, var(--accent-color));
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  opacity: 0.95;
}

.history-link:active{ opacity: 0.75; }


.play-btn {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: none;
  display: grid;
  place-items: center;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  background: var(--accent-grad);
  color: var(--accent-text, #fff);
  transition: transform .15s ease, opacity .15s ease, box-shadow .2s ease;
  margin-left: auto;
  box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}
.play-btn:active { transform: scale(0.96); box-shadow: 0 4px 12px rgba(0,0,0,0.10); }
.play-btn[data-state="playing"] { box-shadow: 0 0 0 3px rgba(0,0,0,.05) inset; }
.play-btn[data-state="loading"] svg{ animation: spin 0.9s linear infinite; }

.play-btn svg {
  width: 18px;
  height: 18px;
  display: block;
  fill: currentColor;
}

.search-item audio,
.search-item iframe {
  margin-top: 8px;
  width: 100%;
  border-radius: 8px;
}

.loading-dots::after {
  content: '';
  display: inline-block;
  width: 1em;
  text-align: left;
  animation: dots 1s steps(3, end) infinite;
}

@keyframes dots {
  0%, 20% { content: ''; }
  40% { content: '.'; }
  60% { content: '..'; }
  80%, 100% { content: '...'; }
}

/* ========= Placeholder (Search) ========= */
.search-placeholder{
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 4px 0 18px;
}

.mg-ph-section{
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mg-ph-title{
  font-size: 14px;
  font-weight: 800;
  opacity: .85;
  padding: 0 2px;
}

.mg-thumb-row{
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 2px 2px 6px;
  scroll-snap-type: x mandatory;
}

.mg-thumb-row::-webkit-scrollbar{ height: 0; }

.mg-thumb-card{
  appearance: none;
  border: 1px solid rgba(0,0,0,.08);
  background: color-mix(in srgb, var(--bg-color) 92%, var(--tg-secondary-bg-color) 8%);
  color: var(--text-color);
  border-radius: 16px;
  padding: 0;
  flex: 0 0 auto;
  width: 118px;
  text-align: left;
  overflow: hidden;
  scroll-snap-align: start;
  -webkit-tap-highlight-color: transparent;
}

.mg-thumb-card:active{ transform: scale(.99); }

.mg-thumb{
  width: 100%;
  height: 78px;
  object-fit: cover;
  display: block;
  background: rgba(0,0,0,.06);
}

.mg-thumb-cap{
  padding: 8px 10px 10px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: .95;
}

.mg-history{
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mg-history-item{
  appearance: none;
  border: 1px solid rgba(0,0,0,.08);
  background: transparent;
  color: var(--text-color);
  border-radius: 14px;
  padding: 0 12px;
  height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}

.mg-history-item:active{ background: rgba(127,127,127,0.10); }

.mg-ico{
  width: 26px;
  height: 26px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: rgba(127,127,127,0.10);
  font-size: 14px;
  flex: 0 0 auto;
}

.mg-text{
  flex: 1;
  min-width: 0;
  font-weight: 800;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mg-go{
  flex: 0 0 auto;
  opacity: .6;
  font-size: 16px;
}

.mg-empty-note{
  font-size: 13px;
  opacity: .65;
  padding: 4px 2px 0;
  font-weight: 700;
}

.sk{
  background: rgba(127,127,127,0.12);
  position: relative;
  overflow: hidden;
}
.sk::after{
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-120%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
  animation: skShimmer 1.1s infinite;
}
@keyframes skShimmer { to { transform: translateX(120%); } }

.mg-thumb.sk{ height: 78px; }
.mg-thumb-cap.sk{ height: 14px; margin: 10px; border-radius: 10px; }
.mg-history-item.sk{ border-color: rgba(0,0,0,0.04); }
.mg-history-item.sk .mg-ico.sk{ width: 26px; height: 26px; border-radius: 9px; }
.mg-history-item.sk .mg-text.sk{ height: 14px; border-radius: 10px; width: 70%; }
.mg-history-item.sk .mg-go.sk{ width: 18px; height: 18px; border-radius: 6px; margin-left: auto; }

@media (prefers-color-scheme: dark){
  .mg-thumb-card{ border-color: rgba(255,255,255,.10); }
  .mg-history-item{ border-color: rgba(255,255,255,.10); }
  .mg-ico{ background: rgba(255,255,255,.10); }
  .sk{ background: rgba(255,255,255,0.10); }
}

/* ========= Home grid cards ========= */
.home-grid{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.home-card{
  position: relative;
  border: 0;
  padding: 0;
  background: transparent;
  border-radius: 14px;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 1 / 1;
}

.home-card-cover{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.home-card-overlay{
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 8px 8px 7px;
  background: linear-gradient(to top, rgba(0,0,0,.70), rgba(0,0,0,0));
}

.home-card-title{
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.home-card--history{
  background:
    radial-gradient(900px 260px at 10% 0%, rgba(101,174,208,.25), transparent 60%),
    radial-gradient(900px 260px at 90% 0%, rgba(99,102,241,.18), transparent 60%),
    color-mix(in srgb, var(--bg-color) 92%, var(--tg-secondary-bg-color) 8%);
  border: 1px solid rgba(127,127,127,0.18);
}

.home-card--history .home-card-overlay{
  inset: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 6px;
  padding: 12px;
}

.home-history-badge{
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(127,127,127,0.12);
  border: 1px solid rgba(127,127,127,0.18);
  color: var(--text-color);
  font-weight: 800;
  font-size: 12px;
}

.home-history-title{
  color: var(--text-color);
  font-weight: 900;
  font-size: 14px;
  line-height: 1.1;
}

.home-history-sub{
  color: var(--tg-hint-color, #888);
  font-weight: 700;
  font-size: 12px;
}

/* ========= Legal note ========= */
.legal-note{
  position: static;
  width: 100%;
  text-align: center;
  font-size: 11px;
  color: var(--tg-hint-color, #888);
  padding: 10px 8px 6px;
  background: transparent;
  opacity: .7;
  pointer-events: none;
}

/* ========= Mini player ========= */
body.has-player{ --player-h: 68px; }

.mini-player {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--tg-bottom, 0px) + 10px);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 28px;
  background: color-mix(in srgb, var(--tg-secondary-bg-color, #f5f5f5) 40%, transparent);
  border: 0.5px solid color-mix(in srgb, var(--text-color, #000) 10%, transparent);
  box-shadow: 0 8px 22px rgba(0,0,0,.12) !important;
  z-index: 2600;
  backdrop-filter: blur(var(--glass-blur)) saturate(160%) !important;
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%) !important;
  overflow: hidden;
}

body.dark .mini-player{
  background: color-mix(in srgb, var(--tg-secondary-bg-color, #252525) 40%, transparent) !important;
  box-shadow: 0 10px 26px rgba(0,0,0,.35) !important;
}

.mini-player.hidden{ display:none; }

.mini-player .mp-cover{
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  background: rgba(0,0,0,.06);
}

.mini-player .mp-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.mini-player .mp-title{
  font-weight: 700;
  font-size: 14px;
  line-height: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--tg-text-color, var(--text-color));
}

.mini-player .mp-sub{
  font-size: 12px;
  line-height: 14px;
  color: var(--tg-hint-color, #7c7d7d);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-player .mp-btn{
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: none;
  display: grid;
  place-items: center;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  background: rgba(0,0,0,0.06);
  color: var(--tg-text-color, var(--text-color));
}
body.dark .mini-player .mp-btn{ background: rgba(255,255,255,0.10); }

.mini-player .mp-btn:active{ transform: scale(.96); }

.mini-player .mp-close{
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: transparent;
  color: var(--tg-text-color, var(--text-color));
  border: 1px solid rgba(0,0,0,.15);
}

body.dark .mini-player .mp-close {
  border-color: rgba(255,255,255,.18);
}

.mini-player .mp-btn svg {
  width: 18px;
  height: 18px;
  display: block;
  fill: currentColor;
}

.mp-yt-wrap { margin-top: 8px; }
.mp-yt-wrap.hidden { display: none; }

#mp-yt { width: 100%; aspect-ratio: 16/9; }
#mp-yt iframe { width: 100%; height: 100%; border: 0; border-radius: 8px; }

/* ========= Player overlay ========= */
body.player-open {
  overflow: hidden !important;
  touch-action: none;
}

.player-overlay.hidden { display: none; }

.player-overlay{
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: transparent;
  pointer-events: none;
  opacity: 0;
  transition: opacity .22s ease;
  overscroll-behavior: contain;
}

.player-overlay.is-open{
  pointer-events: auto;
  opacity: 1;
}

.player-overlay .po-backdrop{
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity .22s ease;
}

.player-overlay.is-open .po-backdrop{ opacity: 1; }

.player-overlay .po-sheet{
  position: absolute;
  left: 0; right: 0;
  bottom: 0;
  height: 100svh;
  height: 100dvh;
  background: var(--app-bg);
  color: var(--text-color);
  display: flex;
  flex-direction: column;
  padding: calc(14px + env(safe-area-inset-top, 0px) + 44px) 16px calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateY(14px);
  transition: transform .22s ease, opacity .22s ease;
  opacity: 0;
  transform-origin: top left;
  will-change: transform;
  touch-action: none;
  border-radius: 26px 26px 0 0;
  overflow: hidden;
  box-shadow: 0 -18px 60px rgba(0,0,0,.20);
}

.player-overlay.is-open .po-sheet{
  transform: translateY(0);
  opacity: 1;
}

.player-overlay.is-dragging .po-sheet{ transition: none !important; }

.po-grabber{
  position: absolute;
  left: 0;
  right: 0;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  height: 22px;
  display:flex;
  align-items:center;
  justify-content:center;
  z-index: 2;
  touch-action: pan-y;
}

.po-grabber::before{
  content:"";
  width: 44px;
  height: 5px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-color) 28%, transparent);
}

.player-overlay .po-header,
.player-overlay .po-controls,
.player-overlay .po-progress{
  flex: 0 0 auto;
}

.player-overlay .po-header{
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding-top: 0;
  transform: translateY(-6px);
}

.player-overlay .po-meta{
  flex: 0 0 auto;
  min-width: 0;
  width: 100%;
}

.player-overlay .po-title{
  font-weight: 800;
  font-size: 18px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.player-overlay .po-sub{
  margin-top: 4px;
  opacity: .7;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.player-overlay .po-cover-wrap{
  margin-top: 8px;
  flex: 1;
  display: grid;
  place-items: center;
  transform: translateY(-10px);
}

.player-overlay .po-cover{
  width: min(80vw, 380px);
  aspect-ratio: 1 / 1;
  border-radius: 22px;
  object-fit: cover;
  box-shadow: 0 18px 60px rgba(0,0,0,.25);
}

.player-overlay .po-progress{ margin-top: 18px; }

.player-overlay .po-times{
  display: flex;
  justify-content: space-between;
  font-variant-numeric: tabular-nums;
  opacity: .8;
  font-size: 13px;
  margin-bottom: 10px;
}

.player-overlay .po-bar{
  cursor: pointer;
  height: 7px;
  border-radius: 999px;
  overflow: hidden;
  width: 100%;
  background: rgba(0,0,0,0.15);
  margin-top: 0px;
  position: relative;
  touch-action: none;
}

body.dark .player-overlay .po-bar{ background: rgba(255,255,255,.12); }

.player-overlay .po-bar::before{
  content:"";
  position:absolute;
  left:0; right:0;
  top:-10px; bottom:-10px;
}

.player-overlay .po-bar.is-scrubbing{ transform: scaleY(1.25); }

.player-overlay .po-bar-fill{
  height: 100%;
  width: 0%;
  background: var(--accent-grad);
  border-radius: 999px;
}

.player-overlay .po-controls{
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.player-overlay .po-btn{
  width: 56px;
  height: 56px;
  border-radius: 16px;
  border: 0;
  background: rgba(127,127,127,.12);
  color: var(--text-color);
  font-size: 18px;
  display:flex;
  align-items:center;
  justify-content:center;
  line-height: 0;
  padding: 0;
}

.player-overlay .po-play{
  width: 72px;
  height: 72px;
  border-radius: 22px;
  background: var(--accent-grad);
  color: var(--accent-text);
  font-size: 22px;
}

.player-overlay .po-btn svg{
  width: 22px;
  height: 22px;
  display: block;
  fill: currentColor;
}
.player-overlay .po-play svg{
  width: 26px;
  height: 26px;
  display: block;
  fill: currentColor;
}

/* ========= Search hint ========= */
.search-hint {
  position: fixed;
  z-index: 1200;
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .25s ease, transform .25s ease;
}

.search-hint.show {
  opacity: 1;
  transform: translateY(0);
}

.search-hint .hint-bubble {
  pointer-events: none;
  background: rgba(255,255,255,.92);
  color: #111;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.25;
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
  text-align: center;
  backdrop-filter: saturate(160%) blur(8px);
  -webkit-backdrop-filter: saturate(160%) blur(8px);
  white-space: nowrap;
}

@media (prefers-color-scheme: dark) {
  .search-hint .hint-bubble {
    background: rgba(30,30,30,.9);
    color: #f2f2f2;
    border-color: rgba(255,255,255,.10);
    box-shadow: 0 8px 28px rgba(0,0,0,.5);
  }
}

.search-hint .hint-arrow {
  display: block;
  margin: 6px auto 0;
  fill: var(--accent-color);
  animation: hint-bounce 1.2s ease-in-out infinite;
  opacity: .95;
}

@keyframes hint-bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(4px); }
}

/* ========= Modal + toast ========= */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 3000;

  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .22s ease, visibility 0s linear .22s;
}

.modal:not(.hidden) {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity .22s ease;
}

.modal .modal-content{
  opacity: 0;
  transform: translateY(10px) scale(.96);
  transition: transform .22s ease, opacity .22s ease;
}

.modal:not(.hidden) .modal-content{
  opacity: 1;
  transform: translateY(0) scale(1);
}

.modal-content {
  background: var(--tg-bg-color, #fff);
  color: var(--tg-text-color, #000);
  padding: 20px;
  border-radius: 18px;
  width: 90%;
  max-width: 400px;
}

.account-modal-content {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--accent-color) 45%, transparent),
    rgba(255, 255, 255, 0.14)
  );
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow:
    0 26px 80px rgba(0,0,0,0.45),
    inset 0 1px 0 rgba(255,255,255,0.22);
  backdrop-filter: blur(16px) saturate(155%);
  -webkit-backdrop-filter: blur(16px) saturate(155%);
  border-radius: 26px;
  max-width: 520px;
}

.account-modal-content::before{
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 52%;
  background: linear-gradient(180deg,
    rgba(255,255,255,0.30),
    rgba(255,255,255,0.08) 45%,
    rgba(255,255,255,0.00)
  );
  pointer-events: none;
}

.account-modal-content::after{
  content: "";
  position: absolute;
  left: -30%;
  top: -35%;
  width: 160%;
  height: 90%;
  background: linear-gradient(115deg,
    rgba(255,255,255,0.00) 0%,
    rgba(255,255,255,0.10) 35%,
    rgba(255,255,255,0.00) 70%
  );
  transform: rotate(-8deg);
  pointer-events: none;
  mix-blend-mode: screen;
  opacity: .9;
}

.account-modal-body{
  position: relative;
  z-index: 1;
}

.account-modal-content .tg-profile-center {
  padding: 18px 18px 10px;
  text-align: center;
}

.account-modal-content .tg-avatar {
  margin: 0 auto 12px;
  width: 96px;
  height: 96px;
  position: relative;
}

.account-modal-content .tg-avatar::before{
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 170px;
  height: 170px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle,
    rgba(255,255,255,0.28),
    rgba(255,255,255,0.00) 68%
  );
  filter: blur(2px);
  pointer-events: none;
  z-index: -1;
}

.account-modal-content .tg-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.account-modal-content #profile-avatar-fallback {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  font-weight: 800;
  background: rgba(0,0,0,0.18);
  color: rgba(255,255,255,0.92);
}

.account-modal-content #profile-name {
  font-size: 30px;
  line-height: 1.05;
  margin: 6px 0 6px;
  font-weight: 850;
  letter-spacing: -0.02em;
}

.account-modal-content #profile-username {
  display: inline-block;
  font-size: 18px;
  font-weight: 750;
  color: var(--tg-link-color, #65aed0);
  text-decoration: none;
  margin-bottom: 14px;
}

.account-modal-content .account-meta{
  display:flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.account-modal-content #profile-id{
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  font-size: 14px;
  opacity: 0.9;
}

.account-modal-content .tg-id-label{
  font-size: 12px;
  opacity: .75;
}

.account-modal-content .tg-id-value{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 16px;
  letter-spacing: 0.01em;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--tg-text-color, #000);
  user-select: none;
}

.account-modal-content .tg-id-value:active{ transform: scale(.985); }

.account-share-btn{
  width: 100%;
  border: 0;
  padding: 12px 14px;
  border-radius: 14px;
  font-weight: 800;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(255,255,255,0.14);
  color: var(--tg-text-color, #000);
  border: 1px solid rgba(255,255,255,0.16);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.account-share-btn .tg-btn-icon{
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  opacity: 0.95;
  fill: currentColor;
}

.account-share-btn:active{ transform: scale(.985); }

.modal-close-icon {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: rgba(0,0,0,0.18);
  color: rgba(255,255,255,0.92);
  font-size: 26px;
  line-height: 40px;
  cursor: pointer;
}

.modal-close-icon:active {
  transform: scale(0.96);
}

.modal-content h3{
  font-weight: 900;
  margin-top: 0;
  margin-bottom: 8px;
}

.modal-content textarea {
  width: 100%;
  height: 100px;
  margin-top: 10px;
  resize: none;
  border: 1px solid color-mix(in srgb, var(--tg-text-color, #000) 18%, transparent);
  border-radius: 6px;
  padding: 8px;
  font-family: inherit;
  font-size: 14px;
  background: var(--tg-secondary-bg-color, #f5f5f5);
  color: var(--tg-text-color, #000);
}

.modal-content textarea:focus{
  outline: none;
  border-color: color-mix(in srgb, var(--accent-color) 55%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-color) 16%, transparent);
}

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

.modal-actions .setting-button{
  min-width: 110px;
  border-radius: 4px;
}

.modal-body { margin: 20px 0; }

.modal-setting{
  padding: 10px 0;
  border-top: 1px solid rgba(0,0,0,.08);
}
.modal-setting:first-child{ border-top: none; }

.modal-setting-row{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 16px;
}

.modal-help{
  margin-top: 10px;
  font-size: 12px;
  opacity: .65;
  line-height: 1.3;
}

.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background-color: #323232;
  color: #fff;
  padding: 10px 20px;
  border-radius: 25px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: 999;
}

.toast.show { opacity: 1; }

/* === Search placeholder === */
.mg-placeholder{
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 10px 2px 14px;
}

.mg-section{
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mg-section-title{
  font-size: 16px;
  font-weight: 800;
  opacity: .92;
  padding: 0 4px;
}

.mg-thumb-row{
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 4px 6px;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
}

.mg-thumb-row::-webkit-scrollbar{ height: 0; }

.mg-thumb-card{
  flex: 0 0 auto;
  width: 118px;
  border: 0;
  background: transparent;
  padding: 0;
  scroll-snap-align: start;
  text-align: left;
  cursor: pointer;
}

.mg-thumb{
  width: 118px;
  height: 72px;
  border-radius: 14px;
  object-fit: cover;
  display: block;
  background: rgba(127,127,127,.12);
  border: 1px solid rgba(0,0,0,.06);
}

body.dark .mg-thumb{
  border-color: rgba(255,255,255,.08);
}

.mg-thumb-title{
  margin-top: 6px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 2px;
}

.mg-history{
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mg-history-item{
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px;
  border-radius: 16px;
  border: 1px solid rgba(0,0,0,.06);
  background: color-mix(in srgb, var(--bg-color) 92%, var(--tg-secondary-bg-color) 8%);
  cursor: pointer;
  text-align: left;
}

.mg-history-item:active{
  transform: scale(.996);
}

body.dark .mg-history-item{
  border-color: rgba(255,255,255,.08);
}

.mg-history-item .mg-ico,
.mg-history-item .mg-go{
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 22px;
  opacity: .85;
  color: color-mix(in srgb, var(--text-color) 88%, transparent);
}

.mg-history-item svg{
  width: 20px;
  height: 20px;
  fill: currentColor;
  display: block;
}

.mg-history-item .mg-text{
  flex: 1;
  min-width: 0;
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mg-empty-note{
  font-size: 13px;
  opacity: .65;
  padding: 2px 4px 0;
}

.mg-clear{
  align-self: flex-start;
  margin-left: 4px;
  margin-top: -2px;
  border: 1px solid rgba(127,127,127,.22);
  background: transparent;
  color: var(--text-color);
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
}

.mg-history-item.sk{
  pointer-events: none;
  opacity: .55;
}

.mg-history-item.sk .mg-ico,
.mg-history-item.sk .mg-go{
  background: rgba(127,127,127,.12);
  border-radius: 999px;
}

.mg-history-item.sk .mg-text{
  height: 12px;
  border-radius: 8px;
  background: rgba(127,127,127,.12);
}

.mg-ico{
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--tg-hint-color);
  opacity: .9;
}

.mg-ico svg{
  width: 20px;
  height: 20px;
  display: block;
}

/* ========= Marquee ========= */
.marquee{
  overflow: hidden;
  position: relative;
}

.marquee .marquee-inner{
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  will-change: transform;
  transform: translate3d(0,0,0);
}

.marquee .mq-text{
  display: inline-block;
  white-space: nowrap;
}

.marquee .mq-gap{
  display: inline-block;
  width: var(--mq-gap, 28px);
  flex: 0 0 var(--mq-gap, 28px);
}

.marquee.is-marquee .marquee-inner{
  animation: mgMarqueeLoop var(--mq-dur, 10s) linear infinite;
}

@keyframes mgMarqueeLoop{
  0%   { transform: translate3d(0,0,0); }
  12%  { transform: translate3d(0,0,0); }
  88%  { transform: translate3d(calc(-1 * var(--mq-shift, 0px)),0,0); }
  100% { transform: translate3d(calc(-1 * var(--mq-shift, 0px)),0,0); }
}

/* ========= Mini-player tweaks ========= */
.mini-player .mp-play{
  background: transparent !important;
  color: var(--accent-color) !important;
  box-shadow: none !important;
  border: 0 !important;
  box-shadow: none !important;
  width: 44px;
  height: 44px;
  margin-left: 8px;
}
.mini-player .mp-play svg{
  width: 26px;
  height: 26px;
  fill: var(--accent-color) !important;
  stroke: var(--accent-color) !important;
}

#mini-player .mp-play svg *{
  fill: var(--accent-color) !important;
  stroke: var(--accent-color) !important;
}

.mini-player .mp-btn.is-loading svg,
.player-overlay .po-play.is-loading svg,
.play-btn[data-state="loading"] svg{
  animation: spin 0.9s linear infinite;
}

.play-btn[data-state="loading"] svg,
.mini-player .mp-play.is-loading svg,
.player-overlay .po-play.is-loading svg {
  fill: none !important;
}

.play-btn[data-state="loading"] svg *,
.mini-player .mp-play.is-loading svg *,
.player-overlay .po-play.is-loading svg * {
  fill: none !important;
}

.mp-play.is-loading svg,
#po-play.is-loading svg {
  animation: mg-spin 0.9s linear infinite;
}

@keyframes mg-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* --- Privacy modal layout fixes --- */
.modal-setting-row .setting-label{
  display: inline-flex;
  align-items: center;
  gap: 12px;
  line-height: 1.1;
}

.modal-setting-row .setting-label svg{
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  display: block;
}

.privacy-note{
  margin-top: 10px;
  margin-bottom: 18px;
  font-size: 12px;
  line-height: 1.3;
  opacity: .65;
}

/* ========= Splash ========= */
.splash{
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: grid;
  place-items: center;
  background: var(--app-bg);
  opacity: 1;
  transition: opacity .35s ease, visibility 0s linear .35s;
  visibility: visible;
  pointer-events: auto;
}

.splash-inner{
  position: relative;
  display: grid;
  place-items: center;
  transform: translateZ(0);
}

.splash-logo{
  width: min(260px, 72vw);
  height: auto;
  display: block;
  filter: drop-shadow(0 18px 44px rgba(0,0,0,.10));
  animation: splashPop .9s cubic-bezier(.2,.9,.2,1) both;
}

.splash-glow{
  position: absolute;
  inset: -90px;
  background:
    radial-gradient(circle at 50% 55%,
      color-mix(in srgb, var(--accent-color) 22%, transparent) 0%,
      transparent 58%),
    radial-gradient(circle at 50% 50%,
      color-mix(in srgb, var(--accent-color) 10%, transparent) 0%,
      transparent 70%);
  filter: blur(22px);
  opacity: .55;
  z-index: -1;
}

@keyframes splashPop{
  0%   { transform: scale(.92); opacity: 0; }
  60%  { transform: scale(1.02); opacity: 1; }
  100% { transform: scale(1.0); }
}

.splash.is-hide{
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.hide-sources .track-source-right{ display:none !important; }

.tg-track-list{
  padding: 2px 0 8px;
}

.search-item--history .history-pill-ico{
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display:flex;
  align-items:center;
  justify-content:center;
  flex: 0 0 52px;
  font-size: 20px;
  background: color-mix(in srgb, var(--tg-secondary-bg-color, #f5f5f5) 80%, transparent);
  color: var(--tg-text-color, var(--text-color));
  opacity: 0.9;
}

.search-item--history .go-ico{
  font-size: 22px;
  line-height: 1;
  opacity: 0.55;
  color: var(--tg-text-color, var(--text-color));
}

/* ========= Track actions sheet (three-dots menu) ========= */
.track-actions-sheet{
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  display: none;
}

.track-actions-sheet.is-open{
  display: block;
  pointer-events: auto;
}

.track-actions-sheet.is-hiding{
  display: block;
  pointer-events: auto;
}

.track-actions-sheet.is-hiding .track-actions-backdrop{ opacity: 0; }
.track-actions-sheet.is-hiding .track-actions-panel{ transform: translateY(110%); }

.track-actions-backdrop{
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.35);
  opacity: 0;
  transition: opacity .18s ease;
}

.track-actions-panel{
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px) + var(--track-actions-lift, 72px));
  background: var(--tg-secondary-bg-color, var(--secondary-bg-color, #f5f5f5));
  color: var(--tg-text-color, var(--text-color, #000));
  border-radius: 18px;
  transform: translateY(110%);
  transition: transform .22s ease;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
  overflow: hidden;
}

.track-actions-sheet.is-open{ pointer-events: auto; }
.track-actions-sheet.is-open .track-actions-backdrop{ opacity: 1; }
.track-actions-sheet.is-open .track-actions-panel{ transform: translateY(0); }

.track-actions-head{
  padding: 14px 16px 10px;
  border-bottom: 1px solid rgba(0,0,0,.08);
}

.track-actions-head-row{
  display: flex;
  align-items: center;
  gap: 12px;
}

.track-actions-cover{
  width: 46px;
  height: 46px;
  border-radius: 12px;
  overflow: hidden;
  flex: 0 0 46px;
  background: rgba(0,0,0,.06);
  display: flex;
  align-items: center;
  justify-content: center;
}

.track-actions-cover img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display:block;
}

.track-actions-cover-fallback{
  font-size: 20px;
  opacity: .7;
}

.track-actions-head-text{
  min-width: 0;
  flex: 1 1 auto;
}

.track-actions-title{
  font-weight: 700;
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-actions-subtitle{
  margin-top: 4px;
  font-size: 13px;
  color: var(--tg-hint-color, var(--hint-color, #777));
  line-height: 1.25;
  word-break: break-word;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-actions-source{
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: .95;
}

.track-actions-source .src-ico{
  display: inline-flex;
}

.track-actions-source svg{
  width: 22px;
  height: 22px;
}

.hide-sources .track-actions-source{ display:flex !important; }

.track-actions-list{
  display: flex;
  flex-direction: column;
}

.track-action-btn{
  appearance: none;
  border: none;
  background: transparent;
  padding: 14px 16px;
  text-align: left;
  font-size: 16px;
  color: inherit;
  cursor: pointer;
}

.track-action-btn + .track-action-btn{
  border-top: 1px solid rgba(0,0,0,.08);
}

.track-action-btn:active{ transform: scale(.99); }

.track-action-btn.primary{
  color: var(--tg-link-color, var(--accent-color, #65aed0));
  font-weight: 700;
}

.track-action-btn.danger{
  color: #e53935;
  font-weight: 700;
}

.track-action-btn.with-ico{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.track-action-btn.with-ico .track-action-ico{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  opacity: .9;
}

.track-action-btn.with-ico svg{
  width: 20px;
  height: 20px;
}

.track-action-btn.cancel{
  font-weight: 700;
}

body.has-actions-sheet{
  overscroll-behavior: none;
}

/* ======= */
.home-appbar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.home-appbar-left{
  display: flex;
  align-items: center;
  min-width: 44px;
}

.home-logo{
  border: 0;
  background: transparent;
  padding: 0;
  width: 56px;
  height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
}

.home-logo img{
  width: 56px;
  height: 56px;
  display: block;
  object-fit: contain;
}
