:root {
  --accent: #e0446c;
  --accent2: #ff9f43;
  --bg: #fff5f7;
  --surface: #ffffff;
  --ink: #2b2438;
  --muted: #706880;
  --line: #f0dfe5;
  --soft: #ffe8ee;
  --good: #0b7a4b;
  --warn: #a35200;
  --danger: #c4243c;
  --radius: 18px;
  color-scheme: light;
}
:root[data-theme="ocean"] { --accent: #1668c4; --accent2: #12a5b8; --bg: #eef7fd; --line: #d5e8f5; --soft: #ddeefb; }
:root[data-theme="forest"] { --accent: #1d7f4e; --accent2: #8ab61c; --bg: #f1f8ee; --line: #dbead4; --soft: #e1f1da; }
:root[data-theme="sunset"] { --accent: #c4511c; --accent2: #d6336c; --bg: #fff4ea; --line: #f4dfcc; --soft: #ffe6d1; }
:root[data-theme="galaxy"] { --accent: #6a4fd0; --accent2: #c34fb8; --bg: #f3f0fd; --line: #e1daf6; --soft: #e9e3fc; }

@media (prefers-color-scheme: dark) {
  :root, :root[data-theme] {
    --bg: #15121d; --surface: #211d2c; --ink: #f1edf8; --muted: #a9a1ba; --line: #383147; --soft: #342b44;
    --good: #52d69a; --warn: #ffb35c; --danger: #e5566a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Hiragino Maru Gothic ProN", "Hiragino Sans", "Noto Sans JP", Meiryo, sans-serif;
  padding-bottom: calc(86px + env(safe-area-inset-bottom));
}
body.timing { padding-bottom: calc(160px + env(safe-area-inset-bottom)); }
body.locked { overflow: hidden; }
h2 { font-size: 1.2rem; margin: .4em 0; }
h3 { font-size: 1.02rem; margin: 0; }
h4 { margin: 12px 0 6px; font-size: .9rem; color: var(--muted); }
p { margin: .5em 0; }
small { font-size: .76rem; }
.muted { color: var(--muted); font-size: .85rem; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; margin-top: 12px; }
.row.center-row { justify-content: center; }
.col { display: flex; flex-direction: column; gap: 8px; align-items: stretch; margin-top: 8px; }

/* ---------- ボタン・入力 ---------- */
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--accent2); outline-offset: 2px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 18px;
  border: 2px solid var(--line); border-radius: 999px; background: var(--surface);
  font-weight: 700; transition: transform .08s, filter .15s;
}
.btn:active, .item:active, .icon-btn:active { transform: scale(.95); }
.btn:hover { filter: brightness(1.04); }
.btn.small { white-space: nowrap; min-height: 34px; padding: 3px 12px; font-size: .82rem; }
.btn.primary, .btn.start { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 4px 0 color-mix(in srgb, var(--accent) 60%, #000); }
.btn.stop { background: #2b2438; border-color: #2b2438; color: #fff; font-variant-numeric: tabular-nums; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.start { width: 100%; margin-top: 10px; min-height: 50px; font-size: 1.05rem; }
.big-btn { min-height: 54px; font-size: 1.1rem; }
.pulse { animation: pulse 1.4s ease-in-out infinite; }
.icon-btn { min-width: 40px; min-height: 40px; border: 0; border-radius: 50%; background: transparent; }
.icon-btn:hover { background: var(--soft); }

/* ---------- 全体レイアウト ---------- */
#head, #view { max-width: 920px; margin: 0 auto; }
#head { display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 14px 6px; }
.avatar { width: 52px; height: 52px; padding: 2px; border: 2px solid var(--accent); border-radius: 50%; background: var(--surface); }
.avatar svg { width: 100%; height: 100%; }
.head-mid { flex: 1; min-width: 0; }
.head-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { display: inline-block; padding: 4px 11px; border-radius: 999px; background: var(--surface); border: 2px solid var(--line); font-weight: 700; white-space: nowrap; }
.chip.hot { border-color: var(--accent2); background: color-mix(in srgb, var(--accent2) 18%, var(--surface)); }
.chips { display: flex; gap: 8px; justify-content: center; }
#view { padding: 4px 12px 12px; }
.card { background: var(--surface); border-radius: var(--radius); padding: 14px; margin: 12px 0; box-shadow: 0 3px 14px #3a1c4a12; border: 1px solid var(--line); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 12px; align-items: start; }
.cards .card { margin: 0; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

#nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
#nav button { min-width: 0; white-space: nowrap; flex: 1; max-width: 150px; display: flex; flex-direction: column; align-items: center; gap: 0; padding: 7px 0 8px; border: 0; background: none; font-size: .68rem; color: var(--muted); }
#nav button span { font-size: 1.35rem; line-height: 1.3; padding: 0 14px; border-radius: 999px; transition: background .2s, transform .2s; }
#nav button[aria-current="page"] { color: var(--accent); font-weight: 800; }
#nav button[aria-current="page"] span { background: var(--soft); transform: translateY(-2px); }

.bar { height: 10px; border-radius: 99px; background: var(--soft); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: var(--c, var(--accent)); transition: width .6s; }
.bar.xp i { background: linear-gradient(90deg, var(--accent), var(--accent2)); }

/* ---------- カレンダー ---------- */
.cal { padding: 10px 6px; }
.cal-nav { display: flex; align-items: center; justify-content: center; gap: 6px; }
.cal-nav h2 { margin: 0; min-width: 7.2em; text-align: center; white-space: nowrap; }
.cal-head, .week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-head { text-align: center; font-size: .75rem; font-weight: 700; color: var(--muted); margin: 6px 0 2px; }
.sun { color: var(--danger); }
.sat { color: #2a6fd6; }
.week { grid-template-rows: 28px repeat(6, minmax(2px, auto)) auto; row-gap: 1px; border-top: 1px solid var(--line); padding-bottom: 2px; }
.day { grid-row: 1 / -1; position: relative; display: flex; justify-content: center; align-items: flex-start; border: 0; border-radius: 10px; background: none; padding: 3px 0 0; }
.day:hover { background: color-mix(in srgb, var(--soft) 55%, transparent); }
.day.sel { background: var(--soft); box-shadow: inset 0 0 0 2px var(--accent); }
.day.out { opacity: .38; }
.day .num { width: 26px; height: 26px; line-height: 26px; border-radius: 50%; font-weight: 700; font-size: .85rem; }
.day.is-today .num { background: var(--accent); color: #fff; }
.studied { position: absolute; top: 0; right: 0; font-size: .55rem; }
.ev { height: 18px; pointer-events: none; z-index: 1; margin: 0 2px; padding: 0 3px; border-radius: 5px; font-size: .64rem; font-weight: 700; line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: clip; }
.ev.exam { background: var(--c); color: var(--on); }
.ev.apply { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--c) 34%, var(--surface)) 0 6px, color-mix(in srgb, var(--c) 18%, var(--surface)) 6px 12px); border: 1.5px solid var(--c); line-height: 15px; }
.ev.exam.tentative { background: color-mix(in srgb, var(--c) 22%, var(--surface)); color: var(--ink); border: 2px dashed var(--c); line-height: 14px; }
.ev.applyPlan { background: color-mix(in srgb, var(--c) 14%, var(--surface)); border: 1.5px dotted var(--c); line-height: 15px; }
.ev.payment, .ev.result, .ev.other { background: var(--surface); border: 1.5px dashed var(--c); line-height: 15px; }
.ev.cl { margin-left: 0; border-radius: 0 5px 5px 0; border-left-width: 0; }
.ev.cr { margin-right: 0; border-radius: 5px 0 0 5px; border-right-width: 0; }
.ev.cl.cr { border-radius: 0; }
.ev.done { opacity: .45; text-decoration: line-through; }
.more { z-index: 1; pointer-events: none; text-align: center; font-size: .62rem; line-height: 14px; color: var(--muted); font-weight: 700; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; justify-content: center; margin-top: 8px; font-size: .72rem; color: var(--muted); }
.legend i { display: inline-block; vertical-align: -1px; margin-right: 3px; }
.next-exams { display: grid; gap: 4px; margin: 10px 4px 0; }
.next-exams button { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 4px 12px; border: 0; border-radius: 12px; background: color-mix(in srgb, var(--c) 11%, var(--surface)); text-align: left; font-size: .84rem; }
.next-exams .grow { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.next-exams b { min-width: 4.8em; text-align: right; }
.lg { width: 18px; height: 10px; border-radius: 3px; }
.lg.exam { background: var(--muted); }
.lg.apply { border: 1.5px solid var(--muted); background: repeating-linear-gradient(135deg, var(--line) 0 3px, transparent 3px 6px); }
.lg.tentative { border: 2px dashed var(--muted); background: var(--line); }
.lg.applyPlan { border: 2px dotted var(--muted); }
.lg.other { border: 1.5px dashed var(--muted); }
.dot { flex: none; width: 11px; height: 11px; border-radius: 50%; background: var(--c); display: inline-block; }

/* ---------- ホーム ---------- */
.speech { display: flex; align-items: center; gap: 10px; }
.mini-buddy { width: 74px; flex: none; }
.speech p { position: relative; flex: 1; background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 10px 14px; font-weight: 700; }
.speech p::before { content: ""; position: absolute; left: -8px; top: calc(50% - 7px); width: 12px; height: 12px; background: var(--surface); border-left: 2px solid var(--line); border-bottom: 2px solid var(--line); transform: rotate(45deg); }
.alert { display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin: 8px 0; border-radius: var(--radius); background: color-mix(in srgb, var(--accent2) 16%, var(--surface)); border: 2px solid var(--accent2); font-size: .86rem; }
.alert > span { font-size: 1.5rem; }
.alert.urgent { background: color-mix(in srgb, var(--danger) 13%, var(--surface)); border-color: var(--danger); animation: pulse 2s ease-in-out infinite; }
.welcome { padding: 26px 14px; }

.list { list-style: none; margin: 8px 0 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }

.exam { border-top: 6px solid var(--c); }
.card-head { display: flex; align-items: center; gap: 8px; }
.card-head h3 { overflow-wrap: anywhere; }
.emoji { font-size: 1.7rem; }
.badge-s { font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--soft); white-space: nowrap; }
.badge-s.good { color: var(--good); }
.badge-s.warn { color: var(--warn); }
.cd { display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 4px 8px; margin: 8px 0; padding: 8px; border-radius: 14px; background: color-mix(in srgb, var(--c) 11%, var(--surface)); }
.cd.tentative { border: 2px dashed var(--c); }
.cd b { font-size: 3rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.cd small { flex-basis: 100%; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.cd.today { flex-direction: column; align-items: center; }
.cd.today b { font-size: 1.6rem; }
.progress { font-size: .84rem; }
.progress .bar { height: 14px; margin-bottom: 3px; }
.quota { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; text-align: center; }
.quota div { border: 2px dashed var(--line); border-radius: 14px; padding: 4px; }
.quota small { display: block; color: var(--muted); }
.quota b { font-size: 1.15rem; }
.hours { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 10px; text-align: center; background: var(--soft); border-radius: 14px; padding: 6px 0; }
.hours div + div { border-left: 1px solid var(--line); }
.hours small { display: block; color: var(--muted); min-height: 1.4em; }
.hours b { font-size: 1.05rem; }
.row.three { flex-wrap: nowrap; align-items: flex-end; }
.form .row.three label { min-width: 0; }
.sources { margin: 0; padding-left: 18px; font-size: .84rem; }
.sources a { color: var(--accent); font-weight: 700; }
.sources small { display: block; color: var(--muted); overflow-wrap: anywhere; line-height: 1.3; }
.due { color: var(--danger); font-weight: 700; }
.field { display: flex; flex-direction: column; gap: 3px; margin: 10px 0 4px; font-size: .84rem; font-weight: 700; }
.ai pre { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: .78rem; background: var(--soft); border-radius: 10px; padding: 8px 10px; max-height: 260px; overflow: auto; }
.offline { background: var(--soft); border-radius: 10px; padding: 8px 10px; font-weight: 700; }
.answer { margin-top: 10px; border-top: 2px dashed var(--line); padding-top: 6px; overflow-wrap: anywhere; font-size: .9rem; }
.answer h4 { color: var(--accent); font-size: 1rem; margin: 14px 0 4px; }
.answer ul, .answer ol { margin: 4px 0; padding-left: 1.4em; }
.asked { font-weight: 700; }
.thinking { animation: pulse 1.4s ease-in-out infinite; }
.btn:disabled { opacity: .45; cursor: default; }
.next { font-size: .85rem; }
.result-ask { margin-top: 8px; }
.timer-row { display: flex; gap: 8px; margin-top: 10px; }
.timer-row .stop { flex: 1; min-height: 50px; animation: glow 1.8s ease-in-out infinite; }
.memo { white-space: pre-wrap; font-size: .85rem; background: var(--soft); border-radius: 10px; padding: 8px 10px; overflow-wrap: anywhere; }
summary { cursor: pointer; font-weight: 700; font-size: .88rem; padding: 6px 0; }
.check { display: flex !important; flex-direction: row !important; align-items: center; gap: 10px; min-height: 36px; font-weight: 400 !important; }
.check input { width: 20px !important; height: 20px; min-height: 0 !important; flex: none; accent-color: var(--accent); }
/* 取り消し線は、やることリストと予定の「済」だけ */
.check input:is([data-change="task"], [data-change="done"]):checked + span { text-decoration: line-through; color: var(--muted); }
.check.mini { gap: 4px; }
.timer-mode .row { gap: 8px 20px; }
.timer-desc { margin: 4px 0 0; }
.switch { display: flex !important; flex-direction: row !important; flex: none !important; align-items: center; gap: 8px; min-height: 40px; margin: 0 !important; font-weight: 700; cursor: pointer; position: relative; }
.switch input { position: absolute; right: 0; width: 48px; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.switch i { width: 48px; height: 28px; border-radius: 99px; background: color-mix(in srgb, var(--muted) 40%, var(--surface)); position: relative; pointer-events: none; transition: background .2s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px #0004; transition: transform .2s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(20px); }
.switch input:focus-visible + i { outline: 3px solid var(--accent2); outline-offset: 2px; }
.switch.off { opacity: .45; cursor: default; }
.sounds { display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); gap: 6px; margin-top: 8px; }
.sounds button { display: flex; flex-direction: column; align-items: center; padding: 8px 2px; border: 2px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); font-size: .78rem; font-weight: 700; line-height: 1.4; }
.sounds button span { font-size: 1.5rem; }
.sounds button small { color: var(--muted); }
.sounds button.on { border-color: var(--accent); background: var(--soft); }
.sounds button.playing span { animation: bounce 1.4s ease-in-out infinite; }
.volume { display: flex !important; flex-direction: row !important; align-items: center; gap: 10px; margin: 8px 0 0 !important; font-size: .84rem; white-space: nowrap; }
.volume input { flex: 1; min-width: 0; min-height: 32px !important; padding: 0 !important; border: 0 !important; background: transparent !important; accent-color: var(--accent); }
.chip.playing { background: var(--soft); border-color: var(--accent); }
.quest .bar { height: 7px; margin: 3px 0; }
.quest.done .emoji { animation: bounce 1.2s ease-in-out infinite; }

/* ---------- 記録 ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.tile small { display: block; color: var(--muted); }
.tile b { font-size: 1.35rem; }
.chart { display: flex; gap: 6px; margin-top: 12px; }
.yaxis { display: flex; flex-direction: column; justify-content: space-between; height: 156px; font-size: .68rem; color: var(--muted); text-align: right; margin-top: -8px; }
.cols { flex: 1; display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 2px; }
.col-bar { display: flex; flex-direction: column; align-items: stretch; padding: 0; border: 0; background: none; }
.col-bar .plot { height: 140px; display: flex; align-items: flex-end; justify-content: center; border-bottom: 1px solid var(--muted); background: linear-gradient(var(--line), var(--line)) top / 100% 1px no-repeat, linear-gradient(var(--line), var(--line)) center / 100% 1px no-repeat; }
.col-bar i { width: min(70%, 24px); border-radius: 4px 4px 0 0; background: var(--accent); }
.col-bar:hover .plot, .col-bar:focus-visible .plot { background-color: var(--soft); }
.col-bar small { font-size: .65rem; color: var(--muted); }
.col-bar small.now { color: var(--accent); font-weight: 800; }
.tip { min-height: 1.5em; text-align: center; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th, td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, auto); grid-auto-columns: minmax(0, 1fr); gap: 2px; margin-top: 10px; max-width: 520px; margin-inline: auto; }
.cell { aspect-ratio: 1; padding: 0; border: 0; border-radius: 3px; background: color-mix(in srgb, var(--muted) 16%, var(--surface)); }
.legend .cell { width: 11px; }
.cell.l1 { background: color-mix(in srgb, var(--accent) 30%, var(--surface)); }
.cell.l2 { background: color-mix(in srgb, var(--accent) 52%, var(--surface)); }
.cell.l3 { background: color-mix(in srgb, var(--accent) 76%, var(--surface)); }
.cell.l4 { background: var(--accent); }
.cell.frozen { box-shadow: inset 0 0 0 2px #4cc9f0; }
.forest { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; }
.forest figure { width: 86px; margin: 0; text-align: center; animation: pop .5s both; }
.forest figcaption { font-size: .72rem; color: var(--muted); }
.hbar { margin: 10px 0; font-size: .86rem; }

/* ---------- ごほうび ---------- */
.stage { background: linear-gradient(180deg, var(--soft), var(--surface)); }
.big-buddy { width: 190px; margin: 0 auto; cursor: pointer; }
.big-buddy.jump { animation: jump .6s; }
.buddy { display: block; width: 100%; overflow: visible; }
.buddy .body { transform-origin: 60px 118px; animation: breathe 3s ease-in-out infinite; }
.buddy .eye { transform-origin: center; transform-box: fill-box; animation: blink 4.5s infinite; }
.buddy.happy .wing.l { transform-origin: 28px 70px; animation: flapL .9s ease-in-out infinite; }
.buddy.happy .wing.r { transform-origin: 92px 70px; animation: flapR .9s ease-in-out infinite; }
.shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.item { display: flex; flex-direction: column; align-items: center; padding: 10px 4px; border: 2px solid var(--line); border-radius: 14px; background: var(--surface); }
.item b { font-size: .74rem; line-height: 1.3; }
.item.on { border-color: var(--accent); background: var(--soft); }
.item[data-locked] { opacity: .55; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin-top: 10px; }
.medal { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; padding: 10px 6px; border-radius: 14px; border: 2px solid var(--line); }
.medal span { font-size: 2rem; filter: grayscale(1); opacity: .35; }
.medal b { font-size: .78rem; }
.medal small { color: var(--muted); line-height: 1.3; }
.medal .bar { width: 100%; height: 6px; margin-top: 3px; }
.medal.got { border-color: var(--accent2); background: color-mix(in srgb, var(--accent2) 12%, var(--surface)); }
.medal.got span { filter: none; opacity: 1; }

/* ---------- 集中画面・タイマーバー ---------- */
#focus { position: fixed; inset: 0; z-index: 40; overflow-y: auto; display: flex; flex-direction: column; align-items: center; justify-content: safe center; gap: 6px; padding: 20px; text-align: center; color: #fff; background: linear-gradient(180deg, #1c2a57, #35508a 55%, #4f8f6c); }
#focus .close { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 12px; color: #fff; font-size: 1.3rem; }
#focus .btn:not(.stop) { color: #2b2438; background: #fff; }
.focus-sound { width: min(100%, 520px); margin-top: 8px; padding: 4px 10px; border-radius: var(--radius); background: var(--surface); color: var(--ink); text-align: left; }
#focus > * { flex-shrink: 0; }
#focus .btn.ghost { background: transparent; color: #ffffffcc; }
.focus-name { font-size: 1.15rem; font-weight: 800; }
.focus-art { display: flex; align-items: flex-end; justify-content: center; }
#treeBox { width: min(52vw, 220px); }
#treeBox svg, .forest svg { display: block; width: 100%; }
#treeBox .leaves { transform-origin: 60px 90px; animation: sway 5s ease-in-out infinite; }
.focus-buddy { width: min(28vw, 110px); }
.clock { font-size: clamp(2.8rem, 15vw, 5rem); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; }
#mini { position: fixed; z-index: 19; left: 8px; right: 8px; bottom: calc(70px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius); background: #2b2438; color: #fff; box-shadow: 0 6px 20px #0005; }
.mini-open { display: flex; flex-direction: column; text-align: left; border: 0; background: none; color: #fff; padding: 0; overflow: hidden; }
.mini-open span, .mini-open small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
#mini b { font-variant-numeric: tabular-nums; }
#mini .btn { background: #fff; color: #2b2438; border-color: #fff; }
#mini .btn.stop { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- ダイアログ・フォーム ---------- */
dialog { width: min(560px, calc(100vw - 20px)); max-height: min(92dvh, 900px); padding: 0; border: 0; border-radius: 22px; background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px #0006; z-index: 50; }
dialog::backdrop { background: #1a1024a8; }
.dlg-body { padding: 16px 18px 20px; animation: fade .2s; }
.form label, .dlg-body > label { display: flex; flex-direction: column; flex: 1; min-width: 130px; gap: 3px; margin: 8px 0; font-size: .84rem; font-weight: 700; }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea { width: 100%; min-width: 0; min-height: 44px; padding: 8px 10px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); font-size: 16px; font-weight: 400; }
fieldset { margin: 10px 0; padding: 8px 10px 10px; border: 2px solid var(--line); border-radius: 14px; min-width: 0; }
legend { font-size: .84rem; font-weight: 700; padding: 0 4px; }
.ev-row { border-bottom: 2px dashed var(--line); padding: 6px 0; }
.ev-row .row { flex-wrap: nowrap; }
.ev-row select { width: auto; flex: none; }
.wds { display: flex; flex-wrap: wrap; gap: 6px; }
.wds label { position: relative; flex: none; min-width: 0; margin: 0; }
.wds input { position: absolute; opacity: 0; }
.wds span { display: grid; place-items: center; min-width: 40px; height: 40px; border-radius: 12px; border: 2px solid var(--line); cursor: pointer; }
.wds input:checked + span { border-color: var(--accent); background: var(--soft); }
.wds input:focus-visible + span { outline: 3px solid var(--accent2); }
.swatches span { background: var(--c); }
.swatches input:checked + span { background: var(--c); border-color: var(--ink); box-shadow: inset 0 0 0 3px var(--surface); }
.sticky { position: sticky; bottom: 0; background: var(--surface); padding: 8px 0; }
.left { margin-right: auto; }
.error { color: var(--danger); font-weight: 700; min-height: 1em; }
.big { font-size: 2.2rem; font-weight: 800; margin: 0; }
.result-buddy { width: 130px; margin: 0 auto; }

.toasts { position: fixed; z-index: 60; left: 0; right: 0; top: calc(10px + env(safe-area-inset-top)); display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 0 12px; pointer-events: none; }
.toast { max-width: 480px; padding: 10px 18px; border-radius: 999px; background: #2b2438; color: #fff; font-weight: 700; font-size: .88rem; box-shadow: 0 6px 20px #0005; animation: toast 4.2s both; }
.confetti { position: fixed; inset: 0; z-index: 70; pointer-events: none; }

@keyframes pulse { 50% { transform: scale(1.025); } }
@keyframes glow { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 35%, transparent); } }
@keyframes bounce { 50% { transform: translateY(-4px); } }
@keyframes breathe { 50% { transform: scale(1.025, .975); } }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.08); } }
@keyframes flapL { 50% { transform: rotate(14deg); } }
@keyframes flapR { 50% { transform: rotate(-14deg); } }
@keyframes jump { 35% { transform: translateY(-24px) rotate(-5deg); } 65% { transform: translateY(0) rotate(4deg); } }
@keyframes sway { 50% { transform: rotate(2.5deg); } }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes toast { 0% { opacity: 0; transform: translateY(-14px); } 8%, 90% { opacity: 1; transform: none; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

@media (max-width: 400px) {
  #mini .mini-open small { font-size: .68rem; }
  .ev { font-size: .58rem; padding: 0 1px; }
}
