:root {
  --page: #f5f7f5;
  --surface: #fff;
  --text: #18211b;
  --muted: #66736a;
  --line: #e1e7e2;
  --green: #16883c;
  --green-dark: #0f6d2f;
  --soft-green: #e8f4eb;
}

html { position: relative; min-height: 100%; font-size: 14px; }
@media (min-width: 768px) { html { font-size: 16px; } }
body { min-height: 100vh; margin: 0 0 60px; background: var(--page); color: var(--text); }
::selection { background: #cce9d3; color: #173b21; }
input, textarea { caret-color: var(--green-dark); }
* { scrollbar-color: #b8c9bc var(--page); scrollbar-width: thin; }
.app-navbar { min-height: 68px; padding: .6rem max(1rem, calc((100vw - 1160px) / 2)); background: var(--surface); border-bottom: 1px solid var(--line); }
.navbar-brand { color: var(--green-dark); font-size: 1.25rem; font-weight: 750; letter-spacing: -.04em; }
.navbar-brand:hover, .navbar .nav-link:hover { color: var(--green-dark); }
.navbar .nav-link, .navbar .navbar-text { color: var(--muted); }
.navbar .btn-link { color: var(--green-dark); }
.navbar form { margin: 0; }
.navbar .container-fluid { align-items: center; gap: 1rem; }
.navbar-collapse { align-items: center; }
.navbar-nav { align-items: center; }
.navbar .btn { min-height: 40px; }
.app-navbar .navbar-toggler { padding: .5rem .65rem; border: 1px solid var(--line); border-radius: .6rem; background: #fff; }
.app-navbar .navbar-toggler:hover { border-color: #b7cdbb; background: var(--soft-green); }
.app-navbar .navbar-toggler:focus { box-shadow: 0 0 0 .2rem #fff, 0 0 0 .35rem #8acb9c; }
.app-navbar .navbar-toggler-icon { width: 1.35rem; height: 1.35rem; background-image: linear-gradient(var(--green-dark), var(--green-dark)), linear-gradient(var(--green-dark), var(--green-dark)), linear-gradient(var(--green-dark), var(--green-dark)); background-position: center 25%, center 50%, center 75%; background-repeat: no-repeat; background-size: 100% 2px; }
.btn { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; gap: .5rem; padding: .65rem 1rem; border-radius: .65rem; font-weight: 650; line-height: 1.2; transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-sm { min-height: 36px; padding: .45rem .72rem; border-radius: .5rem; font-size: .82rem; }
.btn-success, .btn-spotify { border-color: var(--green); background: var(--green); color: #fff; }
.btn-success:hover, .btn-spotify:hover { border-color: var(--green-dark); background: var(--green-dark); color: #fff; }
.btn-spotify { padding: .72rem 1.2rem; font-weight: 700; }
.btn-outline-secondary { border-color: #c5d1c8; background: #fff; color: #344239; }
.btn-outline-secondary:hover { border-color: #a9c5af; background: var(--soft-green); color: var(--green-dark); }
.btn-outline-danger { border-color: #e2b8b4; color: #8c3830; }
.btn-outline-danger:hover { border-color: #ce938d; background: #fff2f0; color: #76251f; }
.btn-link { color: var(--green-dark); text-decoration: none; }
.btn-link:hover { color: var(--green); text-decoration: underline; text-underline-offset: .2em; }
.navbar .btn-link { min-height: 40px; padding: .5rem .75rem; border: 0; border-radius: .55rem; background: transparent; color: var(--green-dark); text-decoration: none; }
.navbar .btn-link:hover { background: var(--soft-green); color: var(--green-dark); }
.navbar .btn-outline-secondary { border-color: #c5d1c8; background: #fff; color: #344239; }
.btn:focus-visible, .btn-link.nav-link:focus-visible, .form-control:focus, .form-check-input:focus { outline: none; box-shadow: 0 0 0 .2rem #fff, 0 0 0 .35rem #8acb9c; }
.app-footer { position: absolute; right: 0; bottom: 0; left: 0; min-height: 48px; padding: .8rem 1rem; border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: .85rem; }
.app-footer a { color: var(--green-dark); }
.global-player-dock { position: fixed; z-index: 1030; right: 1.25rem; bottom: 1rem; display: grid; width: min(390px, calc(100vw - 2rem)); grid-template-columns: minmax(0, 1fr) 42px; align-items: center; gap: .25rem .9rem; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: .9rem; background: var(--surface); box-shadow: 0 12px 38px #15271a24; }
.global-player-dock[hidden] { display: none; }
.dock-state { display: flex; grid-column: 1 / -1; align-items: center; gap: .45rem; overflow: hidden; color: var(--muted); font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
.dock-state .status-dot { width: 7px; height: 7px; flex: 0 0 auto; }
.dock-track { display: grid; min-width: 0; gap: .15rem; }
.dock-track strong, .dock-track span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock-track strong { color: var(--text); font-size: .88rem; }
.dock-track span { color: var(--muted); font-size: .78rem; }
.dock-play-button { display: grid; width: 40px; height: 40px; place-items: center; border: 0; border-radius: 50%; background: var(--soft-green); color: var(--green-dark); }
.dock-play-button:hover:not(:disabled) { background: #d9efdf; }
.dock-play-button svg { width: 18px; height: 18px; fill: currentColor; }
.dock-icon-pause { display: none; }
.dock-play-button.is-playing .dock-icon-play { display: none; }
.dock-play-button.is-playing .dock-icon-pause { display: block; }

.playlist-page, .player-page { max-width: 1080px; margin: 2.5rem auto 3.5rem; }
.playlist-heading { margin-bottom: 2rem; }
.playlist-heading h1, .player-page h1 { color: var(--text); font-size: clamp(2rem, 5vw, 3.25rem); font-weight: 750; letter-spacing: -.045em; }
.playlist-heading p { color: var(--muted); }
.spotify-link-form { margin: 1.75rem 0 2.5rem; padding: clamp(1rem, 2.5vw, 1.4rem); border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); }
.spotify-link-form label { display: block; margin-bottom: .65rem; color: var(--text); font-weight: 650; }
.spotify-link-input { display: flex; gap: .75rem; }
.spotify-link-input input { min-width: 0; flex: 1; padding: .8rem 1rem; border: 1px solid #cbd5cd; border-radius: .55rem; background: #fff; color: var(--text); }
.spotify-link-form small { display: block; margin-top: .65rem; color: var(--muted); }
.playlist-section-heading { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 1rem; }
.playlist-section-heading h2 { color: var(--text); font-size: 1.35rem; font-weight: 700; }
.playlist-section-heading span, .playlist-card-info p { color: var(--muted); }
.playlist-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 1rem; }
.playlist-card { display: grid; grid-template-columns: 72px minmax(0, 1fr); align-items: center; gap: .85rem; padding: 1rem; border: 1px solid var(--line); border-radius: .85rem; background: var(--surface); transition: border-color 150ms ease, background-color 150ms ease; }
.playlist-card:hover { border-color: #c6d8ca; background: #fcfdfc; }
.playlist-artwork { width: 72px; height: 72px; object-fit: cover; border-radius: .55rem; background: #f0f3f0; }
.playlist-artwork-empty { display: grid; place-items: center; color: var(--green); background: var(--soft-green); }
.playlist-artwork-empty svg { width: 34px; height: 34px; fill: currentColor; }
.playlist-card-info { min-width: 0; }
.playlist-card-info h3 { overflow: hidden; margin: 0; color: var(--text); font-size: 1rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.playlist-card-info p { margin: .3rem 0 0; font-size: .85rem; }
.playlist-card form { grid-column: 1 / -1; }
.playlist-card button { width: 100%; }
.empty-state { padding: 2rem; border: 1px dashed #cbd5cd; border-radius: .8rem; color: var(--muted); text-align: center; }

.player-page-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.back-link { display: inline-flex; align-items: center; gap: .45rem; color: var(--green-dark); font-weight: 650; text-decoration: none; }
.back-link svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.back-link:hover { color: var(--green); text-decoration: underline; }
.player-brand { color: var(--muted); font-size: .85rem; font-weight: 650; }
.player-card { max-width: 820px; margin: auto; padding: clamp(1.1rem, 4vw, 2.4rem); border: 1px solid var(--line); border-radius: 1.15rem; background: var(--surface); }
.player-status-row { display: flex; align-items: center; gap: .6rem; min-height: 26px; }
.player-status-row p { margin: 0; color: var(--muted); font-size: .9rem; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #aeb8b0; }
.status-connected { background: #22a34a; box-shadow: 0 0 0 4px #e7f5eb; }
.status-busy { background: #d7a42b; }
.status-error { background: #d74c4c; }
.player-alert { margin-top: 1rem; padding: .8rem 1rem; border: 1px solid #f0c8c5; border-radius: .65rem; background: #fff2f0; color: #852a24; }
.player-main { display: flex; align-items: center; gap: clamp(1.2rem, 4vw, 2.4rem); margin: 1.5rem 0 1.25rem; }
.track-artwork-wrap { display: grid; width: clamp(124px, 25vw, 220px); aspect-ratio: 1; flex: 0 0 auto; place-items: center; overflow: hidden; border-radius: .75rem; background: #f0f3f0; }
.track-artwork { width: 100%; height: 100%; object-fit: contain; }
.track-artwork-placeholder { color: #76a783; }
.track-artwork-placeholder svg { width: 58px; height: 58px; fill: currentColor; }
.track-details { min-width: 0; }
.track-details h1 { overflow-wrap: anywhere; margin-bottom: .45rem; font-size: clamp(1.5rem, 4vw, 2.3rem); }
.track-details > p { margin-bottom: .35rem; color: var(--muted); }
.track-details .context-label { margin-top: 1.2rem; font-size: .85rem; }
.context-label span { color: var(--text); font-weight: 600; }
.progress-block { margin-top: 2rem; }
.progress-block input, .volume-control input { width: 100%; accent-color: var(--green); }
.time-labels { display: flex; justify-content: space-between; margin-top: .2rem; color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.playback-controls { display: flex; align-items: center; justify-content: center; gap: 1.1rem; margin: 1.15rem 0 1.5rem; }
.icon-button, .play-button { display: grid; place-items: center; border: 0; border-radius: 50%; }
.icon-button { width: 46px; height: 46px; background: transparent; color: #46544a; transition: background-color 140ms ease, color 140ms ease; }
.icon-button svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.icon-button:hover:not(:disabled) { background: var(--soft-green); color: var(--green-dark); }
.icon-button:focus-visible, .play-button:focus-visible, .dock-play-button:focus-visible { outline: none; box-shadow: 0 0 0 .2rem #fff, 0 0 0 .35rem #8acb9c; }
.play-button { width: 62px; height: 62px; background: var(--green); color: #fff; box-shadow: 0 4px 12px #16883c30; transition: background-color 140ms ease, transform 140ms ease, box-shadow 140ms ease; }
.play-button svg { width: 24px; height: 24px; fill: currentColor; }
.play-button .icon-pause { display: none; }
.play-button.is-playing .icon-play { display: none; }
.play-button.is-playing .icon-pause { display: block; }
.play-button:hover:not(:disabled) { transform: scale(1.04); background: var(--green-dark); box-shadow: 0 6px 16px #0f6d2f32; }
button:disabled, input:disabled { cursor: not-allowed; opacity: .5; }
.volume-control { display: grid; grid-template-columns: auto minmax(100px, 220px) 42px; align-items: center; justify-content: center; gap: .75rem; color: var(--muted); font-size: .85rem; }
.volume-control label { margin: 0; }
.volume-control span { text-align: right; font-variant-numeric: tabular-nums; }
.player-footer { display: flex; justify-content: center; margin-top: 1rem; }
.player-ready-note { margin: .35rem 0 1rem; color: var(--muted); font-size: .85rem; }
.up-next { margin-top: 2rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.up-next h2 { margin-bottom: .75rem; color: var(--text); font-size: 1rem; font-weight: 700; }
.up-next ol { margin: 0; padding-left: 1.25rem; color: var(--muted); font-size: .9rem; }
.up-next li { padding: .25rem 0; }
.player-note { max-width: 760px; margin: 1rem auto; color: var(--muted); font-size: .85rem; }
.auth-message { max-width: 640px; margin: 4rem auto; padding: 2rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); }
.home-playback-start { max-width: 620px; margin: 3rem auto; padding: 2rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); box-shadow: 0 10px 32px #15271a0a; }
.home-playback-start h2 { margin-bottom: .6rem; color: var(--text); font-size: 1.35rem; font-weight: 700; }
.home-playback-start p { color: var(--muted); }
.home-playback-start #home-play-status { min-height: 1.4rem; color: var(--green-dark); font-size: .9rem; }

.cue-page { max-width: 1080px; margin: 2.5rem auto 5rem; }
.cue-page-heading, .cue-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1.25rem; }
.cue-page-heading { margin-bottom: 1.4rem; }
.cue-page-heading h1 { margin: 0 0 .35rem; color: var(--text); font-size: clamp(2rem, 5vw, 3rem); font-weight: 750; letter-spacing: -.045em; }
.cue-page-heading p, .cue-section-heading p { margin: 0; color: var(--muted); }
.cue-status { min-height: 1.5rem; margin-bottom: .8rem; color: var(--muted); font-size: .88rem; }
.cue-status.is-error { color: #a22f27; }
.cue-library, .cue-script { margin-top: 1.2rem; padding: clamp(1rem, 3vw, 1.5rem); border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); box-shadow: 0 8px 28px #15271a08; }
.cue-section-heading { align-items: center; margin-bottom: 1rem; }
.cue-section-heading h2 { margin: 0 0 .3rem; color: var(--text); font-size: 1.25rem; font-weight: 700; }
.cue-section-heading p { font-size: .85rem; }
.cue-upload-form { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; }
.cue-upload-form input[type=file] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
.file-picker { margin: 0; padding: .42rem .75rem; border: 1px solid #cbd5cd; border-radius: .4rem; color: #344239; cursor: pointer; }
.file-picker:hover { background: var(--soft-green); }
.cue-audio-list { display: grid; gap: .55rem; }
.cue-audio-item { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(180px, 320px) auto; align-items: center; gap: .85rem; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: .65rem; background: #fbfcfb; }
.cue-audio-name { display: grid; min-width: 0; gap: .15rem; }
.cue-audio-name strong { overflow: hidden; color: var(--text); font-size: .9rem; text-overflow: ellipsis; white-space: nowrap; }
.cue-audio-name span { color: var(--muted); font-size: .78rem; }
.cue-audio-item audio { width: 100%; height: 36px; }
.cue-delete-form { margin: 0; }
.cue-empty-library, .cue-empty-script { margin: 0; padding: 1rem; border: 1px dashed #cbd5cd; border-radius: .6rem; color: var(--muted); text-align: center; }
.cue-timeline { display: grid; gap: .75rem; margin: 0; padding: 0; list-style: none; counter-reset: cue; }
.cue-row { padding: .95rem; border: 1px solid var(--line); border-radius: .8rem; background: #fbfcfb; counter-increment: cue; }
.cue-row-heading, .cue-row-footer { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.cue-row-heading { margin-bottom: .8rem; }
.cue-row-heading > strong { overflow: hidden; color: var(--text); font-size: .92rem; text-overflow: ellipsis; white-space: nowrap; }
.cue-row-actions, .cue-row-footer { display: flex; flex-wrap: wrap; gap: .4rem; }
.cue-fields-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; }
.cue-field { display: grid; min-width: 0; gap: .28rem; color: var(--muted); font-size: .75rem; }
.cue-field[hidden] { display: none; }
.cue-field input, .cue-field select { width: 100%; min-width: 0; padding: .4rem .5rem; border: 1px solid #cbd5cd; border-radius: .4rem; background: #fff; color: var(--text); font-size: .85rem; }
.cue-row-footer { justify-content: flex-start; margin-top: .8rem; }
.cue-script-footer { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }
.cue-empty-script { margin-top: .8rem; }

@media (max-width: 560px) {
  .playlist-page, .player-page { margin: 1.5rem auto; }
  .spotify-link-input { flex-direction: column; align-items: stretch; }
  .player-main { align-items: flex-start; }
  .global-player-dock { right: .75rem; bottom: .75rem; width: calc(100vw - 1.5rem); }
  .track-artwork-wrap { width: 104px; }
  .volume-control { grid-template-columns: auto minmax(80px, 1fr) 38px; }
  .cue-page { margin: 1.4rem auto 5rem; }
  .cue-page-heading, .cue-section-heading { align-items: flex-start; flex-direction: column; }
  .cue-upload-form { width: 100%; }
  .cue-audio-item { grid-template-columns: minmax(0, 1fr) auto; }
  .cue-audio-item audio { grid-column: 1 / -1; grid-row: 2; }
  .cue-delete-form { grid-column: 2; grid-row: 1; }
  .cue-fields-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cue-row-heading { align-items: flex-start; flex-direction: column; }
}
