/* ============================================================
   OnePage — Worship Chart Maker (print-first, clean & minimal)
   ============================================================ */
:root{
  --bg:        oklch(0.984 0.004 95);
  --panel:     oklch(0.995 0.002 95);
  --ink:       oklch(0.255 0.012 70);
  --muted:     oklch(0.55 0.012 70);
  --faint:     oklch(0.7 0.01 75);
  --line:      oklch(0.9 0.006 80);
  --line-soft: oklch(0.94 0.005 80);
  --accent:    oklch(0.46 0.105 248);
  --accent-soft: oklch(0.93 0.03 248);
  --paper:     #fdfcf9;
  --ui: "Hanken Grotesk", system-ui, sans-serif;
  --serif: "Spectral", Georgia, serif;

  --danger:      #b42318;
  --danger-soft: #fef3f2;
  --danger-line: #fecdca;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-pill: 999px;
  --radius: var(--r-md);

  --shadow-sm: 0 1px 2px rgba(20,18,16,.06);
  --shadow-md: 0 4px 16px rgba(20,18,16,.10);
  --shadow-lg: 0 12px 40px rgba(20,18,16,.18);
}
*{ box-sizing:border-box; }
html,body{ margin:0; padding:0; }
body{
  font-family:var(--ui);
  color:var(--ink);
  background:var(--bg);
  -webkit-font-smoothing:antialiased;
  font-weight:500;
}
button{ font-family:inherit; cursor:pointer; }
h1,h2,h3{ margin:0; font-weight:700; letter-spacing:-0.01em; }

:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; }

/* ---------- buttons ---------- */
.btn{ border:1px solid var(--line); background:var(--panel); color:var(--ink);
  padding:9px 15px; border-radius:var(--r-md); font-weight:600; font-size:14px; transition:.15s; }
.btn:hover{ border-color:var(--accent); color:var(--accent); }
.btn--primary{ background:var(--accent); border-color:var(--accent); color:#fff; }
.btn--primary:hover{ filter:brightness(1.08); color:#fff; }
.btn--ghost{ background:transparent; }
.btn--sm{ padding:6px 11px; font-size:13px; }
.btn--danger{ color:var(--danger); border-color:var(--danger-line); background:var(--panel); }
.btn--danger:hover{ background:var(--danger); border-color:var(--danger); color:#fff; }
.btn--toggled{ background:var(--accent-soft); border-color:var(--accent); color:var(--accent); }
.btn--toggled:hover{ filter:brightness(0.97); }

/* ---------- topbar ---------- */
.app{ min-height:100vh; }
.topbar{ height:56px; display:flex; align-items:center; justify-content:space-between;
  padding:0 22px; border-bottom:1px solid var(--line); background:var(--panel);
  position:sticky; top:0; z-index:50; }
.topbar__left{ display:flex; align-items:center; gap:14px; }
.navtoggle{ display:flex; flex-direction:column; justify-content:center; gap:4px; width:32px; height:32px;
  padding:8px; border:1px solid var(--line); border-radius:var(--r-md); background:transparent; cursor:pointer; }
.navtoggle:hover{ border-color:var(--accent); }
.navtoggle span{ display:block; height:2px; border-radius:2px; background:var(--ink); }
.brand{ font-weight:800; font-size:18px; letter-spacing:-0.02em; display:flex; align-items:center; gap:8px; }
.brand em{ font-style:normal; font-weight:500; color:var(--muted); font-size:14px; }
.brand__mark{ color:var(--accent); font-size:18px; }
.brand__right{ display:flex; align-items:center; gap:16px; }
.muted{ color:var(--faint); font-size:13px; }
.save-warn{ display:flex; align-items:center; gap:6px; color:var(--danger); font-size:13px; font-weight:600;
  background:var(--danger-soft); border:1px solid var(--danger-line); border-radius:var(--r-pill); padding:4px 10px; }
.save-warn button{ border:none; background:none; color:var(--danger); cursor:pointer; padding:0; font-size:12px; }
.userchip{ display:flex; align-items:center; gap:8px; border:1px solid var(--line);
  background:var(--panel); border-radius:var(--r-pill); padding:4px 12px 4px 4px; font-size:13px; font-weight:600; color:var(--ink); cursor:pointer; }
.userchip:hover{ border-color:var(--accent); }
.avatar{ width:26px; height:26px; border-radius:50%; background:var(--accent); color:#fff;
  display:grid; place-items:center; font-size:13px; font-weight:700; }

/* ---------- auth ---------- */
.auth{ min-height:100vh; display:grid; place-items:center; padding:24px; }
.auth__card{ width:100%; max-width:380px; background:var(--panel); border:1px solid var(--line);
  border-radius:var(--r-lg); padding:32px 28px; }
.auth__back.btn, .auth__back{ margin-bottom:16px; }
.auth__brand{ margin-bottom:20px; }
.auth__card h1{ font-size:22px; margin:0 0 6px; }
.auth__lead{ color:var(--muted); margin:0 0 22px; font-size:14px; }
.auth__card form{ display:flex; flex-direction:column; gap:14px; }
.auth__card label{ display:flex; flex-direction:column; gap:6px; font-size:13px; font-weight:600; color:var(--ink); }
.auth__card input{ border:1px solid var(--line); background:var(--bg); border-radius:var(--r-sm);
  padding:8px 12px; font-size:14px; color:var(--ink); }
.auth__card input:focus{ border-color:var(--accent); }
.auth__submit{ margin-top:4px; justify-content:center; }
.auth__err{ color:var(--danger); font-size:13px; }
.auth__notice{ color:var(--accent); font-size:13px; }
.auth__switch{ margin-top:18px; font-size:13px; color:var(--muted); text-align:center; }
.auth__switch .btn{ margin-left:2px; }

/* ---------- shell + sidebar ---------- */
.shell{ display:flex; align-items:flex-start; min-height:calc(100vh - 56px); }
.navdrawer-overlay{ display:none; }
.nav{ position:sticky; top:56px; width:212px; flex-shrink:0; align-self:stretch;
  border-right:1px solid var(--line); background:var(--panel); padding:18px 12px; display:flex; flex-direction:column; gap:4px; }
.nav__group{ font-size:11px; font-weight:700; letter-spacing:0.06em; text-transform:uppercase; color:var(--faint); padding:4px 12px 6px; }
.nav__item{ display:flex; align-items:center; gap:10px; width:100%; text-align:left; border:none; cursor:pointer;
  background:transparent; border-radius:var(--r-md); padding:10px 12px; font-size:14px; font-weight:600; color:var(--ink); }
.nav__item:hover{ background:var(--accent-soft); }
.nav__item.on{ background:var(--accent-soft); color:var(--accent); }
.nav__lock{ margin-left:auto; color:var(--faint); }
.shell__content{ flex:1; min-width:0; }
.shell__content .lib{ margin:0; max-width:none; }

/* ---------- viewer ---------- */
.viewer{ max-width:920px; margin:0 auto; padding:20px 24px 80px; }
.viewer__bar{ display:flex; align-items:center; gap:16px; margin-bottom:20px; }
.viewer__meta{ display:flex; flex-direction:column; gap:2px; flex:1; min-width:0; }
.viewer__meta strong{ font-size:16px; }
.viewer__placeholder{ border:1px dashed var(--line); border-radius:var(--r-md); padding:48px 24px; text-align:center; color:var(--ink); background:var(--panel); }
.viewer__placeholder p{ margin:0 0 8px; }

/* ---------- profile ---------- */
.profile{ max-width:1000px; margin:0 auto; padding:0 24px 80px; }
.profile__hero{ display:flex; align-items:center; gap:20px; padding:32px 0; }
.profile__avatar{ width:64px; height:64px; border-radius:50%; background:var(--accent); color:#fff;
  display:grid; place-items:center; font-size:26px; font-weight:700; flex-shrink:0; }
.profile__hero h1{ font-size:24px; margin:0; }
.profile__hero p{ margin:4px 0 0; }
.profile__about{ max-width:680px; margin:-18px 0 28px; color:var(--muted); font-size:14px; line-height:1.5; }
.handle-link{ border:none; background:none; padding:0; margin:0; font:inherit; color:inherit; cursor:pointer; }
.handle-link:hover{ color:var(--accent); text-decoration:underline; }

/* ---------- setlist print view ---------- */
.setprint__bar{ display:flex; align-items:center; gap:16px; padding:14px 24px; border-bottom:1px solid var(--line); background:var(--panel); position:sticky; top:0; z-index:5; }
.setprint__meta{ display:flex; flex-direction:column; gap:2px; flex:1; min-width:0; }
.setprint__meta strong{ font-size:16px; }
.setprint__body{ display:flex; flex-direction:column; align-items:center; gap:24px; padding:24px; }
.setprint__body .page{ box-shadow:var(--shadow-md); }

/* ---------- library ---------- */
.lib{ max-width:1080px; margin:0 auto; padding:32px 24px 80px; }
.lib__hero{ display:flex; justify-content:space-between; align-items:flex-end; gap:24px; margin-bottom:24px; }
.lib__hero h1{ font-size:28px; }
.lib__hero p{ margin:6px 0 0; color:var(--muted); }
.lib__actions{ display:flex; align-items:center; justify-content:flex-end; gap:12px; flex-shrink:0; }
.lib__import-actions{ display:flex; align-items:center; gap:8px; }
.lib__actions .btn{ min-height:40px; white-space:nowrap; }
.lib__new-chart{ box-shadow:var(--shadow-sm); }
.lib__filters{ display:flex; gap:8px; margin-bottom:20px; flex-wrap:wrap; }
.lib__search{ flex:1; min-width:0; border:1px solid var(--line); background:var(--panel); border-radius:var(--r-sm);
  padding:8px 12px; font-size:14px; color:var(--ink); }
.lib__filters select{ border:1px solid var(--line); background:var(--panel); border-radius:var(--r-sm);
  padding:8px 12px; font-size:14px; color:var(--ink); }
.lib__setlists{ display:flex; flex-wrap:wrap; align-items:center; gap:8px; margin-bottom:20px; }
.lib__setlists-lbl{ font-size:13px; color:var(--muted); font-weight:600; }
.chip-pill{ display:inline-flex; align-items:center; gap:6px; background:var(--accent-soft); color:var(--accent);
  border-radius:var(--r-pill); padding:3px 6px 3px 9px; font-size:11px; font-weight:600; }
.chip-pill button{ border:none; background:none; color:var(--accent); cursor:pointer; font-size:12px; line-height:1; padding:2px; opacity:.6; }
.chip-pill button:hover{ opacity:1; }
.lib__setlists-new{ border:1px dashed var(--line); background:transparent; border-radius:var(--r-pill); padding:5px 12px; font-size:13px; color:var(--ink); width:130px; }
.lib__group{ margin-bottom:32px; }
.lib__group-hd{ font-size:18px; margin-bottom:16px; display:flex; align-items:center; gap:10px; }
.lib__group-ct{ font-size:12px; font-weight:600; color:var(--faint); background:var(--panel); border:1px solid var(--line); border-radius:var(--r-pill); padding:1px 9px; }
.lib__grid{ display:grid; grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); gap:16px; }
.card__fold{ position:absolute; top:10px; right:34px; border:none; background:none; cursor:pointer; color:var(--faint); font-size:14px; line-height:1; padding:2px; }
.card__fold:hover{ color:var(--accent); }
.card__tags{ display:flex; flex-wrap:wrap; gap:5px; margin-top:10px; }
.card__tag{ font-size:11px; font-weight:600; color:var(--accent); background:var(--accent-soft); border-radius:var(--r-pill); padding:3px 9px; }
.foldmenu{ position:absolute; top:34px; right:10px; z-index:5; width:200px; background:var(--panel);
  border:1px solid var(--line); border-radius:var(--r-md); box-shadow:var(--shadow-lg); padding:8px; }
.foldmenu__hd{ font-size:11px; text-transform:uppercase; letter-spacing:.04em; color:var(--faint); margin:2px 4px 6px; }
.foldmenu__empty{ font-size:12px; color:var(--muted); padding:4px; }
.foldmenu__row{ display:flex; align-items:center; gap:8px; font-size:13px; padding:5px 4px; cursor:pointer; }
.foldmenu__row:hover{ background:var(--accent-soft); border-radius:var(--r-sm); }
.foldmenu__new{ margin-top:6px; padding-top:6px; border-top:1px solid var(--line); }
.foldmenu__new input{ width:100%; border:1px solid var(--line); border-radius:var(--r-sm); padding:8px 12px; font-size:13px; }
.setfield{ display:flex; flex-direction:column; gap:8px; }
.setfield__lbl{ font-size:13px; color:var(--muted); font-weight:600; }
.setfield__list{ display:flex; flex-wrap:wrap; gap:6px; }
.setfield__empty{ font-size:12px; color:var(--muted); }
.fields .setfield__chk{ display:inline-flex; align-items:center; gap:6px; font-size:11px; font-weight:600; color:var(--ink);
  border:1px solid var(--line); border-radius:var(--r-pill); padding:3px 9px; cursor:pointer; margin:0; width:auto; }
.fields .setfield__chk.on{ background:var(--accent-soft); border-color:var(--accent); color:var(--accent); }
.fields .setfield__chk input{ display:none; width:auto; margin:0; }
.fields .setfield__new{ border:1px dashed var(--line); background:transparent; border-radius:var(--r-sm); padding:8px 12px; font-size:13px; margin-top:0; }
.card{ position:relative; background:var(--panel); border:1px solid var(--line); border-radius:var(--r-md);
  padding:16px; cursor:pointer; transition:.15s; }
.card:hover{ border-color:var(--accent); box-shadow:var(--shadow-md); transform:translateY(-1px); }
.card:focus-visible{ border-color:var(--accent); box-shadow:var(--shadow-md); }
.card__mini{ display:flex; gap:5px; margin-bottom:12px; flex-wrap:wrap; }
.card__chip{ font-size:11px; font-weight:600; color:var(--accent); background:var(--accent-soft);
  border-radius:var(--r-pill); padding:3px 9px; letter-spacing:.02em; }
.card__title{ font-weight:700; font-size:16px; }
.card__sub{ color:var(--muted); font-size:13px; margin-top:2px; }
.card__meta{ display:flex; gap:10px; flex-wrap:wrap; margin-top:12px; color:var(--faint); font-size:12px; align-items:center; }
.card__meta span{ position:relative; }
.card__meta .handle-link{ font-size:12px; color:var(--faint); }
.card__meta .handle-link:hover{ color:var(--accent); }
.card__meta .like-btn{ margin-left:auto; font-size:11px; padding:1px 8px; }
.card__del{ position:absolute; top:10px; right:10px; border:none; background:transparent; color:var(--faint);
  font-size:13px; opacity:0; transition:.15s; padding:4px; }
.card:hover .card__del, .card:focus-within .card__del{ opacity:1; }
.card__del:hover{ color:var(--danger); }

.like-btn{ display:inline-flex; align-items:center; gap:4px; border:1px solid var(--line); background:var(--panel);
  color:var(--faint); border-radius:var(--r-pill); padding:2px 9px; font-size:12px; font-weight:600; cursor:pointer;
  line-height:1.6; transition:.15s; align-self:center; flex-shrink:0; width:max-content; }
.like-btn:hover{ border-color:var(--accent); color:var(--accent); }
.like-btn__icon{ font-size:12px; }
.like-btn--on{ background:var(--accent-soft); border-color:var(--accent); color:var(--accent); }

.lib__section{ margin-top:40px; }
.lib__section h2{ font-size:18px; display:flex; align-items:center; gap:10px; margin-bottom:16px; }
.tag{ font-size:11px; font-weight:600; color:var(--muted); background:var(--line-soft); padding:3px 9px; border-radius:var(--r-pill); letter-spacing:0; }
.card--community{ cursor:default; }
.card--community:hover{ transform:none; }
.lib__note{ color:var(--faint); font-size:12px; margin-top:16px; max-width:620px; line-height:1.5; }

/* ---------- editor ---------- */
.editor{ display:grid; grid-template-columns:392px 1fr; height:calc(100vh - 56px); }
.editor__controls{ border-right:1px solid var(--line); display:flex; flex-direction:column;
  background:var(--panel); overflow:hidden; }
.ctl__top{ display:flex; justify-content:space-between; align-items:center; padding:14px 16px; border-bottom:1px solid var(--line-soft); }
.ctl__topright{ display:flex; gap:8px; }
.tabs{ display:flex; gap:4px; padding:12px 16px 0; }
.tabs button{ flex:1; border:none; background:transparent; padding:9px 4px; font-size:13px; font-weight:600;
  color:var(--muted); border-bottom:2px solid transparent; }
.tabs button.on{ color:var(--accent); border-bottom-color:var(--accent); }
.pane{ flex:1; overflow-y:auto; padding:16px; }
.hint{ font-size:13px; color:var(--muted); line-height:1.55; margin:0 0 12px; }
.hint code{ background:var(--line-soft); padding:1px 5px; border-radius:var(--r-sm); font-size:12px; }
.raw{ width:100%; height:calc(100% - 132px); min-height:300px; resize:none; border:1px solid var(--line);
  border-radius:var(--r-md); padding:12px; font-family:"Hanken Grotesk", monospace; font-size:13px; line-height:1.6;
  color:var(--ink); background:var(--bg); tab-size:4; }
.raw:focus{ border-color:var(--accent); }
.raw-tools{ display:flex; align-items:flex-start; gap:10px; }
.raw-tools .hint{ flex:1; margin-bottom:6px; }
.cleanup{ flex-shrink:0; white-space:nowrap; display:inline-flex; align-items:center; gap:6px; }
.cleanup:disabled{ opacity:.5; cursor:default; }
.hint--ai{ margin:0 0 10px; }
.linklike{ border:none; background:none; padding:0; margin-left:4px; color:var(--accent); font-weight:700;
  font-size:inherit; cursor:pointer; text-decoration:underline; text-underline-offset:2px; }
.modal{ position:fixed; inset:0; z-index:2000; background:rgba(20,18,16,.5); backdrop-filter:blur(2px);
  display:flex; align-items:center; justify-content:center; padding:24px; }
.modal__card{ width:min(440px,100%); background:var(--panel); border:1px solid var(--line); border-radius:var(--r-lg);
  padding:22px 22px 18px; box-shadow:var(--shadow-lg); }
.modal__card h3{ margin:0 0 8px; font-size:18px; font-weight:700; }
.modal__lead{ margin:0 0 14px; font-size:13px; line-height:1.5; color:var(--muted); }
.modal__in{ width:100%; border:1px solid var(--line); border-radius:var(--r-sm); padding:8px 12px; font-family:inherit;
  font-size:14px; background:var(--bg); color:var(--ink); }
.modal__in:focus{ border-color:var(--accent); }
.modal__hint{ margin:9px 0 0; font-size:12px; line-height:1.5; color:var(--faint); }
.modal__hint b{ color:var(--muted); }
.modal__row{ display:flex; align-items:center; gap:8px; margin-top:16px; }
.modal__card.driveimp{ width:min(1040px,100%); max-height:calc(100vh - 48px); overflow:auto; }
.driveimp__choose{ display:flex; flex-wrap:wrap; gap:8px; margin:16px 0 4px; }
.driveimp__summary{ padding:9px 12px; margin:12px 0; border-radius:var(--r-sm); background:var(--bg); color:var(--muted); font-size:12px; }
.driveimp__body{ display:grid; grid-template-columns:minmax(280px,.8fr) minmax(360px,1.2fr); gap:16px; min-height:420px; }
.driveimp__list{ border:1px solid var(--line); border-radius:var(--r-sm); overflow:auto; max-height:56vh; background:var(--bg); }
.driveimp__row{ width:100%; display:grid; grid-template-columns:auto 1fr auto; gap:9px; align-items:center; text-align:left; padding:9px 10px; border:0; border-bottom:1px solid var(--line-soft); background:transparent; color:var(--ink); cursor:pointer; }
.driveimp__row:focus-visible{ outline:2px solid var(--accent); outline-offset:-2px; }
.driveimp__row.on{ background:var(--accent-soft); }
.driveimp__row span{ min-width:0; }
.driveimp__row b,.driveimp__row small{ display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.driveimp__row b{ font-size:12px; }.driveimp__row small{ color:var(--faint); margin-top:2px; }
.driveimp__row em{ width:19px; height:19px; border-radius:50%; display:grid; place-items:center; background:var(--danger-soft); color:var(--danger); font-style:normal; font-weight:800; }
.driveimp__detail{ border:1px solid var(--line); border-radius:var(--r-sm); padding:14px; overflow:auto; max-height:56vh; }
.driveimp__detail .fields label{ margin-bottom:9px; }
.driveimp__warnings{ margin:8px 0; padding:9px 10px 9px 28px; border-radius:var(--r-sm); background:var(--danger-soft); color:var(--danger); font-size:11px; }
.driveimp__preview{ max-height:170px; overflow:auto; margin:10px 0; padding:10px; border-radius:var(--r-sm); background:var(--bg); border:1px solid var(--line-soft); font:11px/1.35 var(--mono); white-space:pre-wrap; }
.driveimp__previewbar{ display:flex; align-items:center; justify-content:space-between; gap:10px; margin-top:10px; font-size:11px; font-weight:700; color:var(--muted); }
.driveimp__preview-actions{ display:flex; align-items:center; justify-content:flex-end; gap:6px; flex-wrap:wrap; }
.driveimp__chart{ display:block; width:100%; height:260px; overflow:hidden; margin:8px 0 10px; padding:0; text-align:left; border:1px solid var(--line); border-radius:var(--r-sm); background:#dedbd3; cursor:zoom-in; }
.driveimp__chart:hover{ border-color:var(--accent); box-shadow:var(--shadow-sm); }
.driveimp__chart-inner{ display:block; width:816px; transform:scale(.36); transform-origin:top left; pointer-events:none; }
.importpreview{ position:fixed; inset:0; z-index:2200; display:flex; align-items:center; justify-content:center; padding:24px; background:rgba(20,18,16,.72); backdrop-filter:blur(3px); }
.importpreview__card{ width:min(1040px,100%); height:min(94vh,1120px); display:flex; flex-direction:column; overflow:hidden; border:1px solid var(--line); border-radius:var(--r-lg); background:var(--panel); box-shadow:var(--shadow-lg); }
.importpreview__head{ flex:none; display:flex; align-items:center; justify-content:space-between; gap:18px; padding:16px 18px; border-bottom:1px solid var(--line); }
.importpreview__head h3{ margin:0; }.importpreview__head p{ margin:3px 0 0; font-size:12px; color:var(--muted); }
.importpreview__scroll{ flex:1; overflow:auto; padding:24px; background:#dedbd3; }
.importpreview__page{ width:816px; margin:0 auto; }
.driveimp__detail details{ font-size:11px; color:var(--muted); }
.driveimp__attest{ display:flex; gap:8px; align-items:flex-start; margin-top:14px; font-size:12px; line-height:1.4; color:var(--muted); }
@media(max-width:760px){ .driveimp__body{ grid-template-columns:1fr; }.driveimp__detail{ max-height:none; }.driveimp__list{ max-height:230px; }.importpreview{ padding:8px; }.importpreview__card{ height:calc(100vh - 16px); }.importpreview__scroll{ padding:12px; }.importpreview__page{ margin:0; } }
.spin{ width:12px; height:12px; border:2px solid var(--line); border-top-color:var(--accent);
  border-radius:50%; display:inline-block; animation:spin .7s linear infinite; }
@keyframes spin{ to{ transform:rotate(360deg); } }

/* ---------- toast ---------- */
.toast{ position:fixed; bottom:24px; left:50%; transform:translateX(-50%); z-index:3000;
  background:var(--panel); color:var(--ink); border:1px solid var(--line); border-radius:var(--r-md);
  padding:12px 16px; font-size:13px; font-weight:600; box-shadow:var(--shadow-md); max-width:min(420px,90vw); }
.toast--error{ border-color:var(--danger-line); background:var(--danger-soft); color:var(--danger); }

.fields label{ display:block; font-size:12px; font-weight:600; color:var(--muted); margin-bottom:14px; }
.fields input, .fields select{ display:block; width:100%; margin-top:5px; padding:8px 12px; border:1px solid var(--line);
  border-radius:var(--r-sm); font-family:inherit; font-size:14px; color:var(--ink); background:var(--bg); font-weight:500; }
.fields input:focus, .fields select:focus{ border-color:var(--accent); }
.row2{ display:grid; grid-template-columns:1fr 1fr; gap:12px; }

/* roadmap editor */
.rme__row{ display:grid; grid-template-columns:24px 1fr 46px 58px; gap:6px; align-items:center; margin-bottom:8px; }
.rme__row > select, .rme__row input{ border:1px solid var(--line); border-radius:var(--r-sm); padding:6px 7px;
  font-family:inherit; font-size:12px; background:var(--bg); color:var(--ink); width:100%; }
.rme__ord{ display:flex; flex-direction:column; gap:1px; }
.rme__ord button{ border:1px solid var(--line); background:var(--bg); font-size:8px; line-height:1; padding:2px; border-radius:var(--r-sm); color:var(--muted); }
.rme__ord button:disabled{ opacity:.3; }
.rme__rep{ display:flex; align-items:center; gap:2px; font-size:12px; color:var(--muted); }
.rme__rep input{ width:34px; padding:6px 4px; text-align:center; }
.rme__cue{ grid-column:2 / 5; }
.rme__rm{ border:none; background:transparent; color:var(--faint); font-size:12px; }
.rme__rm:hover{ color:var(--danger); }
.rme__row{ position:relative; }
.rme__actions{ display:flex; gap:8px; margin-top:12px; }

.ctl__bottom{ border-top:1px solid var(--line-soft); padding:12px 16px; display:flex; flex-direction:column; gap:12px; }
.transpose{ display:flex; align-items:center; gap:8px; }
.transpose .lbl{ font-size:12px; font-weight:600; color:var(--muted); margin-right:auto; }
.transpose button{ width:30px; height:30px; border:1px solid var(--line); background:var(--bg); border-radius:var(--r-sm);
  font-size:16px; font-weight:700; color:var(--ink); }
.transpose button:hover{ border-color:var(--accent); color:var(--accent); }
.transpose .keyout{ min-width:60px; text-align:center; font-weight:700; font-size:14px; }
.transpose .reset{ width:auto; padding:0 9px; font-size:11px; font-weight:600; height:26px; }
.toggles{ display:flex; gap:8px; }
.tg{ flex:1; display:flex; align-items:center; gap:7px; justify-content:center; border:1px solid var(--line);
  border-radius:var(--r-sm); padding:8px; font-size:13px; font-weight:600; color:var(--muted); }
.tg.on{ border-color:var(--accent); color:var(--accent); background:var(--accent-soft); }
.tg input{ accent-color:var(--accent); }

.editor__preview{ overflow:auto; background:oklch(0.93 0.006 85); display:flex; flex-direction:column; }
.preview__bar{ display:flex; align-items:center; gap:14px; padding:10px 16px; background:var(--panel);
  border-bottom:1px solid var(--line); position:sticky; top:0; z-index:10; }
.tg--sm{ flex:0 0 auto; padding:6px 11px; font-size:12px; }
.bar-warn{ font-size:12px; font-weight:700; color:var(--danger); display:inline-flex; align-items:center; gap:5px; }
.bar-warn b{ color:var(--danger); }
.ctl__topright .icon{ padding:6px 9px; font-size:14px; line-height:1; font-weight:700; }
.ctl__topright .icon:disabled{ opacity:.35; cursor:default; border-color:var(--line); color:var(--ink); }
.preview__bar-hint{ font-size:12px; color:var(--muted); line-height:1.4; }
.preview__share{ margin-left:auto; flex-shrink:0; }
.preview__bar-hint b{ color:var(--accent); }
.preview__scroll{ padding:24px; display:block; }
.fit{ position:relative; width:100%; margin:0 auto; }
.fit__inner{ position:absolute; top:0; left:0; transform-origin:top left; }
.page-guide{ position:absolute; left:0; right:0; border-top:2px dashed var(--danger); pointer-events:none; z-index:4; }
.page-guide__label{ position:absolute; right:0; top:0; background:var(--danger); color:#fff; font-size:11px; font-weight:800;
  letter-spacing:.04em; padding:2px 8px; border-radius:0 0 0 7px; }
.fit__warn{ position:absolute; top:10px; left:50%; transform:translateX(-50%); background:var(--danger); color:#fff;
  font-size:12px; font-weight:700; padding:6px 14px; border-radius:var(--r-pill); pointer-events:none; z-index:6;
  box-shadow:var(--shadow-md); white-space:nowrap; max-width:92%; }

/* ============================================================
   THE CHART (print target)
   ============================================================ */
.page{ width:816px; min-height:1056px; background:var(--paper); padding:48px; box-shadow:0 4px 30px -10px rgba(0,0,0,.25);
  border:1px solid var(--line-soft); display:flex; flex-direction:column; }
.chead{ display:flex; justify-content:space-between; align-items:flex-start; gap:24px;
  border-bottom:2px solid var(--ink); padding-bottom:12px; }
.chead__title{ font-family:var(--serif); font-size:32px; font-weight:600; letter-spacing:-0.01em; line-height:1.04; }
.chead__sub{ color:var(--muted); font-size:15px; margin-top:5px; font-weight:500; }
.chead__credits{ color:var(--faint); font-size:10.5px; line-height:1.25; margin-top:2px; max-width:470px; }
.chead__meta{ display:flex; gap:18px; flex-shrink:0; padding-top:4px; }
.meta{ display:flex; flex-direction:column; align-items:flex-end; }
.meta label{ font-size:10px; text-transform:uppercase; letter-spacing:.08em; color:var(--faint); font-weight:700; }
.meta b{ font-size:15px; font-weight:700; }
.chead__scripture{ font-style:italic; color:var(--muted); font-size:10.5px; line-height:1.25; margin-top:3px; }

.cbody{ display:flex; gap:30px; margin-top:22px; align-items:flex-start; flex:1; }
.sections{ flex:1; column-count:2; column-gap:30px; }
.rail{ width:calc(188px * var(--rail-scale, 1)); flex-shrink:0; font-size:calc(12.5px * var(--rail-scale, 1)); }
.cbody--off .rail{ display:none; }
.cbody--right .rail{ order:2; border-left:1.5px solid var(--line); padding-left:24px; }
.cbody--right .sections{ order:1; }
.cbody--left .rail{ order:1; border-right:1.5px solid var(--line); padding-right:24px; }
.cbody--left .sections{ order:2; }
/* roadmap as a horizontal strip above or below the chart */
.cbody--top, .cbody--bottom{ flex-direction:column; gap:18px; }
.cbody--top .rail, .cbody--bottom .rail{ width:auto; }
.cbody--top .rail{ order:1; border-bottom:1.5px solid var(--line); padding-bottom:14px; }
.cbody--top .sections{ order:2; }
.cbody--bottom .rail{ order:2; border-top:1.5px solid var(--line); padding-top:14px; }
.cbody--bottom .sections{ order:1; }
.cbody--top .rail__list, .cbody--bottom .rail__list{ display:flex; flex-wrap:wrap; gap:7px 18px; }
.cbody--top .step, .cbody--bottom .step{ border-bottom:none; padding:2px 0; }
.cbody--top .rail__legend, .cbody--bottom .rail__legend{ border-top:none; padding-top:6px; margin-top:8px; }
.rail__title{ font-size:0.88em; font-weight:800; text-transform:uppercase; letter-spacing:.12em; color:var(--accent); margin-bottom:12px; }
.rail__list{ list-style:none; margin:0; padding:0; counter-reset:step; }
.step{ display:flex; gap:9px; padding:6px 0; border-bottom:1px dotted var(--line); align-items:flex-start; }
.step:last-child{ border-bottom:none; }
.step__code{ flex-shrink:0; min-width:30px; text-align:center; border:1.5px solid; border-radius:6px;
  font-weight:800; font-size:1em; padding:3px 5px; line-height:1.1; }
.step__code em{ font-style:normal; font-weight:600; font-size:0.8em; display:block; }
.step__meta{ display:flex; flex-direction:column; gap:1px; padding-top:1px; }
.step__name{ font-size:1em; font-weight:600; }
.step__cue{ font-size:0.92em; color:var(--muted); display:flex; gap:6px; flex-wrap:wrap; align-items:baseline; line-height:1.35; }
.dyn{ font-style:italic; font-weight:800; font-family:var(--serif); }
.rail__legend{ margin-top:16px; padding-top:12px; border-top:1px solid var(--line); display:flex; flex-wrap:wrap;
  gap:8px 12px; font-size:0.84em; color:var(--faint); }
.rail__legend b{ font-family:var(--serif); font-style:italic; }

/* sections — compact, flow in columns, fill the page */
.sections{ column-count:var(--cols, 2); }
.sec{ break-inside:avoid; margin-bottom:calc(18px * var(--sec-space, 1)); }
.sec__head{ display:flex; align-items:center; gap:7px; margin-bottom:5px; border-bottom:1px solid var(--line); padding-bottom:3px; }
.sec__del{ margin-left:auto; border:none; background:transparent; color:var(--faint); font-size:12px; line-height:1;
  padding:3px 4px; border-radius:5px; opacity:0; transition:.12s; }
.sec:hover .sec__del{ opacity:1; }
.sec__del:hover{ color:#fff; background:#d9534f; }
.sec__code{ font-size:10px; font-weight:800; border:1.4px solid; border-radius:4px; padding:1px 5px; letter-spacing:.03em; }
.sec__label{ font-size:14px; font-weight:700; letter-spacing:.01em; }
.sec__body{ font-size:calc(15.5px * var(--text-scale, 1)); }

/* chord-over-lyric slots */
.ln{ display:flex; flex-wrap:wrap; align-items:flex-end; line-height:calc(1.15 * var(--line-space, 1)); margin:1px 0; font-size:calc(1em * var(--lfit, 1)); }
.ln--blank{ height:calc(8px * var(--line-space, 1)); }
.page--fit .ln{ flex-wrap:nowrap; white-space:nowrap; }
.word{ display:inline-flex; align-items:flex-end; flex-shrink:0; }
.slot{ display:inline-flex; flex-direction:column; vertical-align:bottom; }
.ch{ font-weight:700; font-size:calc(0.8em * var(--ch-size, 1)); line-height:1.25; height:1.35em; white-space:pre; letter-spacing:-0.01em; }
.ly{ white-space:pre; line-height:calc(1.3 * var(--line-space, 1)); font-family:var(--ly-font, inherit); }
.ln--chordrow{ gap:8px; margin:2px 0; align-items:center; }
.ch--solo{ font-weight:700; font-size:calc(0.92em * var(--ch-size, 1)); }
.ch--seq{ display:inline-flex; align-items:baseline; gap:6px; white-space:nowrap; }
.chsep{ color:var(--muted); font-weight:500; }

/* instrumental bar lines */
.barline{ display:flex; flex-wrap:wrap; margin:3px 0 5px; border:1px solid var(--line); border-radius:6px; overflow:hidden; width:fit-content; }
.bar{ display:flex; gap:7px; padding:5px 12px; border-right:1px solid var(--line); }
.bar:last-child{ border-right:none; }
.bar .ch{ height:auto; font-size:calc(14px * var(--ch-size, 1)); }

/* chord diagrams */
.diags{ display:flex; flex-wrap:wrap; gap:14px; margin-top:22px; padding-top:16px; border-top:1px solid var(--line); }
.diag{ display:flex; flex-direction:column; align-items:center; gap:2px; }
.diag__name{ font-size:11.5px; font-weight:700; }
.diag__box{ display:block; }
.diag__box--empty{ width:56px; height:70px; display:grid; place-items:center; color:var(--faint); }

/* on-chart chord editing */
.sec--editing .sec__body{ font-family:"Hanken Grotesk", monospace; }
.eln{ display:flex; flex-wrap:wrap; align-items:flex-end; margin:2px 0; }
.eln__cell{ display:inline-flex; flex-direction:column; align-items:flex-start; min-width:0.46em; }
.eln__chord{ height:1.5em; display:flex; align-items:flex-end; }
.eln__chip{ border:none; background:var(--accent-soft); border-radius:4px; padding:0 3px; font-weight:700;
  font-size:calc(0.8em * var(--ch-size, 1)); line-height:1.3; white-space:nowrap; }
.eln__chip:hover{ outline:1px solid var(--accent); }
.eln__add{ border:none; background:transparent; color:transparent; font-size:0.78em; line-height:1.3;
  padding:0 1px; font-weight:700; cursor:pointer; }
.eln__cell:hover .eln__add{ color:var(--faint); }
.eln__add:hover{ color:var(--accent) !important; }
.eln__in{ width:3.4em; border:1px solid var(--accent); border-radius:4px; padding:0 3px; font-family:inherit;
  font-size:0.8em; font-weight:700; color:var(--accent); background:#fff; }
.eln__in:focus{ border-color:var(--accent); }
.eln__ch2{ white-space:pre; line-height:1.32; cursor:text; border-bottom:1px dotted transparent; }
.eln__cell:hover .eln__ch2{ border-bottom-color:var(--line); }

.empty{ padding:48px 24px; text-align:center; color:var(--muted); display:flex; flex-direction:column;
  align-items:center; gap:8px; max-width:360px; margin:0 auto; }
.empty__glyph{ font-size:28px; color:var(--faint); margin-bottom:4px; }
.empty__title{ font-size:16px; font-weight:600; color:var(--ink); }
.empty__hint{ font-size:13px; color:var(--muted); line-height:1.5; }
.empty .btn{ margin-top:8px; }
.empty .spin{ margin-bottom:4px; }

/* ---------- editor first-chart starter card ---------- */
.starter{ max-width:420px; margin:40px auto; background:var(--panel); border:1px solid var(--line);
  border-radius:var(--r-lg); box-shadow:var(--shadow-sm); padding:28px 24px; }
.starter__title{ font-size:16px; font-weight:700; color:var(--ink); text-align:center; margin-bottom:20px; }
.starter__steps{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:16px; }
.starter__step{ display:flex; align-items:flex-start; gap:12px; }
.starter__num{ flex:none; font-size:12px; font-weight:700; color:var(--accent); background:var(--accent-soft);
  border-radius:50%; width:24px; height:24px; display:flex; align-items:center; justify-content:center; }
.starter__step-title{ font-size:13px; font-weight:600; color:var(--ink); }
.starter__step-hint{ font-size:12px; color:var(--muted); line-height:1.5; margin-top:2px; }

/* B&W chart: neutralise accent-tinted rail heading */
.page--mono .rail__title{ color:var(--ink); }

/* ---------- layout editor pane ---------- */
.lay{ display:flex; flex-direction:column; gap:18px; }
.lay__ctl{ display:flex; flex-direction:column; gap:7px; }
.lay__ctl-top{ display:flex; justify-content:space-between; align-items:baseline; font-size:12px; font-weight:600; color:var(--ink); }
.lay__val{ font-size:12px; font-weight:700; color:var(--accent); }
.lay__num{ width:60px; text-align:right; border:1px solid var(--line); border-radius:var(--r-sm); padding:4px 7px;
  font-family:inherit; font-size:12px; font-weight:700; color:var(--accent); background:var(--bg); }
.lay__num:focus{ border-color:var(--accent); }
.lay__switch{ display:inline-flex; align-items:center; gap:6px; font-size:11px; font-weight:700; color:var(--accent); cursor:pointer; }
.lay__switch input{ accent-color:var(--accent); }
.lay input[type=range]{ width:100%; accent-color:var(--accent); height:4px; }
.chord-colors{ display:flex; gap:8px; flex-wrap:wrap; }
.chord-colors button{ width:34px; height:34px; display:grid; place-items:center; border:1px solid var(--line);
  border-radius:var(--r-md); background:var(--bg); padding:0; }
.chord-colors button:hover{ border-color:var(--accent); }
.chord-colors button.on{ border-color:var(--accent); box-shadow:0 0 0 2px var(--accent-soft); }
.chord-colors button span{ width:18px; height:18px; border-radius:50%; box-shadow:inset 0 0 0 1px rgba(0,0,0,.12); }
.lay__color-hint{ font-size:11px; line-height:1.4; color:var(--faint); }
.seg{ display:flex; gap:0; border:1px solid var(--line); border-radius:var(--r-md); overflow:hidden; }
.seg button{ flex:1; border:none; background:var(--bg); padding:9px 0; font-size:13px; font-weight:700; color:var(--muted); border-right:1px solid var(--line); }
.seg button:last-child{ border-right:none; }
.seg button.on{ background:var(--accent); color:#fff; }
.lay__reorder{ display:flex; flex-direction:column; gap:8px; }
.ord{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:4px; }
.ord__row{ display:flex; align-items:center; gap:10px; border:1px solid var(--line); border-radius:var(--r-md); padding:8px; background:var(--bg); }
.ord__code{ font-size:11px; font-weight:700; color:var(--accent); background:var(--accent-soft); border-radius:var(--r-sm); padding:2px 7px; min-width:30px; text-align:center; }
.ord__name{ flex:1; font-size:13px; font-weight:600; }
.ord__btns{ display:flex; gap:4px; }
.ord__btns button{ width:26px; height:26px; border:1px solid var(--line); background:var(--panel); border-radius:var(--r-sm); font-size:9px; color:var(--muted); }
.ord__btns button:hover:not(:disabled){ border-color:var(--accent); color:var(--accent); }
.ord__btns button:disabled{ opacity:.3; cursor:default; }
.ord__del:hover:not(:disabled){ border-color:var(--danger-line) !important; color:var(--danger) !important; }
.ord__row--hidden{ opacity:.45; }
.ord__row--hidden .ord__name{ text-decoration:line-through; }
.lay__hint-sm{ font-size:11px; font-weight:600; color:var(--faint); letter-spacing:0; }
.lay__actions{ display:flex; gap:8px; }

/* ---------- viewer reading controls + dark chart theme ---------- */
.viewctl{ display:inline-flex; gap:4px; flex-shrink:0; }
.viewctl button{ min-width:34px; height:30px; border:1px solid var(--line); background:var(--panel);
  border-radius:var(--r-sm); font-size:12px; font-weight:600; color:var(--muted); }
.viewctl button:hover{ border-color:var(--accent); color:var(--accent); }
.chartdark{ background:#141210; border-radius:var(--r-md); padding:16px; }
  display:flex; align-items:center; gap:6px; background:var(--panel); border:1px solid var(--line);
  border-radius:var(--r-pill); padding:8px; box-shadow:var(--shadow-lg); }

.chartdark .page{ background:#1c1a17; color:#e9e6e1; box-shadow:none; border-color:#2a2724; }
.chartdark .chead{ border-bottom-color:#e9e6e1; }
.chartdark .chead__sub, .chartdark .chead__scripture{ color:#b7b0a4; }
.chartdark .meta label{ color:#8a8377; }
.chartdark .meta b{ color:#e9e6e1; }
.chartdark .sec__head{ border-bottom-color:#332f29; }
.chartdark .sec__code, .chartdark .step__code{ border-color:#8fb4e8 !important; color:#8fb4e8 !important; }
.chartdark .sec__label{ color:#e9e6e1; }
.chartdark .ly{ color:#e9e6e1; }
.chartdark .ch, .chartdark .ch--solo, .chartdark .ch--seq{ color:#8fb4e8 !important; }
.chartdark .chsep{ color:#8a8377; }
.chartdark .barline{ border-color:#332f29; }
.chartdark .bar{ border-right-color:#332f29; }
.chartdark .rail{ color:#e9e6e1; }
.chartdark .rail__title{ color:#8fb4e8; }
.chartdark .cbody--right .rail{ border-left-color:#332f29; }
.chartdark .cbody--left .rail{ border-right-color:#332f29; }
.chartdark .cbody--top .rail, .chartdark .cbody--bottom .rail{ border-color:#332f29; }
.chartdark .step{ border-bottom-color:#3a362f; }
.chartdark .step__name{ color:#e9e6e1; }
.chartdark .step__cue{ color:#b7b0a4; }
.chartdark .dyn{ color:#8fb4e8 !important; }
.chartdark .rail__legend{ border-top-color:#332f29; color:#8a8377; }
.chartdark .rail__legend b{ color:#8fb4e8 !important; }
.chartdark .muted{ color:#8a8377; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 860px){
  .navdrawer-overlay{ display:none; position:fixed; inset:0; background:rgba(20,18,16,.4); z-index:39; }
  .shell.navdrawer-open .navdrawer-overlay{ display:block; }
  .nav{ position:fixed; top:0; left:0; height:100vh; z-index:40; box-shadow:none;
    transform:translateX(-100%); transition:transform .18s ease; }
  .shell.navdrawer-open .nav{ transform:translateX(0); box-shadow:var(--shadow-lg); }

  .editor{ grid-template-columns:1fr; height:auto; }
  .editor__controls{ border-right:none; border-bottom:1px solid var(--line); max-height:45vh; }
  .editor__preview{ overflow:visible; }

  .topbar{ padding:0 12px; }
  .userchip span:not(.avatar){ display:none; }
  .userchip{ padding:4px; gap:0; }

  .lib__hero{ align-items:flex-start; flex-direction:column; gap:16px; }
  .lib__hero h1{ font-size:22px; }
  .lib__actions{ width:100%; justify-content:space-between; }
  .lib__filters{ flex-wrap:wrap; }
}

@media (max-width: 560px){
  .lib{ padding-left:16px; padding-right:16px; }
  .lib__actions{ align-items:stretch; flex-direction:column-reverse; gap:8px; }
  .lib__import-actions{ display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); }
  .lib__actions .btn{ width:100%; }
  .lib__import-actions .btn:only-child{ grid-column:1 / -1; }
}

/* ============================================================
   PRINT
   ============================================================ */
@page{ size:letter portrait; margin:0.5in; }
@media print{
  body{ background:#fff; }
  .topbar, .editor__controls{ display:none !important; }
  .editor{ display:block; height:auto; }
  .editor__preview{ overflow:visible; background:#fff; }
  .preview__scroll{ padding:0; display:block; }
  .fit{ height:auto !important; }
  .fit__inner{ transform:none !important; position:static !important; }
  .page{ width:100%; box-shadow:none; border:none; padding:0; }
  .card:hover{ box-shadow:none; }
  .page-guide, .fit__warn, .sec__del, .preview__bar, .starter{ display:none !important; }
  .toast, .modal, .navdrawer-overlay, .nav{ display:none !important; }
  .viewctl{ display:none !important; }
  .chartdark{ background:#fff; padding:0; }
  /* shared-sheet viewer: print only the chart */
  .viewer{ max-width:none; padding:0; margin:0; }
  .viewer__bar{ display:none !important; }
  .viewer .page{ box-shadow:none; border:none; }

  /* setlist print view: each song starts on a fresh sheet, no top bar */
  .setprint__bar{ display:none !important; }
  .setprint__body{ padding:0; gap:0; }
  .setprint .page{ break-after:page; box-shadow:none; border:none; width:100%; }
}
