/* MexCanTech palette (dark theme of mexcantech.com): navy paper, teal and
   brick accents. Dark only, since this is used on stage. */
:root {
  --bg: #0d111f;
  --surface: #151b2d;
  --surface-2: #1b233a;
  --line: #2b3349;
  --text: #eaeae6;
  --muted: #acb3c3;
  --faint: #838b9e;
  --accent: #5ebecc;
  --accent-hover: #7fcfda;
  --accent-ink: #0d111f;
  --brick: #e87f6c;
  --ok: #5ebecc;
  --warn: #e87f6c;
  --font-body: 'IBM Plex Sans', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: 'Newsreader', Georgia, serif;
  /* Teleprompter, on pure black so it disappears on teleprompter glass. */
  --pl-upcoming: #9aa2b6;
  --pl-past: #3a4257;
  --pl-label: #b5675a;
  --radius: 14px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font-body);
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
a { color: var(--accent); }
h1 { font: 600 2rem/1.15 var(--font-display); margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font: 600 1.3rem/1.25 var(--font-display); margin: 0; }
p { margin: .5rem 0; }
.muted { color: var(--muted); }
.center { text-align: center; }
.pad { padding: 1rem 0; }

.icon { width: 1.25em; height: 1.25em; flex: none; vertical-align: -.25em; }

/* --- chrome --------------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font: 600 1.2rem/1 var(--font-display); letter-spacing: -.005em; }
.topbar-status { display: flex; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; border-radius: 99px; padding: 4px 10px; font: inherit; font-size: .8rem; font-weight: 600;
}
.pill-warn { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.pill-live { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); cursor: pointer; }
.pill-lang { background: var(--surface-2); color: var(--text); cursor: pointer; border: 1px solid var(--line); }

main {
  max-width: 720px; margin: 0 auto;
  padding: 20px 16px calc(var(--tabbar-h) + var(--safe-b) + 32px);
  outline: none;
}

.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 5;
  display: flex; justify-content: center;
  padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1; max-width: 200px; height: var(--tabbar-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: .75rem; font-weight: 600;
}
.tabbar a .icon { width: 24px; height: 24px; }
.tabbar a.active { color: var(--accent); }

/* --- controls ---------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.big { min-height: 52px; font-size: 1.05rem; padding: 0 22px; }
.btn.small { min-height: 36px; font-size: .9rem; padding: 0 12px; }
.btn.wide { width: 100%; }
@media (hover: hover) {
  .btn:hover:not(:disabled) { background: var(--line); }
  .btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
}
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; flex: none;
  border: 0; border-radius: 12px; background: transparent; color: inherit; cursor: pointer;
}
.icon-btn .icon { width: 24px; height: 24px; }
.icon-btn[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 25%, transparent); color: var(--accent); }
.icon-btn:active { background: rgba(255,255,255,.1); }

input, textarea {
  font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; width: 100%;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.notice {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: 12px;
  background: color-mix(in srgb, var(--warn) 12%, var(--surface)); color: var(--text);
}
.notice .icon { color: var(--warn); margin-top: 2px; }

.empty { text-align: center; padding: 48px 8px; }
.empty .btn { margin-top: 12px; }
.empty-icon { width: 56px; height: 56px; color: var(--accent); opacity: .85; margin-bottom: 8px; }

/* --- search & lists ------------------------------------------------------------ */

.search { display: flex; gap: 8px; margin-bottom: 16px; }
.search-box { position: relative; flex: 1; display: block; }
.search-box > .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-box input { padding-left: 44px; min-height: 48px; font-size: 1.05rem; }
.search-box.small input { min-height: 42px; font-size: 1rem; }
.search-box.small { margin-bottom: 12px; }
.search .btn { min-height: 48px; }

.song-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.song-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface); color: var(--text); text-decoration: none;
  border: 1px solid transparent;
}
.song-item:active { background: var(--surface-2); }
@media (hover: hover) { .song-item:hover { border-color: var(--line); } }
.song-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.song-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-meta { color: var(--muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .75rem; font-weight: 650; padding: 3px 8px; border-radius: 99px;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge .icon { width: 14px; height: 14px; }
.badge-timed { background: color-mix(in srgb, var(--brick) 16%, transparent); color: var(--brick); }
.badge-saved { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.dur { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }

.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.lib-foot { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.lib-foot label.btn { position: relative; }

.credit { margin-top: 40px; text-align: center; font-size: .85rem; color: var(--faint); }
.credit a { color: var(--muted); text-decoration: none; font-family: var(--font-display); font-size: 1rem; }

/* --- web lookup ---------------------------------------------------------------- */

.web-panel { margin-top: 28px; padding: 18px 16px; border-radius: var(--radius); border: 1px dashed var(--line); }
.web-panel h2 { margin-bottom: 2px; }
.web-panel > .btn, .web-panel > .notice { margin-top: 10px; }
.web-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.web-item {
  width: 100%; text-align: left; display: flex; flex-direction: column; gap: 2px;
  padding: 12px 14px; border: 0; border-radius: 12px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer;
}
.web-item:active { background: var(--surface-2); }
.web-item .song-meta { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: .85rem; }
.web-site { color: var(--accent); font-size: .8rem; font-weight: 600; }
.url-form { display: flex; gap: 8px; margin-top: 12px; }
.url-form input { min-width: 0; }
.url-form .btn { white-space: nowrap; }
.source-note { margin: 12px 0 0; font-size: .95rem; }
.source-note .icon { color: var(--accent); }

/* --- song page ----------------------------------------------------------------- */

.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; margin: -4px 0 12px -4px; padding: 4px; }
.song-head .song-meta { white-space: normal; font-size: 1rem; }
.song-head .badges { justify-content: flex-start; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 24px; }
.actions .btn.primary { flex: 1 1 100%; }
.lyrics { font-size: 1.15rem; line-height: 1.55; }
.lyrics p { margin: 0; }
.lyrics .gap { height: 1em; }
.lyrics .label { color: var(--brick); font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; margin-top: .2em; }

.edit-form { display: grid; gap: 14px; margin-top: 16px; }
.edit-form label { display: grid; gap: 6px; font-weight: 600; font-size: .9rem; color: var(--muted); }
.edit-form textarea { line-height: 1.5; resize: vertical; min-height: 40vh; }

/* --- send sheet ----------------------------------------------------------------- */

dialog.sheet {
  width: min(480px, calc(100% - 24px)); max-height: calc(100dvh - 48px);
  padding: 0; border: 1px solid var(--line); border-radius: 20px;
  background: var(--surface); color: var(--text);
}
dialog.sheet::backdrop { background: rgba(0,0,0,.6); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 8px 4px 20px; }
.sheet-body { padding: 4px 20px 20px; }
.seg { display: flex; gap: 4px; padding: 4px; margin: 8px 16px; background: var(--bg); border-radius: 12px; }
.seg button {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; border: 0; border-radius: 9px; background: transparent; color: var(--muted);
  font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer;
}
.seg button[aria-selected="true"], .seg button[aria-checked="true"] { background: var(--surface-2); color: var(--text); }
.seg button:disabled { opacity: .35; cursor: default; }
.code-big { font: 600 2.6rem/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .2em; text-align: center; color: var(--accent); margin: 16px 0 8px; }
.qr { background: #fff; border-radius: 12px; padding: 8px; width: min(220px, 70%); margin: 12px auto 4px; }
.qr svg { display: block; width: 100%; height: auto; }
.link-status { text-align: center; color: var(--muted); font-weight: 600; margin: 12px 0; }
.link-status.on { color: var(--ok); }

/* --- be a screen ----------------------------------------------------------------- */

.steps { padding-left: 1.2em; color: var(--muted); }
.steps li { margin: 6px 0; }
.steps .icon { color: var(--text); }
.code-form { display: grid; gap: 12px; margin-top: 24px; max-width: 360px; }
.code-input { font: 700 2rem/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .25em; text-align: center; text-transform: uppercase; padding: 14px; }
.spinner { width: 36px; height: 36px; margin: 0 auto 12px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- teleprompter ----------------------------------------------------------------- */

body.prompting { overflow: hidden; }
body.prompting .topbar, body.prompting .tabbar { display: none; }

.play-view { position: fixed; inset: 0; z-index: 10; background: #000; color: #fff; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.prompter-host { position: absolute; inset: 0; }
.prompter { --prompter-size: 44px; overflow: hidden; cursor: default; }
.prompter-track {
  padding: 0 max(6vw, 20px) 70vh;
  will-change: transform;
}
.pl {
  font-size: var(--prompter-size);
  font-weight: 700;
  line-height: 1.22;
  letter-spacing: -.005em;
  padding: calc(var(--prompter-size) * .14) 0;
  color: var(--pl-upcoming);
  transition: color .25s;
  overflow-wrap: anywhere;
}
.pl.past { color: var(--pl-past); }
.pl.current { color: #fff; }
.pl-gap { height: calc(var(--prompter-size) * .6); padding: 0; }
.pl-music { color: var(--pl-past); font-size: calc(var(--prompter-size) * .7); }
.pl-music.current { color: var(--accent); }
.pl-label { font-size: calc(var(--prompter-size) * .42); letter-spacing: .08em; text-transform: uppercase; color: var(--pl-label); padding-top: calc(var(--prompter-size) * .3); }
.pl-label.current, .pl-label.past { color: var(--pl-label); }
.prompter-guide {
  position: absolute; left: 0; top: 30%; z-index: 1;
  width: 0; height: 0; margin-top: calc(var(--prompter-size) * .45);
  border: 9px solid transparent; border-left: 12px solid var(--accent);
  pointer-events: none; opacity: .9;
}

.pc {
  position: absolute; left: 0; right: 0; z-index: 2;
  transition: opacity .3s, transform .3s;
}
.pc-top {
  top: 0; display: flex; align-items: center; gap: 2px;
  padding: calc(6px + var(--safe-t)) 8px 24px;
  background: linear-gradient(#000 40%, transparent);
}
.pc-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; padding: 0 4px; }
.pc-title b, .pc-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-title span { color: var(--faint); font-size: .85rem; }
.pc-bottom {
  bottom: 0;
  padding: 32px 16px calc(14px + var(--safe-b));
  background: linear-gradient(transparent, #000 35%);
  display: grid; gap: 10px; justify-items: center;
}
.pc-bottom .seg { margin: 0; width: min(420px, 100%); background: rgba(255,255,255,.08); }
.pc-bottom .seg button { color: var(--muted); }
.pc-bottom .seg button[aria-checked="true"] { background: rgba(255,255,255,.16); color: #fff; }
.pc-row { display: flex; align-items: center; justify-content: center; gap: 16px; width: min(420px, 100%); }
.play-btn {
  width: 64px; height: 64px; flex: none; border-radius: 50%; border: 0;
  display: grid; place-items: center; cursor: pointer;
  background: var(--accent); color: var(--accent-ink);
}
.play-btn .icon { width: 30px; height: 30px; }
.play-btn:active { transform: scale(.95); }
.speed { flex: 1; display: flex; align-items: center; gap: 10px; font-size: .85rem; color: var(--muted); font-weight: 600; }
.speed input { flex: 1; padding: 0; accent-color: var(--accent); background: none; border: 0; }
.speed output { width: 2ch; text-align: right; font-variant-numeric: tabular-nums; color: #fff; }
.pc-hint { margin: 0; font-size: .85rem; color: var(--muted); text-align: center; max-width: 420px; }
.mic { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: rgba(255,255,255,.1); color: var(--muted); }
.mic .icon { width: 28px; height: 28px; }
.mic.on { background: var(--accent); color: var(--accent-ink); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px color-mix(in srgb, var(--accent) 20%, transparent); } }

.controls-hidden .pc { opacity: 0; pointer-events: none; }
.controls-hidden .pc-top { transform: translateY(-12px); }
.controls-hidden .pc-bottom { transform: translateY(12px); }

.screen-status {
  position: absolute; top: calc(12px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 3;
  padding: 6px 14px; border-radius: 99px; background: var(--warn); color: var(--accent-ink); font-weight: 700; font-size: .85rem;
}
.is-screen .pc-bottom { padding-top: 40px; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px); z-index: 20;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-weight: 600; font-size: .95rem;
  transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
body.prompting #toast { bottom: calc(150px + var(--safe-b)); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
