/* Minimal Radio — mobile-first, no framework.
   Theme colors match tiny-radio (src/constants/theme.ts). */

:root {
  --text: #000000;
  --bg: #ffffff;
  --bg-elem: #f0f0f3;
  --bg-sel: #e0e1e6;
  --text-2: #60646c;
  --tint: #208aef;
  --danger: #d93025;
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #ffffff;
    --bg: #000000;
    --bg-elem: #212225;
    --bg-sel: #2e3135;
    --text-2: #b0b4ba;
    --tint: #4da3f5;
    --danger: #f28b82;
  }
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  max-width: 560px;
  margin-inline: auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.35;
  touch-action: manipulation;
}

button {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 2px solid var(--tint);
  outline-offset: 2px;
}

.tint {
  color: var(--tint);
}

/* --- app chrome ------------------------------------------------------- */

.app-header {
  padding: 12px 16px 4px;
  flex-shrink: 0;
}

.app-header h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

#main {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.view-title {
  font-size: 20px;
  font-weight: 700;
}

#now-playing {
  display: none;
  flex-shrink: 0;
}

#now-playing.visible {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--bg-elem);
  border-top: 1px solid var(--bg-sel);
}

#tabbar {
  display: flex;
  flex-shrink: 0;
  border-top: 1px solid var(--bg-sel);
  background: var(--bg);
  padding-bottom: env(safe-area-inset-bottom);
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 7px 0 9px;
  background: none;
  border: none;
  color: var(--text-2);
  cursor: pointer;
}

.tab-btn.active {
  color: var(--tint);
}

.tab-label {
  font-size: 11px;
}

/* --- lists and rows ---------------------------------------------------- */

.list {
  padding: 2px 0 24px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 10px 16px;
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
}

.row:active {
  background: var(--bg-sel);
}

.row.active {
  background: var(--bg-elem);
}

.row.muted {
  opacity: 0.45;
}

.row-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.row-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.pill {
  flex-shrink: 0;
  padding: 1px 7px;
  border-radius: 8px;
  background: var(--bg-sel);
  color: var(--text-2);
  font-size: 11px;
  white-space: nowrap;
}

.row-country {
  flex-shrink: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-2);
  font-size: 12px;
}

.freq {
  flex-shrink: 0;
  width: 62px;
  font-size: 19px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.artwork {
  flex-shrink: 0;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-sel);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.artwork-letter {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
}

.heart-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 18px;
  background: var(--bg-elem);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  cursor: pointer;
  padding: 0;
}

.heart-btn.on {
  color: var(--tint);
}

.spinner {
  animation: spin 1s linear infinite;
  color: var(--text-2);
}

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

/* --- empty / loading states -------------------------------------------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 48px 24px;
  text-align: center;
}

.empty-title {
  font-size: 16px;
  font-weight: 600;
}

.empty-sub {
  color: var(--text-2);
  font-size: 14px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--tint);
  font-size: 16px;
  padding: 8px;
  cursor: pointer;
}

/* --- search view --------------------------------------------------------- */

#main input[type='search'] {
  display: block;
  width: calc(100% - 32px);
  margin: 16px 16px 8px;
  padding: 12px 16px;
  border: none;
  border-radius: 12px;
  background: var(--bg-elem);
  color: var(--text);
  font: inherit;
}

/* --- FM dial view ---------------------------------------------------------- */

.dial-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 16px 12px;
}

.dial-title-left {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.dial-count {
  color: var(--text-2);
  font-size: 13px;
  white-space: nowrap;
}

.place-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.pill-btn {
  display: flex;
  align-items: center;
  max-width: 180px;
  height: 34px;
  padding: 0 14px;
  border: none;
  border-radius: 17px;
  background: var(--bg-elem);
  color: var(--tint);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.pill-btn:active {
  opacity: 0.7;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 17px;
  background: var(--tint);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.icon-btn:active {
  opacity: 0.8;
}

.attribution {
  padding: 20px 16px;
  text-align: center;
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
}

/* --- now playing bar ----------------------------------------------------- */

.np-artwork {
  width: 36px;
  height: 36px;
}

.np-text {
  flex: 1;
  min-width: 0;
}

.np-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.np-status {
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.np-status.err {
  color: var(--danger);
}

.np-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 20px;
  background: var(--bg-sel);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.np-btn:active {
  opacity: 0.7;
}

/* --- place search modal ----------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: max(48px, env(safe-area-inset-top)) 20px 20px;
  background: rgba(0, 0, 0, 0.45);
}

.modal-card {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px;
  border-radius: 16px;
  background: var(--bg-elem);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
}

.modal-header .icon-btn {
  background: var(--bg);
  color: var(--text-2);
  width: 28px;
  height: 28px;
}

.modal-input-row {
  display: flex;
  gap: 8px;
}

.modal-input-row input {
  flex: 1;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.modal-hits {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 50vh;
  overflow-y: auto;
}

.modal-hit {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.modal-hit:active {
  background: var(--bg-sel);
}

.hit-name {
  font-size: 15px;
}

.hit-context {
  font-size: 12px;
  color: var(--text-2);
}

.modal-hits .empty-sub {
  padding: 12px 0;
  text-align: center;
}

/* --- toast ------------------------------------------------------------------ */

.toast {
  position: fixed;
  bottom: calc(110px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  max-width: min(90vw, 480px);
  padding: 10px 16px;
  border-radius: 20px;
  background: var(--bg-sel);
  color: var(--text);
  font-size: 14px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.toast.show {
  opacity: 1;
}
