* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }

body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  color: var(--text-color);
  font-family: Vazirmatn, Tahoma, "Segoe UI", system-ui, sans-serif; font-size: 15px;
  background:
    radial-gradient(circle at 15% 8%, color-mix(in srgb, var(--accent) 55%, transparent), transparent 45%),
    radial-gradient(circle at 92% 38%, color-mix(in srgb, var(--accent) 30%, #ff4fa3 20%), transparent 45%),
    radial-gradient(circle at 30% 98%, color-mix(in srgb, var(--accent) 35%, #00c2ff 15%), transparent 50%),
    #0b0c12;
  background-attachment: fixed;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
  transition: background .6s ease;
}
body.has-player { padding-bottom: calc(260px + env(safe-area-inset-bottom)); }
html[data-theme="light"] body {
  background:
    radial-gradient(circle at 15% 8%, color-mix(in srgb, var(--accent) 45%, transparent), transparent 45%),
    radial-gradient(circle at 92% 40%, rgba(255, 150, 210, .45), transparent 45%),
    radial-gradient(circle at 30% 98%, rgba(120, 220, 255, .45), transparent 50%),
    #eef1fb;
  background-attachment: fixed;
}
[hidden] { display: none !important; }

.wrap { max-width: 720px; margin: 0 auto; padding: 12px 14px; padding-top: calc(12px + env(safe-area-inset-top)); }
h1, h2, h3 { margin: 0; }
button { font: inherit; }

/* ---------- App bar ---------- */
.appbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; margin-bottom: 12px; }
.appbar h1 { font-size: 19px; }
.badge {
  border: 1px solid var(--glass-border); background: rgba(255,255,255,.08); color: var(--text-color);
  border-radius: 999px; padding: 5px 12px; font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #9aa3b5; }
.badge.proxy::before { background: #4fd18b; }
.badge.bad::before { background: #ff6b6b; }

/* ---------- Inputs ---------- */
input {
  flex: 1; min-width: 0; padding: 12px 14px; border-radius: 14px; font: inherit;
  border: 1px solid var(--glass-border); background: rgba(255,255,255,.08); color: var(--text-color);
}
input::placeholder { color: color-mix(in srgb, var(--text-color) 55%, transparent); }
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.glass-button { white-space: nowrap; padding: 11px 16px; }
.glass-button.mini { padding: 7px 12px; border-radius: 12px; font-size: 13px; }
.glass-button:focus-visible, .tab:focus-visible, .chip:focus-visible, .badge:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.searchbar { display: flex; gap: 8px; padding: 10px; }
.searchbar input { background: transparent; border-color: transparent; }
.searchbar input:focus { box-shadow: none; border-color: transparent; }
.searchbar .go { background: var(--accent); border-color: transparent; color: #fff; }
html[data-theme="light"] .searchbar .go { color: #fff; }

/* ---------- Chips ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.chip {
  border: 1px solid var(--glass-border); background: var(--glass-bg); color: var(--text-color);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-radius: 999px; padding: 7px 14px; font-size: 13px; cursor: pointer; transition: transform .3s cubic-bezier(.2,.8,.2,1), border-color .3s;
}
.chip:hover { border-color: var(--accent); transform: translateY(-2px); }
.chip.recent { border-style: dashed; }

/* ---------- Link box ---------- */
.linkbox { padding: 12px 14px; margin-bottom: 12px; }
.linkbox summary { cursor: pointer; font-weight: 600; }
.linkbox form { display: flex; gap: 8px; margin-top: 10px; }

#status { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; text-align: center; opacity: .9; margin: 14px 0; min-height: 1em; }
#status:empty { display: none; }

/* ---------- Results ---------- */
.item { display: flex; gap: 12px; align-items: center; padding: 10px; margin-bottom: 10px; cursor: pointer; border-radius: 18px; }
.item img { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; background: rgba(255,255,255,.1); flex: none; }
.item > div { min-width: 0; }
.item .t { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .a { opacity: .7; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Tracks ---------- */
#tracksBox { padding: 14px; margin-top: 6px; }
.tracks-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.tracks-head h2 { font-size: 16px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
ol { list-style: none; padding: 0; margin: 10px 0 0; }
li.track { display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: 14px; transition: background .3s; }
li.track + li.track { border-top: 1px solid color-mix(in srgb, var(--text-color) 10%, transparent); }
.active { background: color-mix(in srgb, var(--accent) 28%, transparent) !important; }
li.track .name { flex: 1; min-width: 0; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
li.track .fmt { opacity: .6; font-size: 11px; direction: ltr; }
li.track .glass-button, .hbtns .glass-button { padding: 6px 11px; border-radius: 12px; }

/* ---------- Views: history / settings ---------- */
.head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 2px 12px; }
.head h2 { font-size: 18px; }
.empty { padding: 18px; line-height: 2; opacity: .85; }
.hrow { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; margin-bottom: 10px; border-radius: 18px; }
.hinfo { min-width: 0; cursor: pointer; }
.hinfo .t { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hinfo .a { opacity: .7; font-size: 12.5px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbtns { display: flex; gap: 8px; flex-wrap: wrap; }
.hbtns .glass-button { flex: 1; min-width: 72px; }

.card { padding: 16px; margin-bottom: 12px; }
.card h3 { font-size: 15px; margin-bottom: 8px; }
.hint { opacity: .78; font-size: 13px; line-height: 1.9; margin: 0 0 10px; }
.card form { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row .glass-button { flex: 1; }
.state { margin: 10px 0 0; min-height: 1.4em; }
.themes { display: flex; gap: 14px; flex-wrap: wrap; }
.dot { width: 34px; height: 34px; border-radius: 50%; padding: 0; cursor: pointer; border: 2px solid rgba(255,255,255,.55); transition: transform .3s cubic-bezier(.2,.8,.2,1); }
.dot:hover { transform: scale(1.15); }
.dot.on { box-shadow: 0 0 0 3px color-mix(in srgb, var(--text-color) 40%, transparent); }

/* ---------- Player ---------- */
#player {
  position: fixed; right: 10px; left: 10px; max-width: 700px; margin: 0 auto;
  bottom: calc(76px + env(safe-area-inset-bottom)); padding: 12px 14px; z-index: 20;
}
.np { margin-bottom: 8px; min-width: 0; }
#nowPlaying { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#nowAlbum { font-size: 12px; opacity: .7; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
audio { width: 100%; height: 38px; border-radius: 12px; }
.ctrl { display: flex; gap: 8px; margin-top: 10px; }
.ctrl .glass-button { flex: 1; padding: 10px 6px; }
#dlNow { background: color-mix(in srgb, var(--accent) 55%, transparent); }

/* ---------- Bottom tabs ---------- */
#tabs {
  position: fixed; right: 10px; left: 10px; max-width: 700px; margin: 0 auto;
  bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 30;
  display: flex; padding: 6px; gap: 6px; border-radius: 22px;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: transparent; border: 0; color: var(--text-color); opacity: .7;
  padding: 8px 4px; border-radius: 16px; font-size: 12px; cursor: pointer;
  transition: background .35s, opacity .35s, transform .3s cubic-bezier(.2,.8,.2,1);
}
.tab .ic { font-size: 18px; line-height: 1.2; }
.tab.on { opacity: 1; background: color-mix(in srgb, var(--accent) 35%, transparent); }
.tab:active { transform: scale(.95); }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(160px + env(safe-area-inset-bottom)); transform: translate(-50%, 12px);
  background: rgba(20,22,30,.92); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s; z-index: 50; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 640px) {
  .hrow { flex-direction: row; align-items: center; justify-content: space-between; }
  .hinfo { flex: 1; }
  .hbtns { flex-wrap: nowrap; }
  .hbtns .glass-button { flex: none; min-width: 0; }
}
@media (max-width: 480px) {
  body { font-size: 14px; }
  .glass-button:hover { transform: none; }
  .glass-hover:hover { transform: none; }
}

.state[data-state="ok"] { color: #4fd18b; }
.state[data-state="bad"] { color: #ff7b7b; }
html[data-theme="light"] .state[data-state="ok"] { color: #1a8f55; }
html[data-theme="light"] .state[data-state="bad"] { color: #c62f2f; }

/* ---------- Brand: Rz Station ---------- */
.brand { display: flex; align-items: center; gap: 10px; margin: 0; font-size: inherit; font-weight: inherit; }
.logo { width: 36px; height: 36px; flex: none; filter: drop-shadow(0 4px 14px color-mix(in srgb, var(--accent) 55%, transparent)); }
.logo .bar { transform-box: fill-box; transform-origin: 50% 100%; animation: eq 1.3s ease-in-out infinite; }
.logo .b2 { animation-delay: -.45s; }
.logo .b3 { animation-delay: -.9s; }
@keyframes eq { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(.45); } }
.wordmark { display: inline-flex; align-items: baseline; gap: 6px; font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif; line-height: 1; white-space: nowrap; }
.wordmark b {
  font-size: 24px; font-weight: 800; letter-spacing: -.01em;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 35%, #ff72b6));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.wordmark span { font-size: 17px; font-weight: 300; letter-spacing: .16em; opacity: .92; }
.bar-actions { display: flex; align-items: center; gap: 8px; }
.langbtn { font-weight: 700; min-width: 44px; justify-content: center; }
.langbtn::before { display: none; }

/* ---------- Share sheet ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(5, 6, 10, .55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  padding: 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom));
}
.sheet-box { width: 100%; max-width: 520px; padding: 18px; background: color-mix(in srgb, var(--glass-bg) 70%, #0b0c12); animation: fadeIn .45s cubic-bezier(.16,1,.3,1) both; }
html[data-theme="light"] .sheet-box { background: rgba(255,255,255,.85); }
.sheet-box h3 { font-size: 16px; margin-bottom: 4px; }
.share-name { opacity: .75; font-size: 13px; margin-bottom: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-box input { width: 100%; font-size: 13px; }
@media (min-width: 640px) { .sheet { align-items: center; } }

.glass-button.on { background: var(--accent); border-color: transparent; color: #fff; }
.badge { white-space: nowrap; }

/* ---------- Favorites / hearts ---------- */
.heart { font-size: 17px; line-height: 1; min-width: 44px; }
.heart.liked { color: #ff5c8a; border-color: #ff5c8a; text-shadow: 0 0 12px rgba(255, 92, 138, .55); }
.ctrl .heart { flex: 0 0 auto; padding: 8px 12px; }
.ctrl .glass-button { min-width: 0; }
li.track .heart { min-width: 0; padding: 6px 10px; }
.tab .ic { font-size: 17px; }
