/* Mes fiches : liste, éditeur, sélecteur d'accord, impression A4. */

/* ---------- Liste ---------- */

.view.fiches { max-width: 1180px; }
#fiches-list { max-width: 820px; margin: 0 auto; }
.list-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin: 6px 0 18px; }
.list-head h1 { margin: 0; font-family: var(--serif); font-size: 40px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.list-actions { display: flex; gap: 8px; }
.btn.small { min-height: 40px; margin-top: 0; padding: 0 14px; font-size: 14px; text-decoration: none; color: var(--ink); cursor: pointer; }
.btn.small svg { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.fiche-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.fiche-card { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: 4px; box-shadow: var(--shadow); }
.fiche-open { flex: 1; display: flex; flex-direction: column; gap: 3px; padding: 18px 18px 16px; border-top: 3px solid var(--accent); border-radius: 4px 4px 0 0; color: inherit; text-decoration: none; }
.fiche-open b { font-family: var(--serif); font-size: 21px; font-weight: 600; line-height: 1.2; letter-spacing: -.01em; }
.fiche-open i { font-family: var(--serif); color: var(--ink-soft); }
.fiche-open small { margin-top: 8px; font-size: 12px; color: var(--ink-soft); }
.card-actions { display: flex; flex-wrap: wrap; padding: 4px 8px; border-top: 1px dashed var(--line); }
.link { min-height: 40px; padding: 0 10px; border: 0; background: none; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.link:hover { color: var(--ink); }
.link.danger[data-armed="1"] { color: var(--accent); }
.list-note { margin-top: 22px; }

/* ---------- Éditeur ---------- */

.print-only { display: none; }
.ed-bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  margin: 0 -16px 12px; padding: 8px 16px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.save-state { margin-right: auto; font-size: 12px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.save-state.error { color: var(--accent); font-weight: 600; }
.transpose { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--ink-soft); white-space: nowrap; }
.transpose b { display: inline-block; min-width: 1.5em; text-align: center; font-family: var(--serif); font-size: 17px; color: var(--ink); }
.icon-btn.small { width: 36px; height: 36px; font-size: 19px; line-height: 1; flex: none; }
.icon-btn.small svg { width: 18px; height: 18px; }
.icon-btn.armed { color: var(--accent); border-color: var(--accent) !important; }

.sheet {
  width: 100%; max-width: 800px; margin: 0 auto;
  padding: 26px 18px 30px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: var(--shadow);
}
.sheet-head { margin-bottom: 22px; padding-bottom: 12px; border-bottom: 2px solid var(--ink); }
.sheet input, .sheet textarea.f-title {
  display: block; resize: none; overflow: hidden;
  width: 100%; padding: 2px 0; border: 0; border-bottom: 1px dashed transparent; border-radius: 0;
  background: none; color: inherit; font: inherit; outline: none;
}
.sheet input:hover, .sheet textarea.f-title:hover { border-bottom-color: var(--line); }
.sheet input:focus, .sheet textarea.f-title:focus { border-bottom-color: var(--accent); }
.sheet input::placeholder, .sheet textarea::placeholder { color: var(--ink-soft); opacity: .6; }
.sheet textarea.f-title { font-family: var(--serif); font-size: 30px; font-weight: 600; font-variation-settings: "opsz" 72; letter-spacing: -.02em; line-height: 1.15; }
.sheet .f-artist { font-family: var(--serif); font-style: italic; font-size: 17px; color: var(--ink-soft); }
.f-meta { display: flex; gap: 22px; margin-top: 10px; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); }
.f-meta label { display: flex; align-items: baseline; gap: 8px; }
.sheet .f-meta input { width: 4.2em; border-bottom-color: var(--line); font-family: var(--serif); font-size: 16px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--ink); }

.sec { margin: 0 0 24px; }
.sec-head { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.sheet .sec-name { flex: 1; min-width: 0; font-size: 11.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.sec-tools { display: flex; opacity: .5; transition: opacity .2s; }
.sec:hover .sec-tools, .sec:focus-within .sec-tools { opacity: 1; }
.sec-tools .icon-btn { width: 32px; height: 32px; border-color: transparent; background: none; }
.sec-tools .icon-btn svg { width: 16px; height: 16px; }

.sec-body { font-family: var(--serif); font-size: 17px; line-height: 1.35; cursor: text; }
.line { display: flex; flex-wrap: wrap; align-items: flex-end; min-height: 1.35em; margin-inline: -6px; padding: 3px 6px; border-radius: 6px; transition: background .15s; }
.line.empty { min-height: 1em; }
@media (hover: hover) { .line:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); } }
.w { display: inline-flex; align-items: flex-end; white-space: pre; }
.sg { display: inline-flex; flex-direction: column; align-items: flex-start; }
.t { white-space: pre; }
.t:empty::before { content: "\200b"; }
.ch {
  font-family: var(--sans); font-size: .8em; font-weight: 700; line-height: 1.3; white-space: nowrap;
  color: var(--accent); cursor: pointer;
  margin-right: .45em; padding: 0 1px; border-radius: 4px;
  transition: background .15s, color .15s;
}
.ch.sel { background: var(--accent); color: var(--on-accent); box-shadow: 0 0 0 3px var(--accent); }
.ch.ghost { background: var(--accent-wash); box-shadow: 0 0 0 3px var(--accent-wash); outline: 1.5px dashed var(--accent); outline-offset: 2px; animation: ghost 1.1s ease-in-out infinite alternate; }
@keyframes ghost { to { outline-color: transparent; } }
.sg.has-ghost > .t { box-shadow: -2px 0 0 var(--accent); }
.line.grid { align-items: center; gap: 2px .55em; font-family: var(--sans); font-size: .95em; }
.line.grid .ch { font-size: 1em; margin-right: 0; }
.line.grid.active { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.bar { color: var(--ink-soft); font-weight: 300; }
.rep { font-size: .85em; font-weight: 700; color: var(--ink-soft); }
.grid-tools { display: flex; flex-wrap: wrap; gap: 6px; flex-basis: 100%; margin: 8px 0 4px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 34px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--paper); color: var(--ink);
  font-family: var(--sans); font-size: 13px; font-weight: 600; white-space: nowrap;
}
.chip svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.chip:disabled { opacity: .45; }
.chip.chord { min-height: 38px; font-family: var(--serif); font-size: 16px; font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.sec-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.sec-text {
  display: block; width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--accent); border-radius: 8px;
  background: var(--paper); color: var(--ink);
  font-family: var(--serif); font-size: 17px; line-height: 1.5;
  resize: none; outline: none;
}
.import-box { margin: 0 0 24px; padding: 14px; border: 1.5px dashed var(--accent); border-radius: 10px; }
.import-box .label { margin-top: 0; color: var(--accent); }
.import-box .hint { margin-bottom: 10px; }
.import-text { font-family: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace; font-size: 13px; line-height: 1.45; white-space: pre; overflow-x: auto; border-width: 1px; }
.import-note { color: var(--accent); font-weight: 600; }
.chip.strong { border-color: var(--accent); color: var(--accent); }
.add-section { margin-top: 28px; padding-top: 14px; border-top: 1px dashed var(--line); }

.diagrams { margin-top: 30px; padding-top: 14px; border-top: 2px solid var(--ink); }
.dg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.dg-head .label { margin: 0; }
.dg-list { display: flex; flex-wrap: wrap; gap: 14px 16px; margin-bottom: 12px; }
.dg-card { display: flex; flex-direction: column; align-items: center; }
.dg-name { font-family: var(--serif); font-size: 17px; font-weight: 600; }
.dg-btn { display: flex; flex-direction: column; align-items: center; padding: 3px 4px; border: 0; border-radius: 8px; background: none; transition: background .15s; }
@media (hover: hover) { .dg-btn:hover { background: var(--paper-deep); } }
.dg-btn small { font-size: 10.5px; color: var(--ink-soft); }
.guitar-mini { width: 88px; }
.piano-mini { width: 136px; margin: 4px 0 2px; }
.mini .m-line { stroke: var(--ink); stroke-width: .8; }
.mini .m-fill { fill: var(--ink); }
.mini .m-open { fill: none; stroke: var(--ink); stroke-width: .9; }
.mini .m-text { font-size: 8px; font-weight: 600; fill: var(--ink); }
.mini .m-finger { font-size: 7px; font-weight: 500; fill: var(--ink-soft); }
.mini .m-white { fill: var(--card); stroke: var(--ink); stroke-width: .7; }
.mini .m-black { fill: var(--ink); }
.mini .m-dot-black { fill: var(--card); }

/* ---------- Sélecteur d'accord : panneau du bas sur téléphone, colonne à droite sur grand écran ---------- */

.picker {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
  display: grid; gap: 10px;
  max-height: 72dvh; overflow-y: auto;
  padding: 12px 14px calc(14px + env(safe-area-inset-bottom));
  background: var(--card);
  border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -12px 32px -16px rgba(40, 25, 10, .45);
  transform: translateY(105%);
  transition: transform .28s cubic-bezier(.3, .9, .4, 1);
}
.picker.open { transform: none; }
body.picker-open { padding-bottom: 430px; }
.pk-head { display: flex; align-items: center; gap: 6px; }
.pk-preview { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pk-preview small { font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pk-preview b { font-family: var(--serif); font-size: 27px; font-weight: 600; line-height: 1.1; letter-spacing: -.02em; }
.pk-hint { display: none; }
.pk-ask { padding: 12px; border: 1.5px solid var(--accent); border-radius: 12px; background: var(--accent-wash); }
.pk-ask p { margin: 0 0 10px; font-size: 14px; }
.pk-ask b { font-family: var(--serif); font-size: 16px; }
.pk-ask-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pk-recent { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.picker .roots button, .picker .types button { min-height: 40px; font-size: 13px; }
.picker .roots button { font-size: 15.5px; }
.picker .roots button.accidental { font-size: 11.5px; }
.pk-bass { display: flex; align-items: center; gap: 10px; font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); }
.pk-bass select { flex: 1; min-height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); font: 500 15px var(--serif); letter-spacing: 0; text-transform: none; }

@media (max-width: 519px) {
  .ed-bar { flex-wrap: wrap; row-gap: 2px; }
  .ed-bar > a.btn { margin-right: auto; }
  .ed-bar .btn.small:not(.primary) span { display: none; }
  .ed-bar .btn.small { padding: 0 11px; }
  .transpose .t-label { display: none; }
  .save-state { order: 9; flex-basis: 100%; margin: 0; text-align: right; font-size: 11px; }
}
@media (min-width: 640px) {
  .ed-bar { margin-inline: -24px; padding-inline: 24px; }
  .sheet { padding: 48px 56px 56px; }
  .sheet textarea.f-title { font-size: 36px; }
}
@media (min-width: 1020px) {
  .ed-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 32px; align-items: start; }
  .picker {
    position: sticky; top: 64px; z-index: 1;
    max-height: none; overflow: visible; padding: 16px;
    border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); transform: none; transition: none;
  }
  .pk-close { display: none; }
  .pk-hint { display: block; }
  body.picker-open { padding-bottom: 0; }
}
@media (orientation: landscape) and (max-height: 520px) and (max-width: 1019px) {
  .picker { top: 0; left: auto; width: 350px; max-height: none; border-radius: 18px 0 0 18px; border-top: 0; border-left: 1px solid var(--line); transform: translateX(105%); }
  body.picker-open { padding-bottom: 0; padding-right: 350px; }
  .picker .roots button, .picker .types button { min-height: 34px; }
}

/* ---------- Impression : page A4 dédiée, noir sur blanc ---------- */

@page { size: A4; margin: 15mm 16mm 16mm; }

@media print {
  :root {
    --paper: #fff; --paper-deep: #fff; --card: #fff; --ink: #000; --ink-soft: #333; --line: #999;
    --accent: #000; --accent-deep: #000; --accent-wash: #fff; --on-accent: #fff; --shadow: none;
  }
  html, body { background: #fff !important; color: #000; }
  body { min-height: 0; padding: 0 !important; font-size: 10pt; }
  .top, .no-print, #view-dictionnaire, #fiches-list, .ghost { display: none !important; }
  .print-only { display: block; }
  main, .view, .view.fiches, #fiche-editor, .ed-layout { display: block; max-width: none; margin: 0; padding: 0; }
  .sheet { max-width: none; margin: 0; padding: 0; border: 0; box-shadow: none; background: none; }

  .sheet-head { margin-bottom: 7mm; padding-bottom: 3mm; border-bottom: .6mm solid #000; }
  .p-title { margin: 0; font-family: var(--serif); font-size: 24pt; font-weight: 600; font-variation-settings: "opsz" 72; letter-spacing: -.02em; line-height: 1.1; }
  .p-artist { margin: 1mm 0 0; font-family: var(--serif); font-style: italic; font-size: 13pt; }
  .p-artist:empty, .p-meta:empty, .p-sec:empty { display: none; }
  .p-meta { margin: 2.5mm 0 0; font-size: 9pt; font-weight: 600; letter-spacing: .04em; }

  .sec { margin: 0 0 6mm; break-inside: avoid; page-break-inside: avoid; }
  /* Une longue section peut passer d'une page à l'autre, mais jamais en laissant une ou deux lignes seules */
  .sec.long { break-inside: auto; page-break-inside: auto; }
  .sec.long .line:nth-child(-n+2) { break-after: avoid; page-break-after: avoid; }
  .sec.long .line:nth-last-child(-n+2) { break-before: avoid; page-break-before: avoid; }
  .p-sec { margin: 0 0 1mm; font-family: var(--sans); font-size: 8pt; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; break-after: avoid; page-break-after: avoid; }
  .sec-body { font-size: 12pt; line-height: 1.3; cursor: auto; }
  .line { margin: 0; padding: .6mm 0; break-inside: avoid; page-break-inside: avoid; background: none !important; }
  .ch, .ch.sel { color: #000; background: none; box-shadow: none; }
  .sg.has-ghost > .t { box-shadow: none; }
  .bar, .rep { color: #000; }

  .diagrams { margin-top: 8mm; padding-top: 4mm; border-top: .4mm solid #000; }
  .dg-list { gap: 4mm 5mm; margin: 0; }
  .dg-card { break-inside: avoid; page-break-inside: avoid; }
  .dg-name { font-size: 11pt; }
  .dg-btn { padding: 0; }
  .dg-btn small { font-size: 7pt; color: #000; }
  .guitar-mini { width: 23mm; }
  .piano-mini { width: 36mm; }
}
