/* Ratzon Sheets — minimal, mobile-first, gig-friendly */
:root {
  --bg: #0A0A0A;
  --panel: #141414;
  --panel-2: #1c1c1c;
  --ink: #f3f3f3;
  --ink-dim: #b4b4b4;
  --muted: #7d7d7d;
  --gold: #c9a35d;
  --accent: #c9a35d;
  --danger: #e0593a;
  --ok: #4cb37b;
  --border: #2a2a2a;
  --radius: 10px;
  --shadow: 0 6px 18px rgba(0,0,0,.4);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: .87rem; }
code { background: var(--panel-2); padding: 1px 6px; border-radius: 4px; font-size: .9em; }
hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }
h1 { font-size: 1.8rem; margin: 0 0 .5rem; }
h2 { font-size: 1.25rem; margin: 1.4rem 0 .6rem; }
h3 { font-size: 1.05rem; margin: 1rem 0 .4rem; }
input, select, textarea {
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .55rem .7rem;
  font: inherit;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
label { display: block; margin: .65rem 0; font-size: .9rem; color: var(--ink-dim); }
label > input, label > select, label > textarea { margin-top: .25rem; }

.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px;
  padding: .55rem 1rem; cursor: pointer; font: inherit;
  text-decoration: none;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #0c0c0c; border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.05); text-decoration: none; }
.btn.ghost { background: transparent; }
.btn.small { padding: .35rem .65rem; font-size: .87rem; border-radius: 6px; }
.btn.danger { color: var(--danger); border-color: rgba(224,89,58,.4); }
.btn.danger:hover { background: rgba(224,89,58,.1); }

.site-head {
  position: sticky; top: 0; z-index: 20;
  background: rgba(10,10,10,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.head-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: .85rem 1.2rem;
}
.brand { font-weight: 700; font-size: 1.1rem; letter-spacing: .02em; color: var(--ink); }
.brand span { color: var(--accent); font-weight: 400; }
.head-nav { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.head-nav a { color: var(--ink-dim); font-size: .92rem; }
.head-nav a:hover { color: var(--ink); text-decoration: none; }

.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1.2rem 3rem; }

.site-foot { border-top: 1px solid var(--border); margin-top: 3rem; }
.foot-inner { max-width: 1200px; margin: 0 auto; padding: 1rem 1.2rem; display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem 1.5rem; box-shadow: var(--shadow); }
.card.narrow { max-width: 460px; margin: 2rem auto; }

.alert { padding: .75rem 1rem; border-radius: 8px; margin: 1rem 0; border: 1px solid; }
.alert.err  { background: rgba(224,89,58,.1); border-color: rgba(224,89,58,.4); color: #ffb39b; }
.alert.ok   { background: rgba(76,179,123,.08); border-color: rgba(76,179,123,.35); color: #9bd9b3; }
.alert.info { background: rgba(201,163,93,.08); border-color: rgba(201,163,93,.35); color: #e5cf99; }

/* Library */
.lib-head { display: flex; justify-content: space-between; align-items: end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.search-wrap { position: relative; min-width: 280px; }
.search { width: 100%; padding-right: 2rem; }
.kbd { position: absolute; right: .55rem; top: 50%; transform: translateY(-50%); font-size: .75rem; color: var(--muted); border: 1px solid var(--border); padding: 1px 6px; border-radius: 4px; }

.cat-tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.tab {
  background: transparent; color: var(--ink-dim);
  border: 1px solid var(--border); border-radius: 999px;
  padding: .35rem .85rem; cursor: pointer; font: inherit; font-size: .88rem;
}
.tab.active { background: var(--accent); color: #0c0c0c; border-color: var(--accent); }
.pill { background: rgba(0,0,0,.2); padding: 1px 7px; border-radius: 999px; margin-left: .3rem; font-size: .72rem; }
.tab.active .pill { background: rgba(0,0,0,.25); }

.sheet-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.sheet {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; display: flex; flex-direction: column; gap: .6rem;
  transition: border-color .15s;
}
.sheet:hover { border-color: var(--accent); }
.sheet .thumb {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1c1c1c, #262626);
  aspect-ratio: 4/3; border-radius: 6px; font-weight: 700; color: var(--accent);
  letter-spacing: .15em; text-decoration: none;
}
.sheet .title { font-weight: 600; line-height: 1.25; }
.sheet .sub { color: var(--muted); font-size: .85rem; }
.sheet .tags { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: .25rem; }
.tag, .cat-tag { font-size: .72rem; padding: 2px 7px; border-radius: 999px; background: var(--panel-2); color: var(--ink-dim); border: 1px solid var(--border); }
.cat-tag { background: rgba(201,163,93,.12); color: #e5cf99; border-color: rgba(201,163,93,.3); }
.row-actions { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .25rem; }

.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }

/* Viewer */
.viewer-body main { max-width: none; padding: 0; }
.viewer-bar {
  position: sticky; top: 54px; z-index: 10;
  background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  padding: .6rem 1rem; gap: .5rem; flex-wrap: wrap;
}
.viewer-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.pdf-wrap { background: #222; height: calc(100vh - 110px); height: calc(100dvh - 110px); position: relative; }
.pdf-wrap iframe,
.pdf-wrap .pdf-embed { width: 100%; height: 100%; border: 0; background: #222; display: block; }
.pdf-wrap object.pdf-embed { width: 100%; height: 100%; }
.pdf-wrap object.pdf-embed iframe { width: 100%; height: 100%; }
.pdf-wrap:fullscreen { background: #000; }
.pdf-wrap:fullscreen iframe,
.pdf-wrap:fullscreen .pdf-embed { height: 100vh; }

/* iOS PDF fallback button — overlays the embed area in case Safari refuses to render inline */
.ios-pdf-fallback {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 1rem; background: rgba(20,20,20,.92);
  text-align: center; border-top: 1px solid #333;
}
.ios-pdf-fallback .btn.big { padding: .75rem 1.2rem; font-size: 1rem; }

/* Image viewer (for JPG/PNG sheets like Mi Adir) — fit-to-page, tap/pinch to zoom */
.img-viewer {
  width: 100%; height: 100%; overflow: auto;
  display: flex; justify-content: center; align-items: flex-start;
  background: #1a1a1a; padding: .5rem;
  touch-action: pinch-zoom;
  -webkit-overflow-scrolling: touch;
}
.img-viewer img {
  max-width: 100%; max-height: 100%;
  height: auto; width: auto;
  object-fit: contain;
  cursor: zoom-in;
  transition: transform .15s ease;
  user-select: none;
  -webkit-user-drag: none;
}
.img-viewer img.zoomed { max-width: none; max-height: none; width: auto; height: auto; cursor: zoom-out; }

/* Overview mode — strip ALL downloadable content + musicians + verbose notes.
   Keep only: schedule, set names + brief intro notes, song titles WITHOUT PDFs. */
.gigplan.overview-mode .musicians-section,
.gigplan.overview-mode .ref-audio-wrap,
.gigplan.overview-mode .audio-refs,
.gigplan.overview-mode .req-versions,
.gigplan.overview-mode .gig-sheets,
.gigplan.overview-mode .req-head .muted.small,
.gigplan.overview-mode .request p.muted.small,
.gigplan.overview-mode .gigplan-section > p.muted,
.gigplan.overview-mode .schedule li .muted.small,
.gigplan.overview-mode .gigplan-locked,
.gigplan.overview-mode .emcee-block { display: none !important; }
/* In overview mode: keep the View-Emcee block visible but hide all download buttons */
.gigplan.overview-mode .emcee-public .dl-only { display: none !important; }
.gigplan.overview-mode .req-versions .btn.ghost { display: none !important; }
/* Mobile vs desktop preview switching */
.desktop-only { display: block; }
.mobile-only  { display: none; }
@media (max-width: 768px) {
  .desktop-only { display: none !important; }
  .mobile-only  { display: block; }
}
.emcee-preview-mobile { background: #fff; border-radius: 8px; padding: 4px; }
.emcee-preview-mobile canvas.emcee-page { display: block; width: 100%; height: auto; margin: 0 0 6px; background: #fff; border-radius: 4px; box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.gigplan.overview-mode .gig-sheet .k { display: none; }
.gigplan.overview-mode .request .req-head { gap: .35rem; }
.gigplan.overview-mode h2 { font-size: 1.05rem; margin: .9rem 0 .35rem; }
.gigplan.overview-mode .gig-sheets li, .gigplan.overview-mode .requests li { margin: .2rem 0; }
.gigplan.overview-mode #viewToggle { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
/* Overview-mode set notes — show as short summary, max ~3 lines */
.gigplan.overview-mode .gigplan-section { margin: .5rem 0; padding: .6rem .8rem; }

/* Audio reference links — Ratzon, studio, reference, alt */
.audio-refs { display: flex; flex-wrap: wrap; gap: .4rem; margin: .55rem 0 .3rem; }
.audio-refs .audio-link {
  display: inline-block; padding: .4rem .7rem;
  background: rgba(255,180,80,.16); color: #ffd089;
  border: 1px solid rgba(255,180,80,.4);
  border-radius: 999px; font-size: .82rem; text-decoration: none; font-weight: 500;
  min-height: 36px;
}
.audio-refs .audio-link:hover { background: rgba(255,180,80,.28); color: #ffe6b8; }
@media (max-width: 768px) {
  .audio-refs .audio-link { padding: .5rem .85rem; min-height: 40px; }
}

/* Toggle button — short label on phone, full on desktop */
#viewToggle .short-label { display: none; }
@media (max-width: 540px) {
  #viewToggle .full-label { display: none; }
  #viewToggle .short-label { display: inline; }
  #viewToggle { padding: .55rem .85rem; font-size: .85rem; }
}

/* Public emcee-script preview (visible in "more details" view) */
.emcee-public { background: rgba(20,22,28,.6); border: 1px solid var(--border); border-radius: 12px; padding: 1rem 1.2rem; }
.emcee-public h2 { margin-top: 0; }
.emcee-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .8rem; }
.emcee-preview { background: #fff; border-radius: 8px; overflow: hidden; }
.emcee-preview iframe { width: 100%; height: 70vh; height: 70dvh; border: 0; display: block; }
@media (max-width: 768px) {
  .emcee-preview iframe { height: 60vh; height: 60dvh; }
}

/* Private emcee/event-details block — login-required */
.gigplan-locked {
  background: linear-gradient(135deg, rgba(120,160,255,.08), rgba(120,160,255,.03));
  border: 1px dashed rgba(120,160,255,.4); border-radius: 12px;
  padding: 1.2rem 1.4rem; margin: 1rem 0;
}
.gigplan-locked code {
  background: rgba(120,160,255,.18); color: #cfe; padding: .15rem .45rem;
  border-radius: 5px; font-size: .85rem;
}
.emcee-block { background: rgba(20,22,28,.6); border: 1px solid var(--border); border-radius: 12px; padding: 1.2rem 1.4rem; }
.emcee-block h3 { margin: 1.1rem 0 .5rem; font-size: 1rem; color: var(--accent); border-bottom: 1px solid var(--border); padding-bottom: .35rem; }
.emcee-list { margin: .3rem 0 .6rem 1.2rem; padding: 0; }
.emcee-list li { margin: .25rem 0; line-height: 1.45; }
.emcee-list.rules li { color: #ff9b9b; font-weight: 500; }

/* Multi-version sheet pills (same song in multiple keys) */
.req-versions { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0 .3rem; }
.req-versions .btn.small { padding: .4rem .75rem; font-size: .82rem; }
.req-versions .btn.small.ghost { padding: .4rem .55rem; }
.gig-sheet.group {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  padding: .65rem .85rem; background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; text-decoration: none; color: var(--ink);
}
.gig-sheet.group .versions { display: flex; flex-wrap: wrap; gap: .35rem; margin-left: auto; }
.gig-sheet.group .ver-pill {
  display: inline-block; padding: .35rem .7rem;
  background: rgba(120,160,255,.18); color: #b0c8ff;
  border-radius: 999px; font-size: .82rem; text-decoration: none;
  border: 1px solid rgba(120,160,255,.35); font-weight: 600; min-height: 32px;
}
.gig-sheet.group .ver-pill:hover { background: rgba(120,160,255,.32); color: #fff; }
li.multi-version { list-style: none; margin: .4rem 0; padding: 0; }

/* Mobile tweaks — fill the viewport, big tap targets, no scroll-jank under sticky bars */
@media (max-width: 768px) {
  .viewer-bar { top: 0; padding: .4rem .6rem; gap: .3rem; }
  .viewer-bar .btn.small { padding: .35rem .55rem; font-size: .82rem; }
  .viewer-bar-title strong { font-size: .95rem; }
  .pdf-wrap { height: calc(100vh - 96px); height: calc(100dvh - 96px); }
  .img-viewer { padding: 0; align-items: flex-start; }
  .img-viewer img { max-width: 100%; max-height: none; width: 100%; height: auto; }
  .audio-ref { padding: .8rem; }
  /* Multi-version pills bigger on touch */
  .req-versions .btn.small, .req-versions .btn.small.ghost { padding: .55rem .85rem; min-height: 40px; }
  .gig-sheet.group { flex-direction: column; align-items: flex-start; }
  .gig-sheet.group .versions { margin-left: 0; width: 100%; }
  .gig-sheet.group .ver-pill { padding: .5rem .85rem; min-height: 40px; }
  .gigplan-section h2 { font-size: 1.15rem; }
  .gig-sheets li { margin: .5rem 0; }
}

/* Thumbnail variant — when card has a real image preview */
.sheet .thumb.thumb-img {
  overflow: hidden;
  position: relative;
  padding: 0;
  background: #1a1a1a;
  aspect-ratio: 4/3;
  width: 100%;
  max-width: 100%;
  max-height: 220px;
  display: block;
}
.sheet .thumb.thumb-img img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  display: block;
  position: absolute;
  inset: 0;
}
.sheet .thumb.thumb-img .ext {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0,0,0,.75);
  color: var(--accent);
  font-size: .65rem;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: .1em;
  z-index: 2;
}

/* Audio reference block (under the sheet viewer) */
.audio-ref { padding: 1rem 1.2rem; border-top: 1px solid var(--border); background: var(--panel); }
.audio-ref-title { margin: 0 0 .6rem; font-size: .95rem; color: var(--ink-dim); font-weight: 500; }
.ref-audio { width: 100%; max-width: 600px; }
.ref-embed { max-width: 700px; }
.ref-embed iframe { width: 100%; border: 0; border-radius: 8px; }
.ref-embed.yt iframe { aspect-ratio: 16/9; }
.ref-embed.spotify iframe { height: 152px; }
.ref-embed.apple iframe { height: 175px; }
.ref-embed.sc iframe { height: 120px; }
.ref-link a { color: var(--accent); }

/* Set list grid */
.setlist-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.setlist-card h3 { margin-top: 0; }

/* Gig mode */
.gig-mode .lib-head h1 { font-size: 2rem; }
.gig-list { display: grid; gap: 1.25rem; }
.gig-section h2 { color: var(--accent); border-bottom: 1px solid var(--border); padding-bottom: .35rem; }
.gig-sheets { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.gig-sheet {
  display: grid; grid-template-columns: 2.5rem 1fr auto 2rem;
  align-items: center; gap: .8rem;
  background: var(--panel); border: 1px solid var(--border);
  padding: .85rem 1rem; border-radius: 10px;
  color: var(--ink); text-decoration: none; font-size: 1.05rem;
}
.gig-sheet:hover { border-color: var(--accent); text-decoration: none; }
.gig-sheet .num { color: var(--accent); font-weight: 700; }
.gig-sheet .k { color: var(--muted); font-size: .85rem; }
.gig-sheet .go { color: var(--accent); }

/* Admin */
.admin-tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin: 1rem 0; }
.pane { display: none; }
.pane.active { display: block; }
.form-grid { display: grid; gap: .8rem 1.2rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form-grid label.wide { grid-column: 1 / -1; }
.admin-table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.admin-table th, .admin-table td { padding: .55rem .6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.admin-table th { color: var(--muted); font-weight: 500; font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; }
.audit { background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; max-height: 60vh; overflow: auto; font-size: .78rem; color: var(--ink-dim); }

/* Edit set list */
.edit-split { display: grid; gap: 1.5rem; grid-template-columns: 1.4fr 1fr; }
@media (max-width: 800px) { .edit-split { grid-template-columns: 1fr; } }
.section-box { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: .8rem 1rem; margin-bottom: .8rem; }
.section-box.active { border-color: var(--accent); }
.section-head { display: flex; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.section-head input { flex: 1; font-weight: 600; }
.section-sheets { list-style: none; padding: 0; min-height: 30px; margin: 0 0 .5rem; display: grid; gap: .35rem; }
.section-sheets li { display: flex; gap: .5rem; align-items: center; background: var(--panel-2); padding: .4rem .6rem; border-radius: 6px; border: 1px solid var(--border); }
.grip { color: var(--muted); cursor: grab; }
.lib-list { list-style: none; padding: 0; max-height: 70vh; overflow: auto; }
.lib-list li { display: grid; grid-template-columns: 1fr auto auto; gap: .5rem; padding: .55rem .6rem; border-bottom: 1px solid var(--border); align-items: center; }
.lib-title { font-weight: 500; }

/* Mobile */
@media (max-width: 600px) {
  .head-nav a { font-size: .85rem; }
  h1 { font-size: 1.5rem; }
  .sheet-grid { grid-template-columns: 1fr; }
  .container { padding: 1rem; }
}
@media print {
  .site-head, .site-foot, .row-actions, .head-nav { display: none !important; }
  body { background: #fff; color: #000; }
  .gig-sheet { background: #fff; color: #000; border: 1px solid #999; break-inside: avoid; }
}
