/* 紋の間 — interface (reprise de 升の間).
   Même socle que 仮, 千, 篆, 粋, 色, 字 et 升 : le papier domine, hiérarchie par
   l'espacement, aucune couleur qui ne soit fonctionnelle, angles vifs.
   La seule couleur est l'encre du kamon, choisie par la personne ; le vermillon marque le tracé. */

: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; border: 1px solid var(--trait) }
.sous-feuille { flex: none; padding-top: 0.9rem; font-size: 0.8rem; letter-spacing: 0.08em; color: var(--encre);
  display: flex; align-items: flex-end; justify-content: center; gap: 1.4rem; flex-wrap: wrap }
/* le kamon presque à taille réelle (1 cm ≈ 38 px à l'écran) : ce qu'on lit encore, ce qui disparaît */
.petits { display: flex; align-items: flex-end; gap: 0.9rem }
.petit { display: flex; flex-direction: column; align-items: center; gap: 0.2rem }
.petit canvas { display: block; width: 38px; height: 38px }
.petit canvas#v2 { width: 76px; height: 76px }
.petit small { font-size: 0.7rem; color: var(--encre) }

/* ---- les modèles : une vignette par kamon ---- */
.modeles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--trait); border: 1px solid var(--trait); margin-bottom: 0.4rem }
.modeles button { font: inherit; background: var(--fond-panneau); border: 0; padding: 0.45rem 0.2rem 0.35rem; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 0.25rem; color: var(--encre) }
.modeles button:hover { background: var(--papier) }
.modeles canvas { width: 44px; height: 44px; display: block }
.modeles span { font-size: 0.74rem; letter-spacing: 0.05em }
.modeles small { font-size: 0.62rem; color: var(--encre); opacity: 0.75 }
.choix { flex-wrap: wrap }
.retrait { border-left: 1px solid var(--trait); padding: 0.3rem 0 0.2rem 0.9rem; margin: 0 0 0.8rem 0.3rem }
.envoi { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--trait); border: 1px solid var(--trait); margin-top: 0.4rem }
.envoi button { font: inherit; cursor: pointer; background: var(--fond-panneau); color: var(--encre); border: 0; padding: 0.5rem 0.3rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.15rem }
.envoi button > span { font-size: 0.8rem } .envoi button small { font-size: 0.66rem; letter-spacing: 0.05em }
.envoi button:hover { background: var(--encre); color: var(--papier) }

/* ---- 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 }

.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 }

.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; gap: 0.8rem }
  .petit.deux { display: none } /* trop grand pour l'aperçu collé en haut */
}

/* ---- refonte du 27/10 (même logique que 篆の間, 粋の間, 色の間, 升の間 : _commun/ERGONOMIE.md) ---- */
:root { --discret: #5f584f; }
/* grand écran : la zone du kamon a une largeur fixe (un carré à la hauteur de l'écran) ; 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 - 4rem), calc(100vw - 320px)); padding: 1.6rem 16px 1.2rem 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 .choix button { min-height: 2.75rem; font-size: 0.88rem; }
.etape .choix button.actif, .modeles button.actif { outline: 2px solid var(--encre); outline-offset: -2px; }
.tuiles { display: grid !important; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.3rem; }
.tuiles button { display: flex; flex-direction: column; align-items: center; gap: 0.2rem; padding: 0.35rem 0.2rem; }
.tuiles button img { width: 34px; height: 34px; display: block; }
.choix .tuiles button.actif img, .tuiles button.actif img { filter: invert(1); }
.modeles { background: #fff; border: 0; gap: 0.3rem; }
.modeles button { background: #fff; border: 1px solid var(--trait); min-height: 44px; }
.modeles button:hover { border-color: var(--encre); background: #fff; }
.modeles span { font-size: 0.85rem; }
.modeles small { font-size: 0.72rem; opacity: 1; }
.plus-formes { margin: 0.3rem 0 0.8rem; }
.plus-formes > summary { display: flex; align-items: center; justify-content: space-between; font-size: 0.92rem; padding: 0.55rem 0.75rem; min-height: 44px; 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 > .modeles { margin-top: 0.4rem; }
.etape .bloc { margin-bottom: 0.6rem; }
.etape .action { font-size: 0.88rem; min-height: 44px; border-color: var(--encre); }
.envoi { background: var(--encre); border-color: var(--encre); }
.envoi button { background: #fff; min-height: 44px; }
.envoi button > span { font-size: 0.82rem; } .envoi button small { font-size: 0.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; flex: none; display: flex; align-items: center; justify-content: center; background: var(--shu); color: #fff; font-weight: 700; }
.sous > summary:hover { background: var(--papier); color: var(--encre); }
.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) { margin-left: 0.8rem; margin-right: 0.8rem; }
.sous[open] > *:not(summary):first-of-type { margin-top: 0.8rem; }
.sous[open] > *:last-child { margin-bottom: 0.7rem; }
.sous select, .sous input { max-width: 100%; }
/* en bas : 共有 / 最初から, 言葉を選ぶ, la langue, le chien */
.bloc.bas { margin-top: 1.2rem; }
.bloc.bas .action { min-height: 44px; font-size: 0.88rem; }
.vers-kotoba { display: block; text-align: center; font-size: 0.9rem; color: var(--encre); margin: 0 0 0.6rem; }
.vers-kotoba:hover { color: var(--shu); }
#panel > .langues { justify-content: center; margin: 0.4rem 0 0.4rem; }
.lang-opt { font-size: 0.8rem; color: var(--encre); padding: 0.5rem 0.4rem; min-width: 44px; min-height: 44px; }
.version { font-size: 0.75rem; text-align: center; }
.credit { font-size: 0.8rem; text-align: center; }
.chien { display: block; width: fit-content; margin: 0.6rem auto 0.4rem; }
.chien .fig { display: block; position: relative; transition: transform .35s ease; }
.chien img { display: block; height: 120px; width: auto; }
.chien:hover .fig { transform: translateY(-6px); }
.chien .queue { position: absolute; left: 0; top: 0; height: 100%; width: auto; transform-origin: 86% 88.5%; animation: remue .55s ease-in-out infinite alternate; }
@keyframes remue { from { transform: rotate(-7deg); } to { transform: rotate(9deg); } }
@media (prefers-reduced-motion: reduce) { .chien .queue { animation: none; } }
/* textes lisibles : plus de petit texte gris */
.glissiere, .case, .etiquette, .note { font-size: 0.88rem; }
.glissiere .val { font-size: 0.88rem; }
.glissiere .bouts { font-size: 0.8rem; opacity: 1; }
.sous-feuille { font-size: 0.85rem; }
.petit small { font-size: 0.78rem; }
/* propositions sous le kamon : 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: grid; grid-template-columns: repeat(8, 4.4rem); gap: 0.3rem; }
#gallery canvas { width: 4.4rem; height: 4.4rem; cursor: pointer; border: 1px solid var(--trait); background: #fff; display: block; }
#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.1rem; 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(--encre); 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; width: 2.6rem; height: 2.6rem; }
.propos-ouvrir[hidden] { display: none; }
@media (min-width: 821px) and (max-height: 900px) { #gallery { grid-template-columns: repeat(8, 3.6rem); } #gallery canvas { width: 3.6rem; height: 3.6rem; } }
@media (max-width: 820px) {
  #stage { height: 58svh; }
  #gallery { display: flex; overflow-x: auto; max-width: calc(100vw - 5rem); }
  #gallery canvas { flex: none; width: 3.4rem; height: 3.4rem; }
  .propos-de, .propos-fermer { width: 2.75rem; height: 1.7rem; }
  .propositions { margin-top: 0.4rem; }
  .sous-feuille { padding-top: 0.3rem; }
}
/* (suite) zone du kamon posée par app.js ; ひな形 sur trois colonnes, lisibles */
@media (min-width: 821px) {
  #stage { justify-content: flex-start; padding: 26px 16px 19px 32px; }
  #feuille-cadre { flex: none; }
  .propositions, .propos-ouvrir { min-height: 4.6rem; }
}
.modeles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.modeles canvas, .modeles img { width: 48px !important; height: 48px !important; }
.modeles span { font-size: 1rem; }
.modeles small { font-size: 0.88rem; }
.tuiles button span { font-size: 0.95rem; }
.choix button { font-size: 0.88rem; min-height: 2.5rem; }
.envoi button > span { font-size: 0.9rem; } .envoi button small { font-size: 0.85rem; }
.petit small, #compte, .marque-nom, .version { font-size: 0.88rem; }
.lang-opt, .credit, .vers-kotoba, .glissiere .bouts { font-size: 0.9rem; }
/* envois : deux colonnes, des libellés qui tiennent (kuma, 27/10) */
.envoi { grid-template-columns: repeat(2, 1fr); }
.envoi button { padding: 0.55rem 0.4rem; }
.envoi button:last-child:nth-child(odd) { grid-column: 1 / -1; }
.envoi button small, .envoi .bg-send-btn small { color: var(--encre) !important; opacity: 1 !important; }
.envoi button > span { letter-spacing: 0.02em; }
.bloc.bas .action { letter-spacing: 0.04em; }
