/* Good Listening — light theme, mobile-first.
   Deliberately understated: warm off-white background, ink-blue accent,
   simple typography hierarchy, no gradients/glass/pill-spam. */

:root {
  --bg: #f7f5ee;
  --surface: #ffffff;
  --surface-alt: #efebe0;
  --line: #ddd6c4;
  --line-soft: #ece6d4;
  --text: #1c1a17;
  --text-soft: #4a473f;
  --muted: #76716a;
  --accent: #2a4d8f;
  --accent-hover: #1f3c74;
  --accent-soft: #e6ecf7;
  --warn: #a36a14;
  --error: #a83020;
  --star: #b5891a;
  --radius: 4px;
  --radius-lg: 8px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --shadow: 0 1px 0 rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}
button { -webkit-tap-highlight-color: transparent; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--error); }
.linklike {
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font: inherit;
}
.linklike:hover { color: var(--accent-hover); text-decoration: underline; }

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

/* ---------- App layout (desktop default) ---------- */

#app {
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: 1fr 84px;
  grid-template-areas:
    "side main"
    "player player";
  height: 100vh;
  height: 100dvh;
}

#sidebar {
  grid-area: side;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 22px 18px env(safe-area-inset-bottom, 18px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

#main {
  grid-area: main;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

#topbar {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

#menu-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
}

#search {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 12px;
  outline: none;
  min-width: 0;
}
#search::placeholder { color: var(--muted); }
#search:focus { border-color: var(--accent); }

#order {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 10px;
  outline: none;
  max-width: 180px;
}

#count { white-space: nowrap; }

#view {
  flex: 1;
  overflow-y: auto;
  padding: 22px 24px env(safe-area-inset-bottom, 22px);
}

/* ---------- Sidebar ---------- */

.brand {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 22px;
}
.brand h1 {
  font-size: 22px;
  line-height: 1.05;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.primary-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
}
.nav-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--text-soft);
  padding: 9px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
}
.nav-btn:hover { background: var(--surface-alt); color: var(--text); }
.nav-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.section { margin-top: 18px; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.section-head h3,
.facet h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 6px;
  font-weight: 600;
}

#playlist-nav { list-style: none; padding: 0; margin: 0; }
#playlist-nav li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-soft);
  font-size: 14px;
}
#playlist-nav li:hover { background: var(--surface-alt); color: var(--text); }
#playlist-nav li.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
#playlist-nav .pl-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}
#playlist-nav .pl-count {
  color: var(--muted);
  font-size: 12px;
  margin-left: 8px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Year / month tree ---------- */
#facet-years ul { list-style: none; padding: 0; margin: 0; }
#facet-years .year-row {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 5px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  color: var(--text-soft);
}
#facet-years .year-row:hover { background: var(--surface-alt); color: var(--text); }
#facet-years .year-row.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
#facet-years .twist {
  display: inline-flex;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
  margin-right: 2px;
  transition: transform 0.15s ease;
}
#facet-years .twist.open { transform: rotate(90deg); }
#facet-years .year-label { flex: 1; }
#facet-years .year-count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
#facet-years .months { list-style: none; padding-left: 22px; margin: 2px 0 4px; }
#facet-years .month-row {
  display: flex;
  align-items: center;
  width: 100%;
  background: transparent;
  border: 0;
  padding: 4px 8px;
  border-radius: var(--radius);
  color: var(--text-soft);
  font-size: 13px;
  cursor: pointer;
}
#facet-years .month-row:hover { background: var(--surface-alt); color: var(--text); }
#facet-years .month-row.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
#facet-years .month-label { flex: 1; }

/* ---------- Library: grouped headers ---------- */
.group-header {
  margin: 18px 0 4px;
  padding: 4px 8px 6px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.group-header:first-child { margin-top: 0; }

/* ---------- Users view ---------- */
.users-view h2 { margin-top: 0; font-size: 22px; font-weight: 700; }
.users-view h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 24px 0 8px;
  font-weight: 600;
}
.user-form { display: grid; gap: 8px; grid-template-columns: 1fr 1fr auto; }
.user-form input {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 11px;
  outline: none;
  font-size: 14px;
}
.user-form input:focus { border-color: var(--accent); }
.user-form input[type=password] { grid-column: 1 / 3; }
.user-form button {
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: var(--radius);
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 500;
  grid-column: 3 / 4;
  grid-row: 2 / 3;
}
.user-form button:hover { background: var(--accent-hover); }
.user-form .error { grid-column: 1 / -1; margin: 0; }
table.users { width: 100%; border-collapse: collapse; }
table.users th, table.users td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
}
table.users th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
table.users .self { color: var(--muted); font-size: 12px; }

@media (max-width: 800px) {
  .user-form { grid-template-columns: 1fr; }
  .user-form input[type=password] { grid-column: 1 / -1; }
  .user-form button { grid-column: 1 / -1; grid-row: auto; }
}

.facet { margin-top: 16px; }
.facet ul { list-style: none; padding: 0; margin: 0; }
.facet li button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  background: transparent;
  color: var(--text-soft);
  border: 0;
  padding: 6px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  font-size: 14px;
}
.facet li button:hover { background: var(--surface-alt); color: var(--text); }
.facet li button.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.facet li button .c { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.facet li button.active .c { color: var(--accent); }

.sidebar-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
}
.install-btn {
  display: block;
  width: 100%;
  background: var(--accent);
  color: white;
  border: 0;
  padding: 9px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}
.install-btn:hover { background: var(--accent-hover); }

/* ---------- Recording list ---------- */

ul.rec-list { list-style: none; padding: 0; margin: 0; }

.rec-row {
  display: grid;
  grid-template-columns: 40px 1fr auto auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line-soft);
  cursor: default;
}
.rec-row:last-child { border-bottom: 0; }
.rec-row:hover { background: var(--surface-alt); }

.rec-row .play,
.rec-row .star,
.rec-row .open {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius);
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.rec-row .play:hover { background: var(--accent); color: white; border-color: var(--accent); }
.rec-row .star:hover { color: var(--star); border-color: var(--star); }
.rec-row .star.starred { color: var(--star); border-color: var(--star); background: #fdf6e3; }
.rec-row .open { color: var(--muted); border: 0; background: transparent; }
.rec-row .open:hover { color: var(--text); }

.rec-row .meta { min-width: 0; }
.rec-row .title {
  font-weight: 600;
  color: var(--text);
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.35;
}
.rec-row .sub {
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.35;
  margin-top: 1px;
}
.rec-row .progress {
  height: 2px;
  background: var(--line-soft);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}
.rec-row .progress .bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
}

.rec-row .row-badges {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
}
.rec-row .row-badges:not(:has(span:not([hidden]))) { display: none; }
.rec-row .badge-offline,
.rec-row .badge-finished {
  display: inline-flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}
.rec-row .badge-offline { color: var(--accent); }
.rec-row .badge-finished { color: var(--muted); }
.rec-row.finished .title { color: var(--muted); }

.empty {
  padding: 60px 0;
  text-align: center;
  color: var(--muted);
}
.empty p:first-child { color: var(--text); margin-bottom: 4px; }

/* ---------- Recording detail ---------- */

.rec-detail .back {
  margin-bottom: 14px;
  display: inline-block;
  font-size: 14px;
}
.rec-detail h2 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
}
.rec-detail .sub {
  margin-bottom: 12px;
  font-size: 14px;
}
.rec-detail .badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 16px;
}
.badge {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 12px;
  color: var(--text-soft);
}
.rec-detail .extras p {
  margin: 4px 0;
  font-size: 14px;
  color: var(--text-soft);
}
.rec-detail .extras strong {
  color: var(--text);
  font-weight: 600;
}
.rec-detail .description {
  color: var(--text-soft);
  white-space: pre-wrap;
  margin: 12px 0;
  font-size: 14px;
}
.rec-detail .row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 16px 0 24px;
}
.rec-detail .row button,
.rec-detail .row a {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  font-size: 14px;
}
.rec-detail .row button:hover,
.rec-detail .row a:hover { border-color: var(--accent); color: var(--accent); }
.rec-detail .row .primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 500;
}
.rec-detail .row .primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: white;
}
.rec-detail .row .star.starred {
  color: var(--star);
  border-color: var(--star);
  background: #fdf6e3;
}
.rec-detail .row .offline.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.rec-detail .row .delete { color: var(--error); margin-left: auto; }
.rec-detail .row .delete:hover { background: var(--error); border-color: var(--error); color: white; }

.notes h3 {
  margin-top: 28px;
  font-size: 16px;
  font-weight: 600;
}
.note-list { list-style: none; padding: 0; margin: 0; }
.note-list li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 10px;
}
.note-list .body {
  white-space: pre-wrap;
  font-size: 14px;
  color: var(--text);
}
.note-list .actions {
  margin-top: 6px;
  display: flex;
  gap: 12px;
}
.note-form textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  outline: none;
  resize: vertical;
  font-size: 14px;
}
.note-form textarea:focus { border-color: var(--accent); }
.note-form button {
  margin-top: 8px;
  background: var(--accent);
  color: white;
  border: 0;
  padding: 9px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 500;
}
.note-form button:hover { background: var(--accent-hover); }

/* ---------- Playlist view ---------- */

.playlist-view .back {
  display: inline-block;
  margin-bottom: 12px;
  font-size: 14px;
}
.playlist-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.playlist-head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}
.playlist-head .actions {
  display: flex;
  gap: 6px;
}
.playlist-head button {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 7px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
}
.playlist-head button:hover { border-color: var(--accent); color: var(--accent); }
.playlist-view .description {
  margin: 4px 0 14px;
  color: var(--text-soft);
}
.playlist-view .count {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}
ul.playlist-items { list-style: none; padding: 0; margin: 0; }
ul.playlist-items li.rec-row {
  grid-template-columns: 28px 40px 1fr auto auto auto;
}
ul.playlist-items .pos {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  text-align: right;
}
ul.playlist-items .remove {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--error);
  border-radius: var(--radius);
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
ul.playlist-items .remove:hover { background: var(--error); color: white; border-color: var(--error); }

/* ---------- Player ---------- */

#player {
  grid-area: player;
  background: var(--surface);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  gap: 14px;
  align-items: center;
  padding: 0 20px env(safe-area-inset-bottom, 0);
}
#player-title {
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}
#player-sub {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#audio {
  width: 100%;
  height: 40px;
}
#player-actions { display: flex; gap: 6px; }
#player-actions button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-soft);
  border-radius: var(--radius);
  width: 40px;
  height: 40px;
  cursor: pointer;
  font-size: 16px;
}
#player-actions button:hover { border-color: var(--accent); color: var(--accent); }
#player-actions button:disabled { opacity: 0.4; cursor: not-allowed; }
#player-star.starred {
  color: var(--star);
  border-color: var(--star);
  background: #fdf6e3;
}

/* ---------- Keys view ---------- */

.keys-view h2 {
  margin-top: 0;
  font-size: 22px;
  font-weight: 700;
}
.keys-view h3 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 24px 0 8px;
  font-weight: 600;
}
.userscript-block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 12px 0 20px;
}
.userscript-block h3 { margin-top: 0; }
.userscript-block p { margin: 0 0 10px; }
.userscript-url-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  flex-wrap: wrap;
}
.userscript-url {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
  color: var(--text-soft);
  user-select: all;
  -webkit-user-select: all;
}
.userscript-url-row button,
.userscript-url-row a {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.userscript-url-row button:hover,
.userscript-url-row a:hover { border-color: var(--accent); color: var(--accent); }
.userscript-url-row button.copied {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.key-form { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.key-form input {
  flex: 1;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 11px;
  outline: none;
}
.key-form input:focus { border-color: var(--accent); }
.key-form button {
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: var(--radius);
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 500;
}
.key-form button:hover { background: var(--accent-hover); }
.key-new {
  background: #fff8e6;
  border: 1px solid var(--warn);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  margin-bottom: 14px;
  word-break: break-all;
  display: none;
  color: var(--text);
}
.key-new.show { display: block; }
table.keys { width: 100%; border-collapse: collapse; }
table.keys th, table.keys td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
}
table.keys th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---------- Login ---------- */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 360px;
  max-width: 100%;
  box-shadow: var(--shadow);
}
.login-card h1 {
  margin: 0 0 22px;
  font-size: 26px;
  line-height: 1.05;
  letter-spacing: -0.01em;
  font-weight: 700;
}
.login-card label {
  display: block;
  margin-bottom: 12px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 500;
}
.login-card input {
  display: block;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px;
  margin-top: 4px;
  outline: none;
  color: var(--text);
  font-size: 16px; /* iOS won't zoom on focus at >=16px */
}
.login-card input:focus { border-color: var(--accent); }
.login-card button {
  width: 100%;
  background: var(--accent);
  color: white;
  border: 0;
  padding: 12px;
  border-radius: var(--radius);
  margin-top: 10px;
  cursor: pointer;
  font-weight: 500;
  font-size: 15px;
}
.login-card button:hover { background: var(--accent-hover); }

/* ---------- Sidebar overlay (mobile only) ---------- */

#sidebar-scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 90;
}

/* ---------- Mobile (<= 800px) ---------- */

@media (max-width: 800px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 96px;
    grid-template-areas:
      "main"
      "player";
  }

  #menu-toggle { display: inline-flex; }

  #sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(320px, 86vw);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 100;
    border-right: 1px solid var(--line);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-top: max(18px, env(safe-area-inset-top));
    box-shadow: var(--shadow);
  }
  #sidebar.open { transform: translateX(0); }
  body.menu-open { overflow: hidden; }
  body.menu-open #sidebar-scrim { display: block; }

  #topbar {
    padding: 10px 14px;
    gap: 8px;
    position: sticky;
    top: 0;
    z-index: 10;
  }
  #search { font-size: 16px; padding: 10px 12px; }
  #order { font-size: 13px; max-width: 56px; padding: 10px 4px; }
  /* Hide the select chevron and visible value, so it becomes an icon-like button */
  #order { appearance: none; -webkit-appearance: none; text-indent: -9999px; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round'><path d='M3 6h18M6 12h12M10 18h4'/></svg>"); background-repeat: no-repeat; background-position: center; background-size: 18px; }
  #count { display: none; }

  #view {
    padding: 12px 14px env(safe-area-inset-bottom, 16px);
  }

  /* Row layout: stack progress under title, keep play left + star/chevron right */
  .rec-row {
    grid-template-columns: 44px 1fr auto;
    gap: 12px;
    padding: 12px 4px;
  }
  .rec-row .play { width: 40px; height: 40px; }
  .rec-row .star {
    width: 40px;
    height: 40px;
  }
  .rec-row .open { display: none; } /* whole row taps to open */
  .rec-row .row-badges {
    grid-column: 2;
    grid-row: 2;
    margin-top: 4px;
  }
  .rec-row .meta { cursor: pointer; }
  .rec-row .title { white-space: normal; }
  .rec-row .sub { white-space: normal; font-size: 12px; }

  ul.playlist-items li.rec-row {
    grid-template-columns: 24px 40px 1fr auto;
  }

  .rec-detail h2 { font-size: 19px; }
  .rec-detail .row button,
  .rec-detail .row a {
    padding: 10px 14px;
    flex: 1 1 auto;
    text-align: center;
  }

  #player {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto 1fr;
    grid-template-areas: "meta actions" "audio audio";
    padding: 8px 14px env(safe-area-inset-bottom, 8px);
    gap: 6px 10px;
    align-items: center;
  }
  #player-meta { grid-area: meta; min-width: 0; }
  #audio { grid-area: audio; height: 38px; width: 100%; }
  #player-actions { grid-area: actions; align-self: start; }
  #player-actions button { width: 38px; height: 38px; }
  #player-title { font-size: 13px; }
  #player-sub { font-size: 11px; }

  .login-card { padding: 24px; box-shadow: none; border: 0; }
}

/* ---------- Reduce motion ---------- */
@media (prefers-reduced-motion: reduce) {
  #sidebar { transition: none; }
}
