/* Thème sombre, sur tous les appareils (application, présentation et tutoriel). */
:root {
  color-scheme: dark;
  --bg: #14111d; --card: #1f1b2c; --text: #eeeaf6; --muted: #a39db5; --line: #37314a;
  --accent: #a586f5; --accent-text: #15101f; --soft: #2c2540; --danger: #ef7b6e; --live: #f08a80; --rehearsal: #6fcfb0;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; padding-bottom: 5rem; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; line-height: 1.2; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .5rem; }
h3 { font-size: 1rem; margin: 0; }
.muted { color: var(--muted); font-size: .9rem; }
.pre { white-space: pre-wrap; }

.top { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .6rem 1rem; padding-top: max(.6rem, env(safe-area-inset-top)); background: #1b1530; color: #fff; }
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; min-width: 0; }
.brand img { height: 36px; width: 36px; object-fit: contain; border-radius: 8px; }
.brand > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand b { font-weight: 800; letter-spacing: -.01em; }
.brand b i { font-style: normal; color: #f472b6; }
.brand-band { font-weight: 500; opacity: .85; margin-left: .5rem; padding-left: .5rem; border-left: 1px solid rgba(255, 255, 255, .35); }
#sync-ind { text-decoration: none; font-size: 1.1rem; margin-left: auto; }
.me { font-size: .8rem; color: #cfc8e6; display: flex; align-items: center; gap: .4rem; white-space: nowrap; }
.me select { width: auto; padding: .3rem .4rem; background: #2c2447; color: #fff; border-color: #4a3f6e; }

.tabs { display: flex; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; overflow-x: auto; }
.tabs a { flex: 1; text-align: center; padding: .75rem .6rem; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .92rem; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }

main { max-width: 900px; margin: 0 auto; padding: 1rem; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.back { display: inline-block; margin-bottom: .5rem; text-decoration: none; font-size: .9rem; }

.btn { font: inherit; font-weight: 600; font-size: .9rem; padding: .5rem .85rem; border-radius: 9px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: .3rem; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.small { padding: .25rem .5rem; font-size: .85rem; }
.icon { font: inherit; border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: .35rem .5rem; border-radius: 7px; font-size: 1rem; line-height: 1; }
.icon:hover { background: var(--soft); color: var(--text); }
.icon:disabled { opacity: .25; cursor: default; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .8rem 1rem; margin-bottom: .6rem; }
a.card { display: block; text-decoration: none; color: inherit; }
a.card:hover { border-color: var(--accent); }
.row { display: flex; align-items: center; gap: .75rem; }
.row .grow { flex: 1; min-width: 0; }
.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: .12rem .5rem; border-radius: 99px; background: var(--soft); color: var(--accent); vertical-align: middle; white-space: nowrap; }
.badge.live { color: var(--live); }
.badge.repetition { color: var(--rehearsal); }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { background: var(--soft); border-radius: 99px; padding: .15rem .6rem; font-size: .85rem; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; border: 1px dashed var(--line); border-radius: 12px; }
.num { width: 1.8rem; height: 1.8rem; flex: none; border-radius: 50%; background: var(--soft); color: var(--accent); font-weight: 700; font-size: .85rem; display: grid; place-items: center; }
.mine { color: var(--accent); font-size: .88rem; font-weight: 600; }
.avatar { width: 56px; height: 56px; flex: none; border-radius: 50%; object-fit: cover; background: var(--soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 1.3rem; }
.top { background-size: cover; background-position: center; }
.hero { position: relative; min-height: 440px; aspect-ratio: 3 / 2; width: 100%; border-radius: 14px; padding: 1rem; display: flex; flex-direction: column; justify-content: flex-end; gap: .75rem; color: #fff;
  background: linear-gradient(135deg, #3a2a78, #1b1530); background-size: cover; background-position: center; }
.hero-edit { position: absolute; top: 1rem; right: 1rem; box-shadow: 0 2px 10px rgba(0, 0, 0, .4); }
.hero-info::after { content: ''; display: block; clear: both; }
.hero-info { background: rgba(20, 14, 40, .72); border-radius: 12px; padding: .7rem .9rem; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.hero h1 { font-size: 1.6rem; margin: 0 0 .4rem; }
.hero .logo-big { float: right; width: 20%; max-width: none; max-height: none; height: auto; margin: 0 0 .5rem .9rem; }
.hero-row { padding: .12rem 0; overflow-wrap: anywhere; }
.hero-row .k { display: inline-block; min-width: 10.5rem; color: #cfc8e6; font-size: .9rem; }
@media (max-width: 520px) { .hero-row .k { display: block; min-width: 0; font-size: .8rem; } }
.hero-info a { color: #e2d6ff; }
.hero-info p { margin: .5rem 0 0; font-size: .85rem; color: #cfc8e6; }
.logo-big { max-width: 96px; max-height: 96px; }
.logo-big { max-width: 160px; max-height: 160px; border-radius: 12px; }

dl.info { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
dl.info dt { color: var(--muted); font-size: .9rem; }
dl.info dd { margin: 0; overflow-wrap: anywhere; }
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; }

.att { display: flex; align-items: center; gap: .5rem; padding: .4rem 0; border-bottom: 1px solid var(--line); }
.att:last-child { border-bottom: 0; }
.att .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.att audio { display: block; width: 100%; max-width: 420px; margin-top: .3rem; height: 36px; }
.thumb { width: 96px; height: 72px; object-fit: cover; border-radius: 8px; display: block; }
.sec-head { display: flex; justify-content: space-between; align-items: center; margin: 1.5rem 0 .5rem; }
.sec-head h2 { margin: 0; }

input, select, textarea { font: inherit; width: 100%; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); }
input[type=checkbox] { width: 1.1rem; height: 1.1rem; flex: none; accent-color: var(--accent); }
textarea { min-height: 4.5rem; resize: vertical; }
label.f { display: block; margin-bottom: .7rem; font-size: .85rem; color: var(--muted); }
label.f > input, label.f > select, label.f > textarea { margin-top: .2rem; color: var(--text); font-size: 1rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .75rem; }
.checks { display: flex; flex-wrap: wrap; gap: .3rem .9rem; margin: .2rem 0 .5rem; }
.checks label, label.check { display: inline-flex; align-items: center; gap: .35rem; font-size: .95rem; color: var(--text); }
fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 0 0 .7rem; padding: .5rem .75rem; }
legend { font-weight: 600; font-size: .9rem; padding: 0 .3rem; }
.picklist { max-height: 45vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; margin: .5rem 0; }
.picklist label { display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; border-bottom: 1px solid var(--line); }
.picklist label:last-child { border-bottom: 0; }

dialog { border: 0; border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 1.5rem)); max-height: calc(100dvh - 2rem); background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(10, 6, 20, .6); }
#dlg-form { padding: 1rem 1.1rem; }
#dlg-title { margin: 0 0 .9rem; font-size: 1.15rem; }
.dlg-actions { display: flex; justify-content: flex-end; gap: .5rem; position: sticky; bottom: 0; background: var(--card); padding: .7rem 0 0; }

#offline { position: fixed; bottom: 0; left: 0; right: 0; background: #1b1530; color: #fff; text-align: center; font-size: .8rem; padding: .4rem; padding-bottom: max(.4rem, env(safe-area-inset-bottom)); }
#print-area { display: none; }

@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } .tabs a { font-size: .85rem; padding: .7rem .4rem; } }

@media print {
  :root { color-scheme: light; }
  @page { size: A4 landscape; margin: 10mm; }
  body { background: #fff; color: #000; padding: 0; font-size: 10pt; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block; }
  #print-area .p-head { display: flex; align-items: center; gap: 12pt; margin-bottom: 8pt; }
  #print-area .p-head img { height: 44pt; }
  #print-area h1 { font-size: 16pt; margin: 0; }
  #print-area table { font-size: 9.5pt; }
  #print-area th, #print-area td { border: 0.5pt solid #999; padding: 3pt 4pt; }
  #print-area th { background: #eee; color: #000; }
  #print-area tr { break-inside: avoid; }
  #print-area .muted { color: #444; font-size: 9pt; }
  #print-area .p-title { font-weight: 700; font-size: 10.5pt; }
}

.lineup { display: flex; flex-wrap: wrap; gap: .15rem .7rem; font-size: .88rem; margin-top: .15rem; }
.who { white-space: nowrap; }
.who.me { color: var(--accent); font-weight: 700; }

.grip { flex: none; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; color: var(--muted); font-size: 1.3rem; line-height: 1; padding: .6rem .35rem; margin: -.4rem -.35rem -.4rem -.5rem; }
.set-row.dragging { position: relative; z-index: 4; border-color: var(--accent); box-shadow: 0 8px 24px rgba(0, 0, 0, .25); }
.set-row.dragging .grip { cursor: grabbing; }

.poster { display: block; margin: 0 0 .75rem; }
.poster img { display: block; max-width: 100%; max-height: 420px; border-radius: 12px; border: 1px solid var(--line); }
.poster-thumb { width: 54px; height: 72px; flex: none; object-fit: cover; border-radius: 8px; }

#song-list.filtering .grip, #song-list.filtering .reorder { display: none; }

/* ---- Onglet Outils : tempo, accordeur, accords et gammes ---- */
main:has(.tl-scales) { max-width: 1400px; }
.tl-sub { display: flex; align-items: center; gap: .4rem; margin-bottom: .9rem; flex-wrap: wrap; }
.tl-sub a { text-decoration: none; font-weight: 600; font-size: .92rem; padding: .45rem .9rem; border-radius: 99px; border: 1px solid var(--line); background: var(--card); color: var(--text); }
.tl-sub a.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.tl-mini { margin-left: auto; display: inline-flex; align-items: center; gap: .4rem; font-size: .9rem; color: var(--muted); }
.tl-mini .tl-b { min-height: 34px; padding: .2rem .7rem; }
.tl-b { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .8rem; min-height: 40px; cursor: pointer; }
.tl-b.on { background: var(--text); color: var(--card); border-color: var(--text); }
.tl-b:focus-visible { outline: 3px solid #3b82f6; outline-offset: 2px; }
.tl-ctl { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: center; align-items: center; }
/* Tempo */
.tl-tempo, .tl-tuner { max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: .9rem; }
.tl-bpm { text-align: center; line-height: 1; position: relative; }
.tl-bpm b { font-size: 5rem; font-variant-numeric: tabular-nums; }
.tl-bpm small { display: block; color: var(--muted); font-size: .9rem; letter-spacing: .1em; margin-top: .2rem; }
#tl-dot { position: absolute; top: .4rem; right: .4rem; width: 18px; height: 18px; border-radius: 50%; background: #f59e0b; opacity: .25; }
.tl-play { width: 76px; height: 76px; border-radius: 50%; font-size: 1.7rem; background: var(--accent) !important; border-color: var(--accent) !important; color: var(--accent-text) !important; }
.tl-tempo input[type=range] { width: 100%; accent-color: #f59e0b; padding: 0; border: 0; background: transparent; }
#tl-fl { position: fixed; inset: 0; background: #f59e0b; opacity: 0; pointer-events: none; z-index: 20; }
/* Accordeur */
.tl-tuner .tl-ctl .tl-b { min-width: 46px; }
.tl-tuner .tl-b small { display: block; font-size: .65rem; opacity: .7; }
.tl-tuner .tl-b.ok b { color: #22c55e; }
.tl-note { text-align: center; font-size: 3rem; font-weight: 700; line-height: 1; }
.tl-note small { display: block; font-size: .9rem; font-weight: 500; color: var(--muted); margin-top: .3rem; min-height: 1.2em; }
.tl-meter { position: relative; height: 50px; border: 1px solid var(--line); border-radius: 8px; background: repeating-linear-gradient(90deg, var(--line) 0 2px, transparent 2px 10%); overflow: hidden; }
.tl-meter .z { position: absolute; left: 45%; width: 10%; top: 0; bottom: 0; background: rgba(34, 197, 94, .25); }
.tl-meter .needle { position: absolute; top: 0; bottom: 0; left: 50%; width: 5px; margin-left: -2.5px; border-radius: 3px; background: var(--muted); transition: left .12s linear, background .12s; }
.tl-meter .l, .tl-meter .r { position: absolute; top: 50%; transform: translateY(-50%); font-size: 1.3rem; color: var(--muted); }
.tl-meter .l { left: 8px; } .tl-meter .r { right: 8px; }
.tl-stat { text-align: center; min-height: 2.8em; color: var(--muted); }
/* Accords et gammes */
.tl-scales { --tl-board: #2b1a12; --tl-fret: #a9a392; --tl-str: #d9d3c1; --tl-ghost: #8b7b6a; display: flex; flex-direction: column; gap: .5rem; }
.tl-head { display: flex; flex-wrap: wrap; gap: .5rem .9rem; align-items: center; }
.tl-nav { display: flex; align-items: center; gap: .5rem; margin-right: auto; }
#tl-title { font-size: 1.25rem; font-weight: 700; min-width: 11ch; }
#tl-title small { display: block; font-size: .75rem; font-weight: 500; color: var(--muted); }
.tl-arrow { width: 44px; font-size: 1.25rem; padding: 0; }
.tl-seg { display: flex; }
.tl-seg .tl-b { border-radius: 0; margin-left: -1px; }
.tl-seg .tl-b:first-child { border-radius: 8px 0 0 8px; margin: 0; }
.tl-seg .tl-b:last-child { border-radius: 0 8px 8px 0; }
.tl-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.tl-row::-webkit-scrollbar { display: none; }
.tl-row .tl-b { flex: none; padding: .35rem .75rem; min-height: 36px; }
.tl-dotc { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.tl-chords { font-size: .82rem; color: var(--muted); }
.tl-chords b { color: var(--text); }
#tl-board { touch-action: pan-y; user-select: none; -webkit-user-select: none; }
#tl-board svg { width: 100%; height: auto; display: block; }
.tl-hint { display: none; font-size: .82rem; color: var(--muted); }
@media (orientation: portrait) and (max-width: 600px) { .tl-hint { display: block; } }
.tl-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .6rem; align-items: center; font-size: .82rem; color: var(--muted); }
#tl-info, #tl-mbtn { display: none; }
/* Plein écran : seul le manche reste, avec le rappel de la gamme et le mini-métronome */
body.tl-full { padding-bottom: 0; }
body.tl-full .top, body.tl-full .tabs, body.tl-full #offline, body.tl-full .tl-sub a,
body.tl-full .tl-head, body.tl-full .tl-row, body.tl-full .tl-hint, body.tl-full .tl-foot, body.tl-full .tl-chords { display: none !important; }
body.tl-full main { max-width: none; padding: 0 .5rem; min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; }
body.tl-full #tl-board svg { max-height: 100dvh; }
body.tl-full #tl-info { display: block; white-space: pre-line; position: fixed; top: calc(env(safe-area-inset-top, 0px) + 8px); left: 12px; z-index: 5; font-weight: 700; font-size: 1rem; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .35rem .6rem; opacity: .85; }
body.tl-full #tl-mbtn { display: block; position: fixed; top: calc(env(safe-area-inset-top, 0px) + 8px); right: 10px; z-index: 5; opacity: .7; min-height: 36px; padding: .35rem .6rem; }
body.tl-full .tl-sub { margin: 0; }
body.tl-full .tl-mini { position: fixed; bottom: calc(env(safe-area-inset-bottom, 0px) + 8px); left: 50%; transform: translateX(-50%); z-index: 5; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .25rem .6rem; opacity: .9; }

#demo-banner { display: flex; align-items: center; justify-content: center; gap: .6rem; flex-wrap: wrap; padding: .5rem 1rem; background: #3b2a12; color: #fde68a; font-size: .9rem; text-align: center; }
#demo-banner[hidden] { display: none; }
body.tl-full #demo-banner { display: none; }
#demo-banner .actions { justify-content: center; }
#demo-banner .btn:not(.primary) { background: transparent; color: #fde68a; border-color: #8a6a2a; }

/* Matériel des musiciens et matériel commun */
.gear { margin-top: .7rem; padding-top: .6rem; border-top: 1px solid var(--line); }
.card > .gear:only-child { margin-top: 0; padding-top: 0; border-top: 0; }
.gear-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.gear .att { padding: .3rem 0; }
.gear .badge { margin-left: .3rem; }
