:root {
  --bg: #07080d;
  --bg-2: #0b0d16;
  --glass: rgba(22, 25, 38, 0.62);
  --glass-2: rgba(30, 34, 52, 0.55);
  --stroke: rgba(255, 255, 255, 0.08);
  --stroke-strong: rgba(255, 255, 255, 0.14);
  --text: #eef1f8;
  --muted: #8b93ad;
  --faint: #5a6178;
  --primary: #7c5cff;   /* violet */
  --primary-2: #22d3ee; /* cyan */
  --accent: #34e0b0;
  --danger: #ff6b81;
  --warn: #ffcf5c;
  --grad: linear-gradient(120deg, #7c5cff 0%, #22d3ee 100%);
  --grad-soft: linear-gradient(120deg, rgba(124,92,255,.22), rgba(34,211,238,.22));
  --radius: 18px;
  --radius-sm: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.8);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.01em;
}
/* 環境光（アンビエントグロー） */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60% 50% at 15% -5%, rgba(124, 92, 255, 0.20), transparent 60%),
    radial-gradient(55% 45% at 100% 0%, rgba(34, 211, 238, 0.16), transparent 55%),
    radial-gradient(80% 60% at 50% 120%, rgba(52, 224, 176, 0.10), transparent 60%),
    var(--bg);
}

.hidden { display: none !important; }

/* ---- Gate ---- */
.gate {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; z-index: 50;
}
.gate-card {
  width: 100%; max-width: 350px; background: var(--glass); border: 1px solid var(--stroke);
  border-radius: var(--radius); padding: 34px 26px; text-align: center;
  backdrop-filter: blur(18px); box-shadow: var(--shadow);
}
.gate-card h1 { margin: 0 0 6px; font-size: 24px; }
.gate-card p { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.gate-card input {
  width: 100%; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--stroke-strong);
  background: rgba(0,0,0,.25); color: var(--text); font-size: 16px; margin-bottom: 14px;
}
.gate-card input:focus { outline: none; border-color: var(--primary); }

/* ---- Layout ---- */
.app { max-width: 760px; margin: 0 auto; min-height: 100vh; padding-bottom: 92px; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; background: linear-gradient(180deg, rgba(7,8,13,.92), rgba(7,8,13,.4));
  backdrop-filter: blur(10px);
}
.brand {
  font-weight: 800; font-size: 17px; letter-spacing: .02em;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.streak-badge {
  background: var(--grad-soft); color: var(--warn); font-weight: 800; font-size: 13px;
  padding: 7px 13px; border-radius: 999px; border: 1px solid var(--stroke);
}
.view { padding: 16px 16px 8px; }

/* ---- Tabbar (floating glass) ---- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; max-width: 520px; margin: 0 auto 12px; border-radius: 22px;
  background: var(--glass); backdrop-filter: blur(20px);
  border: 1px solid var(--stroke); box-shadow: var(--shadow);
  padding-bottom: var(--safe-bottom); overflow: hidden;
}
.tab {
  flex: 1; background: none; border: none; color: var(--faint);
  font-size: 10.5px; padding: 11px 0 12px; display: flex; flex-direction: column;
  align-items: center; gap: 3px; cursor: pointer; transition: color .2s; position: relative;
}
.tab span { font-size: 20px; transition: transform .2s; }
.tab.active { color: var(--text); }
.tab.active span { transform: translateY(-1px) scale(1.08); }
.tab.active::before {
  content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 26px; height: 3px; border-radius: 0 0 4px 4px; background: var(--grad);
}

/* ---- Cards ---- */
.card {
  background: var(--glass); border: 1px solid var(--stroke); border-radius: var(--radius);
  padding: 18px; margin-bottom: 14px; backdrop-filter: blur(14px); box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 14px; font-size: 17px; }
.card h3 { margin: 0 0 10px; font-size: 12px; color: var(--muted); font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.section-title { font-size: 12px; color: var(--muted); margin: 20px 6px 10px;
  text-transform: uppercase; letter-spacing: .1em; font-weight: 700; }

/* ---- Buttons ---- */
button { font-family: inherit; }
.btn-primary, .btn, .btn-ghost, .btn-danger {
  border-radius: 12px; padding: 12px 16px; font-size: 15px; font-weight: 700;
  cursor: pointer; border: 1px solid transparent; transition: transform .06s ease, filter .2s;
}
.btn-primary { background: var(--grad); color: #0a0a12; width: 100%; box-shadow: 0 10px 30px -12px rgba(124,92,255,.7); }
.btn { background: var(--glass-2); color: var(--text); border-color: var(--stroke-strong); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--stroke); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--stroke); }
.btn-primary:active, .btn:active, .btn-ghost:active { transform: scale(.97); }
.btn:hover, .btn-primary:hover { filter: brightness(1.08); }
.btn-sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled, .btn-primary:disabled { opacity: .4; cursor: not-allowed; filter: none; }
.btn-mic {
  background: var(--grad); color: #0a0a12; border: none;
  box-shadow: 0 0 0 0 rgba(124,92,255,.5);
}
.btn-mic.recording { background: linear-gradient(120deg,#ff6b81,#ff9a5c); color: #2b0008; animation: pulse 1.4s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255,107,129,.55); }
  70% { box-shadow: 0 0 0 16px rgba(255,107,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,107,129,0); }
}

/* ---- Forms ---- */
input[type=text], textarea, select {
  width: 100%; padding: 12px 13px; border-radius: 12px; border: 1px solid var(--stroke-strong);
  background: rgba(0,0,0,.22); color: var(--text); font-size: 15px; font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); }
textarea { min-height: 120px; resize: vertical; line-height: 1.55; }
label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 6px; font-weight: 600; }

/* ---- Stats ---- */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--glass-2); border: 1px solid var(--stroke); border-radius: 14px; padding: 16px 8px; text-align: center; }
.stat .num { font-size: 26px; font-weight: 800; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat .lbl { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ---- Chart ---- */
.chart { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding-top: 8px; }
.chart .bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; }
.chart .bar { width: 70%; background: var(--grad); border-radius: 6px 6px 2px 2px; min-height: 3px; transition: height .4s ease; }
.chart .bar.empty { background: rgba(255,255,255,.06); }
.chart .blbl { font-size: 9px; color: var(--faint); }

/* ---- Level pills ---- */
.level-pills { display: flex; gap: 8px; }
.pill {
  flex: 1; text-align: center; padding: 11px 6px; border-radius: 12px; cursor: pointer;
  background: var(--glass-2); border: 1px solid var(--stroke); color: var(--muted);
  font-weight: 700; font-size: 14px; transition: all .2s;
}
.pill .pl-sub { display: block; font-size: 10px; font-weight: 500; color: var(--faint); margin-top: 2px; }
.pill.on { background: var(--grad); color: #0a0a12; border-color: transparent; }
.pill.on .pl-sub { color: rgba(10,10,18,.7); }

/* ---- Recommendation banner ---- */
.reco {
  display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-radius: 14px;
  background: var(--grad-soft); border: 1px solid var(--stroke-strong); margin-bottom: 14px;
}
.reco .ico { font-size: 22px; }
.reco .txt { flex: 1; font-size: 13px; line-height: 1.45; }
.reco b { color: var(--text); }

/* ---- Difficulty meter ---- */
.meter { height: 6px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--warn), var(--danger)); }

/* ---- Material rows ---- */
.mat {
  display: flex; align-items: center; gap: 14px; padding: 15px 16px;
  background: var(--glass); border: 1px solid var(--stroke); border-radius: 16px; margin-bottom: 11px;
  cursor: pointer; backdrop-filter: blur(12px); transition: transform .08s, border-color .2s;
}
.mat:active { transform: scale(.99); }
.mat:hover { border-color: var(--stroke-strong); }
.mat .mat-main { flex: 1; min-width: 0; }
.mat .mat-title { font-weight: 700; font-size: 15px; }
.mat .mat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mat-meter { width: 56px; }
.badge { font-size: 10px; padding: 4px 9px; border-radius: 999px; background: var(--glass-2);
  color: var(--muted); border: 1px solid var(--stroke); font-weight: 700; }
.badge.easy { color: var(--accent); } .badge.hard { color: var(--danger); } .badge.normal { color: var(--primary-2); }

/* ---- Feed ---- */
.feed-item { padding: 13px 14px; border: 1px solid var(--stroke); border-radius: 13px; margin-bottom: 9px; background: var(--glass-2); }
.feed-item .ft { font-weight: 600; font-size: 14px; line-height: 1.4; }
.feed-item .fs { font-size: 12px; color: var(--muted); margin: 5px 0 9px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---- Practice screen (学習ページ) ---- */
.practice-wrap { padding-top: 6px; }
.practice-head { display: flex; align-items: center; margin-bottom: 14px; }
.practice-title { font-size: 13px; color: var(--muted); font-weight: 600; }
.stage {
  position: relative; border-radius: 24px; padding: 30px 22px;
  background: linear-gradient(160deg, rgba(124,92,255,.12), rgba(34,211,238,.06)), var(--glass);
  border: 1px solid var(--stroke-strong); box-shadow: var(--shadow); overflow: hidden;
}
.stage::after {
  content: ""; position: absolute; top: -40%; right: -20%; width: 240px; height: 240px;
  background: radial-gradient(circle, rgba(124,92,255,.25), transparent 70%); pointer-events: none;
}
.seg { display: inline-flex; padding: 4px; border-radius: 12px; background: rgba(0,0,0,.25); border: 1px solid var(--stroke); gap: 4px; }
.seg button { border: none; background: none; color: var(--muted); font-weight: 700; font-size: 13px; padding: 8px 14px; border-radius: 9px; cursor: pointer; }
.seg button.on { background: var(--grad); color: #0a0a12; }

.practice-sentence {
  font-size: 25px; line-height: 1.55; text-align: center; padding: 26px 6px 14px;
  min-height: 96px; display: grid; place-items: center; font-weight: 600; position: relative; z-index: 1;
}
.practice-sentence.dim { color: var(--faint); font-weight: 400; font-size: 17px; }

.progress-dots { display: flex; gap: 6px; justify-content: center; margin: 4px 0 6px; flex-wrap: wrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.14); transition: all .2s; }
.dot.done { background: var(--accent); }
.dot.current { background: var(--primary-2); transform: scale(1.5); box-shadow: 0 0 10px rgba(34,211,238,.7); }

.score-line { font-size: 15px; text-align: center; margin-top: 12px; min-height: 24px; }
.score-big { font-size: 34px; font-weight: 800; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tok-ok { color: var(--accent); font-weight: 700; }
.tok-bad { color: var(--danger); font-weight: 700; text-decoration: line-through; opacity: .8; }
.tok-miss { color: var(--warn); }

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

.speed-row { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.speed-row input[type=range] { flex: 1; accent-color: var(--primary); }

.heard {
  background: rgba(0,0,0,.25); border: 1px solid var(--stroke); border-radius: 12px;
  padding: 12px 14px; font-size: 15px; margin-top: 12px; min-height: 22px; line-height: 1.5;
}
.heard.empty { color: var(--faint); }

/* ---- Toast / misc ---- */
.toast {
  position: fixed; bottom: 104px; left: 50%; transform: translateX(-50%);
  background: var(--glass); color: var(--text); border: 1px solid var(--stroke-strong);
  padding: 11px 18px; border-radius: 999px; font-size: 13px; z-index: 60;
  box-shadow: var(--shadow); backdrop-filter: blur(14px); max-width: 90%;
}
.error { color: var(--danger); }
.empty-state { text-align: center; color: var(--muted); padding: 48px 20px; }
.empty-state .big { font-size: 44px; margin-bottom: 12px; opacity: .85; }
.hint { font-size: 12px; color: var(--faint); margin-top: 8px; line-height: 1.55; }
.divider { height: 1px; background: var(--stroke); margin: 16px 0; border: none; }
a { color: var(--primary-2); }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--stroke-strong);
  border-top-color: var(--primary); border-radius: 50%; animation: rot .7s linear infinite; vertical-align: -3px; }
@keyframes rot { to { transform: rotate(360deg); } }
