/* ================= 音読くん ================= */
:root {
  --bg: #0a0f1e;
  --bg2: #101832;
  --card: #141d3a;
  --card2: #1a2547;
  --line: rgba(255, 255, 255, 0.09);
  --text: #eef2ff;
  --sub: #93a0c4;
  --accent: #35e0c2;
  --accent2: #7ef29a;
  --grad: linear-gradient(100deg, #35e0c2, #7ef29a);
  --warn: #ffd166;
  --bad: #ff6b81;
  --radius: 18px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
  background: radial-gradient(1200px 700px at 80% -10%, #17224a 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.6;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
textarea, input, select { font-family: inherit; }

#app { max-width: 640px; margin: 0 auto; padding: 0 16px 120px; }

/* ---------- ヘッダー ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 2px 10px;
}
.logo { font-size: 1.35rem; font-weight: 900; letter-spacing: 0.02em; }
.logo .dot { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.chip-btn {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 13px; font-size: 0.85rem; font-weight: 700;
  display: inline-flex; align-items: center; gap: 5px;
}
.chip-btn:active { transform: scale(0.96); }
.streak-on { border-color: rgba(255, 170, 60, 0.55); color: #ffc46b; }

/* ---------- カード共通 ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
}
.card h2 { font-size: 0.85rem; color: var(--sub); font-weight: 700; letter-spacing: 0.08em; margin-bottom: 10px; }

/* ---------- 今日の音読 ---------- */
.daily {
  background: linear-gradient(135deg, #16305c 0%, #143b4d 100%);
  border: 1px solid rgba(53, 224, 194, 0.35);
  position: relative; overflow: hidden;
}
.daily::after {
  content: ""; position: absolute; top: -60px; right: -60px; width: 180px; height: 180px;
  background: radial-gradient(circle, rgba(53, 224, 194, 0.25), transparent 70%);
}
.daily .tag {
  display: inline-block; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.12em;
  background: var(--grad); color: #06281f; border-radius: 6px; padding: 3px 8px; margin-bottom: 8px;
}
.daily .ttl { font-size: 1.3rem; font-weight: 900; margin-bottom: 2px; }
.daily .meta { color: var(--sub); font-size: 0.85rem; margin-bottom: 14px; }
.daily .done-line { font-size: 0.95rem; margin-bottom: 12px; color: #b7f8e8; font-weight: 700; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 14px; font-weight: 800; font-size: 1rem;
  padding: 14px 22px; transition: transform 0.08s ease;
  position: relative; z-index: 1;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--grad); color: #06281f; box-shadow: 0 6px 24px rgba(53, 224, 194, 0.35); }
.btn-ghost { background: var(--card2); border: 1px solid var(--line); color: var(--text); }
.btn-wide { width: 100%; }
.btn-sm { padding: 9px 14px; font-size: 0.88rem; border-radius: 11px; }
.btn:disabled { opacity: 0.45; pointer-events: none; }

/* ---------- レベルタブ ---------- */
.levels {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 12px;
  scrollbar-width: none;
}
.levels::-webkit-scrollbar { display: none; }
.lv {
  flex: 0 0 auto; padding: 8px 15px; border-radius: 999px; font-weight: 800; font-size: 0.9rem;
  background: var(--card); border: 1px solid var(--line); color: var(--sub); white-space: nowrap;
}
.lv.on { background: var(--grad); color: #06281f; border-color: transparent; }

/* ---------- パッセージリスト ---------- */
.plist { display: flex; flex-direction: column; gap: 9px; }
.prow {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; text-align: left; width: 100%;
}
.prow:active { background: var(--card2); }
.prow .t { font-weight: 800; font-size: 0.98rem; }
.prow .w { color: var(--sub); font-size: 0.78rem; margin-top: 1px; }
.pb {
  flex: 0 0 auto; font-size: 0.78rem; font-weight: 800; color: var(--accent);
  background: rgba(53, 224, 194, 0.1); border-radius: 8px; padding: 4px 9px;
}
.pb.none { color: var(--sub); background: rgba(255, 255, 255, 0.05); }

/* ---------- カスタム英文 ---------- */
.custom textarea {
  width: 100%; min-height: 96px; background: var(--bg2); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: 0.95rem;
  resize: vertical; margin-bottom: 10px; line-height: 1.6;
}
.custom textarea:focus { outline: 2px solid rgba(53, 224, 194, 0.5); }

/* ---------- フロー画面 ---------- */
.flowbar {
  display: flex; align-items: center; gap: 10px; padding: 16px 2px 8px;
}
.back { font-size: 1.3rem; padding: 4px 10px; color: var(--sub); }
.flowbar .fttl { font-weight: 900; font-size: 1.02rem; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.steps { display: flex; gap: 5px; }
.stepdot { width: 22px; height: 5px; border-radius: 3px; background: var(--card2); }
.stepdot.on { background: var(--grad); }

.passage {
  font-size: 1.16rem; line-height: 2.0; font-weight: 500;
  letter-spacing: 0.005em; padding: 4px 2px 8px;
}
.passage .sen { border-radius: 6px; padding: 1px 2px; transition: background 0.2s; }
.passage .sen.playing { background: rgba(53, 224, 194, 0.22); }
.passage .miss { color: var(--bad); font-weight: 800; border-bottom: 2px solid var(--bad); }

.ja {
  color: var(--sub); font-size: 0.92rem; background: var(--bg2);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-top: 10px;
}

.listen-ctrl { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 14px 0 8px; }
.speed { display: flex; gap: 5px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
.speed button { padding: 5px 12px; border-radius: 999px; font-weight: 800; font-size: 0.82rem; color: var(--sub); }
.speed button.on { background: var(--grad); color: #06281f; }
select.voice {
  background: var(--card); color: var(--text); border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 12px; font-weight: 700; font-size: 0.85rem;
}

.bottom-cta {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: linear-gradient(transparent, var(--bg) 40%);
  padding: 26px 16px calc(16px + env(safe-area-inset-bottom));
}
.bottom-cta .inner { max-width: 640px; margin: 0 auto; display: flex; gap: 10px; }
.bottom-cta .btn { flex: 1; }

/* ---------- 録音 ---------- */
.recwrap { display: flex; flex-direction: column; align-items: center; padding: 22px 0 8px; }
.recbtn {
  width: 108px; height: 108px; border-radius: 50%;
  background: var(--grad); color: #06281f; font-weight: 900; font-size: 1.05rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  box-shadow: 0 0 0 10px rgba(53, 224, 194, 0.12), 0 10px 34px rgba(53, 224, 194, 0.35);
  transition: transform 0.1s;
}
.recbtn:active { transform: scale(0.95); }
.recbtn.rec {
  background: linear-gradient(120deg, #ff6b81, #ff9770); color: #3d0812;
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 8px rgba(255, 107, 129, 0.18); }
  50% { box-shadow: 0 0 0 20px rgba(255, 107, 129, 0.07); }
  100% { box-shadow: 0 0 0 8px rgba(255, 107, 129, 0.18); }
}
.rectime { font-size: 1.6rem; font-weight: 900; margin-top: 14px; font-variant-numeric: tabular-nums; }
.rechint { color: var(--sub); font-size: 0.85rem; margin-top: 4px; text-align: center; }
.countnum { font-size: 4rem; font-weight: 900; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

.grading { text-align: center; padding: 60px 0; }
.spinner {
  width: 44px; height: 44px; margin: 0 auto 18px; border-radius: 50%;
  border: 4px solid var(--card2); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 結果 ---------- */
.result { text-align: center; padding-top: 16px; }
.result .label { font-size: 0.72rem; letter-spacing: 0.22em; color: var(--sub); font-weight: 800; }
.bigwpm {
  font-size: clamp(88px, 30vw, 150px); font-weight: 900; line-height: 1.05;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
}
.wpmunit { font-size: 1.1rem; font-weight: 900; letter-spacing: 0.35em; color: var(--sub); margin-top: -8px; }
.badge {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 16px;
  font-size: 1.25rem; font-weight: 900; padding: 10px 22px; border-radius: 999px;
  border: 2px solid; background: rgba(255, 255, 255, 0.04);
}
.newrec { margin-top: 12px; font-weight: 900; color: #ffd166; font-size: 1rem; }
.updiff { margin-top: 12px; font-weight: 800; color: var(--accent2); font-size: 0.95rem; }
.sqgrid { display: flex; justify-content: center; gap: 5px; margin: 20px 0 4px; font-size: 1.5rem; letter-spacing: 2px; }

.subscores { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 16px 0 4px; }
.ss {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 13px; min-width: 74px;
}
.ss .v { font-weight: 900; font-size: 1.15rem; }
.ss .k { color: var(--sub); font-size: 0.7rem; font-weight: 700; }

.misses { margin: 14px 0 4px; }
.misses .mt { color: var(--sub); font-size: 0.8rem; font-weight: 700; margin-bottom: 8px; }
.misschips { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; }
.mchip {
  background: rgba(255, 107, 129, 0.12); border: 1px solid rgba(255, 107, 129, 0.4);
  color: #ffb3c0; border-radius: 999px; padding: 6px 13px; font-weight: 800; font-size: 0.9rem;
}
.mchip:active { transform: scale(0.95); }

.resbtns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; }
.resbtns .full { grid-column: 1 / -1; }

.share-x { background: #000; color: #fff; border: 1px solid #333; }

.coach {
  text-align: left; background: var(--card); border: 1px solid rgba(53, 224, 194, 0.3);
  border-radius: var(--radius); padding: 16px; margin-top: 16px;
}
.coach .who { display: flex; align-items: center; gap: 8px; font-weight: 900; margin-bottom: 8px; }
.coach .avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--grad);
  display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
}
.coach .verdict { font-size: 1.05rem; font-weight: 900; margin-bottom: 6px; }
.coach .praise { color: var(--accent2); font-weight: 700; font-size: 0.92rem; margin-bottom: 8px; }
.coach .cm { font-size: 0.92rem; margin-bottom: 10px; }
.coach ul { margin-left: 1.2em; font-size: 0.9rem; }
.coach li { margin-bottom: 5px; }

.restext { margin-top: 18px; text-align: left; }
.restext summary { color: var(--sub); font-size: 0.85rem; font-weight: 700; cursor: pointer; padding: 8px 0; }

/* ---------- 履歴 ---------- */
.histwrap .spark { width: 100%; height: 120px; background: var(--bg2); border-radius: 12px; border: 1px solid var(--line); }
.histrow {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 4px; border-bottom: 1px solid var(--line); font-size: 0.9rem;
}
.histrow .d { color: var(--sub); font-size: 0.78rem; }
.histrow .wv { font-weight: 900; color: var(--accent); }

/* ---------- モーダル ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(4, 8, 20, 0.72); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: 22px 22px 0 0; width: 100%; max-width: 640px;
  max-height: 86dvh; display: flex; flex-direction: column; overflow: hidden;
}
.modal .mh {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 18px; border-bottom: 1px solid var(--line); font-weight: 900;
}
.modal .mclose { color: var(--sub); font-size: 1.5rem; padding: 0 6px; }
.modal .mbody { overflow-y: auto; padding: 16px 18px; flex: 1; }

/* チャット */
.chatlog { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 86%; padding: 10px 14px; border-radius: 16px; font-size: 0.92rem; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: #1f4d46; border-bottom-right-radius: 4px; }
.msg.ai { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chatin { display: flex; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.chatin input {
  flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 14px; color: var(--text); font-size: 0.95rem;
}
.chatin input:focus { outline: 2px solid rgba(53, 224, 194, 0.5); }

/* ---------- トースト・紙吹雪 ---------- */
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
  background: #2a1520; color: #ffc4cf; border: 1px solid rgba(255, 107, 129, 0.5);
  padding: 12px 20px; border-radius: 12px; font-size: 0.88rem; font-weight: 700;
  z-index: 99; max-width: 90vw; text-align: center; white-space: pre-wrap;
}
.toast.ok { background: #10261f; color: #a8f0d8; border-color: rgba(53, 224, 194, 0.5); }

.confetti-p {
  position: fixed; top: -12px; z-index: 98; pointer-events: none;
  width: 9px; height: 14px; border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(105vh) rotate(720deg); opacity: 0.7; }
}

.foot { text-align: center; color: var(--sub); font-size: 0.75rem; padding: 24px 0 8px; }
.foot a { color: var(--sub); }
