:root {
  --bg: #f6f5f2; --panel: #ffffff; --ink: #1d1d1b; --sub: #6b6a66; --line: #e4e2dc;
  --track: #eeece7; --ok: #1f9d6b; --warn: #d98a12; --bad: #d6452f; --accent: #2f5bd8;
  --hot: var(--bad); --hot-bg: rgba(214, 69, 47, .16); --hot-soft: rgba(217, 138, 18, .15);
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121211; --panel: #1b1b1a; --ink: #ecebe7; --sub: #9b9a95; --line: #2c2c2a;
    --track: #262624; --ok: #3cc28b; --warn: #f0a63a; --bad: #f06a52; --accent: #7e9cff;
    --hot-bg: rgba(240, 106, 82, .22); --hot-soft: rgba(240, 166, 58, .18);
    --shadow: none;
  }
}
/* ページごとの「光らせる色」 */
body[data-mode="aite"] { --hot: #8b5cf6; --hot-bg: rgba(139, 92, 246, .16); --hot-soft: rgba(139, 92, 246, .08); }
body[data-mode="jibun"] { --hot: #2f8fd8; --hot-bg: rgba(47, 143, 216, .16); --hot-soft: rgba(47, 143, 216, .08); }

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.6; -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 24px 48px; }
nav { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 20px; }
nav a {
  color: var(--sub); text-decoration: none; font-size: 13px; padding: 6px 12px; border-radius: 8px;
  border: 1px solid transparent;
}
nav a:hover { color: var(--ink); }
nav a[aria-current="page"] { color: var(--ink); border-color: var(--line); background: var(--panel); }
header { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
h1 { font-size: 28px; margin: 0; letter-spacing: .02em; }
header p { margin: 0; color: var(--sub); font-size: 14px; }
.grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; box-shadow: var(--shadow); }
.stack { display: grid; gap: 16px; }
.label { font-size: 12px; color: var(--sub); letter-spacing: .06em; margin: 0 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: transparent; color: var(--ink); border-radius: 999px;
  padding: 6px 14px; font: inherit; font-size: 14px; cursor: pointer; transition: background .15s, border-color .15s;
}
.chip:hover { border-color: var(--sub); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--panel); border-color: var(--ink); }
input[type="text"], textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; outline: none; transition: border-color .15s;
}
input[type="text"]:focus, textarea:focus { border-color: var(--accent); }
textarea { min-height: 170px; resize: vertical; font-size: 16px; line-height: 1.75; }
.samples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.samples button {
  font: inherit; font-size: 12px; color: var(--sub); background: none; border: 1px dashed var(--line);
  border-radius: 8px; padding: 4px 10px; cursor: pointer;
}
.samples button:hover { color: var(--ink); border-color: var(--sub); }
.xray { font-size: 16px; line-height: 2; min-height: 2em; }
.xray .s { border-radius: 4px; padding: 2px 1px; transition: background .3s; }
.xray .s[data-level="hot"] { background: var(--hot-bg); text-decoration: underline wavy var(--hot); text-underline-offset: 5px; }
.xray .s[data-level="warm"] { background: var(--hot-soft); }
.xray .pct { font-size: 11px; color: var(--sub); margin-left: 2px; vertical-align: super; }
.empty { color: var(--sub); font-size: 14px; }

.verdict { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: center; }
.gauge { width: 132px; height: 132px; position: relative; }
.gauge svg { transform: rotate(-90deg); }
.gauge .num { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.gauge .num b { font-size: 34px; font-variant-numeric: tabular-nums; line-height: 1; }
.gauge .num small { display: block; font-size: 11px; color: var(--sub); margin-top: 4px; }
.verdict h2 { margin: 0 0 4px; font-size: 22px; }
.verdict p { margin: 0; color: var(--sub); font-size: 14px; }
[hidden] { display: none !important; }
.tag { display: inline-block; font-size: 12px; border: 1px solid var(--line); border-radius: 6px; padding: 1px 8px; margin-top: 8px; color: var(--sub); }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.big { font-size: 20px; font-weight: 700; margin: 0; }
.conf { font-size: 12px; color: var(--sub); }
.stackbar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--track); margin: 10px 0 6px; }
.stackbar span { transition: width .4s ease; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--sub); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; }
.toplist { margin: 8px 0 0; padding: 0; list-style: none; font-size: 13px; }
.toplist li { display: flex; justify-content: space-between; gap: 8px; color: var(--sub); }
.toplist li:first-child { color: var(--ink); }

.scale-row + .scale-row { margin-top: 18px; }
.scale { position: relative; height: 10px; border-radius: 999px; opacity: .85; margin: 14px 0 6px; }
.scale[data-sweet="middle"] { background: linear-gradient(90deg, var(--bad), var(--warn) 25%, var(--ok) 50%, var(--warn) 78%, var(--bad)); }
.scale[data-sweet="high"] { background: linear-gradient(90deg, var(--bad), var(--warn) 45%, var(--ok)); }
.scale[data-sweet="low"] { background: linear-gradient(90deg, var(--ok), var(--warn) 55%, var(--bad)); }
.scale .pin { position: absolute; top: 50%; width: 18px; height: 18px; border-radius: 50%; background: var(--panel); border: 3px solid var(--ink); transform: translate(-50%, -50%); transition: left .4s ease; }
.scale-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--sub); gap: 4px; }

.bars { display: grid; gap: 9px; }
.bar { display: grid; grid-template-columns: 9.6em 1fr 3em; gap: 10px; align-items: center; font-size: 13px; }
.bar .track { height: 8px; background: var(--track); border-radius: 999px; overflow: hidden; }
.bar .fill { height: 100%; width: 0; border-radius: 999px; transition: width .4s ease, background .4s; }
.bar .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--sub); }

.alert { border-color: var(--bad); }
.alert p { margin: 0 0 8px; font-size: 14px; }
.alert a { display: block; color: var(--accent); font-weight: 700; font-size: 15px; margin-top: 4px; }

.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: center; font-size: 12px; color: var(--sub); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--line); margin-right: 6px; vertical-align: 1px; }
.dot.live { background: var(--ok); }
.dot.busy { background: var(--warn); animation: pulse 1s infinite; }
.dot.err { background: var(--bad); }
@keyframes pulse { 50% { opacity: .3; } }
.spark { width: 160px; height: 28px; }
.err { color: var(--bad); font-size: 13px; margin-top: 8px; }
.notice { margin: 0; font-size: 12px; color: var(--sub); line-height: 1.7; }

/* ---- 絵で見せる結果 ---- */
.stage { text-align: center; padding: 18px 20px 22px; transition: opacity .2s; }
.stage.busy { opacity: .75; }
.stage-label { margin: 0; font-size: 14px; color: var(--sub); font-weight: 700; }
.face-wrap { position: relative; width: min(260px, 70vw); aspect-ratio: 1; margin: 4px auto 0; }
.face svg { width: 100%; height: 100%; display: block; }
.face.pop { animation: face-pop .35s cubic-bezier(.3,1.6,.5,1); }
@keyframes face-pop { 0% { transform: scale(.9); } 100% { transform: scale(1); } }
.fx { position: absolute; opacity: 0; transform: scale(.4); transition: opacity .3s, transform .35s cubic-bezier(.3,1.6,.5,1); pointer-events: none; }
.fx.on { opacity: 1; transform: scale(1); }
.fx-anger { width: 24%; right: 0; top: 6%; }
.fx-sweat { width: 15%; left: 3%; top: 26%; }
.fx-heart { width: 20%; right: -2%; bottom: 14%; }
.fx-sparkle { width: 24%; left: -2%; top: 0; }
.sound { position: absolute; width: 52%; right: -22%; top: -6%; transform: rotate(-10deg); pointer-events: none; }
.sound.pop { animation: pop .45s cubic-bezier(.3,1.7,.5,1); }
@keyframes pop { 0% { transform: rotate(-10deg) scale(.2); opacity: 0; } 100% { transform: rotate(-10deg) scale(1); opacity: 1; } }
.bubble {
  position: relative; display: inline-block; margin: 6px 0 4px; background: var(--panel); color: var(--ink);
  border: 2px solid var(--hot); border-radius: 18px; padding: 6px 14px; font-size: 15px; font-weight: 700; line-height: 1.4;
}
.bubble::before { content: "💭"; margin-right: 6px; }
.bubble::after { content: ""; position: absolute; left: 50%; top: -9px; width: 14px; height: 14px; margin-left: -7px; background: var(--panel); border-left: 2px solid var(--hot); border-top: 2px solid var(--hot); transform: rotate(45deg); }
.headline { margin: 2px 0 6px; font-size: 30px; letter-spacing: .02em; }
.pill { display: inline-flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 999px; padding: 4px 6px 4px 14px; font-size: 14px; font-weight: 700; }
.pill b { font-size: 16px; background: var(--bg); border-radius: 999px; padding: 2px 10px; font-variant-numeric: tabular-nums; }
.extras { display: flex; justify-content: center; flex-wrap: wrap; gap: 18px; margin-top: 16px; }
.extras:empty, .icon-chips:empty { display: none; }
.meter { display: grid; justify-items: center; gap: 4px; min-width: 64px; }
.meter small { font-size: 11px; color: var(--sub); line-height: 1.4; }
.meter.advice small b { color: var(--ink); font-size: 13px; }
.big-emoji { font-size: 38px; line-height: 1.1; }
.battery { position: relative; width: 52px; height: 26px; border: 3px solid var(--ink); border-radius: 6px; padding: 2px; margin-top: 8px; }
.battery::after { content: ""; position: absolute; right: -8px; top: 6px; width: 4px; height: 8px; background: var(--ink); border-radius: 0 2px 2px 0; }
.battery i { display: block; height: 100%; border-radius: 2px; transition: width .5s; }
.thermo { width: 16px; height: 42px; border: 3px solid var(--ink); border-radius: 10px; display: flex; align-items: flex-end; padding: 2px; overflow: hidden; }
.thermo i { display: block; width: 100%; border-radius: 6px; transition: height .5s; }
.icon-chips { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.ichip { display: inline-flex; align-items: center; gap: 6px; background: var(--hot-soft); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px 5px 8px; font-size: 13px; font-weight: 700; }
.ichip.good { background: rgba(31,157,107,.1); }
.ichip .ico { font-size: 18px; }
.ichip small { color: var(--sub); font-weight: 400; }
details.more summary { cursor: pointer; color: var(--sub); font-size: 13px; list-style: none; text-align: center; }
details.more summary::before { content: "▸ "; }
details.more[open] summary::before { content: "▾ "; }
.mini-face { width: 40px; height: 40px; flex: none; }
.mini-face svg { width: 100%; height: 100%; }

.mini { display: none; }
@media (max-width: 860px) {
  .wrap { padding: 16px 16px 96px; }
  .grid { grid-template-columns: 1fr; }
  .split { grid-template-columns: 1fr; }
  .scale-labels[data-n="5"] span:nth-child(2n) { visibility: hidden; }
  .mini {
    display: flex; align-items: center; gap: 12px; position: fixed; left: 12px; right: 12px; bottom: 12px;
    background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 16px;
    box-shadow: 0 8px 28px rgba(0,0,0,.18); z-index: 10; font-size: 14px;
  }
  .mini b { font-size: 24px; font-variant-numeric: tabular-nums; min-width: 2ch; margin-left: auto; }
  .mini .t { font-weight: 700; font-size: 16px; }
  .face-wrap { width: min(220px, 58vw); }
  /* スマホは「入力 → 顔 → 光る一文 → くわしく」の順 */
  .grid > .stack { display: contents; }
  .grid { display: flex; flex-direction: column; align-items: stretch; gap: 16px; }
  .o-input { order: 1; } .o-stage { order: 2; } .o-alert { order: 3; } .o-xray { order: 4; } .o-more { order: 5; } .o-notice { order: 6; }
  .sound { right: -30%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
