/* ============================================================
   Wedding Music Console — theme
   Palette: ivory, burgundy, antique gold, sage, charcoal
   ============================================================ */

:root {
  --ivory:      #FBF7F0;
  --ivory-2:    #F4ECDF;
  --cream-card: #FFFDF8;
  --burgundy:   #7A2E3A;
  --burgundy-d: #5E2129;
  --rose:       #C4848C;
  --rose-soft:  #E7C9CE;
  --gold:       #C9A24B;
  --gold-d:     #A9842F;
  --gold-soft:  #EBD9A6;
  --sage:       #8A9A82;
  --charcoal:   #2E2A28;
  --ink-soft:   #6B625C;
  --line:       #E6DCC9;
  --danger:     #B23A3A;
  --ok:         #4E8C5A;

  --shadow-sm: 0 1px 2px rgba(46,42,40,.06), 0 2px 6px rgba(46,42,40,.05);
  --shadow-md: 0 6px 22px rgba(46,42,40,.10);
  --shadow-lg: 0 18px 48px rgba(46,42,40,.18);

  --radius: 14px;
  --radius-sm: 10px;
  --serif: "Cormorant Garamond", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --display: "Playfair Display", "Cormorant Garamond", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --maxw: 1080px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

/* The `hidden` attribute must always win, even over rules that set an explicit
   display (e.g. .modal-backdrop{display:grid}, .menu-item{display:flex}).
   JS shows elements by removing the attribute, restoring their normal display. */
[hidden] { display: none !important; }

body {
  font-family: var(--sans);
  color: var(--charcoal);
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(201,162,75,.10), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(196,132,140,.10), transparent 55%),
    var(--ivory);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

.page-frame {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 22px 20px 80px;
}

/* ───────────── Header ───────────── */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px; flex-wrap: wrap;
  padding: 14px 22px;
  background: linear-gradient(180deg, var(--cream-card), #FFFCF4);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  position: relative;
}
.app-header::after {
  content: ""; position: absolute; left: 22px; right: 22px; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-soft) 20%, var(--gold) 50%, var(--gold-soft) 80%, transparent);
  opacity: .7;
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-rings { width: 56px; height: 36px; flex: none; }
.brand-rings circle { fill: none; stroke: var(--gold); stroke-width: 2.4; }
.brand-rings .brand-gem { fill: var(--rose); stroke: var(--gold-d); stroke-width: 1; }
.brand-eyebrow {
  font-family: var(--sans); font-size: 10px; letter-spacing: .28em;
  text-transform: uppercase; color: var(--gold-d); font-weight: 600;
}
.brand-title {
  font-family: var(--display); font-weight: 600; font-size: 30px;
  line-height: 1.05; margin: 1px 0 0; color: var(--burgundy);
}
.brand-title[contenteditable="true"] { outline: 2px dashed var(--rose-soft); border-radius: 6px; padding: 0 4px; }
.brand-sub { font-family: var(--serif); font-style: italic; color: var(--ink-soft); font-size: 15px; }

.header-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ───────────── Buttons ───────────── */
.btn {
  font-family: var(--sans); font-size: 13.5px; font-weight: 600;
  border-radius: 999px; padding: 9px 16px; cursor: pointer;
  border: 1px solid transparent; transition: transform .08s ease, box-shadow .15s ease, background .15s ease, color .15s;
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn .i { font-weight: 700; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--charcoal); }
.btn-ghost:hover { border-color: var(--gold); color: var(--burgundy); }
.btn-soft { background: var(--ivory-2); border-color: var(--line); color: var(--burgundy-d); }
.btn-soft:hover { background: var(--rose-soft); }
.btn-gold {
  background: linear-gradient(180deg, var(--gold), var(--gold-d));
  color: #fff; box-shadow: 0 2px 10px rgba(169,132,47,.35);
}
.btn-gold:hover { box-shadow: 0 4px 16px rgba(169,132,47,.5); }
.btn-show { background: var(--burgundy); color: #fff; border-color: var(--burgundy-d); }
.btn-show:hover { background: var(--burgundy-d); }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover { border-color: var(--danger); background: #fbecec; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ───────────── Popover (session menu) ───────────── */
.popover {
  position: absolute; right: 20px; top: 88px; z-index: 40;
  width: 320px; background: var(--cream-card);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 14px;
}
.popover-title { font-family: var(--display); color: var(--burgundy); font-size: 18px; margin: 0 0 6px; }
.popover-note { font-size: 12.5px; color: var(--ink-soft); margin: 0 0 12px; line-height: 1.5; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; font-family: var(--sans); font-size: 14px; font-weight: 500;
  color: var(--charcoal); cursor: pointer; margin-bottom: 8px; text-align: left;
}
.menu-item:hover { border-color: var(--gold); color: var(--burgundy); }
.menu-item .i { color: var(--gold-d); font-size: 16px; }
.menu-divider { height: 1px; background: var(--line); margin: 6px 0 12px; }
.server-status { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-soft); margin-bottom: 10px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #c9c2b6; flex: none; }
.dot.online { background: var(--ok); box-shadow: 0 0 0 3px rgba(78,140,90,.18); }
.dot.offline { background: #c98b8b; }

/* ───────────── Transport ───────────── */
.transport {
  margin-top: 18px; padding: 18px 22px;
  background: linear-gradient(180deg, #fff, var(--cream-card));
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.now-playing { display: flex; align-items: center; gap: 16px; }
.np-art {
  width: 60px; height: 60px; flex: none; border-radius: 12px;
  background: radial-gradient(circle at 30% 25%, var(--rose), var(--burgundy));
  color: #fff; display: grid; place-items: center; font-size: 26px;
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.18), var(--shadow-sm);
}
.np-art.playing { animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 0%,100%{ box-shadow: inset 0 0 0 3px rgba(255,255,255,.18), 0 0 0 0 rgba(196,132,140,.4);} 50%{ box-shadow: inset 0 0 0 3px rgba(255,255,255,.3), 0 0 0 10px rgba(196,132,140,0);} }
.np-eyebrow { font-size: 10px; letter-spacing: .22em; text-transform: uppercase; color: var(--gold-d); font-weight: 600; }
.np-title { font-family: var(--display); font-size: 22px; color: var(--burgundy); line-height: 1.15; margin: 1px 0; }
.np-times { font-variant-numeric: tabular-nums; color: var(--ink-soft); font-size: 14px; }
.np-sep { margin: 0 4px; opacity: .5; }

.scrub-wrap { margin: 14px 0 12px; }
.scrub { width: 100%; }

/* range inputs */
input[type="range"] {
  -webkit-appearance: none; appearance: none; height: 6px; border-radius: 999px;
  background: linear-gradient(90deg, var(--gold) 0%, var(--gold) var(--fill, 0%), var(--ivory-2) var(--fill, 0%));
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 2px solid var(--gold-d); box-shadow: var(--shadow-sm); margin-top: -1px;
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 2px solid var(--gold-d);
}

.transport-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tbtn {
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line);
  background: #fff; color: var(--burgundy); font-size: 17px; cursor: pointer;
  display: grid; place-items: center; transition: all .12s ease;
}
.tbtn:hover { border-color: var(--gold); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.tbtn-primary {
  width: 58px; height: 58px; font-size: 22px; color: #fff; border: none;
  background: linear-gradient(180deg, var(--burgundy), var(--burgundy-d));
  box-shadow: 0 4px 14px rgba(122,46,58,.4);
}
.tbtn-primary:hover { box-shadow: 0 6px 20px rgba(122,46,58,.55); }
.transport-divider { width: 1px; height: 30px; background: var(--line); margin: 0 4px; }

.inline-num { font-size: 13px; color: var(--ink-soft); display: inline-flex; align-items: center; gap: 6px; }
.inline-num input { width: 58px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font-family: var(--sans); text-align: center; }

.master-vol { display: inline-flex; align-items: center; gap: 8px; }
.master-vol input[type=range] { width: 120px; }
.mv-read { font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--ink-soft); width: 38px; }

/* toggle */
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 13px; color: var(--charcoal); }
.toggle input { display: none; }
.toggle-track { width: 40px; height: 22px; border-radius: 999px; background: var(--ivory-2); border: 1px solid var(--line); position: relative; transition: background .15s; }
.toggle-thumb { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: left .15s; }
.toggle input:checked + .toggle-track { background: var(--sage); border-color: var(--sage); }
.toggle input:checked + .toggle-track .toggle-thumb { left: 20px; }

/* ───────────── Section titles ───────────── */
.section-title { font-family: var(--display); font-size: 19px; color: var(--burgundy); margin: 0; display: flex; align-items: center; gap: 8px; }
.section-title .i { color: var(--gold-d); }
.count-pill { font-family: var(--sans); font-size: 12px; font-weight: 600; background: var(--rose-soft); color: var(--burgundy-d); border-radius: 999px; padding: 2px 9px; }

/* ───────────── YouTube panel ───────────── */
.yt-panel { margin-top: 18px; padding: 16px 22px; background: var(--cream-card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.yt-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.yt-badge { font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); background: var(--ivory-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; }
.yt-badge.online { color: var(--ok); background: #eef6ef; border-color: #cfe6d3; }
.yt-row { display: flex; gap: 10px; }
.yt-input { flex: 1; padding: 11px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-family: var(--sans); font-size: 14px; background: #fff; }
.yt-input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,162,75,.15); }
.yt-jobs { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.yt-job { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; font-size: 13px; }
.yt-job .yt-job-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.yt-job .progress-track { flex: 1; max-width: 180px; }
.yt-job-state { font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.yt-job.error { border-color: #e7c4c4; background: #fdf1f1; }
.yt-job.done { border-color: #cfe6d3; background: #f1f8f2; }
.yt-fineprint { font-size: 11.5px; color: var(--ink-soft); margin: 12px 0 0; }

/* ───────────── Queue ───────────── */
.queue-section { margin-top: 18px; }
.queue-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.queue-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.track-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.track {
  display: grid;
  grid-template-columns: 26px 46px 28px 1fr minmax(160px, 220px) auto;
  align-items: center; gap: 14px;
  padding: 12px 16px; background: var(--cream-card);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); transition: box-shadow .15s, border-color .15s, transform .08s;
}
.track:hover { box-shadow: var(--shadow-md); }
.track.playing { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(201,162,75,.25), var(--shadow-md); }
.track.dragging { opacity: .5; }
.track.drag-over { border-color: var(--rose); border-style: dashed; }
.track.missing { border-style: dashed; opacity: .8; }

.t-handle { cursor: grab; color: var(--gold-d); font-size: 18px; text-align: center; line-height: 1; user-select: none; }
.t-handle:active { cursor: grabbing; }
.t-play {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line);
  background: #fff; color: var(--burgundy); font-size: 15px; cursor: pointer;
  display: grid; place-items: center; transition: all .12s;
}
.t-play:hover { border-color: var(--gold); box-shadow: var(--shadow-sm); }
.t-play.playing { background: linear-gradient(180deg, var(--burgundy), var(--burgundy-d)); color: #fff; border-color: var(--burgundy-d); }
.t-play:disabled { opacity: .4; cursor: not-allowed; }
.t-index { font-family: var(--display); font-size: 20px; color: var(--rose); text-align: center; }

.t-main { min-width: 0; }
.t-title { font-weight: 600; font-size: 15px; color: var(--charcoal); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-sub { font-size: 12px; color: var(--ink-soft); margin-top: 2px; display: flex; gap: 10px; flex-wrap: wrap; }
.t-tag { background: var(--ivory-2); border-radius: 6px; padding: 1px 7px; font-variant-numeric: tabular-nums; }
.t-tag.warn { background: #fbeede; color: var(--gold-d); }

.t-vol { display: flex; align-items: center; gap: 9px; }
.t-vol input[type=range] { flex: 1; }
.t-db { font-size: 11.5px; color: var(--ink-soft); font-variant-numeric: tabular-nums; width: 56px; text-align: right; }

.t-actions { display: flex; align-items: center; gap: 4px; }
.iconbtn { width: 34px; height: 34px; border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--ink-soft); cursor: pointer; display: grid; place-items: center; font-size: 15px; transition: all .12s; }
.iconbtn:hover { background: var(--ivory-2); color: var(--burgundy); }
.iconbtn.play-row.playing { color: var(--burgundy); background: var(--rose-soft); }
.iconbtn.danger:hover { color: var(--danger); background: #fbecec; }
.t-nudge { display: flex; flex-direction: column; }
.t-nudge .iconbtn { width: 28px; height: 18px; font-size: 11px; }

/* empty state */
.empty-state { text-align: center; padding: 56px 20px; color: var(--ink-soft); }
.empty-state.hidden { display: none; }
.empty-art { width: 80px; height: 80px; fill: var(--rose-soft); stroke: var(--rose); margin-bottom: 8px; }
.empty-state h3 { font-family: var(--display); color: var(--burgundy); font-size: 22px; margin: 6px 0; }
.empty-state p { margin: 0 0 16px; }

/* footer */
.app-footer { margin-top: 26px; text-align: center; font-size: 12px; color: var(--ink-soft); }
.footer-dot { margin: 0 8px; color: var(--gold); }
.footer-muted { color: #9a9085; }

/* ───────────── Modals ───────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: rgba(46,42,40,.42); backdrop-filter: blur(3px); padding: 20px;
  animation: fadein .15s ease;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 540px; background: var(--cream-card);
  border-radius: 18px; box-shadow: var(--shadow-lg); overflow: hidden;
  border: 1px solid var(--line); animation: rise .2s ease;
}
.modal-narrow { max-width: 420px; }
@keyframes rise { from { transform: translateY(10px); opacity: .7; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-family: var(--display); color: var(--burgundy); font-size: 21px; margin: 0; }
.modal-x { background: none; border: none; font-size: 18px; color: var(--ink-soft); cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.modal-x:hover { background: var(--ivory-2); color: var(--burgundy); }
.modal-body { padding: 20px 22px; }
.modal-track-name { font-family: var(--serif); font-style: italic; font-size: 17px; color: var(--burgundy); margin: 0 0 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--line); background: #fffdf6; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.field-wide { grid-column: 1 / -1; }
.field span { letter-spacing: .04em; }
.field input[type=text], .field input[type=number] { padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; font-family: var(--sans); font-size: 14px; font-weight: 500; color: var(--charcoal); }
.field input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,162,75,.15); }
.field-inline { display: flex; align-items: center; gap: 8px; }
.field-inline input[type=range] { flex: 1; }
.field-inline input[type=number] { width: 72px; }
.unit { color: var(--ink-soft); }
.db-read { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--gold-d); min-width: 56px; }
.mini-btn { font-size: 11px; font-weight: 600; padding: 6px 9px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--burgundy); cursor: pointer; white-space: nowrap; }
.mini-btn:hover { border-color: var(--gold); }
.field-help { font-size: 12px; color: var(--ink-soft); margin: 16px 0 0; line-height: 1.5; }
.field-help code { background: var(--ivory-2); padding: 1px 5px; border-radius: 5px; font-size: 11.5px; }

/* progress */
.progress-track { height: 10px; border-radius: 999px; background: var(--ivory-2); overflow: hidden; }
.progress-fill { height: 100%; width: 0%; border-radius: 999px; background: linear-gradient(90deg, var(--gold), var(--rose)); transition: width .2s ease; }
.progress-label { font-size: 13px; color: var(--ink-soft); margin: 12px 0 0; text-align: center; }

/* toasts */
.toast-stack { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 10px; align-items: center; pointer-events: none; }
.toast {
  background: var(--charcoal); color: #fff; padding: 12px 18px; border-radius: 12px;
  font-size: 13.5px; box-shadow: var(--shadow-lg); max-width: 90vw;
  animation: toastin .25s ease; pointer-events: auto;
}
.toast.ok { background: #335b3c; }
.toast.err { background: #7c2b2b; }
.toast.gold { background: var(--burgundy); }
@keyframes toastin { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ───────────── Show mode ───────────── */
body[data-mode="show"] .header-actions .btn:not(#btnShowMode),
body[data-mode="show"] #ytPanel,
body[data-mode="show"] .queue-tools,
body[data-mode="show"] .t-vol,
body[data-mode="show"] .t-actions,
body[data-mode="show"] .t-handle { display: none !important; }
/* Remaining visible row cells in DOM order: play, index, main */
body[data-mode="show"] .track { grid-template-columns: 52px 36px 1fr; }
body[data-mode="show"] .t-play { width: 46px; height: 46px; font-size: 17px; }
body[data-mode="show"] #btnShowMode { background: var(--gold-d); }
body[data-mode="show"] #btnShowMode::after { content: " · locked"; font-weight: 400; opacity: .85; }
body[data-mode="show"] .brand-title { pointer-events: none; }

/* ───────────── Responsive ───────────── */
@media (max-width: 720px) {
  .brand-title { font-size: 24px; }
  .track {
    grid-template-columns: 46px 1fr auto; row-gap: 10px;
    grid-template-areas: "play main actions" "vol vol vol";
  }
  .track .t-handle, .track .t-index { display: none; }
  .track .t-play { grid-area: play; }
  .track .t-main { grid-area: main; }
  .track .t-actions { grid-area: actions; }
  .track .t-vol { grid-area: vol; }
  body[data-mode="show"] .track { grid-template-columns: 52px 1fr; grid-template-areas: "play main"; }
  .header-actions .btn { padding: 8px 12px; font-size: 12.5px; }
  .transport-divider { display: none; }
  .popover { left: 12px; right: 12px; width: auto; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
