/* 升の間 — interface.
   Même socle que 仮, 千, 篆, 粋, 色 et 字 : le papier domine, hiérarchie par
   l'espacement, aucune couleur qui ne soit fonctionnelle, angles vifs.
   Les seules couleurs sont celles des lignes du sous-main, choisies par la personne. */

:root {
  --papier: #f6f3ec;
  --encre: #161310;
  --discret: #8b8378;
  --trait: rgba(22, 19, 16, 0.12);
  --fond-panneau: #fbf9f4;
  --shu: #b8372a;
}

* { box-sizing: border-box; margin: 0; padding: 0 }
html, body { height: 100% }

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%;
}

#scene { display: grid; grid-template-columns: 1fr 320px; height: 100vh; overflow: hidden }
#scene > * { min-height: 0; min-width: 0 }

#stage { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 0; min-height: 0; padding: 2rem }

/* ---- la feuille ---- */
#feuille-cadre { position: relative; flex: 1 1 auto; width: 100%; min-height: 0; display: flex; align-items: center; justify-content: center }
/* pendant qu'une police arrive (comme 篆の間) */
.attente { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 1rem;
  padding: 1.4rem 1.8rem; background: rgba(251, 249, 244, 0.94); border: 1px solid var(--trait); z-index: 2 }
.attente[hidden] { display: none }
.attente-sceau { width: 2.4rem; height: 2.4rem; border: 2px solid var(--shu); animation: attente-tourne 1.6s cubic-bezier(.6,0,.4,1) infinite }
.attente-txt { white-space: pre-line; font-size: 0.82rem; letter-spacing: 0.1em; color: var(--encre); text-align: center; line-height: 1.8 }
@keyframes attente-tourne { 0% { transform: rotate(0deg) } 50% { transform: rotate(90deg); background: rgba(184,55,42,.12) } 100% { transform: rotate(180deg) } }
@media (prefers-reduced-motion: reduce) { .attente-sceau { animation: none } }
select.chargement { animation: pouls 0.9s ease-in-out infinite }
@keyframes pouls { 50% { border-color: var(--shu) } }
#feuille { display: block; box-shadow: 0 26px 60px -32px rgba(22, 19, 16, 0.8); border: 1px solid var(--trait) }
.sous-feuille { flex: none; padding-top: 0.9rem; font-size: 0.8rem; letter-spacing: 0.08em; color: var(--encre); text-align: center }

/* ---- le panneau ---- */
#panel { background: var(--fond-panneau); border-left: 1px solid var(--trait);
  overflow-y: auto; padding: 1.4rem 1.2rem 3rem }

.marque { padding-bottom: 1.4rem; border-bottom: 1px solid var(--trait); margin-bottom: 1.2rem }
.marque-ligne { display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem }
.marque-kanji { font-size: 1.24rem; font-weight: 400; letter-spacing: 0.14em }
.marque-nom { font-size: 0.66rem; letter-spacing: 0.22em; color: var(--discret) }
.langues { display: flex; gap: 0.45rem }
.lang-opt { font: inherit; font-size: 0.68rem; letter-spacing: 0.1em; background: none; border: 0;
  color: var(--discret); cursor: pointer; padding: 0.1rem 0 }
.lang-opt.actif { color: var(--encre); border-bottom: 1px solid var(--encre) }

.bloc { display: flex; gap: 0.5rem; margin-bottom: 1rem }
.action { flex: 1 1 auto; font: inherit; font-size: 0.8rem; letter-spacing: 0.1em;
  padding: 0.55rem 0.4rem; background: var(--fond-panneau); border: 1px solid var(--trait);
  color: var(--encre); cursor: pointer; transition: background 0.2s, color 0.2s, border-color 0.2s }
.action:hover { background: var(--encre); color: var(--papier); border-color: var(--encre) }
.action.majeure { background: var(--encre); color: var(--papier); border-color: var(--encre) }
.action.majeure:hover { background: var(--shu); border-color: var(--shu) }
.modele { margin-bottom: 1.6rem }

.section { margin-bottom: 1.6rem }
.section-tete { display: flex; align-items: center; gap: 0.55rem; font-weight: 400;
  padding-bottom: 0.45rem; border-bottom: 1px solid var(--encre); margin-bottom: 0.9rem }
.sec-num { background: var(--encre); color: var(--papier); font-size: 0.62rem;
  letter-spacing: 0.06em; padding: 0.1rem 0.42rem; line-height: 1.5 }
.sec-titre { color: var(--encre); font-size: 0.8rem; letter-spacing: 0.22em }

select { width: 100%; font: inherit; font-size: 0.82rem; padding: 0.45rem 0.5rem;
  background: var(--papier); border: 1px solid var(--trait); color: var(--encre); border-radius: 0 }

.note { font-size: 0.8rem; line-height: 1.75; color: var(--encre); margin: 0.2rem 0 0.8rem }
textarea.texte { width: 100%; font: inherit; font-size: 1rem; line-height: 1.6; padding: 0.45rem 0.5rem; resize: vertical;
  background: var(--papier); border: 1px solid var(--trait); color: var(--encre); border-radius: 0 }
.etiquette { font-size: 0.8rem; color: var(--encre); margin: 0.2rem 0 0.35rem }

.choix { display: flex; gap: 0.35rem; margin-bottom: 0.8rem }
.choix button { flex: 1 1 auto; font: inherit; font-size: 0.78rem; padding: 0.4rem 0.2rem;
  background: var(--papier); border: 1px solid var(--trait); color: var(--encre); cursor: pointer }
.choix button.actif { background: var(--encre); color: var(--papier); border-color: var(--encre) }

.choix.choix-col { flex-direction: column }
.case { display: flex; align-items: center; gap: 0.45rem; font-size: 0.82rem; padding: 0.3rem 0;
  color: var(--encre); cursor: pointer }
.case input { accent-color: var(--encre) }

.glissiere { display: grid; grid-template-columns: 1fr auto; gap: 0.1rem 0.5rem; align-items: center;
  margin-bottom: 0.7rem; font-size: 0.82rem; color: var(--encre) }
.glissiere input[type=range] { grid-column: 1 / -1; width: 100%; accent-color: var(--encre) }
.glissiere .val { font-size: 0.8rem; color: var(--encre); font-variant-numeric: tabular-nums }
.glissiere .bouts { grid-column: 1 / -1; display: flex; justify-content: space-between; font-size: 0.74rem; color: var(--encre); opacity: 0.7 }

.dimensions { display: flex; gap: 0.6rem; margin-bottom: 0.8rem }
.dimensions label { flex: 1 1 0; font-size: 0.8rem; display: flex; flex-direction: column; gap: 0.25rem }
.dimensions input { font: inherit; font-size: 0.85rem; padding: 0.35rem 0.4rem; width: 100%;
  background: var(--papier); border: 1px solid var(--trait); color: var(--encre); border-radius: 0 }

/* ---- les couches de lignes ---- */
.couche { border-top: 1px solid var(--trait); padding: 0.35rem 0 }
.couche:last-child { border-bottom: 1px solid var(--trait) }
.couche-tete { display: flex; align-items: center; justify-content: space-between; gap: 0.4rem }
.couche-tete .case { flex: 1 1 auto }
.plier { font: inherit; font-size: 0.74rem; background: none; border: 0; color: var(--encre); cursor: pointer; padding: 0.3rem 0.1rem; white-space: nowrap }
.plier:hover { color: var(--shu) }
.couche-corps { padding: 0.5rem 0 0.4rem 1.4rem }

.nuancier { display: flex; align-items: center; gap: 0.35rem; margin-bottom: 0.8rem; flex-wrap: wrap }
.nuancier button { width: 1.6rem; height: 1.6rem; border: 1px solid var(--trait); cursor: pointer; padding: 0 }
.nuancier button.actif { outline: 2px solid var(--encre); outline-offset: 2px }
.nuancier input[type=color] { width: 2.2rem; height: 1.7rem; border: 1px solid var(--trait); background: none; padding: 0; cursor: pointer }

/* ---- l'éditeur de la case à main levée ---- */
#editeur { display: block; width: 100%; max-width: 240px; aspect-ratio: 1; margin: 0.2rem auto 0.6rem;
  background: var(--papier); border: 1px solid var(--trait); touch-action: none; cursor: crosshair }

.version { font-size: 0.66rem; letter-spacing: 0.12em; color: var(--discret); padding-top: 0.6rem }
.credit { font-size: 0.72rem; padding-top: 0.4rem }
.credit a { color: var(--encre) }
.credit a:hover { color: var(--shu) }

.toast { position: fixed; left: 50%; bottom: 1.6rem; transform: translateX(-50%); z-index: 60;
  background: var(--encre); color: var(--papier); font-size: 0.82rem; letter-spacing: 0.08em; padding: 0.55rem 1rem }

@media (max-width: 820px) {
  /* comme kana, genji, ten, shiki et iki : la feuille reste en haut, le panneau défile dessous */
  #scene { display: block; height: auto; overflow: visible }
  #panel { border-left: 0 }
  #stage { position: sticky; top: 0; z-index: 5; height: 46svh; min-height: 15rem; padding: 0.7rem 1rem;
    background: var(--papier); border-bottom: 1px solid var(--trait) }
  .sous-feuille { padding-top: 0.4rem; font-size: 0.74rem }
}

/* ---- annuler, rétablir ---- */
.action:disabled { opacity: 0.35; cursor: default }
.action:disabled:hover { background: var(--fond-panneau); color: var(--encre); border-color: var(--trait) }

/* ---- mes modèles ---- */
input.nom-type { width: 100%; font: inherit; font-size: 0.9rem; padding: 0.45rem 0.5rem; margin-bottom: 0.7rem;
  background: var(--papier); border: 1px solid var(--trait); color: var(--encre); border-radius: 0 }
.type-ligne { display: flex; align-items: baseline; gap: 0.5rem; border-top: 1px solid var(--trait); padding: 0.3rem 0; font-size: 0.85rem }
.type-ligne:last-of-type { border-bottom: 1px solid var(--trait); margin-bottom: 0.9rem }
.type-nom { flex: 1 1 auto; overflow-wrap: anywhere }
.type-date { font-size: 0.78rem; font-variant-numeric: tabular-nums }

/* ---- la taille réelle ---- */
.reel-voir { flex: none; margin-top: 0.6rem; font: inherit; font-size: 0.8rem; letter-spacing: 0.1em; padding: 0.4rem 0.9rem;
  background: var(--fond-panneau); border: 1px solid var(--encre); color: var(--encre); cursor: pointer }
.reel-voir:hover { background: var(--encre); color: var(--papier) }
.reel { position: fixed; inset: 0; z-index: 100; background: #e9e5dc; overflow: hidden }
.reel-toile { display: block; touch-action: none; cursor: grab }
.reel-barre { position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem;
  padding: 0.6rem max(0.8rem, env(safe-area-inset-right)) max(0.6rem, env(safe-area-inset-bottom)) max(0.8rem, env(safe-area-inset-left));
  background: rgba(251, 249, 244, 0.96); border-top: 1px solid var(--trait) }
.reel-barre .action { flex: 0 0 auto; padding: 0.55rem 0.8rem }
.reel-info { flex: 1 1 8rem; text-align: center; font-size: 0.9rem; font-variant-numeric: tabular-nums }
.reel-aide { position: absolute; top: max(0.8rem, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); max-width: 90%;
  font-size: 0.9rem; background: rgba(251, 249, 244, 0.96); padding: 0.4rem 0.8rem; text-align: center }
.reel-aide:empty { display: none }
.reel.nu .reel-barre, .reel.nu .reel-aide { display: none }
.cal { position: absolute; inset: 0; z-index: 2; overflow: auto; background: var(--papier); padding: 1.4rem max(1.2rem, env(safe-area-inset-left)) 2rem;
  display: flex; flex-direction: column; align-items: center }
.cal > * { width: min(100%, 30rem) }
.cal .cal-carte { flex: none; width: auto; border: 2px solid var(--shu); margin: 0.8rem 0 1rem }
.cal .bloc .action { font-size: 1.1rem }

/* ---- refonte du 26/10 (même logique que 篆の間, _commun/ERGONOMIE.md) ---- */
:root { --discret: #5f584f; }
/* grand écran : la zone de la feuille est un carré fixe (--cote, posée par app.js) ; le menu y est collé ; l'ensemble se centre */
@media (min-width: 821px) {
  #scene { display: flex; justify-content: center; }
  #stage { flex: 0 0 auto; width: min(calc(100vh - 6rem), calc(100vw - 320px)); padding: 2rem 2rem 1.2rem; }
  #panel { flex: 0 0 320px; height: 100vh; }
}
.marque-nom { font-size: 0.78rem; color: var(--discret); }
.outils-btn { margin-left: auto; display: inline-flex; align-items: center; gap: 0.35rem; 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); }
.outils-btn .fleche-menu { color: var(--shu); font-size: 0.75rem; }
.outils-btn:hover .fleche-menu { color: var(--papier); }
/* les quatre étapes */
.section.etape { border: 2px solid var(--encre); background: #fff; padding: 0.85rem 0.9rem 0.5rem; margin-bottom: 0; }
.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; color: var(--encre); }
.fleche { text-align: center; color: var(--shu); font-size: 1.6rem; line-height: 1; margin: 0.3rem 0; font-weight: 700; }
.etape select, .etape textarea.texte { border: 2px solid var(--encre); background-color: #fff; }
.choix-modeles { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.3rem; }
.choix-modeles button { min-height: 2.75rem; }
/* 「細かな調整」 : niveau 1 en pointillés ; niveau 2 en boutons cernés, ＋ sur carré vermillon ; ouvert, un bandeau d'encre */
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
.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; }
.affiner > summary::after { content: "＋"; margin-left: auto; }
.affiner[open] > summary::after { content: "−"; }
.affiner[open] > summary { border-bottom: 2px solid var(--encre); margin-bottom: 0.6rem; }
.affiner[open] { padding-bottom: 0.6rem; }
.sous { margin: 0 0 0.45rem; }
.sous > summary { display: flex; align-items: center; gap: 0.6rem; font-size: 0.95rem; font-weight: 700; letter-spacing: 0.05em; padding: 0.6rem 0.6rem 0.6rem 0.8rem; min-height: 44px; border: 2px solid var(--encre); background: #fff; color: var(--encre); }
.sous > summary::after { content: "＋"; margin-left: auto; width: 1.6rem; height: 1.6rem; display: flex; align-items: center; justify-content: center; background: var(--shu); color: #fff; font-weight: 700; }
.sous > summary:hover { background: var(--papier); }
.sous[open] { border: 2px solid var(--encre); margin-bottom: 0.8rem; }
.sous[open] > summary { border: 0; background: var(--encre); color: var(--papier); }
.sous[open] > summary:hover { background: var(--encre); color: var(--papier); }
.sous[open] > summary::after { content: "−"; background: var(--papier); color: var(--encre); }
.sous[open] > *:not(summary) { padding-left: 0.8rem; padding-right: 0.8rem; }
.sous[open] > *:not(summary):first-of-type { padding-top: 0.8rem; }
.sous[open] > *:last-child { padding-bottom: 0.6rem; }
.sous .section { margin-bottom: 0; }
.sous .section-tete { display: none; }
.sous select, .sous textarea, .sous input { max-width: 100%; }
/* en bas : 戻す / やり直す / 最初から, puis la langue */
.bloc.bas { margin-top: 1.2rem; }
#panel > .langues { justify-content: center; margin: 0.4rem 0 1rem; }
.lang-opt { font-size: 0.75rem; }
/* propositions sous la feuille : huit vignettes serrées, ⚄ et ✕ au bout de la rangée */
.propositions { display: flex; align-items: center; justify-content: center; gap: 0.35rem; margin-top: 0.8rem; flex: none; }
.propositions[hidden] { display: none; }
#gallery { display: flex; gap: 0.3rem; align-items: center; }
#gallery canvas { max-width: 5.2rem; max-height: 5.2rem; width: auto; height: auto; cursor: pointer; border: 1px solid transparent; background: #fff; }
#gallery canvas:hover { border-color: var(--encre); }
.propos-tete { display: flex; flex-direction: column; gap: 0.25rem; }
.propos-de, .propos-fermer, .propos-ouvrir { width: 2.6rem; height: 2.6rem; padding: 0; display: flex; align-items: center; justify-content: center; font: inherit; font-size: 1.2rem; color: var(--encre); background: #fff; border: 1px solid var(--trait); cursor: pointer; }
.propos-de:hover, .propos-fermer:hover, .propos-ouvrir:hover { background: var(--encre); color: var(--papier); }
.propos-ouvrir { margin: 0.6rem auto 0; flex: none; }
.propos-ouvrir[hidden] { display: none; }
@media (max-width: 820px) { #gallery { overflow-x: auto; } #gallery canvas { max-height: 3.6rem; } .propos-de, .propos-fermer { width: 2.2rem; height: 2.2rem; } }
.plus-formes { margin: 0.5rem 0 0.8rem; }
.plus-formes > summary { display: flex; align-items: center; justify-content: space-between; font-size: 0.92rem; padding: 0.55rem 0.75rem; border: 1px solid var(--encre); background: #fff; }
.plus-formes > summary::after { content: "▼"; color: var(--shu); font-size: 0.8rem; }
.plus-formes[open] > summary::after { content: "▲"; }
.plus-formes > .choix-modeles { margin-top: 0.4rem; }
