:root {
  --accent: #6ecbff;
  --accent-bright: #9ddeff;
  --accent-dark: #4db4f0;
  --accent-soft: rgba(110, 203, 255, 0.14);
  --accent-border: rgba(110, 203, 255, 0.28);
  --bg: #000000;
  --surface: #141414;
  --surface-raised: #1c1c1c;
  --surface-muted: #1a1a1a;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f5f5f7;
  --text-secondary: #a1a1a6;
  --text-muted: #6e6e73;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 28px rgba(0, 0, 0, 0.55);
  --font: "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 0 0 40px;
  background: var(--bg);
}

/* ── Top bar ── */

.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: rgba(0, 0, 0, 0.88);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
}

.top-bar--plain {
  background: var(--bg);
  border-bottom: none;
  backdrop-filter: none;
}

.top-bar-title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.top-bar-sub {
  margin: 2px 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Header ── */

.site-header {
  padding: 28px 20px 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-bright) 0%, var(--accent-dark) 100%);
  color: #0a0a0a;
  box-shadow: 0 0 20px rgba(110, 203, 255, 0.25);
}

.brand-mark svg {
  width: 22px;
  height: 22px;
}

.logo {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.tagline {
  margin: 4px 0 0;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.sub-header {
  padding: 16px 20px 12px;
}

.learn-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.15s ease;
}

.back-link:hover {
  color: var(--accent);
}

.back-link::before {
  content: "";
  width: 8px;
  height: 8px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  margin-right: 2px;
}

.group-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.group-name {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.25;
}

.group-tagline {
  margin: 4px 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.progress-pill {
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  padding: 6px 12px;
  border-radius: 999px;
}

/* ── Group icon ── */

.group-icon {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--icon-from), var(--icon-to));
  color: #fff;
  box-shadow: 0 0 16px rgba(110, 203, 255, 0.15);
}

.group-icon--md {
  width: 52px;
  height: 52px;
}

.group-icon--sm {
  width: 44px;
  height: 44px;
}

.group-icon-img {
  width: 52%;
  height: 52%;
  object-fit: contain;
  filter: brightness(0) invert(1);
  opacity: 0.95;
}

/* ── Section ── */

.home-main,
.phrases-main,
.learn-main {
  padding: 0 20px;
}

.section-head {
  margin-bottom: 16px;
  padding: 0 2px;
}

.section-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}

.section-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ── Group cards ── */

.group-grid {
  display: grid;
  gap: 10px;
}

.group-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition:
    border-color 0.2s ease,
    background 0.2s ease,
    transform 0.15s ease;
}

.group-card:hover {
  border-color: var(--accent-border);
  background: var(--surface-raised);
  transform: translateY(-1px);
}

.group-card-body {
  flex: 1;
  min-width: 0;
}

.group-card-name {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.group-card-tagline {
  margin: 3px 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.group-card-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 8px 0 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
}

.group-card-meta::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}

.group-card-chevron {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 1.25rem;
  line-height: 1;
  transition: transform 0.15s ease, color 0.15s ease;
}

.group-card:hover .group-card-chevron {
  color: var(--accent);
  transform: translateX(2px);
}

.loading {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 48px 20px;
}

/* ── Phrase selection ── */

.phrases-hint {
  margin: 0 0 14px;
  padding: 12px 14px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.phrase-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.phrase-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  overflow: hidden;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    transform 0.12s ease;
}

.phrase-btn:hover {
  border-color: var(--accent-border);
  background: var(--surface-raised);
  transform: translateY(-1px);
}

.phrase-btn:active {
  transform: translateY(0);
}

.phrase-btn-inner {
  display: flex;
  align-items: stretch;
  gap: 0;
}

.phrase-btn-accent {
  width: 3px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--accent-bright) 0%, var(--accent-dark) 100%);
  box-shadow: 0 0 8px rgba(110, 203, 255, 0.4);
}

.phrase-btn-content {
  flex: 1;
  padding: 14px 16px;
  min-width: 0;
}

.phrase-btn-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.phrase-btn-ko-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.phrase-btn-reading {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.04em;
  line-height: 1.3;
}

.phrase-btn-ko {
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: -0.01em;
}

.phrase-btn-badge {
  flex-shrink: 0;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  padding: 4px 8px;
  border-radius: 999px;
}

.phrase-btn-ja {
  display: block;
  margin-top: 6px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ── Learn ── */

.learn-main {
  display: grid;
  gap: 12px;
  padding-bottom: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.video-wrap {
  aspect-ratio: 16 / 9;
  background: #000;
}

#player {
  width: 100%;
  height: 100%;
}

.video-meta {
  margin: 0;
  padding: 12px 16px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-muted);
  border-top: 1px solid var(--border);
  line-height: 1.4;
}

.phrase-card {
  padding: 20px 18px 22px;
}

.label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.label::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.phrase-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.reading {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.05em;
  line-height: 1.3;
}

.phrase {
  margin: 0;
  font-size: clamp(1.5rem, 5vw, 1.875rem);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.meaning {
  margin: 16px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-secondary);
  font-weight: 500;
}

.controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
}

/* ── Buttons ── */

.btn-primary,
.btn-secondary {
  border: none;
  border-radius: 999px;
  padding: 13px 18px;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    opacity 0.15s ease,
    transform 0.15s ease,
    background 0.15s ease,
    box-shadow 0.15s ease;
}

.btn-primary {
  background: var(--accent);
  color: #0a0a0a;
  box-shadow: 0 0 20px rgba(110, 203, 255, 0.2);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-bright);
  transform: translateY(-1px);
  box-shadow: 0 0 24px rgba(110, 203, 255, 0.35);
}

.btn-primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--accent-border);
  background: var(--surface-raised);
  color: var(--accent-bright);
}

.btn-secondary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-large {
  padding: 15px 24px;
}

.auto-advance {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 10px;
  padding: 4px 8px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  line-height: 1.45;
}

.auto-advance input {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  margin-top: 2px;
  flex-shrink: 0;
}

@media (max-width: 400px) {
  .controls {
    grid-template-columns: 1fr;
  }

  #btn-replay {
    order: -1;
  }
}
