/* ═══════════════════════════════════════════════════════════════
   hiragana.web.id — Design System v3.0
   Japanese Learning Platform · Professional · Clean · Modern
   ═══════════════════════════════════════════════════════════════ */

/* ── CSS Custom Properties ── */
:root {
  /* Colors — Light Theme (default) */
  --color-bg:             #fafbfc;
  --color-surface:        #ffffff;
  --color-surface-raised: #f0f2f5;
  --color-border:         #e1e4e8;
  --color-border-light:   #ebeef2;
  --color-text:           #1a1d23;
  --color-text-secondary: #586069;
  --color-text-tertiary:  #8b949e;

  /* Brand */
  --color-sakura:         #e8536c;  /* primary red/pink */
  --color-sakura-light:   #ff7b93;
  --color-sakura-dark:    #c73e54;
  --color-indigo:         #4c6ef5;  /* blue accent */
  --color-indigo-light:   #748ffc;
  --color-indigo-dark:    #3b5bdb;
  --color-amber:          #f59f00;  /* gold/highlight */
  --color-amber-light:    #fcc419;
  --color-emerald:        #20c997;  /* success */
  --color-rose:           #e64980;  /* accent pink */
  --color-violet:         #7950f2;  /* purple */
  --color-teal:           #15aabf;  /* teal */
  --color-orange:         #fd7e14;  /* orange */

  /* Semantic */
  --color-success:        #2b8a3e;
  --color-warning:        #e67700;
  --color-error:          #c92a2a;
  --color-info:           #1864ab;

  --color-success-bg:     #ebfbee;
  --color-warning-bg:     #fff9db;
  --color-error-bg:       #fff5f5;
  --color-info-bg:        #e7f5ff;

  /* Typography */
  --font-sans:            'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-jp:              'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic', sans-serif;
  --font-mono:            'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  --text-xs:              0.75rem;   /* 12px */
  --text-sm:              0.875rem;  /* 14px */
  --text-base:            1rem;      /* 16px */
  --text-lg:              1.125rem;  /* 18px */
  --text-xl:              1.25rem;   /* 20px */
  --text-2xl:             1.5rem;    /* 24px */
  --text-3xl:             1.875rem;  /* 30px */
  --text-4xl:             2.25rem;   /* 36px */
  --text-5xl:             3rem;      /* 48px */

  --leading-tight:        1.25;
  --leading-normal:       1.6;
  --leading-relaxed:      1.75;

  --font-weight-light:    300;
  --font-weight-normal:   400;
  --font-weight-medium:   500;
  --font-weight-semibold: 600;
  --font-weight-bold:     700;
  --font-weight-extrabold:800;

  /* Spacing */
  --space-1:              0.25rem;  /* 4px */
  --space-2:              0.5rem;   /* 8px */
  --space-3:              0.75rem;  /* 12px */
  --space-4:              1rem;     /* 16px */
  --space-5:              1.25rem;  /* 20px */
  --space-6:              1.5rem;   /* 24px */
  --space-8:              2rem;     /* 32px */
  --space-10:             2.5rem;   /* 40px */
  --space-12:             3rem;     /* 48px */
  --space-16:             4rem;     /* 64px */
  --space-20:             5rem;     /* 80px */

  /* Layout */
  --max-width:            1200px;
  --max-width-narrow:     800px;
  --max-width-wide:       1400px;
  --container-padding:    1.5rem;

  /* Border Radius */
  --radius-sm:            6px;
  --radius-md:            10px;
  --radius-lg:            16px;
  --radius-xl:            24px;
  --radius-full:          9999px;

  /* Shadows */
  --shadow-sm:            0 1px 2px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md:            0 4px 12px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-lg:            0 12px 32px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);
  --shadow-xl:            0 24px 48px rgba(0,0,0,0.1), 0 4px 16px rgba(0,0,0,0.04);

  /* Transitions */
  --transition-fast:      150ms ease;
  --transition-base:      250ms ease;
  --transition-slow:      400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Z-index */
  --z-dropdown:           100;
  --z-sticky:             200;
  --z-navbar:             300;
  --z-modal:              400;
  --z-toast:              500;
}

/* ── Dark Theme ── */
[data-theme="dark"] {
  --color-bg:             #0a0e17;
  --color-surface:        #111827;
  --color-surface-raised: #1a2332;
  --color-border:         #1e2d3d;
  --color-border-light:   #263548;
  --color-text:           #e6edf3;
  --color-text-secondary: #8b949e;
  --color-text-tertiary:  #6e7681;

  --color-success-bg:     #0d2b1a;
  --color-warning-bg:     #2d1f0c;
  --color-error-bg:       #2d0f13;
  --color-info-bg:        #0c1d3b;

  --shadow-sm:            0 1px 2px rgba(0,0,0,0.3), 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md:            0 4px 12px rgba(0,0,0,0.4), 0 1px 4px rgba(0,0,0,0.2);
  --shadow-lg:            0 12px 32px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.2);
  --shadow-xl:            0 24px 48px rgba(0,0,0,0.6), 0 4px 16px rgba(0,0,0,0.2);
}

/* ── Base Reset ── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  min-height: 100vh;
  transition: background var(--transition-base), color var(--transition-base);
}

/* ── Typography ── */
h1, h2, h3, h4, h5, h6 {
  line-height: var(--leading-tight);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
}

h1 { font-size: var(--text-4xl); letter-spacing: -0.02em; }
h2 { font-size: var(--text-3xl); letter-spacing: -0.015em; }
h3 { font-size: var(--text-2xl); letter-spacing: -0.01em; }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); }

p { margin-bottom: var(--space-4); }
p:last-child { margin-bottom: 0; }

a {
  color: var(--color-indigo);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--color-indigo-light); }

img {
  max-width: 100%;
  height: auto;
  display: block;
}

.ja { font-family: var(--font-jp); }

/* ── Layout ── */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

.container-narrow {
  max-width: var(--max-width-narrow);
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

.container-wide {
  max-width: var(--max-width-wide);
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

.section {
  padding: var(--space-16) 0;
}

.section-sm {
  padding: var(--space-8) 0;
}

/* ── Grid ── */
.grid {
  display: grid;
  gap: var(--space-6);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .grid-auto { grid-template-columns: 1fr; }
}

/* ── Card ── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: all var(--transition-base);
  box-shadow: var(--shadow-sm);
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--color-indigo);
}

.card--clickable {
  cursor: pointer;
}

.card--accent-sakura { border-left: 3px solid var(--color-sakura); }
.card--accent-indigo { border-left: 3px solid var(--color-indigo); }
.card--accent-amber  { border-left: 3px solid var(--color-amber); }
.card--accent-emerald { border-left: 3px solid var(--color-emerald); }
.card--accent-violet { border-left: 3px solid var(--color-violet); }
.card--accent-rose   { border-left: 3px solid var(--color-rose); }

.card__icon {
  font-size: 2rem;
  margin-bottom: var(--space-3);
}

.card__title {
  font-size: var(--text-lg);
  font-weight: var(--font-weight-bold);
  margin-bottom: var(--space-2);
}

.card__subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semibold);
  line-height: 1;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}

.btn:active { transform: scale(0.97); }

.btn--primary {
  background: var(--color-sakura);
  color: #fff;
}
.btn--primary:hover {
  background: var(--color-sakura-dark);
  color: #fff;
}

.btn--secondary {
  background: var(--color-indigo);
  color: #fff;
}
.btn--secondary:hover {
  background: var(--color-indigo-dark);
  color: #fff;
}

.btn--outline {
  background: transparent;
  color: var(--color-text);
  border-color: var(--color-border);
}
.btn--outline:hover {
  border-color: var(--color-indigo);
  color: var(--color-indigo);
  background: var(--color-surface-raised);
}

.btn--ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: transparent;
}
.btn--ghost:hover {
  color: var(--color-text);
  background: var(--color-surface-raised);
}

.btn--sm { padding: var(--space-1) var(--space-3); font-size: var(--text-xs); }
.btn--lg { padding: var(--space-4) var(--space-8); font-size: var(--text-base); }

.btn--icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-full);
}

/* ── Badge ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  border-radius: var(--radius-full);
  line-height: 1.4;
}

.badge--sakura  { background: var(--color-sakura); color: #fff; }
.badge--indigo  { background: var(--color-indigo); color: #fff; }
.badge--amber   { background: var(--color-amber); color: #fff; }
.badge--emerald { background: var(--color-emerald); color: #fff; }
.badge--outline {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
}

/* ── Navbar ── */
.navbar {
  position: sticky;
  top: 0;
  z-index: var(--z-navbar);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  backdrop-filter: blur(12px);
}

@supports (backdrop-filter: blur(12px)) {
  .navbar {
    background: color-mix(in srgb, var(--color-surface) 85%, transparent);
  }
}

.navbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--max-width-wide);
  margin: 0 auto;
  padding: var(--space-3) var(--container-padding);
  gap: var(--space-4);
}

.navbar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: var(--font-weight-extrabold);
  font-size: var(--text-lg);
  color: var(--color-sakura);
  text-decoration: none;
  letter-spacing: -0.5px;
  white-space: nowrap;
}

.navbar__brand span {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  font-weight: var(--font-weight-normal);
  display: none;
}

@media (min-width: 1024px) {
  .navbar__brand span { display: inline; }
}

.navbar__nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  list-style: none;
  flex-wrap: wrap;
}

.navbar__nav a,
.navbar__dropdown-toggle {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  white-space: nowrap;
  cursor: pointer;
  background: none;
  border: none;
  font-family: var(--font-sans);
}

.navbar__nav a:hover,
.navbar__dropdown-toggle:hover {
  color: var(--color-text);
  background: var(--color-surface-raised);
}

.navbar__nav a.active {
  color: var(--color-sakura);
  background: color-mix(in srgb, var(--color-sakura) 10%, transparent);
}

.navbar__dropdown {
  position: relative;
}

.navbar__dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2);
  z-index: var(--z-dropdown);
}

.navbar__dropdown:hover .navbar__dropdown-menu,
.navbar__dropdown.open .navbar__dropdown-menu {
  display: block;
}

.navbar__dropdown-menu a {
  display: block;
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  border-radius: var(--radius-sm);
}

.navbar__dropdown-menu a:hover {
  color: var(--color-text);
  background: var(--color-surface-raised);
}

.navbar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Mobile menu toggle */
.navbar__toggle {
  display: none;
  background: none;
  border: none;
  color: var(--color-text);
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--space-2);
}

@media (max-width: 1024px) {
  .navbar__nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    flex-direction: column;
    padding: var(--space-4);
    box-shadow: var(--shadow-lg);
    max-height: 70vh;
    overflow-y: auto;
  }

  .navbar__nav.open {
    display: flex;
  }

  .navbar__toggle {
    display: block;
  }

  .navbar__dropdown-menu {
    position: static;
    box-shadow: none;
    border: none;
    padding-left: var(--space-6);
  }
}

/* ── Theme Toggle ── */
.theme-toggle {
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.theme-toggle:hover {
  border-color: var(--color-amber);
  color: var(--color-amber);
  background: var(--color-surface-raised);
}

/* ── Hero ── */
.hero {
  text-align: center;
  padding: var(--space-20) 0 var(--space-16);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -20%;
  width: 140%;
  height: 200%;
  background: radial-gradient(
    ellipse at 30% 20%,
    color-mix(in srgb, var(--color-sakura) 8%, transparent) 0%,
    transparent 60%
  ),
  radial-gradient(
    ellipse at 70% 60%,
    color-mix(in srgb, var(--color-indigo) 6%, transparent) 0%,
    transparent 60%
  );
  pointer-events: none;
  z-index: 0;
}

.hero > * {
  position: relative;
  z-index: 1;
}

.hero__title {
  font-size: clamp(2rem, 5vw, var(--text-5xl));
  font-weight: var(--font-weight-extrabold);
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin-bottom: var(--space-4);
}

.hero__title .highlight {
  background: linear-gradient(135deg, var(--color-sakura), var(--color-rose));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero__subtitle {
  font-size: var(--text-xl);
  color: var(--color-text-secondary);
  max-width: 600px;
  margin: 0 auto var(--space-8);
  font-family: var(--font-jp);
}

.hero__cta {
  display: flex;
  gap: var(--space-4);
  justify-content: center;
  flex-wrap: wrap;
}

.hero__stats {
  display: flex;
  gap: var(--space-8);
  justify-content: center;
  margin-top: var(--space-12);
  flex-wrap: wrap;
}

.hero__stat {
  text-align: center;
}

.hero__stat-value {
  font-size: var(--text-3xl);
  font-weight: var(--font-weight-extrabold);
  color: var(--color-sakura);
}

.hero__stat-label {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  margin-top: var(--space-1);
}

/* ── Sections ── */
.section__header {
  text-align: center;
  margin-bottom: var(--space-12);
}

.section__title {
  font-size: var(--text-3xl);
  font-weight: var(--font-weight-extrabold);
  margin-bottom: var(--space-3);
}

.section__description {
  font-size: var(--text-lg);
  color: var(--color-text-secondary);
  max-width: 600px;
  margin: 0 auto;
}

/* ── Tables ── */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

th {
  background: var(--color-surface-raised);
  color: var(--color-text-secondary);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  font-size: var(--text-xs);
  letter-spacing: 0.05em;
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 2px solid var(--color-border);
  white-space: nowrap;
}

td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border-light);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--color-surface-raised); }

/* ── Kana Grid ── */
.kana-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: var(--space-2);
}

.kana-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.kana-card:hover {
  border-color: var(--color-sakura);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.kana-card__char {
  font-family: var(--font-jp);
  font-size: var(--text-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
}

.kana-card__romaji {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  margin-top: var(--space-1);
}

/* ── Quiz ── */
.quiz-container {
  max-width: var(--max-width-narrow);
  margin: 0 auto;
}

.quiz__progress {
  height: 4px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  margin-bottom: var(--space-6);
  overflow: hidden;
}

.quiz__progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--color-sakura), var(--color-indigo));
  border-radius: var(--radius-full);
  transition: width var(--transition-base);
}

.quiz__question {
  font-size: var(--text-2xl);
  font-weight: var(--font-weight-bold);
  margin-bottom: var(--space-8);
  text-align: center;
  font-family: var(--font-jp);
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.quiz__options {
  display: grid;
  gap: var(--space-3);
}

.quiz__option {
  padding: var(--space-4) var(--space-6);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
}

.quiz__option:hover {
  border-color: var(--color-indigo);
  background: var(--color-surface-raised);
}

.quiz__option--correct {
  border-color: var(--color-emerald);
  background: var(--color-success-bg);
}

.quiz__option--wrong {
  border-color: var(--color-error);
  background: var(--color-error-bg);
}

.quiz__option--disabled {
  pointer-events: none;
  opacity: 0.7;
}

.quiz__result {
  text-align: center;
  padding: var(--space-8);
}

.quiz__score {
  font-size: var(--text-5xl);
  font-weight: var(--font-weight-extrabold);
  background: linear-gradient(135deg, var(--color-sakura), var(--color-amber));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Progress Tracker ── */
.progress-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-4);
}

.progress-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.progress-card__title {
  font-weight: var(--font-weight-bold);
  font-size: var(--text-lg);
}

.progress-bar {
  height: 8px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
  background: linear-gradient(90deg, var(--color-sakura), var(--color-indigo));
}

.progress-bar__fill--emerald { background: var(--color-emerald); }
.progress-bar__fill--amber { background: var(--color-amber); }
.progress-bar__fill--violet { background: var(--color-violet); }

.checklist {
  list-style: none;
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.checklist__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--color-surface-raised);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.checklist__item:hover {
  background: var(--color-border);
}

.checklist__checkbox {
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.checklist__item--done .checklist__checkbox {
  background: var(--color-emerald);
  border-color: var(--color-emerald);
  color: #fff;
}

.checklist__item--done .checklist__label {
  text-decoration: line-through;
  color: var(--color-text-tertiary);
}

/* ── Search ── */
.search-bar {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.search-bar__input {
  flex: 1;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--color-text);
  transition: border-color var(--transition-fast);
}

.search-bar__input:focus {
  outline: none;
  border-color: var(--color-indigo);
}

.search-bar__input::placeholder {
  color: var(--color-text-tertiary);
}

/* ── Vocabulary Cards ── */
.vocab-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.vocab-card:hover {
  border-color: var(--color-sakura);
  box-shadow: var(--shadow-md);
}

.vocab-card__jp {
  font-family: var(--font-jp);
  font-size: var(--text-2xl);
  font-weight: var(--font-weight-bold);
}

.vocab-card__reading {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
}

.vocab-card__meaning {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.vocab-card__category {
  display: inline-block;
  font-size: var(--text-xs);
  padding: 2px 8px;
  background: color-mix(in srgb, var(--color-sakura) 15%, transparent);
  color: var(--color-sakura);
  border-radius: var(--radius-full);
  font-weight: var(--font-weight-semibold);
  align-self: flex-start;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 2px solid var(--color-border);
  margin-bottom: var(--space-6);
  overflow-x: auto;
}

.tab {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
  font-family: var(--font-sans);
}

.tab:hover {
  color: var(--color-text);
}

.tab.active {
  color: var(--color-sakura);
  border-bottom-color: var(--color-sakura);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ── Footer ── */
.footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: var(--space-12) 0;
  margin-top: var(--space-16);
}

.footer__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--container-padding);
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: var(--space-8);
}

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

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

.footer__brand {
  font-weight: var(--font-weight-extrabold);
  font-size: var(--text-lg);
  color: var(--color-sakura);
  margin-bottom: var(--space-3);
}

.footer__desc {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  line-height: var(--leading-relaxed);
}

.footer__heading {
  font-weight: var(--font-weight-bold);
  font-size: var(--text-sm);
  color: var(--color-text);
  margin-bottom: var(--space-4);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.footer__links {
  list-style: none;
  display: grid;
  gap: var(--space-2);
}

.footer__links a {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.footer__links a:hover {
  color: var(--color-sakura);
}

.footer__bottom {
  max-width: var(--max-width);
  margin: var(--space-8) auto 0;
  padding: var(--space-6) var(--container-padding) 0;
  border-top: 1px solid var(--color-border);
  text-align: center;
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
}

/* ── Utility Classes ── */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.font-jp { font-family: var(--font-jp); }
.font-mono { font-family: var(--font-mono); }

.mt-0 { margin-top: 0; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mt-12 { margin-top: var(--space-12); }

.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.flex-col { flex-direction: column; }

.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  :root {
    --container-padding: 1rem;
    --text-4xl: 1.75rem;
    --text-3xl: 1.5rem;
  }
  .section { padding: var(--space-10) 0; }
  .hero { padding: var(--space-12) 0 var(--space-10); }
}

/* ── Responsive Tables & Overflow ── */
table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
}

@media (max-width: 640px) {
  /* Wrap tables in scrollable container */
  .table-responsive,
  table:not(.no-responsive) {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  /* Prevent body horizontal scroll */
  body {
    overflow-x: hidden;
  }

  main {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
  }

  /* Ensure images don't overflow */
  img, svg, video, canvas, iframe, embed, object {
    max-width: 100%;
    height: auto;
  }

  /* Pre/code blocks */
  pre, code {
    max-width: 100%;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
  }

  /* Any div with explicit width */
  div[style*="width"],
  span[style*="width"] {
    max-width: 100% !important;
    word-wrap: break-word;
  }
}

/* ── General overflow safety ── */
*, *::before, *::after {
  box-sizing: border-box;
}

main {
  word-wrap: break-word;
  overflow-wrap: break-word;
}


/* ── Content Typography ── */
.content h1, .content h2, .content h3, .content h4 {
  margin-top: var(--space-8);
  margin-bottom: var(--space-4);
  line-height: 1.3;
}

.content h1 { font-size: var(--text-4xl); font-weight: var(--font-weight-extrabold); }
.content h2 { font-size: var(--text-3xl); font-weight: var(--font-weight-bold); }
.content h3 { font-size: var(--text-2xl); font-weight: var(--font-weight-semibold); }
.content h4 { font-size: var(--text-xl); font-weight: var(--font-weight-semibold); }

.content p {
  margin-bottom: var(--space-4);
  line-height: 1.75;
  font-size: var(--text-base);
}

.content ul, .content ol {
  margin-bottom: var(--space-4);
  padding-left: var(--space-6);
}

.content li {
  margin-bottom: var(--space-2);
  line-height: 1.6;
}

.content blockquote {
  border-left: 4px solid var(--color-sakura);
  padding: var(--space-3) var(--space-5);
  margin: var(--space-5) 0;
  background: var(--color-surface-raised);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--color-text-secondary);
  font-style: italic;
}

.content .highlight-box {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-5) var(--space-6);
  margin: var(--space-5) 0;
}

.content .warning-box {
  background: var(--color-warning-bg);
  border: 1px solid var(--color-warning);
  border-radius: var(--radius-md);
  padding: var(--space-5) var(--space-6);
  margin: var(--space-5) 0;
}

.content .info-box {
  background: var(--color-info-bg);
  border: 1px solid var(--color-info);
  border-radius: var(--radius-md);
  padding: var(--space-5) var(--space-6);
  margin: var(--space-5) 0;
}

/* ── Content Tables ── */
.content table,
.kana-table,
.vocab-table,
.comparison-table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-5) 0;
  font-size: var(--text-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.content table th,
.kana-table th,
.vocab-table th,
.comparison-table th {
  background: var(--color-surface-raised);
  color: var(--color-text);
  font-weight: var(--font-weight-semibold);
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 2px solid var(--color-border);
  white-space: nowrap;
}

.content table td,
.kana-table td,
.vocab-table td,
.comparison-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border-light);
  vertical-align: top;
  line-height: 1.5;
}

.content table tr:last-child td,
.kana-table tr:last-child td,
.vocab-table tr:last-child td,
.comparison-table tr:last-child td {
  border-bottom: none;
}

.content table tr:hover,
.kana-table tr:hover,
.vocab-table tr:hover,
.comparison-table tr:hover {
  background: var(--color-surface-raised);
}

/* Kana character styling */
.kana-char {
  font-family: var(--font-jp);
  font-size: var(--text-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-sakura);
  display: inline-block;
  min-width: 3rem;
}

.romaji-text {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  font-weight: var(--font-weight-medium);
}

/* ── Tabs ── */
.tab-nav {
  display: flex;
  gap: var(--space-1);
  border-bottom: 2px solid var(--color-border);
  margin-bottom: var(--space-6);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-btn {
  padding: var(--space-3) var(--space-5);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  white-space: nowrap;
  transition: all var(--transition-fast);
  font-family: var(--font-sans);
}

.tab-btn:hover {
  color: var(--color-text);
  background: var(--color-surface-raised);
}

.tab-btn.active {
  color: var(--color-sakura);
  border-bottom-color: var(--color-sakura);
  font-weight: var(--font-weight-semibold);
}

.tab-panel {
  display: none;
  animation: fadeIn var(--transition-base) ease;
}

.tab-panel.active {
  display: block;
}

/* ── Chapter / Sub Navigation ── */
.chapter-nav {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-6);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);
}

.chapter-nav a {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  text-decoration: none;
  color: var(--color-text-secondary);
  background: var(--color-surface-raised);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.chapter-nav a:hover {
  background: var(--color-sakura);
  color: white;
}

.chapter-nav a.active {
  background: var(--color-sakura);
  color: white;
}

/* ── Section Spacing ── */
.content-section {
  margin-bottom: var(--space-10);
  padding-bottom: var(--space-8);
  border-bottom: 1px solid var(--color-border-light);
}

.content-section:last-child {
  border-bottom: none;
}

/* ── Lists with icons ── */
.icon-list {
  list-style: none;
  padding-left: 0;
}

.icon-list li {
  padding: var(--space-2) 0 var(--space-2) var(--space-6);
  position: relative;
  line-height: 1.7;
}

.icon-list li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--color-sakura);
  font-weight: var(--font-weight-bold);
}

/* ── Audio button ── */
.audio-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--color-text);
  transition: all var(--transition-fast);
}

.audio-btn:hover {
  background: var(--color-sakura);
  color: white;
  border-color: var(--color-sakura);
}

/* ── Card inside content ── */
.content .card {
  margin: var(--space-4) 0;
}

/* ── Strong/em in content ── */
.content strong {
  color: var(--color-text);
  font-weight: var(--font-weight-semibold);
}

.content em {
  color: var(--color-text-secondary);
}

/* ── Code in content ── */
.content code {
  background: var(--color-surface-raised);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--color-sakura);
}

/* ── HR in content ── */
.content hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-8) 0;
}

/* ── Print ── */
@media print {
  .navbar, .footer, .theme-toggle, .navbar__toggle { display: none !important; }
  body { background: white; color: black; }
}

/* ── Animations ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
  animation: fadeIn var(--transition-base) ease forwards;
}

.animate-slide-up {
  animation: slideUp var(--transition-slow) ease forwards;
}

/* Stagger children */
.stagger > * {
  opacity: 0;
  animation: fadeIn var(--transition-base) ease forwards;
}

.stagger > *:nth-child(1) { animation-delay: 0.05s; }
.stagger > *:nth-child(2) { animation-delay: 0.1s; }
.stagger > *:nth-child(3) { animation-delay: 0.15s; }
.stagger > *:nth-child(4) { animation-delay: 0.2s; }
.stagger > *:nth-child(5) { animation-delay: 0.25s; }
.stagger > *:nth-child(6) { animation-delay: 0.3s; }
.stagger > *:nth-child(7) { animation-delay: 0.35s; }
.stagger > *:nth-child(8) { animation-delay: 0.4s; }
.stagger > *:nth-child(9) { animation-delay: 0.45s; }
.stagger > *:nth-child(10) { animation-delay: 0.5s; }

/* Smooth page transitions */
.page-transition {
  animation: fadeIn 0.3s ease;
}

/* Flashcard flip (for vocab practice) */
.flashcard {
  perspective: 1000px;
  cursor: pointer;
  min-height: 200px;
}

.flashcard__inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s;
  transform-style: preserve-3d;
}

.flashcard.flipped .flashcard__inner {
  transform: rotateY(180deg);
}

.flashcard__front,
.flashcard__back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: var(--space-8);
}

.flashcard__back {
  transform: rotateY(180deg);
}

.flashcard__front-text {
  font-family: var(--font-jp);
  font-size: var(--text-4xl);
  font-weight: var(--font-weight-extrabold);
}

.flashcard__back-text {
  font-size: var(--text-xl);
  color: var(--color-text-secondary);
}

/* Toast notifications */
.toast {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-6);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-toast);
  animation: slideUp 0.3s ease;
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.toast--success { border-left: 3px solid var(--color-emerald); }
.toast--error   { border-left: 3px solid var(--color-error); }
.toast--info    { border-left: 3px solid var(--color-indigo); }
