/* 千の間 — interface.
   Même socle que iki, ji et ten : le papier domine, hiérarchie par l'espacement,
   aucune couleur qui ne soit fonctionnelle, angles vifs. Le texte au centre,
   les réglages s'effacent à droite. */

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

* { 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 300px; height: 100vh; overflow: hidden }
/* sans min-height nul, le contenu d'une case de grille l'étire : la feuille
   cesserait de se répartir en colonnes et deviendrait une seule ligne. */
#scene > * { min-height: 0; min-width: 0 }

/* ---- la feuille ---- */
#stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 2rem 2rem 1rem }

/* le titre vit dans le panneau, comme dans 篆, 粋, 色 et 字 : le hanko rouge y
   ramène à l'accueil, et c'est le seul chemin de retour depuis l'outil. */
.accroche { display: flex; align-items: baseline; gap: 0.6rem; flex: none; padding-bottom: 1.1rem;
  font-size: 0.74rem; letter-spacing: 0.1em; color: var(--discret) }
.accroche .sujet { font-size: 1rem; letter-spacing: 0.18em; color: var(--encre) }

/* le compte vit dans le panneau, sous les sources */
.compte {
  font-size: 0.68rem; letter-spacing: 0.1em; color: var(--discret);
  padding-top: 0.5rem; line-height: 1.6;
}

.feuille {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  writing-mode: vertical-rl;
  text-orientation: upright;
  padding: 0.4rem 0;
  line-height: 1.5;
  font-size: var(--taille, 1.7rem);
}
.feuille.horizontal { writing-mode: horizontal-tb; text-orientation: mixed }

/* une expression : un groupe insécable, souligné d'un filet discret */
.mot {
  display: inline-block;
  cursor: pointer;
  border-inline-end: 1px solid transparent;
  padding-inline-end: 0.06em;
  margin-block-end: 0.34em;
  transition: background 0.12s;
}
.feuille.horizontal .mot { margin-inline-end: 0.34em; margin-block-end: 0 }
.mot:hover, .mot.actif { background: rgba(22, 19, 16, 0.07) }
.mot .kana { color: var(--discret) }

/* le filet qui sépare les séries, quand on classe par longueur */
.serie {
  display: block;
  font-size: 0.56rem;
  letter-spacing: 0.24em;
  color: var(--discret);
  border-inline-start: 1px solid var(--trait);
  margin-inline-start: 0.5em;
  padding-inline-start: 0.5em;
  writing-mode: inherit;
}

/* le point de séparation : présent, mais qui ne compte pas comme un caractère */
.sep { color: var(--discret); opacity: 0.55; font-size: 0.62em; margin-block-end: 0.34em; display: inline-block }

.vide { color: var(--discret); font-size: 0.86rem; writing-mode: horizontal-tb; letter-spacing: 0.1em }

/* ---- le panneau ---- */
#panel {
  background: var(--fond-panneau);
  border-left: 1px solid var(--trait);
  padding: 1.6rem 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  overflow-y: auto;
  font-family: 'Hiragino Kaku Gothic ProN', 'Yu Gothic', system-ui, sans-serif;
}

.marque { display: flex; flex-direction: column; gap: 0.3rem; padding-bottom: 1rem }
.marque-ligne { display: flex; align-items: center; gap: 0.6rem }
.marque-kanji { font-size: 1.5rem; letter-spacing: 0.15em; line-height: 1; font-weight: 400;
  font-family: 'Hiragino Mincho ProN', 'Yu Mincho', serif; display: flex; align-items: center }
.marque-nom { font-size: 0.7rem; letter-spacing: 0.35em; color: var(--discret); text-transform: lowercase }
.langues { display: flex; gap: 0.3rem; margin-left: auto }
.lang-opt {
  appearance: none; border: 1px solid var(--trait); background: none; color: var(--discret);
  font: inherit; font-size: 0.6rem; letter-spacing: 0.16em; padding: 0.1rem 0.45rem; cursor: pointer;
}
.lang-opt.actif { background: var(--encre); color: var(--papier); border-color: var(--encre) }

.section { margin-top: 0.9rem }
.section-tete {
  width: 100%; border: none; border-bottom: 1px solid var(--encre); background: none;
  color: var(--encre); font-size: 0.74rem; letter-spacing: 0.22em; text-transform: uppercase;
  padding: 1.5rem 0 0.45rem; margin-bottom: 0.5rem; text-align: left; font-weight: 400;
}

.bloc { display: flex; gap: 0.4rem; flex-wrap: wrap }
.action {
  appearance: none; border: 1px solid var(--encre); background: none; color: var(--encre);
  font: inherit; font-size: 0.74rem; letter-spacing: 0.18em; padding: 0.4rem 0.8rem; cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.action:hover { background: var(--encre); color: var(--papier) }
.action.majeure { flex: 1 1 auto; padding-block: 0.5rem }
.action[disabled] { opacity: 0.35; cursor: default }
.action[disabled]:hover { background: none; color: var(--encre) }

.cibles { display: flex; gap: 0.3rem; flex-wrap: wrap }
.cible {
  appearance: none; border: 1px solid var(--trait); background: none; color: var(--discret);
  font: inherit; font-size: 0.72rem; letter-spacing: 0.1em; padding: 0.25rem 0.6rem; cursor: pointer;
}
.cible.actif { border-color: var(--encre); color: var(--encre) }
/* réservé à la licence : lisible, mais visiblement sous clé */
.cible.reserve { color: rgba(139, 131, 120, 0.7) }
.cible.reserve::after { content: '許'; font-size: 0.56rem; margin-left: 0.3rem; color: var(--shu, #b8372a) }
.cible.reserve:hover { border-color: var(--discret); color: var(--encre) }
.note-licence { font-size: 0.66rem; line-height: 1.7; color: var(--discret); padding-top: 0.5rem }
.note-licence:empty { display: none }

.cases { display: flex; flex-direction: column; gap: 0.1rem }
.case {
  display: flex; align-items: baseline; gap: 0.45rem; font-size: 0.78rem; color: var(--encre);
  cursor: pointer; padding: 0.12rem 0;
}
.case input { accent-color: var(--encre); flex: none }
.case .nb { margin-left: auto; font-size: 0.64rem; color: var(--discret); font-variant-numeric: tabular-nums }

/* glissières : filet de 1 px, pastille d'encre — comme dans les autres modules */
.glissiere { padding: 0.45rem 0 0.2rem }
.glissiere .tete { display: flex; align-items: baseline; gap: 0.5rem; font-size: 0.74rem; color: var(--encre) }
.glissiere .valeur { margin-left: auto; font-size: 0.66rem; color: var(--discret); font-variant-numeric: tabular-nums }
.glissiere input[type='range'] { width: 100%; margin-top: 0.3rem; accent-color: var(--encre); height: 1rem }
.bornes { display: flex; justify-content: space-between; font-size: 0.58rem; color: var(--discret); letter-spacing: 0.1em }

.choix {
  width: 100%; appearance: none; border: 1px solid var(--trait); background: none; color: var(--encre);
  font: inherit; font-size: 0.78rem; padding: 0.3rem 0.4rem; cursor: pointer; border-radius: 0;
}
.note-police { font-size: 0.64rem; color: var(--discret); min-height: 1rem; padding-top: 0.25rem }

.version { margin-top: 1.6rem; font-size: 0.58rem; letter-spacing: 0.18em; color: var(--discret) }

.credit { margin-top: 0.8rem; font-size: 0.58rem; line-height: 1.7; color: var(--discret) }
.credit a { color: inherit }

/* ---- la fiche d'un mot ---- */
.fiche {
  position: fixed; z-index: 20; max-width: min(22rem, 86vw);
  background: var(--fond-panneau); border: 1px solid var(--encre); padding: 0.9rem 1rem;
  font-family: 'Hiragino Kaku Gothic ProN', 'Yu Gothic', system-ui, sans-serif;
  box-shadow: 0 6px 24px rgba(22, 19, 16, 0.12);
}
.fiche[hidden] { display: none }
.fiche .mot-t { font-size: 1.5rem; letter-spacing: 0.08em; font-family: 'Hiragino Mincho ProN', 'Yu Mincho', serif }
.fiche .mot-y { font-size: 0.76rem; color: var(--discret); letter-spacing: 0.1em; margin-top: 0.15rem }
.fiche .mot-s { font-size: 0.78rem; line-height: 1.6; margin-top: 0.45rem }
.fiche .mot-c { font-size: 0.62rem; letter-spacing: 0.14em; color: var(--discret); margin-top: 0.3rem }
.fiche .kanjis { margin-top: 0.7rem; border-top: 1px solid var(--trait); padding-top: 0.5rem; display: flex; flex-direction: column; gap: 0.35rem }
.fiche .kj { display: flex; align-items: baseline; gap: 0.5rem; font-size: 0.7rem; line-height: 1.4 }
.fiche .kj .c { font-size: 1.25rem; font-family: 'Hiragino Mincho ProN', 'Yu Mincho', serif; flex: none; width: 1.5em }
.fiche .kj .d { color: var(--discret); flex: 1 1 auto; min-width: 0 }
.fiche .kj .x { appearance: none; border: 1px solid var(--trait); background: none; color: var(--discret); font: inherit; font-size: 0.6rem; padding: 0 0.3rem; cursor: pointer; flex: none }
.fiche .kj .x:hover { border-color: var(--encre); color: var(--encre) }
.fiche .outils { display: flex; gap: 0.4rem; margin-top: 0.7rem }
.fiche .outils .action { font-size: 0.68rem; padding: 0.25rem 0.6rem }

.exclus { font-size: 0.66rem; color: var(--discret); line-height: 1.8; margin-top: 0.4rem }
.exclus button { appearance: none; border: 1px solid var(--trait); background: none; font: inherit; cursor: pointer; padding: 0 0.25rem; margin: 0 0.1rem; color: inherit }
.exclus button:hover { border-color: var(--encre); color: var(--encre) }

/* ---- écran étroit : le panneau passe dessous ---- */
@media (max-width: 760px) {
  #scene { grid-template-columns: 1fr; height: auto }
  #stage { padding: 1rem 1rem 0; height: 68vh }
  #panel { border-left: none; border-top: 1px solid var(--trait) }
}

/* ---- impression : rien que la feuille ---- */
@media print {
  #panel, #entete, .fiche { display: none !important }
  #scene { display: block; height: auto }
  #stage { padding: 0 }
  .feuille { overflow: visible; height: auto; font-size: 1.5rem }
  body { background: #fff }
}
