:root {
  --text: #f6f1ea;
  --muted: rgba(246, 241, 234, 0.66);
  --glass: rgba(18, 16, 30, 0.42);
  --glass-strong: rgba(18, 16, 30, 0.72);
  --line: rgba(255, 255, 255, 0.14);
  --accent: #ffb38a;
  --accent-soft: rgba(255, 179, 138, 0.22);
  --focus: #ffb38a;
  --short: #8fd8c8;
  --long: #b9a8ff;
  --radius: 22px;
  --font: 'Zen Maru Gothic', 'Hiragino Maru Gothic ProN', 'Hiragino Sans', 'Noto Sans JP', system-ui, sans-serif;
}

body[data-phase='short'] { --accent: var(--short); --accent-soft: rgba(143, 216, 200, 0.22); }
body[data-phase='long'] { --accent: var(--long); --accent-soft: rgba(185, 168, 255, 0.22); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #14121f;
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

#bg { position: fixed; inset: 0; display: block; }
.vignette {
  position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 45%, rgba(0,0,0,0.45) 100%);
}

.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}

/* 全体の進捗バー */
.overall { position: fixed; top: 0; left: 0; right: 0; height: 4px; background: rgba(255,255,255,0.08); z-index: 5; }
.overall-fill { height: 100%; width: 0; background: var(--accent); box-shadow: 0 0 12px var(--accent); transition: width 0.6s linear, background 0.6s; }

/* メイン */
.stage {
  position: relative;
  z-index: 2;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px 16px 110px;
  transition: opacity 0.4s;
}

.task-row { width: min(360px, 100%); display: flex; align-items: center; gap: 8px; }
.subject-pill {
  position: relative; flex: none; display: flex; align-items: center; gap: 6px;
  padding: 5px 10px 5px 10px; border-radius: 99px;
  background: rgba(0,0,0,0.25); border: 1px solid var(--line); font-size: 13px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.subject-pill select { appearance: none; -webkit-appearance: none; background: transparent; border: none; outline: none; padding-right: 12px; cursor: pointer; max-width: 10em; }
.subject-pill select option { background: #221e33; }
.subject-pill::after { content: ''; position: absolute; right: 10px; top: 50%; width: 5px; height: 5px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.subject-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--subj, #9a96a8); flex: none; box-shadow: 0 0 8px var(--subj, transparent); }
.task-input {
  flex: 1;
  min-width: 0;
  text-align: center;
  background: transparent;
  border: none;
  border-bottom: 1px dashed rgba(255,255,255,0.3);
  padding: 6px 4px;
  font-size: 15px;
  text-shadow: 0 1px 8px rgba(0,0,0,0.6);
  outline: none;
}
.task-input::placeholder { color: rgba(255,255,255,0.55); }
.task-input:focus { border-bottom-color: var(--accent); }

.timer-card {
  width: min(360px, 100%);
  border-radius: 32px;
  padding: 22px 22px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.ring-wrap { position: relative; width: min(260px, 70vw); aspect-ratio: 1; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ring circle { fill: none; }
.ring-track { stroke: rgba(255,255,255,0.1); stroke-width: 10; }
.ring-ticks { stroke: rgba(255,255,255,0.22); stroke-width: 4; stroke-linecap: butt; stroke-dasharray: 1.2 10.947; }
.ring-fill {
  stroke: var(--accent);
  stroke-width: 10;
  stroke-linecap: round;
  filter: drop-shadow(0 0 6px var(--accent));
  transition: stroke-dashoffset 0.3s linear, stroke 0.6s;
}
.ring-dot { fill: #fff; stroke: none; transform-origin: 130px 130px; filter: drop-shadow(0 0 6px var(--accent)); transition: transform 0.3s linear; }

.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.phase-label {
  font-size: 14px;
  letter-spacing: 0.2em;
  padding: 4px 12px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
}
.time { font-size: clamp(52px, 16vw, 68px); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; line-height: 1.15; margin-top: 4px; }
.sub { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.sets { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; max-width: 280px; }
.set-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.4); position: relative; overflow: hidden; }
.set-dot.done { background: var(--focus); border-color: var(--focus); }
.set-dot.current { border-color: var(--focus); }
.set-dot .fill { position: absolute; left: 0; bottom: 0; width: 100%; background: var(--focus); opacity: 0.8; transition: height 0.3s linear; }
.sets-caption { font-size: 12px; color: var(--muted); margin-top: 6px; }

.controls { display: flex; align-items: center; gap: 22px; margin-top: 14px; }
.icon-btn {
  width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.06);
  display: grid; place-items: center;
  transition: background 0.2s, transform 0.1s;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: rgba(255,255,255,0.14); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.small { width: 36px; height: 36px; }
.play-btn {
  width: 72px; height: 72px; border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #1b1626;
  display: grid; place-items: center;
  box-shadow: 0 6px 24px var(--accent-soft), 0 0 0 6px var(--accent-soft);
  transition: transform 0.1s, background 0.6s;
}
.play-btn svg { width: 28px; height: 28px; fill: currentColor; }
.play-btn .i-pause { fill: none; stroke-width: 3; }
.play-btn:active { transform: scale(0.95); }
.play-btn .i-pause, body.running .play-btn .i-play { display: none; }
body.running .play-btn .i-pause { display: block; }

.goal { width: min(360px, 100%); border-radius: 99px; padding: 8px 16px; display: flex; align-items: center; gap: 10px; font-size: 12px; }
.goal-label { color: var(--muted); white-space: nowrap; }
.goal-track { flex: 1; height: 6px; border-radius: 99px; background: rgba(255,255,255,0.12); overflow: hidden; }
.goal-fill { height: 100%; width: 0; background: linear-gradient(90deg, #ffd08a, #ff9f7a); border-radius: 99px; transition: width 0.6s; }
.goal-text { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ドック */
.dock {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  gap: 2px;
  padding: 6px;
  border-radius: 22px;
  max-width: calc(100% - 24px);
  transition: opacity 0.4s, transform 0.4s;
}
.dock-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-width: 52px;
  padding: 7px 6px 6px;
  border: none; background: transparent; border-radius: 16px;
  font-size: 11px; color: var(--muted); white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}
.dock-btn svg { width: 21px; height: 21px; }
.dock-btn:hover, .dock-btn.active { background: rgba(255,255,255,0.1); color: var(--text); }
.music-toggle .i-off { display: block; }
.music-toggle .i-on { display: none; }
.music-toggle.on { color: var(--accent); }
.music-toggle.on .i-on { display: block; }
.music-toggle.on .i-off { display: none; }

/* 没入モード：UIをほぼ隠す */
body.zen .dock, body.zen .goal, body.zen .task-row, body.zen .presence { opacity: 0; pointer-events: none; }
body.zen .timer-card { background: transparent; border-color: transparent; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
body.zen .controls { opacity: 0; pointer-events: none; transition: opacity 0.3s; }
body.zen.zen-peek .controls { opacity: 1; pointer-events: auto; }
/* マウスのある端末だけ、ホバーでも出す（スマホはタップ後も:hoverが残るため） */
@media (hover: hover) {
  body.zen .timer-card:hover .controls { opacity: 1; pointer-events: auto; }
}
body.zen .time { text-shadow: 0 2px 20px rgba(0,0,0,0.5); }
.zen-exit { display: none; }
body.zen .zen-exit { display: grid; position: fixed; top: 14px; right: 14px; z-index: 12; opacity: 0.5; }
body.zen .zen-exit:hover { opacity: 1; }

/* パネル（シート） */
.sheet-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,0.25); opacity: 0; pointer-events: none; transition: opacity 0.25s; }
.sheet {
  position: fixed; z-index: 21;
  right: 16px; top: 16px; bottom: 16px;
  width: min(400px, calc(100% - 32px));
  background: var(--glass-strong);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  transform: translateX(calc(100% + 24px));
  transition: transform 0.3s cubic-bezier(.2,.8,.2,1);
}
body.sheet-open .sheet { transform: none; }
body.sheet-open .sheet-backdrop { opacity: 1; pointer-events: auto; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px 22px; }
.sheet-head h2 { margin: 0; font-size: 18px; }
.sheet-body { overflow-y: auto; padding: 4px 22px 24px; }
.panel { display: none; }
.panel.active { display: block; }
.panel h3 { font-size: 13px; color: var(--muted); font-weight: 500; margin: 20px 0 10px; letter-spacing: 0.08em; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.7; }

@media (max-width: 640px) {
  .sheet { left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; max-height: 78vh; transform: translateY(calc(100% + 24px)); }
  .dock-btn { min-width: 44px; padding: 6px 3px; }
  .dock-btn span { font-size: 10px; }
}

.scene-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.scene-card {
  position: relative; aspect-ratio: 16/10; border-radius: 16px; border: 2px solid transparent;
  overflow: hidden; text-align: left; padding: 10px; display: flex; flex-direction: column; justify-content: flex-end;
}
.scene-card::after { content: ''; position: absolute; inset: 0; background: linear-gradient(transparent 40%, rgba(0,0,0,0.55)); }
.scene-card > * { position: relative; z-index: 1; }
.scene-card b { font-size: 15px; }
.scene-card small { font-size: 11px; color: rgba(255,255,255,0.8); }
.scene-card.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.row select { background: rgba(255,255,255,0.08); border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; }
.row select option { background: #221e33; }
.row.slider input { width: 55%; }

input[type='range'] { accent-color: var(--accent); }

.switch { appearance: none; -webkit-appearance: none; width: 42px; height: 24px; border-radius: 99px; background: rgba(255,255,255,0.18); position: relative; cursor: pointer; transition: background 0.2s; flex: none; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }

.num-row { display: grid; grid-template-columns: 110px 1fr 56px; align-items: center; gap: 10px; padding: 8px 0; font-size: 14px; }
.num-row output { text-align: right; font-variant-numeric: tabular-nums; color: var(--accent); }

.track-list { display: flex; flex-direction: column; gap: 8px; }
.track {
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,0.04);
}
.track .eq { width: 22px; height: 18px; display: flex; align-items: flex-end; gap: 2px; flex: none; }
.track .eq i { flex: 1; background: var(--muted); height: 30%; border-radius: 2px; }
.track.active { border-color: var(--accent); background: var(--accent-soft); }
.track.active .eq i { background: var(--accent); }
body.music-on .track.active .eq i { animation: eq 0.9s ease-in-out infinite alternate; }
.track .eq i:nth-child(2) { animation-delay: -0.3s !important; }
.track .eq i:nth-child(3) { animation-delay: -0.6s !important; }
@keyframes eq { from { height: 20%; } to { height: 100%; } }
.track b { display: block; font-size: 14px; }
.track small { color: var(--muted); font-size: 12px; }

.file-btn { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; padding: 10px 12px; border-radius: 14px; border: 1px dashed var(--line); cursor: pointer; font-size: 14px; }
.file-btn small { color: var(--muted); font-size: 12px; }
.file-btn.active { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 0; }
.chip { padding: 7px 12px; border-radius: 99px; border: 1px solid var(--line); background: rgba(255,255,255,0.05); font-size: 13px; }
.chip.active { background: var(--accent); color: #1b1626; border-color: var(--accent); }
.chips.disabled { opacity: 0.45; pointer-events: none; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { padding: 12px 14px; border-radius: 16px; background: rgba(255,255,255,0.06); }
.stat small { color: var(--muted); font-size: 12px; }
.stat b { display: block; font-size: 22px; margin-top: 2px; }

.bars { display: flex; align-items: flex-end; gap: 8px; height: 120px; padding-top: 16px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; font-size: 11px; color: var(--muted); }
.bar i { width: 100%; border-radius: 6px 6px 3px 3px; background: rgba(255,255,255,0.3); min-height: 3px; transition: height 0.4s; }
.bar.today i { background: var(--focus); }
.bar em { font-style: normal; font-size: 10px; color: var(--text); }

.heatmap { display: grid; grid-template-rows: repeat(7, 1fr); grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; }
.heatmap i { aspect-ratio: 1; border-radius: 3px; background: rgba(255,255,255,0.07); }
.heatmap i[data-l='1'] { background: rgba(255,179,138,0.35); }
.heatmap i[data-l='2'] { background: rgba(255,179,138,0.6); }
.heatmap i[data-l='3'] { background: rgba(255,179,138,0.85); }
.heatmap i[data-l='4'] { background: #ffd2a8; }
.heatmap i.pad { visibility: hidden; }

.history { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.history li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.history .h-time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.history .h-task { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history .h-min { font-variant-numeric: tabular-nums; }
.history li.row { cursor: pointer; border-radius: 8px; }
.history li.row:hover { background: rgba(255,255,255,0.05); }
.history .h-edit { color: var(--muted); font-size: 12px; }
.history .tag { flex: none; font-size: 10px; padding: 1px 6px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.history .empty { color: var(--muted); justify-content: center; }

.btn-row { display: flex; gap: 8px; margin-top: 16px; }
.btn-row.wrap { flex-wrap: wrap; }
.btn-row.wrap .btn { flex: 1 1 45%; }
.btn { padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,0.08); font-size: 13px; }
.btn:hover { background: rgba(255,255,255,0.15); }
.btn.primary { background: var(--accent); color: #1b1626; border-color: var(--accent); font-weight: 700; }
.btn.danger { color: #ff9f9f; }

.share-preview { width: 100%; border-radius: 14px; display: block; aspect-ratio: 1200/630; background: rgba(255,255,255,0.05); }
.link-row { display: flex; gap: 8px; }
.link-row input { flex: 1; min-width: 0; background: rgba(255,255,255,0.06); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 12px; }

.toast {
  position: fixed; left: 50%; top: 24px; z-index: 40;
  transform: translate(-50%, -20px); opacity: 0; pointer-events: none;
  padding: 10px 18px; border-radius: 99px; background: var(--glass-strong); border: 1px solid var(--line);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  font-size: 14px; transition: opacity 0.3s, transform 0.3s; white-space: nowrap; max-width: calc(100% - 32px); overflow: hidden; text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-height: 640px) {
  .ring-wrap { width: min(200px, 60vw); }
  .time { font-size: 48px; }
  .stage { gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* PCではパネルを開いたままドックで切り替えられるように */
@media (min-width: 641px) {
  body.sheet-open .dock { z-index: 22; }
}

.install-box { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-top: 8px; border-radius: 16px; background: var(--accent-soft); border: 1px solid var(--accent); }
.install-box[hidden] { display: none; }
.install-box > div { flex: 1; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.install-box small { color: var(--muted); font-size: 12px; }
.install-box .btn { flex: none; }

/* 科目 */
.h3-row { display: flex; align-items: center; justify-content: space-between; margin: 20px 0 10px; }
.h3-row h3 { margin: 0; }
.seg { display: flex; padding: 2px; border-radius: 10px; background: rgba(255,255,255,0.06); }
.seg button { border: none; background: none; padding: 4px 10px; border-radius: 8px; font-size: 12px; color: var(--muted); }
.seg button.active { background: rgba(255,255,255,0.14); color: var(--text); }
.subj-bar { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: rgba(255,255,255,0.07); }
.subj-bar i { height: 100%; transition: width 0.4s; }
.subj-list { list-style: none; margin: 10px 0 0; padding: 0; font-size: 13px; }
.subj-list li { display: flex; align-items: center; gap: 8px; padding: 5px 0; }
.subj-list .name { flex: 1; }
.subj-list .pct { color: var(--muted); width: 3.5em; text-align: right; font-variant-numeric: tabular-nums; }
.subj-list .min { width: 5.5em; text-align: right; font-variant-numeric: tabular-nums; }
.subj-list .empty { color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }
.bar .stack { width: 100%; display: flex; flex-direction: column-reverse; border-radius: 6px 6px 3px 3px; overflow: hidden; min-height: 3px; background: rgba(255,255,255,0.15); transition: height 0.4s; }
.bar .stack span { display: block; width: 100%; }
.bar.today { color: var(--text); }
.subj-editor { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.subj-editor .se-row { display: flex; align-items: center; gap: 8px; }
.subj-editor input[type='color'] { width: 30px; height: 30px; padding: 0; border: none; border-radius: 50%; background: none; cursor: pointer; flex: none; }
.subj-editor input[type='color']::-webkit-color-swatch-wrapper { padding: 0; }
.subj-editor input[type='color']::-webkit-color-swatch { border: 2px solid rgba(255,255,255,0.3); border-radius: 50%; }
.subj-editor input[type='color']::-moz-color-swatch { border: 2px solid rgba(255,255,255,0.3); border-radius: 50%; }
.subj-editor input[type='text'] { flex: 1; min-width: 0; background: rgba(255,255,255,0.06); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; font-size: 13px; }
.subj-editor button { border: none; background: none; color: var(--muted); padding: 4px 8px; }
.history .dot { width: 8px; height: 8px; }
.history .h-sub { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* クラウド同期 */
.cloud { padding: 14px; border-radius: 16px; background: rgba(255,255,255,0.06); border: 1px solid var(--line); margin-bottom: 14px; }
.cloud-head { display: flex; flex-direction: column; gap: 3px; font-size: 14px; }
.cloud-head b { display: flex; align-items: center; gap: 8px; overflow: hidden; text-overflow: ellipsis; }
.cloud-head small { color: var(--muted); font-size: 12px; }
.cloud-form { display: flex; gap: 8px; margin-top: 10px; }
.cloud-form input { flex: 1; min-width: 0; background: rgba(255,255,255,0.08); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; font-size: 14px; }
.cloud-form input:focus { outline: none; border-color: var(--accent); }
.cloud-form .btn { flex: none; }
.cloud-sent .hint { margin: 10px 0 0; }
.cloud-actions { display: flex; gap: 8px; margin-top: 10px; }
.link-btn { border: none; background: none; color: var(--muted); font-size: 12px; text-decoration: underline; padding: 8px 0 0; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: #7fd89a; flex: none; box-shadow: 0 0 8px #7fd89a; }
.sync-dot[data-s='syncing'] { background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: pulse 1s ease-in-out infinite alternate; }
.sync-dot[data-s='offline'] { background: #9a96a8; box-shadow: none; }
.sync-dot[data-s='error'] { background: #ff8a8a; box-shadow: 0 0 8px #ff8a8a; }
@keyframes pulse { from { opacity: 0.4; } to { opacity: 1; } }
.btn:disabled { opacity: 0.5; cursor: default; }

.auth-tabs { margin-top: 12px; }
.auth-tabs button { flex: 1; }
.auth-form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.auth-form input { background: rgba(255,255,255,0.08); border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-size: 14px; }
.auth-form input:focus { outline: none; border-color: var(--accent); }
#authNote { margin: 8px 0 0; }

/* 実績バッジ */
.badge-count { font-size: 12px; color: var(--muted); }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.badge {
  --c1: #8a8699; --c2: #5d5a6c;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 2px 6px; border: 1px solid transparent; border-radius: 14px; background: rgba(255,255,255,0.04);
  font-size: 10px; color: var(--muted); line-height: 1.2; text-align: center;
}
.badge .b-icon {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 20px;
  background: rgba(255,255,255,0.06); border: 2px dashed rgba(255,255,255,0.15); filter: grayscale(1); opacity: 0.45;
}
.badge .b-name { min-height: 2.4em; display: flex; align-items: center; }
.badge .b-prog { width: 70%; height: 3px; border-radius: 3px; background: rgba(255,255,255,0.1); overflow: hidden; }
.badge .b-prog i { display: block; height: 100%; background: var(--accent); }
.badge.on { color: var(--text); }
.badge.on .b-icon { filter: none; opacity: 1; border: 2px solid var(--c1); background: radial-gradient(circle at 35% 30%, var(--c1), var(--c2)); box-shadow: 0 0 12px color-mix(in srgb, var(--c1) 50%, transparent); }
.badge.on .b-prog { visibility: hidden; }
.badge.selected { border-color: var(--accent); background: var(--accent-soft); }
.badge.t1 { --c1: #e0a878; --c2: #8a5a36; }
.badge.t2 { --c1: #d8e0ea; --c2: #7d8796; }
.badge.t3 { --c1: #ffd66b; --c2: #b98a1c; }
.badge.t4 { --c1: #b8f3ff; --c2: #7a6cff; }
.badge-detail { font-size: 12px; color: var(--muted); min-height: 2.8em; margin: 8px 0 0; line-height: 1.6; }
.badge-detail b { color: var(--text); }

.unlock { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(8,6,16,0.55); padding: 16px; animation: fadeIn 0.3s ease; }
.unlock-card { position: relative; width: min(320px, 100%); border-radius: 28px; padding: 26px 22px 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; background: var(--glass-strong); animation: pop 0.5s cubic-bezier(.2,1.4,.4,1); }
.unlock-kicker { color: var(--accent); letter-spacing: 0.2em; font-size: 12px; }
.unlock-icon { width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; font-size: 46px; border: 3px solid var(--c1, #ffd66b); background: radial-gradient(circle at 35% 30%, var(--c1, #ffd66b), var(--c2, #b98a1c)); box-shadow: 0 0 40px var(--c1, #ffd66b); animation: spinIn 0.8s ease; }
.unlock-name { font-size: 20px; }
.unlock-desc, .unlock-more { margin: 0; font-size: 13px; color: var(--muted); }
.unlock .btn { margin-top: 8px; min-width: 140px; }
.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 12px; border-radius: 2px; animation: fall var(--d, 2.4s) linear var(--delay, 0s) forwards; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }
@keyframes spinIn { from { transform: rotateY(360deg) scale(0.4); } }
@keyframes fall { to { transform: translate(var(--x, 0), 110vh) rotate(var(--r, 540deg)); } }

/* 記録の追加・編集 */
.btn.small { padding: 5px 10px; font-size: 12px; }
.modal { position: fixed; inset: 0; z-index: 45; display: grid; place-items: center; background: rgba(8,6,16,0.55); padding: 16px; animation: fadeIn 0.2s ease; }
.modal-card { width: min(380px, 100%); max-height: calc(100% - 16px); overflow-y: auto; border-radius: 24px; padding: 20px; display: flex; flex-direction: column; gap: 10px; background: var(--glass-strong); }
.modal-card h3 { margin: 0 0 4px; font-size: 17px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); flex: 1; min-width: 0; }
.field input, .field select { background: rgba(255,255,255,0.08); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; font-size: 15px; color: var(--text); width: 100%; min-width: 0; color-scheme: dark; }
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); }
.field select option { background: #221e33; }
.field-row { display: flex; gap: 10px; }
#edQuick { padding: 0; }
.edit-error { margin: 0; font-size: 13px; color: #ff9f9f; }
#editNote { margin: 0; }
.modal-actions { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.modal-actions .spacer { flex: 1; }

.scene-group { grid-column: 1 / -1; margin: 10px 0 0; font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0.1em; }
.scene-group:first-child { margin-top: 0; }

/* 今○人が勉強中 */
.presence { display: flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 99px; font-size: 12px; color: var(--muted); background: rgba(0,0,0,0.22); border: 1px solid var(--line); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: opacity 0.4s; }
.presence .p-dot { width: 8px; height: 8px; border-radius: 50%; background: #9a96a8; flex: none; }
.presence.active { color: var(--text); }
.presence.active .p-dot { background: #7fd89a; box-shadow: 0 0 8px #7fd89a; animation: pulse 1.6s ease-in-out infinite alternate; }
