:root {
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
  --paper: #f4f4f0;
  --ink: #151515;
  --muted: #555b62;
  --blue: #1646e5;
  --orange: #ff752b;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--paper); }
body { margin: 0; color: var(--ink); font-size: 1rem; line-height: 1.4; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button, input { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
button, input[type="range"] { touch-action: manipulation; }
svg { display: block; width: 24px; height: 24px; flex-shrink: 0; }
p, h1, h2, h3 { margin: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.app-shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.site-header, .main-content, .player-inner { width: min(100% - 48px, 980px); margin-inline: auto; }

.site-header { display: flex; align-items: center; gap: 32px; padding-block: 22px; }
.header-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-shrink: 0; }
h1 { flex-shrink: 0; font-size: 1.5rem; font-weight: 750; letter-spacing: -0.8px; }
.install-button { min-height: 44px; padding: 6px 0; border: 0; border-radius: 0; background: transparent; color: var(--blue); font-size: 0.875rem; font-weight: 600; text-align: right; }
.install-button:hover { color: #0c2fb2; }
.install-button:disabled { color: var(--muted); }
.search-form { display: flex; flex: 1; min-width: 0; gap: 8px; }
.search-field { display: flex; align-items: center; flex: 1; min-width: 0; gap: 10px; height: 46px; padding-inline: 12px 4px; background: #fff; }
.search-field:has(:focus-visible) { outline: 2px solid var(--blue); outline-offset: 1px; }
.search-icon { width: 20px; height: 20px; color: var(--muted); }
#search-input { width: 100%; min-width: 0; border: 0; outline: 0; padding: 10px 0; background: transparent; color: var(--ink); font-size: 1rem; }
#search-input::placeholder { color: var(--muted); opacity: 1; }
#search-input::-webkit-search-cancel-button { -webkit-appearance: none; }
.icon-button { display: grid; place-items: center; flex-shrink: 0; width: 36px; height: 40px; padding: 0; border: 0; background: transparent; color: var(--ink); }
.icon-button:hover { background: #e9eaf0; }
.icon-button svg { width: 18px; height: 18px; }
.search-button { min-width: 92px; padding: 10px 16px; border: 0; border-radius: 0; background: var(--blue); color: #fff; font-size: 0.9375rem; font-weight: 700; }
.search-button:hover { background: #0c2fb2; }
.search-button:active { background: var(--ink); }

.install-dialog { width: min(calc(100% - 32px), 380px); max-height: calc(100dvh - 48px); padding: 24px; border: 0; background: var(--paper); color: var(--ink); }
.install-dialog::backdrop { background: rgb(0 0 0 / 0.45); }
.install-dialog h2 { font-size: 1.25rem; }
.install-dialog p { margin-top: 14px; }
.install-dialog ol { margin: 16px 0; padding-left: 22px; }
.install-dialog li + li { margin-top: 10px; }
#install-hint { color: var(--muted); font-size: 0.875rem; }
.dialog-actions { display: flex; justify-content: flex-end; margin-top: 20px; }
.dialog-close { min-height: 44px; }

.main-content { flex: 1; padding-block: 16px 24px; }
.search-status { min-height: 20px; margin-bottom: 8px; color: var(--muted); font-size: 0.8125rem; overflow-wrap: anywhere; }
.empty-state { padding: 54px 12px; text-align: center; }
.empty-state h3 { font-size: 1rem; font-weight: 400; color: var(--muted); }
.empty-state p { max-width: 420px; margin: 8px auto 0; color: var(--muted); font-size: 0.875rem; overflow-wrap: anywhere; }
.empty-state p:empty { display: none; }
#results-section[data-mode="error"] .empty-state h3 { color: var(--ink); font-weight: 700; }
.results-list { display: flex; flex-direction: column; list-style: none; margin: 0; padding: 0; }
.result { display: grid; grid-template-columns: 44px minmax(0, 1fr) 62px 32px; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 10px 8px; border: 0; border-radius: 0; background: transparent; color: var(--ink); text-align: left; }
.result:hover { background: #e4e7ee; }
.result.is-selected { background: var(--blue); color: #fff; }
.result:focus-visible { outline-offset: -3px; }
.result.is-selected:focus-visible { outline-color: #fff; }
.result-art { position: relative; display: grid; place-items: center; width: 44px; height: 44px; overflow: hidden; background: #dddeda; color: #555b62; }
.result-art img { position: absolute; width: 100%; height: 100%; object-fit: cover; }
.result-art svg { width: 20px; height: 20px; }
.result-copy { min-width: 0; }
.result-title { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 1rem; font-weight: 500; }
.result-channel { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; margin-top: 3px; color: var(--muted); font-size: 0.8125rem; }
.result-duration { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.8125rem; text-align: right; }
.result-play { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; }
.result-play svg { width: 16px; height: 16px; }
.result.is-selected .result-channel, .result.is-selected .result-duration { color: #e3eaff; }
.result.is-selected .result-play { background: #fff; color: var(--blue); }

.player { position: sticky; bottom: 0; z-index: 2; margin-top: auto; background: var(--ink); color: #fff; color-scheme: dark; }
.player-inner { display: grid; grid-template-columns: minmax(170px, 1fr) minmax(240px, 1.15fr) 150px; align-items: center; gap: 24px; min-height: 94px; padding-block: 14px; }
.current-track { display: flex; align-items: center; min-width: 0; gap: 10px; }
.player-art { position: relative; display: grid; flex-shrink: 0; place-items: center; width: 40px; height: 40px; overflow: hidden; background: #343434; color: #bbb; }
.player-art svg { width: 22px; height: 22px; }
.player-art img { position: absolute; width: 100%; height: 100%; object-fit: cover; }
.current-track-copy { min-width: 0; }
.current-track h2 { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 0.875rem; font-weight: 600; }
#now-playing-channel { margin-top: 3px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: #bbb; font-size: 0.75rem; }
.playback-controls { display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: center; gap: 14px; min-width: 0; }
.play-button { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: var(--orange); color: var(--ink); }
.play-button:hover:not(:disabled) { background: #ff9a63; }
.play-button:disabled { background: #4d4d4d; color: #bcbcbc; }
.play-button svg { width: 22px; height: 22px; }
.player button:focus-visible, .player input:focus-visible { outline-color: var(--orange); }
.timeline { min-width: 0; }
.seek-row { display: flex; align-items: center; gap: 8px; }
.time { flex-shrink: 0; color: #ddd; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.range-input { appearance: none; -webkit-appearance: none; display: block; width: 100%; min-width: 0; height: 24px; margin: 0; border: 0; border-radius: 0; background: linear-gradient(to right, var(--orange) var(--progress, 0%), #666 var(--progress, 0%)) center / 100% 4px no-repeat; cursor: pointer; }
.range-input::-webkit-slider-runnable-track { height: 4px; border: 0; background: transparent; }
.range-input::-moz-range-track { height: 4px; border: 0; background: transparent; }
.range-input::-moz-range-progress { border: 0; background: transparent; }
.range-input::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 12px; height: 12px; margin-top: -4px; border: 0; border-radius: 50%; background: var(--orange); }
.range-input::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--orange); }
.range-input:disabled { cursor: default; opacity: 0.5; }
.playback-status { min-height: 18px; margin-top: 2px; color: #bbb; font-size: 0.8125rem; line-height: 1.4; overflow-wrap: anywhere; }
.player[data-state="error"] .playback-status, .player[data-state="blocked"] .playback-status { color: #ffb58d; }
.volume-control { display: flex; align-items: center; gap: 8px; min-width: 0; }
.volume-control > svg { width: 18px; height: 18px; color: #ddd; }
.volume-output { flex-shrink: 0; color: #bbb; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.75rem; }

@media (max-width: 760px) {
  .site-header { gap: 20px; }
  h1 { font-size: 1.25rem; }
  .player-inner { grid-template-columns: minmax(140px, 1fr) minmax(220px, 1.2fr) 90px; gap: 16px; }
  .volume-output { display: none; }
}

@media (max-width: 600px) {
  .site-header, .main-content, .player-inner { width: calc(100% - 24px); }
  .site-header { display: block; padding-block: 16px; }
  .header-title { margin-bottom: 12px; }
  h1 { font-size: 1.375rem; }
  .search-form { gap: 6px; }
  .search-button { min-width: 78px; padding-inline: 12px; }
  .search-field { gap: 8px; padding-left: 10px; }
  .main-content { padding-top: 12px; }
  .empty-state { padding-top: 40px; }
  .result { grid-template-columns: 40px minmax(0, 1fr) 52px 26px; gap: 8px; min-height: 60px; padding: 9px 6px; }
  .result-art { width: 40px; height: 40px; }
  .result-title { font-size: 0.9375rem; }
  .result-channel, .result-duration { font-size: 0.75rem; }
  .result-play { width: 26px; height: 26px; }
  .result-play svg { width: 14px; height: 14px; }
  .player-inner { grid-template-columns: minmax(0, 1fr) 90px; gap: 10px 16px; min-height: 0; padding-block: 12px max(12px, env(safe-area-inset-bottom)); }
  .current-track { grid-column: 1; grid-row: 1; }
  .player-art { width: 34px; height: 34px; }
  .volume-control { grid-column: 2; grid-row: 1; }
  .playback-controls { grid-column: 1 / -1; grid-row: 2; }
}
