/* ==========================================================
   シニア向け対話型AIパートナー — デモ用スタイル
   設計方針: 高コントラスト / 大きな文字 / 押し間違えない当たり判定
   ========================================================== */

:root {
  --bg: #FBF4E9;
  --bg-2: #F3E8D6;
  --ink: #2B2118;
  --ink-2: #6B5B4A;
  --card: #FFFDF9;
  --line: #E3D4BE;

  --accent: #B8562F;      /* 俳句モード（朱） */
  --accent-soft: #F6E4D8;
  --face-hi: #FFE9C9;
  --face-lo: #FFCE96;

  --danger: #B3261E;
  --ok: #4B6B3A;

  --shadow: 0 10px 30px rgba(90, 60, 30, .12);
  --radius: 22px;
}

#app[data-mode="chat"]  { --accent: #3F6B70; --accent-soft: #DCEAEB; --face-hi:#FFE9C9; --face-lo:#FFD3A2; }
#app[data-mode="quiz"]  { --accent: #6A5A9E; --accent-soft: #E6E1F2; --face-hi:#FFE9C9; --face-lo:#F5CBA9; }

* { box-sizing: border-box; }

/* hidden 属性は UA スタイルの display:none なので、
   .panel { display:flex } のような指定に負けてしまう。ここで確実に勝たせる。 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: radial-gradient(120% 90% at 50% 0%, var(--bg) 0%, var(--bg-2) 100%);
  color: var(--ink);
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 14px clamp(14px, 3vw, 34px) 10px;
  gap: 10px;
  max-width: 1280px;
  margin: 0 auto;
}

/* ---------------------------------------------------- ヘッダー */
#header {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-mark {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 22px; font-weight: 700;
  transition: background .3s;
}

.brand-name { font-size: 21px; font-weight: 700; letter-spacing: .04em; }

.env-chip {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 18px;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 999px;
  font-size: 19px; font-weight: 600;
  color: var(--ink-2);
}
.env-weather { color: var(--accent); }

.header-tools { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.tool-btn {
  font: inherit;
  font-size: 16px; font-weight: 600;
  padding: 10px 16px;
  min-height: 46px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--ink-2);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  transition: .15s;
}
.tool-btn:hover { border-color: var(--accent); color: var(--accent); }
.tool-btn-dev { border-style: dashed; }

.badge {
  min-width: 24px; height: 24px; padding: 0 6px;
  display: grid; place-items: center;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 13px; font-weight: 700;
}

/* ---------------------------------------------------- モード */
#modes { display: flex; gap: 12px; }

.mode-btn {
  flex: 1;
  font: inherit;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 16px 10px;
  min-height: 72px;
  font-size: clamp(19px, 2.3vw, 25px);
  font-weight: 700;
  color: var(--ink-2);
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: 18px;
  cursor: pointer;
  transition: .18s;
}
.mode-emoji { font-size: 1.4em; line-height: 1; }
.mode-btn:hover { border-color: var(--accent); }
.mode-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--shadow);
}

/* ---------------------------------------------------- ステージ */
#stage {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: clamp(16px, 3vw, 34px);
  align-items: center;
}

#faceCol { display: flex; flex-direction: column; align-items: center; gap: 10px; flex: 0 0 auto; }

.face-wrap { position: relative; width: clamp(150px, 21vw, 240px); }
#face { width: 100%; display: block; }

.halo { fill: none; stroke: var(--accent); stroke-width: 3; opacity: 0; }
.blush { fill: #F6A98A; opacity: .5; }
.eye-white { fill: #FFFDF8; }
.pupil { fill: #3A2C1F; transition: transform .3s ease; }
.glint { fill: #fff; }
#mouth { fill: #8A4A33; transition: rx .09s, ry .09s; }

/* 状態: まばたき・呼吸 */
@keyframes breathe { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-5px) } }
@keyframes blink   { 0%,94%,100% { transform: scaleY(1) } 97% { transform: scaleY(.08) } }
@keyframes haloPulse { 0% { opacity:.75; r:96 } 100% { opacity:0; r:116 } }
@keyframes lookUp  { 0%,100% { transform: translate(0,0) } 50% { transform: translate(3px,-6px) } }

#face { animation: breathe 4.5s ease-in-out infinite; }
#eyes { transform-origin: 120px 108px; animation: blink 5.2s infinite; }

.face-wrap.state-listening .halo { animation: haloPulse 1.5s ease-out infinite; }
.face-wrap.state-listening .pupil { transform: scale(1.15); }
.face-wrap.state-thinking .pupil { animation: lookUp 1.4s ease-in-out infinite; }

.think-dots {
  position: absolute; top: -6px; left: 50%; transform: translateX(-50%);
  display: none; gap: 8px;
}
.face-wrap.state-thinking .think-dots { display: flex; }
.think-dots i {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent);
  animation: dot 1.1s ease-in-out infinite;
}
.think-dots i:nth-child(2) { animation-delay: .18s }
.think-dots i:nth-child(3) { animation-delay: .36s }
@keyframes dot { 0%,100% { opacity:.25; transform: translateY(0) } 50% { opacity:1; transform: translateY(-8px) } }

.state-label {
  font-size: 16px; font-weight: 700; color: var(--ink-2);
  padding: 5px 15px; border-radius: 999px;
  background: var(--accent-soft);
  transition: .2s;
}

/* ---------------------------------------------------- 吹き出し */
.bubble {
  flex: 1;
  min-width: 0;
  align-self: stretch;
  position: relative;
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(20px, 3vw, 34px);
  display: flex; flex-direction: column; gap: 18px;
  overflow-y: auto;
  justify-content: center;
}

.bubble::before {
  content: '';
  position: absolute; left: -16px; top: 50%; margin-top: -14px;
  border: 14px solid transparent;
  border-right-color: var(--line);
}

.bubble-text {
  margin: 0;
  font-size: clamp(23px, 2.9vw, 34px);
  line-height: 1.75;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: pre-wrap;
}
.bubble-text.is-placeholder { color: var(--ink-2); font-weight: 500; }

/* 句が出たら主役は句。前置きの文は控えめにして場所をゆずる */
.bubble.has-haiku .bubble-text {
  font-size: clamp(16px, 1.8vw, 22px);
  line-height: 1.65;
  max-height: 8.5em;
  overflow-y: auto;
}

/* 俳句（縦書き） */
.haiku-box {
  border-top: 2px dashed var(--line);
  padding-top: 18px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  min-height: 0;
}
.haiku-inner {
  writing-mode: vertical-rl;
  text-orientation: upright;
  /* vertical-rl では row が「縦方向」になってしまう。
     三句を右から左へ並べるので、主軸はブロック方向 = column を使う */
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.6vw, 20px);
  flex: 1 1 auto;
  min-height: 0;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  font-size: clamp(17px, 2.1vw, 26px);
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: .14em;
  color: var(--ink);
  padding: 4px 0;
}
/* 折り返すと句が読めなくなるので、1句1列を死守する */
.haiku-line {
  white-space: nowrap;
  animation: fadeUp .5s both;
}
.haiku-line[data-i="1"] { animation-delay: .3s; padding-top: .7em; }
.haiku-line[data-i="2"] { animation-delay: .6s; padding-top: 1.4em; }

/* 横長の画面では、句を短冊のように文章の隣に立てる。
   縦に積むと吹き出しの高さが足りず、句が折り返してしまうため。 */
@media (min-width: 861px) and (orientation: landscape) {
  .bubble.has-haiku { flex-direction: row; align-items: stretch; gap: clamp(16px, 2vw, 28px); }
  .bubble.has-haiku .bubble-text { flex: 1 1 0; align-self: center; min-width: 0; }
  .bubble.has-haiku .haiku-box {
    flex: 0 0 auto;
    justify-content: center;
    border-top: none;
    border-left: 2px dashed var(--line);
    padding: 0 0 0 clamp(16px, 2vw, 28px);
  }
  .bubble.has-haiku .haiku-line[data-i="1"],
  .bubble.has-haiku .haiku-line[data-i="2"] { padding-top: 0; }
}
@keyframes fadeUp { from { opacity:0; transform: translateX(10px) } to { opacity:1; transform:none } }

.haiku-save {
  font: inherit; font-size: 17px; font-weight: 700;
  padding: 12px 26px; min-height: 50px;
  border-radius: 999px;
  border: 2px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.haiku-save:disabled { opacity: .45; cursor: default; }

/* 脳トレ */
.quiz-box {
  border: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 16px;
  padding: 20px 24px;
  position: relative;
}
.quiz-tag {
  position: absolute; top: -15px; left: 20px;
  background: var(--accent); color: #fff;
  font-size: 14px; font-weight: 700;
  padding: 4px 14px; border-radius: 999px;
}
.quiz-box p { margin: 4px 0 0; font-size: clamp(22px, 2.7vw, 31px); font-weight: 700; line-height: 1.6; }

/* ガード表示 */
.guard-note {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  border-left: 6px solid var(--danger);
  background: #FBEAE8;
  color: #7A1F19;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 16px; font-weight: 600;
}
.guard-note b { font-size: 15px; }

/* ---------------------------------------------------- 聞き取り */
/* 聞き取り中の吹き出し。
   出たり消えたりで画面が跳ねないよう、高さは常に確保して不透明度だけ切り替える。 */
.heard {
  flex: 0 0 auto;
  align-self: center;
  max-width: 92%;
  height: clamp(44px, 6vh, 56px);
  display: flex;
  align-items: center;
  padding: 0 26px;
  border-radius: 999px;
  background: var(--ink);
  color: #FFF6E8;
  font-size: clamp(17px, 2.1vw, 24px);
  font-weight: 600;
  opacity: 0;
  transition: opacity .16s ease;
  pointer-events: none;
  overflow: hidden;
}
.heard.is-on { opacity: 1; }
/* 長くなったら「古いほう」を隠して、いま話している末尾を必ず見せる */
.heard { justify-content: flex-end; }
.heard span { white-space: nowrap; flex: 0 0 auto; }
#heardInterim { opacity: .55; font-style: italic; }

/* ---------------------------------------------------- 音声認識ログ */
.asr-live {
  display: flex; align-items: baseline; gap: 12px;
  background: var(--ink); color: #FFF6E8;
  border-radius: 12px; padding: 14px 18px;
  min-height: 62px;
}
.asr-live-k { font-size: 12px; opacity: .7; flex: 0 0 auto; font-weight: 700; }
.asr-live-text { font-size: 19px; font-weight: 600; line-height: 1.5; word-break: break-all; }

.asr-meta {
  display: flex; flex-wrap: wrap; gap: 8px 18px;
  padding: 12px 4px 0;
  font-size: 13px; color: var(--ink-2);
}
.asr-meta b { color: var(--accent); font-size: 14px; }

.asr-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 6px;
  font-variant-numeric: tabular-nums;
}
.asr-row {
  display: grid;
  grid-template-columns: 62px 44px 1fr;
  gap: 10px;
  align-items: start;
  padding: 9px 12px;
  border-radius: 9px;
  background: #FDF9F1;
  font-size: 14px;
  line-height: 1.6;
}
.asr-time { color: #A6947E; font-size: 12px; padding-top: 2px; }
.asr-kind {
  font-size: 11px; font-weight: 700; text-align: center;
  padding: 3px 0; border-radius: 999px;
  background: var(--line); color: var(--ink-2);
}
.asr-body { min-width: 0; }
.asr-text { word-break: break-all; }

.asr-final { background: #F2F7EE; }
.asr-final .asr-kind { background: var(--ok); color: #fff; }
.asr-final .asr-text { font-weight: 700; font-size: 16px; }
.asr-interim { background: transparent; color: var(--ink-2); }
.asr-interim .asr-kind { background: transparent; border: 1px solid var(--line); }
.asr-interim .asr-text { font-style: italic; }
.asr-error { background: #FDF3F2; }
.asr-error .asr-kind { background: var(--danger); color: #fff; }
.asr-start .asr-kind, .asr-end .asr-kind { background: var(--accent-soft); color: var(--accent); }

.asr-conf {
  display: inline-block; margin-top: 4px;
  font-size: 11.5px; font-weight: 700;
  padding: 2px 9px; border-radius: 999px;
}
.asr-conf.is-high { background: #E3EFDC; color: #3D5A2E; }
.asr-conf.is-mid  { background: #FBEFD8; color: #7A5A18; }
.asr-conf.is-low  { background: #FBE0DD; color: #8C2A22; }
.asr-alts { margin-top: 4px; font-size: 12.5px; color: var(--ink-2); }

.asr-accurate { background: #EFF2FA; }
.asr-accurate .asr-kind { background: #4A5A8C; color: #fff; }
.asr-accurate .asr-text { font-weight: 700; font-size: 16px; }
.asr-compare {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 6px; font-size: 13px; color: var(--ink-2);
}
.asr-mark {
  font-size: 11px; font-weight: 700;
  padding: 2px 9px; border-radius: 999px;
}
.asr-mark.is-same { background: #E3EFDC; color: #3D5A2E; }
.asr-mark.is-diff { background: #FBE0DD; color: #8C2A22; }
.asr-browser-text { word-break: break-all; }

.asr-engine {
  display: flex; align-items: center; gap: 12px;
  margin: 14px 0 4px;
  font-size: 14px; font-weight: 700;
}
.asr-engine select {
  flex: 1; font: inherit; font-size: 14px; font-weight: 500;
  padding: 10px 12px; border-radius: 10px;
  border: 2px solid var(--line); background: var(--card);
}
.asr-engine select:disabled { opacity: .5; }
.asr-nokey { margin: 6px 0 0; font-size: 13px; color: var(--danger); font-weight: 600; }

.setting small { display: block; font-size: 12px; font-weight: 500; color: var(--ink-2); margin-top: 2px; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

/* ---------------------------------------------------- フッター */
#footer { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 0 0 auto; }

.mic-btn {
  position: relative;
  width: clamp(115px, 16vh, 162px);
  height: clamp(115px, 16vh, 162px);
  border-radius: 50%;
  border: none;
  padding: 0;
  cursor: pointer;
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 82%, white) 0%, var(--accent) 100%);
  box-shadow: 0 12px 26px rgba(120, 55, 25, .32), inset 0 -5px 12px rgba(0,0,0,.14);
  transition: transform .12s;
}
.mic-btn:active { transform: scale(.95); }

.mic-inner {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: #fff;
}
.mic-icon { width: 34%; fill: currentColor; stroke: currentColor; }
.mic-label { font-size: clamp(14px, 1.7vh, 18px); font-weight: 800; letter-spacing: .04em; }

.mic-ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 4px solid var(--accent);
  opacity: 0;
  pointer-events: none;
}
#app.is-listening .mic-ring   { animation: ring 1.6s ease-out infinite; }
#app.is-listening .mic-ring-2 { animation: ring 1.6s ease-out .8s infinite; }
@keyframes ring { 0% { opacity:.7; transform: scale(1) } 100% { opacity:0; transform: scale(1.45) } }

#app.is-busy .mic-btn { filter: grayscale(.45); opacity: .6; }

.hint { margin: 0; font-size: 15px; color: var(--ink-2); font-weight: 600; }

/* テキスト入力（保険） */
.text-fallback { display: flex; gap: 8px; justify-content: center; padding-bottom: 4px; }
.text-fallback input {
  font: inherit; font-size: 19px;
  padding: 12px 18px; min-width: min(460px, 70vw);
  border: 2px solid var(--line); border-radius: 12px; background: var(--card);
}
.text-fallback button {
  font: inherit; font-size: 17px; font-weight: 700;
  padding: 0 24px; border-radius: 12px;
  border: 2px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer;
}

/* ---------------------------------------------------- 緊急 */
.emergency {
  position: fixed; inset: 0; z-index: 100;
  background: var(--danger);
  color: #fff;
  display: grid; place-items: center;
  text-align: center;
  animation: emgIn .25s;
}
@keyframes emgIn { from { opacity: 0 } to { opacity: 1 } }
.emergency-inner { padding: 30px; }
.emergency-icon { font-size: 84px; animation: shake .9s ease-in-out infinite; }
@keyframes shake { 0%,100% { transform: rotate(-11deg) } 50% { transform: rotate(11deg) } }
.emergency h1 { font-size: clamp(38px, 7vw, 76px); margin: 14px 0 6px; letter-spacing: .04em; }
.emergency p  { font-size: clamp(22px, 3.4vw, 36px); margin: 0 0 26px; opacity: .92; }
.emergency-meta {
  display: flex; gap: 22px; justify-content: center; flex-wrap: wrap;
  font-size: 16px; opacity: .82; margin-bottom: 22px;
}
.emergency-close {
  font: inherit; font-size: 16px; font-weight: 700;
  padding: 12px 28px; border-radius: 999px;
  background: transparent; border: 2px solid rgba(255,255,255,.65); color: #fff; cursor: pointer;
}

/* ---------------------------------------------------- パネル */
.scrim { position: fixed; inset: 0; background: rgba(40, 26, 14, .45); z-index: 40; }

.panel {
  position: fixed; z-index: 50;
  top: 3vh; bottom: 3vh; right: 3vw;
  width: min(520px, 94vw);
  background: var(--card);
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(60, 35, 15, .3);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: slideIn .22s ease-out;
  user-select: text;
}
.panel-wide { width: min(760px, 94vw); }
@keyframes slideIn { from { opacity: 0; transform: translateX(28px) } to { opacity:1; transform:none } }

.panel-head {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 22px;
  border-bottom: 2px solid var(--line);
}
.panel-head h2 { margin: 0; font-size: 22px; flex: 1; display: flex; align-items: center; gap: 10px; }
.panel-tag {
  font-size: 12px; font-weight: 700; padding: 3px 10px;
  background: var(--accent-soft); color: var(--accent); border-radius: 999px;
}
.panel-close, .ghost-btn {
  font: inherit; font-size: 15px; font-weight: 700;
  padding: 10px 18px; min-height: 44px;
  border-radius: 12px;
  border: 2px solid var(--line); background: var(--card); color: var(--ink-2);
  cursor: pointer;
}
.ghost-btn.danger { color: var(--danger); border-color: #E9C9C5; }

.panel-body { flex: 1; overflow-y: auto; padding: 20px 22px; -webkit-overflow-scrolling: touch; }
.panel-lead { margin: 0 0 18px; font-size: 15px; line-height: 1.8; color: var(--ink-2); }
.panel-empty { color: var(--ink-2); font-size: 15px; text-align: center; padding: 30px 0; }
.panel-foot { display: flex; gap: 10px; padding: 14px 22px; border-top: 2px solid var(--line); }

/* 句集 */
.kushu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 14px; }
.kushu-card {
  background: #FFFBF2;
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 16px 8px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  min-height: 230px;
}
.kushu-card .k-body {
  writing-mode: vertical-rl; text-orientation: upright;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: 18px; letter-spacing: .1em; line-height: 1.5;
  /* vertical-rl では column がブロック方向（右→左）。row だと縦に積まれてしまう */
  display: flex; flex-direction: column; gap: 6px; flex: 1; min-height: 0;
  justify-content: center;
}
.kushu-card .k-body span { white-space: nowrap; }
.kushu-card .k-date { font-size: 12px; color: var(--ink-2); }

/* おもいで */
.memory-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.memory-list li {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--accent-soft);
  border-radius: 12px; padding: 14px 16px;
  font-size: 17px; line-height: 1.6;
}
.memory-list button {
  font: inherit; margin-left: auto; flex: 0 0 auto;
  border: none; background: none; color: var(--ink-2);
  font-size: 18px; cursor: pointer; padding: 0 4px;
}

/* 家族ダイジェスト */
.phone {
  width: 320px; margin: 0 auto;
  background: #1C1712; border-radius: 34px; padding: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,.28);
  position: relative;
}
.phone-notch {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  width: 110px; height: 20px; background: #1C1712; border-radius: 0 0 14px 14px; z-index: 2;
}
.phone-screen { background: #fff; border-radius: 24px; padding: 34px 18px 18px; min-height: 420px; }
.digest-head { border-bottom: 2px solid #EEE6D8; padding-bottom: 10px; margin-bottom: 14px; }
.digest-date { font-size: 12px; color: #9A8A78; font-weight: 700; }
.digest-head h3 { margin: 4px 0 0; font-size: 19px; }
.digest-body { display: flex; flex-direction: column; gap: 14px; font-size: 14px; line-height: 1.75; }
.digest-item { display: flex; gap: 10px; }
.digest-item .d-icon { flex: 0 0 auto; font-size: 17px; }
.digest-haiku {
  background: #FBF4E9; border-radius: 10px; padding: 14px;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  text-align: center; font-size: 16px; letter-spacing: .08em;
}
.digest-foot { margin-top: 18px; padding-top: 12px; border-top: 1px solid #EEE6D8; font-size: 11px; color: #9A8A78; }

/* 前提とリスク */
.notes h3 { font-size: 17px; margin: 26px 0 10px; padding-bottom: 6px; border-bottom: 2px solid var(--line); }
.notes h3:first-child { margin-top: 0; }
.note-list { margin: 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; }
.note-list li {
  font-size: 14.5px; line-height: 1.85;
  padding: 12px 14px 12px 16px;
  border-radius: 10px;
  border-left: 5px solid var(--line);
  background: #FDF9F1;
}
.note-list.good li { border-left-color: var(--ok); }
.note-list.bad  li { border-left-color: var(--danger); background: #FDF3F2; }
.try {
  display: inline-block; margin-top: 6px;
  background: var(--ok); color: #fff; font-size: 12.5px; font-weight: 700;
  padding: 4px 12px; border-radius: 999px;
}

.note-live { background: var(--accent-soft); border-radius: 14px; padding: 16px 18px; }
.note-live h3 { margin: 0 0 12px; border: none; padding: 0; }
.live-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 18px; }
.live-grid > div { display: flex; flex-direction: column; gap: 2px; }
.live-k { font-size: 12px; color: var(--ink-2); font-weight: 700; }
.live-v { font-size: 16px; font-weight: 600; }
.live-v b { font-size: 19px; color: var(--accent); }

.note-settings { margin-top: 26px; }
.setting {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
  font-size: 15px; font-weight: 600;
}
.setting > span { flex: 1; }
.setting select, .setting input[type="range"] { font: inherit; font-size: 15px; }
.setting select { padding: 8px 10px; border-radius: 8px; border: 2px solid var(--line); background: var(--card); }
.setting input[type="checkbox"] { width: 24px; height: 24px; accent-color: var(--accent); }
.setting output { font-variant-numeric: tabular-nums; color: var(--ink-2); min-width: 3em; text-align: right; }

/* ---------------------------------------------------- 合言葉ゲート */
.gate {
  position: fixed; inset: 0; z-index: 200;
  background: radial-gradient(120% 90% at 50% 0%, var(--bg) 0%, var(--bg-2) 100%);
  display: grid; place-items: center;
  padding: 24px;
}
.gate-card {
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 40px 34px;
  text-align: center;
  width: min(420px, 100%);
}
.gate-mark {
  width: 62px; height: 62px; margin: 0 auto 16px;
  display: grid; place-items: center;
  border-radius: 50%; background: var(--accent); color: #fff;
  font-size: 30px; font-weight: 700;
}
.gate-card h1 { font-size: 26px; margin: 0 0 6px; }
.gate-card p { font-size: 15px; color: var(--ink-2); margin: 0 0 22px; }
.gate-card input {
  font: inherit; font-size: 20px; text-align: center;
  width: 100%; padding: 14px; margin-bottom: 12px;
  border: 2px solid var(--line); border-radius: 12px; background: #FFFDF9;
}
.gate-card button {
  font: inherit; font-size: 18px; font-weight: 700;
  width: 100%; padding: 15px; border-radius: 12px;
  border: none; background: var(--accent); color: #fff; cursor: pointer;
}
.gate-error { color: var(--danger) !important; font-weight: 700; margin: 14px 0 0 !important; }

/* ---------------------------------------------------- トースト */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 120;
  background: var(--ink); color: #FFF6E8;
  padding: 14px 26px; border-radius: 999px;
  font-size: 17px; font-weight: 600;
  box-shadow: var(--shadow);
  animation: fadeIn .2s;
  max-width: 90vw; text-align: center;
}

/* ---------------------------------------------------- レイアウト調整 */
@media (max-width: 860px), (orientation: portrait) {
  #stage { flex-direction: column; }
  .bubble::before { display: none; }
  .bubble { align-self: auto; width: 100%; flex: 1; }
  .face-wrap { width: clamp(110px, 26vw, 170px); }
  .header-tools { width: 100%; margin-left: 0; }
  .mode-label { font-size: .9em; }
}

@media (max-height: 620px) {
  .face-wrap { width: 120px; }
  #modes .mode-btn { min-height: 58px; padding: 10px; }
}

/* ---------------------------------------------------- 印刷（句集） */
@media print {
  body { background: #fff; }
  #app > *:not(#panel-kushu), .scrim, .panel-head, .panel-foot, .panel-lead { display: none !important; }
  #panel-kushu {
    position: static; width: auto; box-shadow: none; border-radius: 0;
    display: block !important; animation: none;
  }
  .panel-body { overflow: visible; padding: 0; }
  .kushu-grid { grid-template-columns: repeat(3, 1fr); gap: 20px; }
  .kushu-card { break-inside: avoid; border-color: #999; }
}
