/* QK Webplayer layout — mobile-first, two-column on ≥900px */

* { box-sizing: border-box; }

body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }

/* ── Header ── */
.app-header {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
  background: rgba(4,40,32,0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--pt-gold-line);
}
html.dark .app-header { background: rgba(11,15,23,0.88); }
.brand { font-weight: 700; letter-spacing: .4px; white-space: nowrap; }
.brand .gold { font-weight: 800; }
.header-spacer { flex: 1; }
.icon-btn {
  padding: 7px 10px; border-radius: 10px; line-height: 1;
  background: transparent; border-color: transparent; font-size: 17px;
}
.icon-btn:hover { background: var(--row-hover); border-color: transparent; }

.onair-pill {
  font-size: 12px; font-weight: 700; letter-spacing: 1px;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--pt-gold-line); color: var(--pt-text-muted);
  white-space: nowrap;
}
.onair-pill.live {
  background: rgba(255,60,40,0.22); color: #ff8d80; border-color: rgba(255,107,91,0.7);
  animation: blink 1s infinite;
}
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,107,91,0.35);} 50% { box-shadow: 0 0 0 6px rgba(255,107,91,0);} }
@keyframes blink { 0%,100% { opacity: 1; box-shadow: 0 0 0 0 rgba(255,107,91,0.4);} 50% { opacity: 0.35; box-shadow: 0 0 0 6px rgba(255,107,91,0);} }

.hdr-btn { padding: 6px 12px; font-size: 12.5px; font-weight: 700; letter-spacing: .5px; white-space: nowrap; }
#btn-onair.live { background: rgba(255,60,40,0.22); border-color: rgba(255,107,91,0.65); color: #ff9d92; }

/* ── Tab bar ── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: space-around;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: rgba(4,40,32,0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--pt-gold-line);
}
html.dark .tabbar { background: rgba(11,15,23,0.94); }
.tabbar button {
  flex: 1; max-width: 140px;
  background: transparent; border: none; border-radius: 12px;
  padding: 7px 4px; font-size: 12px; color: var(--pt-text-muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tabbar button .ticon { font-size: 19px; }
.tabbar button.active { color: var(--accent); background: var(--row-hover); }

/* ── Views (edge-to-edge on mobile) ── */
.view { display: none; padding: 6px 4px; max-width: 1280px; margin: 0 auto; }
.view.active { display: block; }
@media (min-width: 900px) { .view { padding: 14px; } }

/* ── Login ── */
#view-login { display: none; min-height: 82vh; align-items: center; justify-content: center; }
#view-login.active { display: flex; }
.login-card { width: min(400px, 92vw); padding: 28px 24px; text-align: center; }
.login-card h1 { margin: 4px 0 2px; font-size: 22px; }
.login-card .sub { margin-bottom: 18px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card input { text-align: center; font-size: 18px; letter-spacing: 1px; }

/* ── Player grid ── */
.player-grid { display: flex; flex-direction: column; gap: 8px; }
@media (min-width: 900px) { .player-grid { gap: 14px; } }
@media (min-width: 900px) {
  body { padding-bottom: 20px; }
  .tabbar {
    position: sticky; top: 49px; bottom: auto;
    justify-content: flex-start; gap: 4px;
    border-top: none; border-bottom: 1px solid var(--pt-gold-line);
  }
  .tabbar button { flex: none; flex-direction: row; gap: 7px; font-size: 14px; padding: 8px 16px; }
  .player-grid { display: grid; grid-template-columns: minmax(340px, 5fr) 7fr; align-items: start; }
}

/* ── Deck ── */
.deck { position: relative; padding: 12px 14px; overflow: hidden; }
@media (min-width: 900px) { .deck { padding: 16px; } }

/* Mobile: deck sticks under the header; .compact shrinks it while scrolling */
@media (max-width: 899px) {
  .deck { position: sticky; top: 46px; z-index: 30; transition: padding .2s; }
  .deck.compact { padding: 8px 12px; border-radius: 12px; }
  .deck.compact #waveform { display: none; }
  .deck.compact .deck-sub { display: none; }
  .deck.compact .deck-title { font-size: 14px; min-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .deck.compact .deck-times { font-size: 12px; margin-top: 2px; }
  .deck.compact .deck-times .remaining { font-size: 13.5px; }
  .deck.compact .deck-controls { margin-top: 6px; }
  .deck.compact .deck-controls button { padding: 5px 12px; font-size: 13px; }
}
.deck-tint {
  position: absolute; inset: 0; border-radius: 16px;
  background: transparent; transition: background .6s;
  pointer-events: none;
}
.deck.st-green  .deck-tint { background: var(--deck-green); }
.deck.st-yellow .deck-tint { background: var(--deck-yellow); }
.deck.st-red    .deck-tint { background: var(--deck-red); animation: pulse 1.2s infinite; }
.deck > :not(.deck-tint) { position: relative; }

.deck-title { font-size: 17px; font-weight: 650; min-height: 24px; word-break: break-word; }
.deck-sub { font-size: 12.5px; margin-top: 2px; min-height: 16px; }
#waveform { width: 100%; height: 96px; display: block; margin: 12px 0 4px; border-radius: 8px; cursor: default; }
.deck-times { display: flex; justify-content: space-between; font-size: 13.5px; }
.deck-times .remaining { font-weight: 700; font-size: 16px; }

.deck-controls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; align-items: center; }
.deck-controls .grow { flex: 1; }
#btn-play { min-width: 96px; font-size: 15px; }
#btn-onair.live { background: rgba(255,60,40,0.22); border-color: rgba(255,107,91,0.65); color: #ff9d92; font-weight: 700; }
#btn-listen.on { color: var(--accent); border-color: var(--accent); }

.icecast-strip { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.ice-chip {
  font-size: 11.5px; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--pt-gold-line); color: var(--pt-text-muted);
}
.ice-chip.connected { color: var(--pt-green-ok); border-color: rgba(46,204,113,0.5); }
.ice-chip.error, .ice-chip.retrying { color: var(--pt-err); border-color: rgba(255,107,91,0.5); }
.ice-chip.connecting { color: var(--pt-warn); border-color: rgba(243,156,18,0.5); }

/* ── Panels / lists ── */
.panel { padding: 14px; }
.panel h2 { margin: 0 0 10px; font-size: 15px; letter-spacing: .3px; }
.panel-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.panel-head h2 { margin: 0; flex: 1; }

.pl-row, .hist-row {
  display: grid; align-items: center; gap: 8px;
  padding: 8px 6px; border-radius: 10px;
  border-bottom: 1px solid var(--pt-gold-line-soft);
  font-size: 13.5px;
}
.pl-row { grid-template-columns: 26px 62px 1fr 52px 62px 30px; }
.hist-row { grid-template-columns: 62px 1fr 62px 72px; }
.pl-row:hover, .hist-row:hover { background: var(--row-hover); }
.pl-row.selected { background: var(--row-hover); outline: 1px solid var(--glass-border); }
.pl-row .title, .hist-row .title { word-break: break-word; cursor: pointer; }
.pl-row .title .by { display: block; font-size: 11px; }
.t { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: embed; }
.t.start { color: var(--accent-soft); }
.t.end { color: var(--pt-text-muted); }
.drag-handle { cursor: grab; color: var(--pt-text-muted); text-align: center; touch-action: none;
               font-size: 18px; line-height: 1; }
.sortable-ghost { opacity: .35; background: var(--row-hover); }
.sortable-drag { opacity: .9; }
.pl-empty { padding: 24px 8px; text-align: center; }

.subtabs { display: flex; gap: 6px; margin-bottom: 10px; }
.subtabs button { padding: 6px 14px; font-size: 13px; }
.subtabs button.active { background: var(--accent); color: #0f1e1a; border-color: transparent; font-weight: 600; }
html.dark .subtabs button.active { color: #041016; }

.audit-row { display: flex; gap: 8px; padding: 7px 6px; font-size: 13px; border-bottom: 1px solid var(--pt-gold-line-soft); align-items: baseline; }
.audit-row .when { min-width: 96px; }
.audit-row .icon { width: 20px; text-align: center; }

/* ── Modal / Explorer ── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(2,10,8,0.6); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal { width: min(960px, 96vw); max-height: 92vh; display: flex; flex-direction: column; overflow: hidden; }
@media (max-width: 640px) {
  .modal { width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; }
}
.modal-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--pt-gold-line); }
.modal-head h3 { margin: 0; flex: 1; font-size: 15px; }
.modal-body { flex: 1; overflow: hidden; display: flex; }

.exp-side {
  width: 210px; border-right: 1px solid var(--pt-gold-line-soft);
  padding: 10px; overflow-y: auto; flex-shrink: 0;
}
.exp-side h4 { margin: 2px 0 8px; font-size: 12px; letter-spacing: .6px; color: var(--pt-text-muted); }
.bm-row { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 8px; font-size: 13px; cursor: pointer; }
.bm-row:hover { background: var(--row-hover); }
.bm-row .x { visibility: hidden; }
.bm-row:hover .x { visibility: visible; }
.exp-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.exp-search { display: flex; gap: 10px; align-items: center; padding: 8px 12px 4px; }
.exp-search input[type=search] { flex: 1; padding: 7px 10px; font-size: 13.5px; }
.exp-search label { font-size: 12.5px; color: var(--pt-text-muted); white-space: nowrap; display: flex; gap: 4px; align-items: center; }
.exp-row .pathline { display: block; font-size: 11px; color: var(--pt-text-muted); word-break: break-all; }
.exp-crumbs { padding: 8px 12px; font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; border-bottom: 1px solid var(--pt-gold-line-soft); }
.exp-crumbs a { color: var(--accent-soft); cursor: pointer; text-decoration: none; }
.exp-list { flex: 1; overflow-y: auto; padding: 6px 8px; }
.exp-row {
  display: grid; grid-template-columns: 26px 1fr 74px 60px auto;
  gap: 8px; align-items: center; padding: 7px 6px;
  border-radius: 8px; font-size: 13.5px; border-bottom: 1px solid var(--pt-gold-line-soft);
}
.exp-row:hover { background: var(--row-hover); }
.exp-row .nm { word-break: break-word; cursor: pointer; }
.exp-row.dim { opacity: .45; }
.exp-actions { display: flex; gap: 4px; }
.exp-actions button { padding: 4px 10px; font-size: 12px; }
@media (max-width: 640px) {
  .exp-side { position: absolute; z-index: 5; background: var(--pt-bg-darker); height: 100%; left: 0; transform: translateX(-100%); transition: transform .2s; }
  .exp-side.open { transform: none; box-shadow: 20px 0 40px rgba(0,0,0,.4); }
  .exp-row { grid-template-columns: 24px 1fr 58px auto; }
  .exp-row .sz { display: none; }
}

/* ── Recorder ── */
.rec-modal { width: min(440px, 94vw); padding: 20px; }
.rec-level { height: 10px; border-radius: 5px; background: var(--pt-gold-line-soft); overflow: hidden; margin: 12px 0; }
.rec-level i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .1s; }
.rec-time { font-size: 30px; text-align: center; font-variant-numeric: tabular-nums; margin: 6px 0; }

/* ── Tables (settings/users) ── */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-size: 11.5px; letter-spacing: .5px; color: var(--pt-text-muted); padding: 6px; border-bottom: 1px solid var(--pt-gold-line); }
.tbl td { padding: 7px 6px; border-bottom: 1px solid var(--pt-gold-line-soft); vertical-align: middle; }
.tbl input { padding: 6px 8px; font-size: 13px; width: 100%; }
.tbl input[type=checkbox] { width: auto; }
.tbl-scroll { overflow-x: auto; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--pt-gold-line); }
.badge.admin { color: var(--accent); border-color: var(--accent); }

.form-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; align-items: center; }

/* ── Toasts ── */
#toasts { position: fixed; right: 12px; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 80; display: flex; flex-direction: column; gap: 8px; }
@media (min-width: 900px) { #toasts { bottom: 18px; } }
.toast {
  padding: 10px 14px; border-radius: 12px; font-size: 13px;
  max-width: 320px; animation: slidein .2s;
}
.toast.err { border-color: rgba(255,107,91,0.6); }
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } }

/* ── Popup menu (playlist item + playlist tools) ── */
.popup-menu {
  position: fixed; z-index: 90; min-width: 220px; max-width: 300px;
  padding: 6px; border-radius: 14px;
}
.popup-menu .pm-item {
  display: block; width: 100%; text-align: start;
  background: transparent; border: none; border-radius: 10px;
  padding: 11px 12px; font-size: 14px; color: var(--pt-text);
}
.popup-menu .pm-item:hover { background: var(--row-hover); }
.popup-menu .pm-item.danger { color: var(--pt-err); }
.popup-menu .pm-title {
  padding: 6px 12px 8px; font-size: 12px; color: var(--pt-text-muted);
  border-bottom: 1px solid var(--pt-gold-line-soft); margin-bottom: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.popup-menu .pm-row { display: flex; gap: 6px; align-items: center; padding: 6px 8px; }
.popup-menu .pm-row .grow { flex: 1; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; }

/* Compact panels on mobile */
@media (max-width: 899px) {
  .panel { padding: 10px 8px; }
  .app-header { padding-left: 10px; padding-right: 10px; gap: 6px; }
  .icon-btn { padding: 6px 7px; }
  .hdr-btn { padding: 5px 9px; font-size: 11.5px; }
}

/* RTL adjustments */
html[dir="rtl"] .exp-side { border-right: none; border-left: 1px solid var(--pt-gold-line-soft); }
html[dir="rtl"] #toasts { right: auto; left: 12px; }

.hidden { display: none !important; }
