:root {
  /* ZyGen CI: Navy Blue #021D44 / Teal Green #00C684 / Tangerine #F28500 */
  --bg: #051a3a;
  --bg-card: #0b2347;
  --bg-card-2: #123061;
  --accent: #00c684;
  --accent-2: #f28500;
  --accent-3: #00c684;
  --text: #f3f6fa;
  --text-dim: #9fb0c9;
  --border: #1c3d6b;
  --danger: #ff5c5c;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Noto Sans Thai", "Sarabun", sans-serif;
  background: radial-gradient(circle at top, #0b2347, #021d44 60%);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 90px;
}

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px;
}

header.top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(2, 29, 68, 0.94);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px 10px;
}

header.top .brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

header.top .brand-row img.brand-logo {
  height: 18px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

.event-title-wrap {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

header.top h1 {
  margin: 0;
  font-size: 1.15rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

header.top h1.event-title-link {
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

.leave-link {
  flex-shrink: 0;
  font-size: 0.7rem;
  padding: 2px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  text-decoration: none;
}

header.top .sub {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-top: 2px;
}

/* Page label ("🎶 Request List — ...") + presence pill share one row with
   the login/Favourite status + inbox bell, to keep the header compact —
   label/presence on the left, account info on the right, both on a single
   line. On narrow phones the label is dropped entirely (kept only in this
   row, nowhere else) so the rest still fits without wrapping. align-items
   is flex-start (not center) so expanding the presence panel below the
   pill doesn't visually re-center the login status on the taller row. */
.info-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}

.info-row-left {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.page-label {
  min-width: 0;
  flex: 1;
  color: var(--text-dim);
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  font-size: 0.76rem;
  color: var(--text-dim);
  white-space: nowrap;
}

/* Groups the login status and the inbox bell together at the top-right of
   the header, so the bell sits right next to your logged-in name. */
.info-row-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.auth-bar a {
  color: var(--accent);
  text-decoration: none;
}

@media (max-width: 480px) {
  .page-label { display: none; }
}

/* Presence widget — compact "N คน join" pill, now inline in the info-row
   next to the page label, expands into a small panel with everyone's
   name/status + your own status toggle. */
.presence-widget { flex-shrink: 0; }

.presence-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
}

.presence-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.presence-panel {
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.presence-status-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.presence-status-row button {
  flex: 1;
  padding: 6px;
  font-size: 0.8rem;
}

.presence-status-row button.selected {
  background: linear-gradient(135deg, var(--accent), #1de39b);
  color: #04231a;
}

.presence-person {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 2px;
  font-size: 0.85rem;
}

/* Bell icon lives inline next to the login status (top-right of header). Its
   dropdown is absolutely positioned so opening it never pushes the rest of
   the page down — sized to its content, not a full-screen overlay. */
.inbox-widget { position: relative; }

.inbox-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 0.95rem;
  cursor: pointer;
  font-family: inherit;
}

.inbox-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  padding: 6px 12px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  width: min(300px, 84vw);
  max-height: 340px;
  overflow-y: auto;
  box-shadow: 0 10px 28px rgba(2, 10, 24, 0.5);
}

.inbox-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--accent-2);
  color: #2a1400;
  font-size: 0.68rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

.inbox-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.inbox-item:last-child { border-bottom: none; }
.inbox-item.unread { background: rgba(0, 198, 132, 0.07); border-radius: 8px; padding: 10px 8px; }

.inbox-item-head { line-height: 1.4; }

.inbox-time {
  float: right;
  color: var(--text-dim);
  font-size: 0.72rem;
}

.inbox-item .btn-row button {
  font-size: 0.76rem;
  padding: 6px 4px;
}

nav.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

nav.tabs a {
  flex: 1;
  min-width: 21%;
  text-align: center;
  padding: 8px 6px;
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.78rem;
  border: 1px solid var(--border);
}

nav.tabs a.active {
  background: linear-gradient(135deg, var(--accent), #1de39b);
  color: #04231a;
  border-color: transparent;
  font-weight: 600;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.card h3 {
  margin: 0 0 4px;
  font-size: 1.02rem;
}

.card .artist {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.badge {
  font-size: 0.72rem;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-card-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.badge.strong { color: var(--accent-2); border-color: var(--accent-2); }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Musician page's "คุณคือ ..." card — name/roles text on one side, action
   buttons on the other. flex-wrap (not float) so a long name + role list
   drops the buttons to their own line instead of overlapping the text. */
.name-display-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.name-display-text { min-width: 0; }

button, .btn {
  font-family: inherit;
  border: none;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 0.82rem;
  background: var(--bg-card-2);
  color: var(--text);
  cursor: pointer;
  border: 1px solid var(--border);
  transition: transform 0.05s ease;
}

button:active { transform: scale(0.97); }

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.3);
  transform: none;
}

button.btn-queue-remove {
  background: linear-gradient(135deg, #e0b400, #f2cf4d);
  color: #2a2000;
  font-weight: 600;
  border: none;
}

button.selected {
  background: linear-gradient(135deg, var(--accent-3), #1de39b);
  color: #04231a;
  border-color: transparent;
  font-weight: 600;
}

button.btn-verify {
  background: linear-gradient(135deg, #2f6fe4, #5b93f0);
  color: #f3f6fa;
  font-weight: 600;
  border: none;
}

button.primary {
  background: linear-gradient(135deg, var(--accent), #1de39b);
  color: #04231a;
  font-weight: 600;
  border: none;
}

button.warn { background: var(--danger); color: #2a0000; border: none; font-weight: 600; }

input[type=text], textarea, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #06132b;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  margin-bottom: 8px;
}

label { font-size: 0.78rem; color: var(--text-dim); }

.fab {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  padding: 12px 26px;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0, 198, 132, 0.35);
}

/* The generic button:active rule below sets transform:scale(), which would
   otherwise replace .fab's translateX(-50%) centering and make the button
   visibly jump sideways out from under the cursor on press. Keep both. */
.fab:active {
  transform: translateX(-50%) scale(0.97);
}

.empty {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 10px;
  font-size: 0.9rem;
}

.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(2, 10, 24, 0.75);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal {
  background: var(--bg-card);
  border-radius: 18px 18px 0 0;
  padding: 18px;
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}

.modal h2 { margin-top: 0; font-size: 1.05rem; }

.close-x {
  position: absolute;
  top: 10px;
  right: 14px;
  font-size: 1.3rem;
  background: none;
  border: none;
  color: var(--text-dim);
}

.order-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-2);
  color: #221a00;
  font-weight: 700;
  font-size: 0.8rem;
  margin-right: 8px;
}

.zoom-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.zoom-row .zoom-label {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.zoom-row button {
  padding: 6px 14px;
  font-size: 0.95rem;
  font-weight: 700;
}

.zoom-row .zoom-input {
  width: 56px;
  padding: 6px 4px;
  text-align: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #06132b;
  color: var(--text);
  font-size: 0.85rem;
  margin-bottom: 0;
}

/* Split view (nextshow.html) — shown once a chord is opened "ในนี้": left
   80% is the chord viewer, right 20% is a compact upcoming-songs list, so
   musicians can see what's next without losing the chord on screen. */
.split-layout {
  display: grid;
  grid-template-columns: 4fr 1fr;
  gap: 14px;
  max-width: 1700px;
  margin: 0 auto;
  padding: 14px 16px 28px;
  box-sizing: border-box;
  align-items: start;
}

@media (max-width: 900px) {
  .split-layout {
    grid-template-columns: 1fr;
  }
  .split-right {
    position: static;
    max-height: 260px;
    overflow-y: auto;
  }
}

.split-right {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  position: sticky;
  top: 14px;
  max-height: calc(100vh - 28px);
  overflow-y: auto;
}

.split-right-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.split-right-head button {
  padding: 5px 10px;
  font-size: 0.9rem;
}

.split-song-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 6px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
}

.split-song-item:hover { background: var(--bg-card-2); }

.split-song-item.active {
  background: var(--bg-card-2);
  border-color: var(--accent);
}

.split-song-item .order-num { margin-right: 0; flex-shrink: 0; }

.split-song-item .info { min-width: 0; }

.split-song-item .info .t {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.split-song-item .info .a {
  font-size: 0.72rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chord-panel-inner {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.chord-panel-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
}

.chord-panel-head .grow { flex: 1; min-width: 200px; }

.chord-panel-head strong {
  display: block;
  font-size: 1.05rem;
}

/* Fixed-height viewport window for the chord iframe. The iframe inside is
   sized in JS (container-size / zoom) so that after CSS zoom scales it back
   up/down, its on-screen footprint always exactly fills this fixed box —
   the window itself never grows or shrinks when the user zooms. */
.chord-frame-wrap {
  width: 100%;
  height: clamp(420px, 82vh, 1150px);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-top: 8px;
  overflow: hidden;
  background: #fff;
}

.chord-frame-wrap iframe {
  border: none;
  display: block;
  transform-origin: 0 0;
}

.link-out {
  display: inline-block;
  margin-top: 6px;
  color: var(--accent-2);
  font-size: 0.82rem;
  text-decoration: none;
  border-bottom: 1px dashed var(--accent-2);
}

.played {
  opacity: 0.45;
}

.drag-handle {
  cursor: grab;
  color: var(--text-dim);
  padding: 4px 8px;
  font-size: 1.1rem;
}

.row-flex {
  display: flex;
  align-items: center;
  gap: 8px;
}

.row-flex .grow { flex: 1; }

/* Admin song-card action cluster (ตรวจ/ขยาย + คิว + ลบ) — sits beside the
   song info in the card header instead of its own full-width button row,
   with smaller buttons so the three fit compactly side by side. */
.admin-card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 6px;
  flex-shrink: 0;
}
.admin-card-actions button {
  padding: 7px 9px;
  font-size: 0.76rem;
  white-space: nowrap;
}

/* One box per "ขอให้คนอื่นร้อง" request on a song — who asked, who they
   asked, and the answer (or "ยังไม่ตอบ" while pending). Border colour is
   the at-a-glance signal: green = yes, orange = no, grey = no answer yet. */
.admin-request-boxes {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.admin-request-box {
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 2px solid var(--text-dim);
  background: var(--bg-card);
  font-size: 0.82rem;
  line-height: 1.4;
}
.admin-request-box.status-yes { border-color: var(--accent-3); background: rgba(0, 198, 132, 0.12); }
.admin-request-box.status-no { border-color: var(--accent-2); background: rgba(242, 133, 0, 0.12); }
.admin-request-box.status-pending { border-color: var(--text-dim); }

.toast {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent-3);
  color: #04231a;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.toast.show { opacity: 1; }

.section-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 18px 4px 8px;
}

.pin-box {
  max-width: 320px;
  margin: 60px auto;
  text-align: center;
}

.small-note {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 4px;
}

/* Login page — one full-width button per enabled OAuth provider. */
.login-box {
  max-width: 380px;
  margin: 50px auto;
  text-align: center;
  padding: 0 16px;
}

.login-box h2 { margin-bottom: 4px; }

.login-box .sub { color: var(--text-dim); font-size: 0.85rem; margin-bottom: 24px; }

.provider-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 10px;
  border-radius: 12px;
}

.provider-btn.provider-microsoft { background: #f3f6fa; color: #1b1b1b; border: none; }
.provider-btn.provider-google { background: #ffffff; color: #1b1b1b; border: none; }
.provider-btn.provider-line { background: #06c755; color: #ffffff; border: none; }

.login-skip {
  display: block;
  margin-top: 18px;
  color: var(--text-dim);
  font-size: 0.82rem;
  text-decoration: underline;
}

.login-error {
  background: rgba(255, 92, 92, 0.15);
  border: 1px solid var(--danger);
  color: #ffb3b3;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.82rem;
  margin-bottom: 16px;
}

.login-none-note {
  color: var(--text-dim);
  font-size: 0.85rem;
  line-height: 1.6;
}

/* Favourite List — one compact row per song: reorder arrows, title/artist
   (truncates with ellipsis instead of wrapping), then the action buttons —
   all on the same line to save vertical space. */
.fav-card {
  padding: 10px 12px;
}

.fav-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fav-reorder {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.fav-reorder button {
  padding: 1px 7px;
  font-size: 0.65rem;
  line-height: 1.4;
}

.fav-info {
  min-width: 0;
  flex: 1;
}

.fav-info .fav-title {
  font-weight: 600;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fav-info .fav-sub {
  font-size: 0.76rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fav-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.fav-actions button {
  padding: 7px 9px;
  font-size: 0.9rem;
}

/* "Favourite ของ xxx" share modal — per-song add button (blue, ZyGen navy-
   adjacent tone) vs. already-added state (solid green, visually inactive —
   deliberately NOT the native :disabled style, which would grey/desaturate
   it; pointer-events:none in the markup itself is what blocks clicks). */
button.btn-favshare-add {
  background: linear-gradient(135deg, #2f6fe4, #5b93f0);
  color: #f3f6fa;
  font-weight: 600;
  border: none;
  white-space: nowrap;
}
button.btn-favshare-added {
  background: linear-gradient(135deg, var(--accent-3), #1de39b);
  color: #04231a;
  font-weight: 600;
  border: none;
  white-space: nowrap;
  cursor: default;
}

button.btn-fav-remove {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

button.btn-fav-edit {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

button.btn-fav-request {
  background: linear-gradient(135deg, var(--accent), #1de39b);
  color: #04231a;
  font-weight: 600;
  border: none;
}
