/* ==========================================================================
   هدوء — styles
   Mobile-first, right-to-left, dark. Big touch targets (>= 48px) because this
   is used in bed, in the dark, half asleep.
   ========================================================================== */

:root {
  --bg: #0b0f14;
  --bg-2: #0f151d;
  --card: #141b25;
  --card-2: #1a2331;
  --line: #24303f;
  --text: #e8eef7;
  --muted: #93a1b3;
  --accent: #8b5cf6;
  --accent-2: #f0b429;
  --danger: #f0616d;
  --radius: 20px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  /* safety net: nothing should be able to scroll the page sideways */
  overflow-x: hidden;
  max-width: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Arabic", "Segoe UI",
               "Noto Naskh Arabic", Tahoma, Arial, sans-serif;
  line-height: 1.6;
  min-height: 100dvh;
  /* soft glow at the top so the page doesn't look flat black */
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(139, 92, 246, .22), transparent 60%),
    radial-gradient(80% 40% at 90% 0%, rgba(240, 180, 41, .10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

.app {
  max-width: 540px;
  margin: 0 auto;
  padding: 18px 14px calc(28px + env(safe-area-inset-bottom));
}

/* ---------- header ---------- */

.top { padding: 6px 4px 14px; }

.brand { display: flex; align-items: center; gap: 12px; }

.logo {
  font-size: 30px;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(160deg, #241a3f, #131a26);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
}

.logo svg { width: 30px; height: 30px; color: var(--accent-2); }

.brand-text h1 { margin: 0; font-size: 26px; letter-spacing: 0; }

.tag { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

/* ---------- cards ---------- */

.card {
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .2px;
}

/* ---------- player ---------- */

.track-title {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seek {
  display: flex;
  align-items: center;
  gap: 10px;
  direction: ltr; /* the slider itself reads left-to-right like the audio */
}

.time {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--muted);
  min-width: 40px;
  text-align: center;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  background: transparent;
  margin: 0;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 99px;
  background: #263243;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  margin-top: -8px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .5);
}

input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 99px;
  background: #263243;
}

input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  margin: 10px 0 6px;
}

.icon-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #101825;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
}

.icon-btn svg { width: 22px; height: 22px; display: block; margin: 0 auto; }

.icon-btn:active { transform: scale(.96); }

.play-btn {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(160deg, #a78bfa, var(--accent));
  color: #fff;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(139, 92, 246, .35);
  display: grid;
  place-items: center;
}

.play-btn svg { width: 34px; height: 34px; display: block; }

.play-btn:active { transform: scale(.97); }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 8px;
}

.vol {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  color: var(--muted);
}

.vol-icon { width: 20px; height: 20px; flex: 0 0 auto; }

.plus { font-weight: 700; margin-inline-end: 2px; }

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}

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

.check.small { font-size: 12.5px; line-height: 1.5; align-items: flex-start; margin-top: 10px; }

.check.small input { flex: 0 0 auto; margin-top: 2px; }

/* ---------- timer ---------- */

.timer { text-align: center; }

.countdown {
  font-size: 52px;
  font-weight: 800;
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  line-height: 1.15;
  margin: 2px 0 2px;
  background: linear-gradient(180deg, #fff, #b9c6d8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.countdown.idle {
  background: none;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  color: #3c4a5c;
}

.countdown.running {
  background: linear-gradient(180deg, #fde68a, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hint {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  min-height: 20px;
}

.presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.presets button {
  min-height: 48px;
  padding: 6px 4px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #101825;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

.presets button:active { transform: scale(.97); }

.presets button.active {
  border-color: var(--accent);
  background: rgba(139, 92, 246, .18);
  color: #d9ccff;
}

.custom {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  min-width: 0;
}

.custom input {
  flex: 1 1 0;
  min-width: 0;
  min-height: 52px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #0d141d;
  color: var(--text);
  padding: 0 14px;
  font-size: 16px; /* 16px stops iOS from zooming into the field */
  font-family: inherit;
}

.custom input::placeholder { color: #6d7b8d; }

.primary {
  flex: 0 0 auto;
  min-height: 52px;
  padding: 0 18px;
  border-radius: 14px;
  border: 0;
  background: linear-gradient(160deg, #a78bfa, var(--accent));
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(139, 92, 246, .3);
}

.primary:active { transform: scale(.98); }

.fade-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
}

.fade-row select {
  min-height: 46px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0d141d;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
}

.ghost {
  width: 100%;
  min-height: 52px;
  margin-top: 14px;
  border-radius: 14px;
  border: 1px solid rgba(240, 97, 109, .45);
  background: rgba(240, 97, 109, .10);
  color: #ffb3b9;
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
}

/* ---------- playlist ---------- */

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.count {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 1px 10px;
  min-width: 30px;
  text-align: center;
}

.playlist {
  list-style: none;
  margin: 6px 0 12px;
  padding: 0;
  display: grid;
  gap: 8px;
}

.playlist .empty {
  color: var(--muted);
  font-size: 13px;
  padding: 14px 4px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 14px;
}

.track {
  display: flex;
  align-items: stretch;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #101825;
  overflow: hidden;
}

.track.active { border-color: var(--accent); background: rgba(139, 92, 246, .14); }

.track-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 12px 14px;
  border: 0;
  background: transparent;
  color: inherit;
  font-family: inherit;
  text-align: right;
  cursor: pointer;
}

.tname {
  max-width: 100%;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tmeta { font-size: 11.5px; color: var(--muted); }

.del {
  flex: 0 0 52px;
  border: 0;
  border-inline-start: 1px solid var(--line);
  background: transparent;
  color: #7d8b9c;
  font-size: 16px;
  cursor: pointer;
}

.del:active { background: rgba(240, 97, 109, .15); color: var(--danger); }

.add {
  display: grid;
  gap: 8px;
  /* grid/flex children default to min-width:auto, which lets a wide child
     stretch the whole page sideways on a phone (found in testing: the page
     zoomed out because the URL row was 434px wide inside a 330px card). */
  min-width: 0;
}

.add > * { min-width: 0; max-width: 100%; }

.secondary {
  min-height: 50px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #0d141d;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
}

.secondary:active { transform: scale(.99); }

.url-add { display: flex; gap: 8px; min-width: 0; }

.url-add input {
  flex: 1 1 0;
  width: 100%;
  min-width: 0;
  min-height: 50px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #0d141d;
  color: var(--text);
  padding: 0 12px;
  font-size: 16px;
  font-family: inherit;
}

.url-add .secondary { flex: 0 0 auto; padding: 0 18px; }

/* ---------- misc ---------- */

.how {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  margin: 4px 0 10px;
  color: var(--muted);
  font-size: 13px;
  background: rgba(255, 255, 255, .02);
}

.how summary { cursor: pointer; color: var(--text); font-size: 14px; }

.how p { margin: 8px 0 0; }

.foot {
  text-align: center;
  color: #6d7b8d;
  font-size: 12px;
  margin: 6px 0 0;
}

.toast {
  position: fixed;
  inset-inline: 0;
  bottom: calc(22px + env(safe-area-inset-bottom));
  margin: 0 auto;
  width: fit-content;
  max-width: 88vw;
  padding: 12px 18px;
  border-radius: 999px;
  background: #1d2735;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .22s ease, transform .22s ease;
  pointer-events: none;
  z-index: 20;
}

.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 360px) {
  .presets { grid-template-columns: repeat(3, 1fr); }
  .countdown { font-size: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
