/* 軸の間 — habillage commun de shonoma (genji, senjimon, ten, 禅語の間) : l'œuvre à gauche, de taille fixe ; le panneau à droite,
   étapes numérotées reliées par une flèche, 「細かな調整」 replié avant la dernière étape (_commun/ERGONOMIE.md). */

:root {
  --papier: #f6f3ec;
  --encre: #161310;
  --discret: #5f584f;
  --trait: rgba(22, 19, 16, 0.16);
  --fond-panneau: #fbf9f4;
  --shu: #b8372a;
  --cible: 44px;
  --toko-w: 480px;
  --toko-h: 576px;
}
* { box-sizing: border-box; margin: 0; padding: 0 }
body { background: var(--papier); color: var(--encre); font-family: 'Hiragino Mincho ProN', 'Yu Mincho', 'Songti SC', Georgia, serif;
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; line-height: 1.7 }
a { color: var(--shu); text-underline-offset: 0.2em }

#scene { display: grid; grid-template-columns: minmax(0, 1fr) 340px; height: 100vh; overflow: hidden }
#scene > * { min-height: 0 }
#stage { display: flex; flex-direction: column; align-items: center; padding: 1.6rem 16px 2rem; min-width: 0; overflow-y: auto }
.toko-wrap { position: relative; width: var(--toko-w); height: var(--toko-h); flex: none; box-shadow: 0 1px 0 var(--encre) }
#toko { display: block; width: 100%; height: 100%; touch-action: none }
.attente[hidden], .poignees[hidden], .toast[hidden] { display: none }
.attente { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(246, 243, 236, 0.55); font-size: 1rem }

/* poignées de la retouche (comme 篆の間) */
.poignees { position: absolute; inset: 0; pointer-events: none }
.boite { position: absolute; border: 1.5px solid var(--shu); pointer-events: auto; cursor: move; transform-origin: 50% 50% }
.boite i { position: absolute; width: 14px; height: 14px; background: #fff; border: 1.5px solid var(--shu) }
.boite i[data-h="nw"] { left: -8px; top: -8px; cursor: nwse-resize } .boite i[data-h="ne"] { right: -8px; top: -8px; cursor: nesw-resize }
.boite i[data-h="se"] { right: -8px; bottom: -8px; cursor: nwse-resize } .boite i[data-h="sw"] { left: -8px; bottom: -8px; cursor: nesw-resize }
.boite i[data-h="n"] { left: calc(50% - 7px); top: -8px; cursor: ns-resize } .boite i[data-h="s"] { left: calc(50% - 7px); bottom: -8px; cursor: ns-resize }
.boite i[data-h="e"] { right: -8px; top: calc(50% - 7px); cursor: ew-resize } .boite i[data-h="w"] { left: -8px; top: calc(50% - 7px); cursor: ew-resize }
.boite b { position: absolute; left: calc(50% - 8px); top: -34px; width: 16px; height: 16px; border-radius: 50%; background: var(--shu); cursor: grab }

/* huit montures proposées, à la largeur de l'œuvre */
.propositions { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; width: var(--toko-w); margin-top: 10px }
.propositions button { padding: 0; border: 1px solid var(--trait); background: #fff; cursor: pointer; aspect-ratio: 5 / 6 }
.propositions button:hover { border-color: var(--encre) }
.propositions canvas { display: block; width: 100%; height: 100% }

.fiche { width: var(--toko-w); margin-top: 1rem; border-top: 1px solid var(--encre); padding-top: 0.8rem }
.fiche h2 { font-size: 1.6rem; font-weight: 400; letter-spacing: 0.08em }
.fiche .lecture { font-size: 1.05rem }
.fiche .sens { font-size: 1.08rem; margin: 0.5rem 0 0.7rem }
.fiche dl { display: grid; grid-template-columns: 7rem 1fr; gap: 0.35rem 0.8rem; font-size: 0.98rem }
.fiche dt { font-weight: 600 }
.fiche .ok { color: #2f6b2f }
.fiche .averifier { color: var(--shu) }

/* ---- le panneau ---- */
#panel { background: var(--fond-panneau); border-left: 1px solid var(--trait); padding: 1.2rem 1rem 2rem; display: flex; flex-direction: column; gap: 0; overflow-y: auto }
.marque { padding-bottom: 1rem; border-bottom: 1px solid var(--trait); margin-bottom: 1rem }
.marque-ligne { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem }
.marque-kanji { font-size: 1.24rem; font-weight: 400; letter-spacing: 0.14em; display: flex; align-items: center; gap: 0.5rem }
.marque .shonoma-hanko { margin-right: 0.4rem }
.marque-nom { font-size: 0.85rem; letter-spacing: 0.22em }
.outils-btn { display: inline-flex; align-items: center; gap: 0.35rem; min-height: 2.4rem; font: inherit; font-size: 0.88rem; letter-spacing: 0.08em; color: var(--encre); background: #fff; border: 1px solid var(--encre); padding: 0.35rem 0.7rem; cursor: pointer }
.outils-btn:hover { background: var(--encre); color: var(--papier) }
.fleche-menu { color: var(--shu); font-size: 0.75rem }

.etape { border: 2px solid var(--encre); background: #fff; padding: 0.85rem 0.9rem 0.9rem }
.etape-tete { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.8rem }
.etape-num { flex: none; width: 2rem; height: 2rem; display: flex; align-items: center; justify-content: center; background: var(--shu); color: #fff; font-size: 1.1rem; font-weight: 700; line-height: 1 }
.etape-titre { font-size: 1.05rem; font-weight: 700; letter-spacing: 0.08em }
.fleche { text-align: center; color: var(--shu); font-size: 1.6rem; line-height: 1; margin: 0.3rem 0; font-weight: 700 }

.champ { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.6rem }
.fleche-champ { font-size: 0.8rem }
.champ input { flex: 1; min-width: 0; min-height: var(--cible); font: inherit; font-size: 1rem; padding: 0.4rem 0.6rem; border: 1.5px solid var(--encre); border-radius: 0; background: #fff; color: var(--encre); box-shadow: 0 0 0 3px rgba(184, 55, 42, 0.12) }
select { width: 100%; font: inherit; font-size: 0.95rem; min-height: var(--cible); padding: 0.4rem 0.5rem; background: #fff; border: 1.5px solid var(--encre); border-radius: 0; color: var(--encre) }
.note { font-size: 0.9rem; margin: 0.4rem 0 0 }
.sous-titre { font-size: 0.95rem; font-weight: 700; margin: 0.6rem 0 0.3rem }

.bloc { display: flex; gap: 0.5rem; margin: 0.5rem 0 }
.bloc-col { flex-direction: column }
.action { flex: 1 1 auto; font: inherit; font-size: 0.92rem; letter-spacing: 0.06em; min-height: var(--cible); padding: 0.35rem 0.7rem; background: #fff; color: var(--encre); border: 1px solid var(--encre); cursor: pointer }
.action:hover { background: var(--encre); color: var(--papier) }
.action.majeure { background: var(--encre); color: var(--papier) }
.action.majeure:hover { background: var(--shu); border-color: var(--shu) }
.choix { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.3rem 0 }
.choix button { flex: 1 1 auto; font: inherit; font-size: 0.92rem; min-height: var(--cible); padding: 0.2rem 0.5rem; background: #fff; color: var(--encre); border: 1px solid var(--encre); cursor: pointer }
.choix button.actif { background: var(--encre); color: var(--papier) }

/* l'arbre des thèmes (comme 源氏の間) */
.arbre { display: flex; flex-direction: column; margin-bottom: 0.4rem }
.branche-nom { display: flex; justify-content: space-between; align-items: center; width: 100%; font: inherit; font-size: 0.95rem; min-height: var(--cible); padding: 0.3rem 0.2rem; background: none; border: 0; border-bottom: 1px solid var(--trait); cursor: pointer; color: var(--encre); text-align: left }
.branche-nom:hover { background: var(--papier) }
.branche-nom .fl { display: inline-flex; align-items: center; justify-content: center; width: 1.4rem; height: 1.4rem; background: var(--shu); color: #fff; font-size: 0.9rem }
.branche.ouverte > .branche-nom { background: var(--encre); color: var(--papier) }
.branche.ouverte > .branche-nom .fl { background: var(--papier); color: var(--encre) }
.branche .mots { display: none; flex-wrap: wrap; gap: 0.3rem; padding: 0.5rem 0 0.6rem }
.branche.ouverte .mots { display: flex }
.mots button { font: inherit; font-size: 0.9rem; min-height: 40px; padding: 0.15rem 0.55rem; background: #fff; border: 1px solid var(--encre); cursor: pointer; color: var(--encre) }
.mots button.actif { background: var(--encre); color: var(--papier) }

.liste { list-style: none; max-height: 17rem; overflow-y: auto; border-top: 1px solid var(--trait) }
.liste button { display: flex; width: 100%; gap: 0.7rem; align-items: baseline; text-align: left; font: inherit; background: none; border: 0; border-bottom: 1px solid var(--trait); padding: 0.45rem 0.3rem; min-height: var(--cible); cursor: pointer; color: var(--encre) }
.liste button:hover { background: var(--papier) }
.liste button.actif { background: var(--encre); color: var(--papier) }
.liste .t { font-size: 1.1rem; letter-spacing: 0.05em; white-space: nowrap }
.liste .y { font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.liste .vide { padding: 0.6rem 0.3rem }

/* nuancier des tissus : une vignette dessinée et son nom au survol */
.nuancier { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px }
.nuancier button { padding: 0; aspect-ratio: 1; border: 1px solid var(--trait); background: #fff; cursor: pointer; min-height: 40px }
.nuancier button.actif { outline: 3px solid var(--shu); outline-offset: 1px }
.nuancier canvas { display: block; width: 100%; height: 100% }

.affiner { border: 2px dashed var(--encre); background: #fff; padding: 0 0.9rem }
.affiner > summary { display: flex; align-items: center; gap: 0.6rem; font-size: 1rem; font-weight: 700; letter-spacing: 0.08em; padding: 0.95rem 0; cursor: pointer; list-style: none }
.affiner > summary::before { content: "＋"; display: inline-flex; align-items: center; justify-content: center; width: 1.6rem; height: 1.6rem; background: var(--shu); color: #fff }
.affiner[open] > summary::before { content: "−" }
.sous { border: 2px solid var(--encre); margin: 0 0 0.6rem; padding: 0 0.7rem }
.sous > summary { font-weight: 700; font-size: 0.95rem; min-height: var(--cible); display: flex; align-items: center; justify-content: space-between; cursor: pointer; list-style: none }
.sous > summary::after { content: "＋"; display: inline-flex; align-items: center; justify-content: center; width: 1.4rem; height: 1.4rem; background: var(--shu); color: #fff }
.sous[open] > summary { background: var(--encre); color: var(--papier); margin: 0 -0.7rem 0.6rem; padding: 0 0.7rem }
.sous[open] > summary::after { content: "−"; background: var(--papier); color: var(--encre) }
.sous[open] { padding-bottom: 0.7rem }
.ctrl { margin: 0.4rem 0 }
.ctrl label { display: block; font-size: 0.9rem }
.range-row { display: flex; align-items: center; gap: 0.6rem }
.range-row input { flex: 1; accent-color: var(--encre); min-height: 32px }
.rv { min-width: 3.2rem; text-align: right; font-size: 0.9rem }
.check { display: flex; align-items: center; gap: 0.5rem; min-height: var(--cible); font-size: 0.95rem }
.memos button { display: block; width: 100%; text-align: left; font: inherit; font-size: 0.92rem; min-height: 40px; background: none; border: 0; border-bottom: 1px solid var(--trait); cursor: pointer; color: var(--encre) }

.langues { display: flex; gap: 0.3rem; margin-top: 1.2rem; justify-content: center }
.lang-opt { font: inherit; font-size: 0.9rem; letter-spacing: 0.1em; background: none; border: 0; color: var(--encre); cursor: pointer; min-width: var(--cible); min-height: var(--cible) }
.lang-opt.actif { text-decoration: underline; text-underline-offset: 0.25em; font-weight: 600 }
.version, .credit { font-size: 0.85rem; text-align: center; margin-top: 0.3rem }
.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); background: var(--encre); color: var(--papier); padding: 0.5rem 1rem; font-size: 0.95rem; z-index: 60 }

/* ---- téléphone : l'œuvre en haut, fixée pendant qu'on règle ---- */
@media (max-width: 860px) {
  #scene { grid-template-columns: minmax(0, 1fr); height: auto; overflow: visible }
  #stage, #panel { overflow: visible }
  :root { --toko-w: min(480px, calc(100vw - 32px)); --toko-h: calc(var(--toko-w) * 1.2) }
  #stage { padding: 0.8rem 16px 1rem }
  .toko-wrap { position: sticky; top: 0; z-index: 5 }
  .propositions { grid-template-columns: repeat(4, 1fr) }
  #panel { border-left: 0; border-top: 1px solid var(--trait) }
}

/* ---- propre au 軸の間 ---- */
.recu { font-size: 1rem; margin: 0.2rem 0 0.4rem }
:root { --toko-h: 640px }
.kake-wrap { box-shadow: none; border: 1px solid var(--trait) }
.echelle { display: flex; align-items: center; justify-content: center; gap: 0.7rem; width: var(--toko-w); margin-top: 8px; font-size: 0.92rem }
.echelle input { flex: 0 1 220px; accent-color: var(--encre); min-height: 32px }
.mesure { font-size: 0.95rem; margin-top: 2px; text-align: center }
.fiche h2 { font-size: 1.2rem; letter-spacing: 0.06em }
.fiche dl { display: block }
.fiche dt { margin-top: 0.45rem }
.fichier { position: relative; display: flex; align-items: center; justify-content: center; cursor: pointer }
.fichier input { position: absolute; inset: 0; opacity: 0; cursor: pointer }
.lien-action { text-decoration: none; display: flex; align-items: center; justify-content: center; text-align: center }
.choix-petit button { flex: 0 1 auto; font-size: 0.88rem; min-height: 40px }
#blocImage[hidden], #blocTexte[hidden], .etape[hidden], .fleche[hidden], .sous[hidden], .ctrl[hidden], .choix[hidden] { display: none }
@media (max-width: 860px) {
  :root { --toko-h: calc(var(--toko-w) * 1.2) }
}

/* grand écran (kuma, 04/11) : la fiche à gauche de l'œuvre, l'œuvre aussi haute que l'écran le permet */
@media (min-width: 1200px) {
  #stage { display: grid; grid-template-columns: minmax(240px, 340px) auto; column-gap: 32px; justify-content: center; align-content: start; align-items: start }
  #stage > * { grid-column: 2 }
  #stage > .fiche { grid-column: 1; grid-row: 1 / span 8; width: auto; margin-top: 0 }
}
@media (min-width: 1200px) { :root { --toko-w: max(380px, min(calc((100vh - 112px) / 1.49), calc(100vw - 790px))); --toko-h: calc(var(--toko-w) / 0.75) } }

/* compact (kuma, 04/11) : le panneau tient sur un écran ; un bouton a la taille de son mot ; peu de texte, sans effort de lecture */
#panel { padding: 0.8rem 0.9rem 1rem }
.marque { padding-bottom: 0.5rem; margin-bottom: 0.6rem }
.etape { padding: 0.6rem 0.7rem 0.7rem }
.etape-tete { margin-bottom: 0.5rem; gap: 0.55rem }
.etape-num { width: 1.7rem; height: 1.7rem; font-size: 1rem }
.etape-titre { font-size: 1rem }
.fleche { font-size: 1.1rem; margin: 0.1rem 0 }
.choix { gap: 0.3rem; margin: 0.25rem 0 }
.choix button, .bloc .action { flex: 0 0 auto; min-height: 40px; padding: 0.1rem 0.75rem; font-size: 0.95rem; letter-spacing: 0.02em }
.bloc { flex-wrap: wrap; gap: 0.4rem; margin: 0.35rem 0 }
.affiner > summary { padding: 0.55rem 0 }
.sous > summary { min-height: 40px }
.langues { margin-top: 0.7rem }
.lien-discret { display: inline-block; font-size: 0.92rem; margin-top: 0.2rem }
.aide { font-size: 0.88rem; margin: 0.2rem 0 0 }
.recu { font-size: 0.98rem; margin: 0 }
.nuancier.vite { grid-template-columns: repeat(8, 1fr); margin-top: 0.4rem }
/* la fiche : un cartel de musée, petit et net */
.fiche { border-top: 0; padding-top: 0 }
.fiche h2.titre-fiche { display: none }
.fiche dl { display: grid; grid-template-columns: auto 1fr; gap: 0.35rem 0.9rem; font-size: 0.88rem; line-height: 1.5 }
.fiche dt { font-weight: 400; font-size: 0.78rem; letter-spacing: 0.12em; color: var(--shu); padding-top: 0.12rem; white-space: nowrap }
.fiche dd { margin: 0 }
.propositions { margin-bottom: 16px }
.nuancier.vite button { min-height: 0 }
.fiche dl { align-items: baseline }
.fiche dt { padding-top: 0 }
@media (min-width: 861px) { #stage { padding-bottom: 0 } }
