:root {
  --bg: #e7ebef;
  --bg-deep: #d5dde6;
  --surface: rgba(255, 255, 255, 0.72);
  --ink: #15202b;
  --muted: #5c6b7a;
  --line: rgba(21, 32, 43, 0.12);
  --accent: #0f6b5c;
  --accent-ink: #073d35;
  --warn: #a85b12;
  --ok: #1f7a45;
  --danger: #a33b3b;
  --font: "Figtree", "Segoe UI", sans-serif;
  --display: "Syne", "Figtree", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --radius: 2px;
  --shadow: 0 18px 50px rgba(21, 32, 43, 0.08);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html {
  scroll-behavior: smooth;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  max-width: 100%;
}

body {
  height: 100%;
  height: 100dvh;
  max-width: 100vw;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  background: var(--bg);
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(900px 520px at 8% -8%, rgba(15, 107, 92, 0.14), transparent 58%),
    radial-gradient(700px 480px at 96% 12%, rgba(45, 78, 120, 0.12), transparent 55%),
    linear-gradient(165deg, #f4f6f8 0%, var(--bg) 42%, var(--bg-deep) 100%);
}
.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

/* —— header —— */
.top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.7rem 1.25rem;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px) saturate(1.1);
  min-width: 0;
}
.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
  justify-self: start;
}
.brand-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  line-height: 1;
}
.mark {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--accent-ink);
  border-bottom: 2px solid var(--accent);
  padding-bottom: 0.05rem;
}

.nav {
  display: flex;
  gap: 0.15rem;
  justify-self: center;
}
.nav a {
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.92rem;
  letter-spacing: -0.02em;
  color: var(--muted);
  text-decoration: none;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius);
  position: relative;
  transition: color 0.25s var(--ease);
}
.nav a:hover { color: var(--ink); }
.nav a.active {
  color: var(--ink);
}
.nav a.active::after {
  content: "";
  position: absolute;
  left: 0.85rem;
  right: 0.85rem;
  bottom: 0.15rem;
  height: 2px;
  background: var(--accent);
  transform-origin: left;
  animation: inkIn 0.35s var(--ease) both;
}

.device-bar {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  justify-self: end;
  flex-wrap: nowrap;
  min-width: 0;
  max-width: 100%;
}
.status {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 11rem;
}
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }
.status.muted { color: var(--muted); }

/* —— pages —— */
main {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 1rem 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.page[hidden] { display: none !important; }
.page {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: rise 0.45s var(--ease);
}
.page-head {
  flex-shrink: 0;
  margin-bottom: 0.85rem;
  max-width: 36rem;
}
.page-head h1 {
  margin: 0 0 0.2rem;
  font-family: var(--display);
  font-size: clamp(1.55rem, 3.2vw, 2.15rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1.05;
}
.lede {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}
.lede code {
  font-family: var(--mono);
  font-size: 0.86em;
  color: var(--ink);
}

/* —— help —— */
.help-page {
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}
.help-body {
  display: grid;
  gap: 0.85rem;
  max-width: 40rem;
  padding-bottom: 1.5rem;
}
.help-block {
  padding: 0.95rem 1.05rem 1.05rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.help-block h2 {
  margin: 0 0 0.45rem;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.help-block p,
.help-block li {
  margin: 0 0 0.55rem;
  color: var(--muted);
  font-size: 0.92rem;
}
.help-block p:last-child,
.help-block ol:last-child {
  margin-bottom: 0;
}
.help-block ol {
  margin: 0 0 0.55rem;
  padding-left: 1.2rem;
}
.help-block strong { color: var(--ink); font-weight: 600; }
.help-block code {
  font-family: var(--mono);
  font-size: 0.86em;
  color: var(--ink);
}
.help-note {
  margin-bottom: 0.4rem !important;
  font-size: 0.85rem !important;
}
.help-keys {
  display: grid;
  gap: 0.35rem;
  margin: 0;
}
.help-keys > div {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: 0.65rem;
  align-items: baseline;
}
.help-keys dt {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink);
}
.help-keys dd {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.eyebrow, .section-label h2 {
  font-family: var(--display);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0;
}
.section-label {
  margin-bottom: 0.85rem;
}
.section-label p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

/* —— controls —— */
label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
input, select, button, textarea, summary {
  font: inherit;
  color: var(--ink);
}
input, select {
  font-family: var(--mono);
  font-size: 0.86rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.55rem 0.65rem;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
input:focus, select:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 3px rgba(15, 107, 92, 0.12);
}
button {
  cursor: pointer;
  background: var(--accent);
  color: #f4fffc;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0.55rem 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: transform 0.2s var(--ease), background 0.2s var(--ease), opacity 0.2s;
}
button:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
button:active { transform: translateY(1px); }
button.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
  font-weight: 500;
}
button.ghost:hover {
  background: rgba(255, 255, 255, 0.55);
  border-color: color-mix(in srgb, var(--ink) 22%, var(--line));
}
button:disabled { opacity: 0.38; cursor: not-allowed; transform: none; }

.row { display: flex; gap: 0.5rem; align-items: end; flex-wrap: wrap; }
.row .grow, .grow { flex: 1; min-width: 140px; }
.muted { color: var(--muted); }

/* —— search page —— */
.search-layout {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 1.25rem;
  align-items: stretch;
  overflow: hidden;
}
.filters {
  position: static;
  padding: 0.9rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  min-height: 0;
  max-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.form { display: grid; gap: 0.7rem; }
.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  align-items: end;
}
.pair-end span { visibility: hidden; height: 0; }
.pair-end { justify-content: end; }
.advanced {
  border-top: 1px solid var(--line);
  padding-top: 0.65rem;
  margin-top: 0.15rem;
}
.advanced summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.55rem;
  list-style: none;
}
.advanced summary::-webkit-details-marker { display: none; }
.advanced[open] summary { color: var(--ink); margin-bottom: 0.7rem; }
.advanced label { margin-bottom: 0.55rem; }
.form .actions { margin-top: 0.35rem; }
.results-pane {
  min-height: 0;
  min-width: 0;
  max-height: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.prog {
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  margin: 0 0 0.65rem;
  color: var(--muted);
}
/* Actual scrollports — must be height-constrained (not grow with content). */
#results,
#favorites {
  flex: 1 1 0;
  min-height: 0;
  max-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  scrollbar-gutter: stable;
}

/* —— lists / interactive rows —— */
.list { display: flex; flex-direction: column; gap: 0.55rem; }
.card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.35rem 1rem;
  align-items: center;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  border-radius: 0;
  min-width: 0;
}
.card.is-new {
  animation: rise 0.35s var(--ease) both;
}
.card .seed-block { min-width: 0; overflow: hidden; }
.card .phrase {
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.card .seed {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: -0.01em;
  margin-top: 0.15rem;
  overflow-wrap: anywhere;
}
.card .meta {
  grid-column: 1;
  color: var(--muted);
  font-size: 0.86rem;
  min-width: 0;
  overflow-wrap: anywhere;
}
.card .actions {
  grid-column: 2;
  grid-row: 1 / span 3;
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: end;
  align-items: start;
}
.card .actions > button {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}
.card.liked .phrase { color: var(--accent-ink); }
.card.disliked { opacity: 0.72; }
.card.disliked .phrase { color: var(--muted); }
.mods-meta {
  grid-column: 1;
  font-size: 0.8rem !important;
  color: var(--accent-ink) !important;
}
.mods-tag {
  display: inline-block;
  margin-right: 0.35rem;
  padding: 0.05rem 0.35rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-ink);
  background: rgba(15, 107, 92, 0.12);
  border-radius: var(--radius);
}

.rate {
  display: inline-flex;
  gap: 0.2rem;
  align-items: center;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: var(--radius);
}
.icon-btn svg {
  width: 1.05rem;
  height: 1.05rem;
  fill: currentColor;
  display: block;
}
.icon-btn:hover:not(:disabled) {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.55);
  border-color: var(--line);
}
.icon-btn.is-on[data-act="like"],
#btnLikeNow.is-on {
  color: var(--danger);
}
.icon-btn.is-on[data-act="dislike"],
#btnDislikeNow.is-on {
  color: var(--warn);
}

.library-toolbar {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.filter-tabs {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}
.filter-tab {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}
.filter-tab.is-on {
  background: var(--accent);
  color: #f4fffc;
  border-color: transparent;
}
.filter-tab.is-on:hover {
  background: color-mix(in srgb, var(--accent) 88%, #000);
}
.library-list {
  flex: 1 1 0;
  min-height: 0;
}
.library-list .card:first-child { border-top: 1px solid var(--line); }
.library-empty {
  padding: 1.5rem 0;
  color: var(--muted);
  font-size: 1.02rem;
  max-width: 28rem;
}

/* —— device page —— */
.device-layout {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 1.25rem;
  align-items: stretch;
  overflow: hidden;
}
.device-layout.with-log {
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.85fr);
}
.device-main {
  min-height: 0;
  min-width: 0;
  max-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding-right: 0.15rem;
}
.seed-row {
  display: flex;
  gap: 0.75rem;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.seed-field input {
  font-size: 1.15rem;
  padding: 0.7rem 0.8rem;
  letter-spacing: 0.02em;
}
.seed-field .label-hint {
  font-family: var(--font);
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
  font-size: 0.78rem;
  margin-left: 0.35rem;
}
.seed-phrase {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-top: 0.4rem;
  color: var(--accent-ink);
}
.seed-phrase .phrase-line {
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.seed-phrase .hex-line {
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
}
.seed-phrase.muted {
  font-family: var(--font);
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
  font-size: 0.82rem;
}
.seed-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.now-playing {
  padding: 0.9rem 0 1rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.15rem;
  min-height: 0;
}
.now-playing.empty { opacity: 0.85; }
.now-playing-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}
.live .phrase {
  font-family: var(--display);
  font-size: clamp(1.45rem, 2.8vw, 1.95rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--ink);
  margin-bottom: 0.15rem;
  animation: inkIn 0.4s var(--ease) both;
  transform-origin: left;
}
.live .seed {
  font-family: var(--mono);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.live .meta {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.live.muted {
  font-family: var(--font);
  color: var(--muted);
  padding: 0.35rem 0;
}
.lock-warn {
  margin-top: 0.65rem;
  padding: 0.55rem 0.7rem;
  border-left: 3px solid var(--warn);
  background: rgba(168, 91, 18, 0.08);
  color: var(--ink);
  font-size: 0.86rem;
  line-height: 1.4;
}
.lock-warn code { font-family: var(--mono); font-size: 0.84em; }

.callout {
  flex-shrink: 0;
  max-width: 40rem;
  margin: 0 0 0.85rem;
  padding: 0.55rem 0.85rem;
  border-left: 3px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
  font-size: 0.86rem;
  line-height: 1.4;
  color: var(--ink);
}
.callout.warn {
  border-left-color: var(--warn);
  background: rgba(168, 91, 18, 0.1);
}
.callout summary {
  cursor: pointer;
  list-style: none;
  font-size: 0.86rem;
}
.callout summary::-webkit-details-marker { display: none; }
.callout summary strong { font-weight: 600; }
.callout p { margin: 0.55rem 0 0; }
.callout strong { display: inline; }

.check-row {
  flex-direction: row !important;
  align-items: center;
  gap: 0.5rem !important;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
}
.check-row input { width: auto; accent-color: var(--accent); }

.kbd-hint {
  display: inline-block;
  margin-left: 0.35rem;
  font-family: var(--mono);
  font-size: 0.78em;
  color: var(--muted);
}
.nav-count {
  font-family: var(--mono);
  font-size: 0.72em;
  font-weight: 500;
  color: var(--accent);
  margin-left: 0.15rem;
}
.results-head {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  align-items: baseline;
  margin-bottom: 0.65rem;
}
.results-head .prog { margin: 0; }
.audition {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--accent-ink);
}
.card.is-active {
  border-left: 3px solid var(--accent);
  padding-left: 0.55rem;
}
.note-field {
  grid-column: 1 / -1;
  margin-top: 0.15rem;
}
.note-input {
  width: 100%;
  font-family: var(--font);
  font-size: 0.84rem;
  padding: 0.35rem 0.5rem;
  background: rgba(255, 255, 255, 0.65);
}
.export-stamp {
  font-family: var(--mono);
  font-size: 0.78em;
}
.library-io {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  align-items: center;
}
.library-io input[type="search"] {
  min-width: 12rem;
  flex: 1;
  font-family: var(--font);
  font-size: 0.86rem;
}
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.log-reveal {
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
}

.live-block { margin-bottom: 1rem; }
.live-cc {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem 1rem;
}
.live-cc .slider { grid-column: 1 / -1; }
.live-cc .vol-btns { grid-column: 1 / -1; }
.live-cc .reverb-block {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.hint-callout {
  margin: 0;
  padding: 0.55rem 0.7rem;
  border-left: 3px solid var(--warn);
  background: rgba(168, 91, 18, 0.1);
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--ink);
  transition: box-shadow 0.25s var(--ease), background 0.25s var(--ease);
}
.hint-callout strong { color: var(--warn); }
.hint-callout.is-pulse {
  background: rgba(168, 91, 18, 0.18);
  box-shadow: 0 0 0 2px rgba(168, 91, 18, 0.25);
}
.lock-badge {
  display: inline-block;
  margin-left: 0.45rem;
  padding: 0.12rem 0.4rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #5a3208;
  background: rgba(168, 91, 18, 0.22);
  border: 1px solid rgba(168, 91, 18, 0.45);
  border-radius: var(--radius);
  vertical-align: middle;
}
.live-cc input[type="range"] {
  width: 100%;
  padding: 0.4rem 0;
  accent-color: var(--accent);
  background: transparent;
  border: none;
  box-shadow: none;
}
.live-cc em {
  font-style: normal;
  font-family: var(--mono);
  color: var(--ink);
  float: right;
  font-size: 0.85rem;
}

.log-pane {
  position: static;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.log-pane .section-label { flex-shrink: 0; }
.log {
  margin: 0;
  flex: 1 1 0;
  min-height: 8rem;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 0.75rem 0.85rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.55;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: var(--shadow);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.4rem;
  transform: translateX(-50%) translateY(8px);
  background: var(--ink);
  color: #f2f5f7;
  font-size: 0.86rem;
  padding: 0.65rem 1rem;
  border-radius: var(--radius);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
  z-index: 20;
  max-width: min(90vw, 28rem);
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@keyframes rise {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes inkIn {
  from { opacity: 0; transform: scaleX(0.4); }
  to { opacity: 1; transform: scaleX(1); }
}
@media (max-width: 900px) {
  /* Keep list scrollports even when stacked — don't fall back to a broken page scroll. */
  .top {
    grid-template-columns: 1fr;
    justify-items: start;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
  }
  .nav { justify-self: start; flex-wrap: wrap; }
  .device-bar {
    justify-self: start;
    flex-wrap: wrap;
  }
  .status { max-width: 100%; }
  .page-head { display: none; }
  .search-layout,
  .device-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, auto) minmax(0, 1fr);
  }
  .filters {
    max-height: 38vh;
  }
  .results-pane {
    min-height: 0;
    height: auto;
  }
  .log {
    min-height: 8rem;
  }
  .card {
    grid-template-columns: 1fr;
  }
  .card .actions {
    grid-column: 1;
    grid-row: auto;
    justify-content: start;
    margin-top: 0.35rem;
  }
}

@media (max-height: 700px) {
  .page-head { margin-bottom: 0.55rem; }
  .page-head h1 { font-size: 1.45rem; }
  .lede { font-size: 0.85rem; }
  .callout {
    padding: 0.45rem 0.65rem;
    font-size: 0.8rem;
    margin-bottom: 0.55rem;
  }
  .now-playing { min-height: 0; margin-bottom: 0.85rem; padding: 0.65rem 0 0.85rem; }
  .filters { padding: 0.7rem; }
}
