:root {
  --ink: #1a1a1a;
  --muted: #555;
  --accent: #c0392b;
  --rule: #ddd;
  --bg: #faf9f7;
  --card: #fff;
  --explain-bg: #f5f0eb;
  --particle-bg: #f7e9e7;
  --particle-border: #d9a39c;
  --note-bg: #f0f4f1;
  --note-border: #6b8f71;
  --chunk-sep: #8a8a8a;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  padding: 2rem 1.25rem 3rem;
}

.page {
  max-width: 44rem;
  margin: 0 auto;
}

header h1 {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

header h1 a {
  color: inherit;
  text-decoration: none;
}

header h1 a:hover {
  text-decoration: underline;
}

header p {
  color: var(--muted);
  font-size: 17px;
  margin-top: 0.35rem;
}

header .tagline {
  color: var(--ink);
  font-size: 18px;
  margin-top: 0.5rem;
  line-height: 1.45;
}

footer.credit .learner-note {
  margin: 0 0 0.35rem;
  padding: 0.65rem 0.85rem;
  background: var(--note-bg);
  border-left: 3px solid var(--note-border);
  border-radius: 0 6px 6px 0;
  color: #333;
  font-size: 15px;
  line-height: 1.55;
  max-width: 40rem;
}

footer.credit .learner-note strong {
  font-weight: 600;
  color: var(--ink);
}

nav.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 0.85rem;
  margin-bottom: 1.75rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--accent);
  font-size: 15px;
}

nav.site-nav a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

nav.site-nav a:hover {
  text-decoration: underline;
}

nav.site-nav a[aria-current="page"] {
  color: var(--ink);
  text-decoration: none;
  cursor: default;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 0.1rem;
}

ol.sentences {
  list-style: none;
  counter-reset: point;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

ol.sentences li {
  counter-increment: point;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1rem 1.1rem 1rem 3.25rem;
  position: relative;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

ol.sentences li::before {
  content: counter(point);
  position: absolute;
  left: 0.85rem;
  top: 1rem;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.english {
  font-size: 19px;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.romaji {
  font-size: 18px;
  color: var(--muted);
  font-style: italic;
  margin-bottom: 0.25rem;
}

.japanese {
  font-size: 24px;
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", "Meiryo", sans-serif;
  letter-spacing: 0.02em;
  margin-bottom: 0.75rem;
  line-height: 2.25;
}

/* Chunked Japanese — spaces like romaji, so particles (は / を / に…) are easy to find */
.japanese.jp-chunks {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  line-height: 2.4;
}

.japanese .chunk {
  display: inline-block;
  white-space: nowrap;
}

/*
  Role labels: wrappable flex (same idea as plain jp-chunks).
  Each chunk-block stacks Japanese + label; · separators sit on the Japanese row.
  Do not restyle .chunk / .particle inside blocks — keep the same look as unlabeled sentences.
*/
.japanese.jp-chunks.has-roles {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  align-content: flex-start;
  gap: 0.35em 0;
  line-height: 2.4;
}

.japanese .chunk-block {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between; /* Japanese at top, role at bottom */
  text-align: center;
  max-width: 100%;
  min-height: 4.35em; /* slightly tighter than the first “justify bottom” pass */
}

.japanese .chunk-block .chunk {
  /* Same row height for every chunk so role labels share one baseline
     (particles have padding; without this their label sits lower) */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 2.4em;
  line-height: 2.4;
}

.japanese .chunk-sep {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  color: var(--chunk-sep);
  font-weight: 700;
  font-size: 1em;
  line-height: 1;
  height: 1.2em;
  padding: 0 0.08em;
  margin: 0;
  user-select: none;
  /* Nudge the middot up so it sits mid-character, not like a period */
  transform: translateY(-0.08em);
}

.japanese.jp-chunks.has-roles > .chunk-sep {
  /* Keep · on the Japanese row (unchanged by role nudge) */
  align-self: flex-start;
  height: 2.4em;
  transform: none;
  align-items: center;
}

.japanese .chunk-role {
  display: block;
  margin-top: auto; /* justify to bottom of the chunk-block */
  margin-bottom: 0;
  padding: 0 0.15em;
  border: none;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 12px;
  font-weight: 500;
  font-style: normal;
  line-height: 1.25;
  color: var(--muted);
  letter-spacing: 0.01em;
  max-width: 7.5em;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.japanese .chunk-role.particle-role {
  color: #9b3a32;
  font-weight: 600;
}

.japanese .chunk.particle {
  color: #9b3a32;
  font-weight: 700;
  background: var(--particle-bg);
  border: 1px solid var(--particle-border);
  border-radius: 0.45em;
  padding: 0.06em 0.28em 0.1em;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* Furigana above kanji */
.japanese ruby {
  ruby-position: over;
  ruby-align: center;
}

.japanese rt {
  font-size: 55%;
  font-weight: 500;
  color: var(--muted);
  font-style: normal;
  letter-spacing: 0;
  user-select: none;
}

.speech-cue {
  margin: -0.5rem 0 1.25rem;
  padding: 0.65rem 0.85rem;
  background: #f3f6f4;
  border-radius: 6px;
  color: #333;
  font-size: 15px;
  line-height: 1.5;
}

.speech-cue a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.speech-cue a:hover {
  text-decoration: underline;
}

/* ========== Core words list chrome ========== */
.intro {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  margin-bottom: 1.5rem;
  font-size: 17px;
  line-height: 1.6;
  color: #333;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.intro p + p {
  margin-top: 0.65rem;
}

.intro strong {
  color: var(--ink);
}

.how-to {
  margin: 0 0 1.75rem;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  counter-reset: how;
}

.how-to li {
  font-size: 16px;
  color: #333;
  padding-left: 1.35rem;
  position: relative;
  line-height: 1.55;
}

.how-to li::before {
  content: counter(how, decimal);
  counter-increment: how;
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
}

.how-to strong {
  color: var(--ink);
}

.section-title {
  font-size: 22px;
  font-weight: 700;
  margin: 1.75rem 0 0.35rem;
  letter-spacing: -0.01em;
}

.section-note {
  color: var(--muted);
  font-size: 16px;
  margin-bottom: 0.85rem;
  line-height: 1.45;
}

.next-steps {
  margin-top: 2rem;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  font-size: 16px;
  line-height: 1.6;
  color: #333;
}

.next-steps h2 {
  font-size: 18px;
  margin-bottom: 0.45rem;
}

.next-steps ul {
  margin: 0.4rem 0 0 1.2rem;
}

.next-steps li {
  margin-bottom: 0.3rem;
}

.next-steps a {
  color: var(--accent);
}

/* Core-word example box + study filter / section chip */
html {
  scroll-behavior: smooth;
}

.study-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0 0 1rem;
}

.study-filter button,
.study-filter a {
  appearance: none;
  border: 1px solid var(--rule);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.study-filter button:hover,
.study-filter a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.study-filter button[aria-pressed="true"],
.study-filter a[aria-current="true"] {
  border-color: var(--accent);
  background: var(--particle-bg);
  color: var(--accent);
}

.core-section.is-hidden {
  display: none;
}

.section-title[id],
#everyday {
  scroll-margin-top: 1.25rem;
}

.card-section {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.45rem;
}

.example {
  background: var(--explain-bg);
  border-left: 3px solid var(--accent);
  padding: 0.75rem 0.95rem;
  border-radius: 0 4px 4px 0;
  margin-bottom: 0.65rem;
}

.example .label {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-bottom: 0.35rem;
}

.example .english {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.example .romaji {
  font-size: 16px;
  margin-bottom: 0.15rem;
}

.example .japanese {
  font-size: 20px;
  margin-bottom: 0;
  line-height: 2.1;
}

.example .japanese.jp-chunks.has-roles {
  font-size: 20px;
  line-height: 2.2;
  margin-bottom: 0;
}

.example .japanese .chunk-role {
  font-size: 11px;
}

/* Tips on core study cards stay quieter than apple .explain boxes */
.study-cards .explain {
  background: transparent;
  border-left: none;
  padding: 0;
  border-radius: 0;
  font-size: 16px;
  line-height: 1.55;
}

.study-empty {
  display: none;
  padding: 1.25rem 1rem;
  background: var(--card);
  border: 1px dashed var(--rule);
  border-radius: 8px;
  color: var(--muted);
  font-size: 16px;
  text-align: center;
}

.study-empty.is-visible {
  display: block;
}

/* ========== Study mode (one card at a time) ========== */
.study-deck {
  margin-bottom: 1.5rem;
}

.study-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.85rem;
}

.study-progress {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.study-btn {
  appearance: none;
  border: 1px solid var(--accent);
  background: #fff;
  color: var(--accent);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  min-width: 6.5rem;
}

.study-btn:hover:not(:disabled) {
  background: var(--particle-bg);
}

.study-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.study-viewport {
  touch-action: pan-y;
}

.study-cards {
  gap: 0;
}

.study-cards > li {
  display: none;
}

.study-cards > li.is-active {
  display: block;
}

/*
  display:none items skip CSS counters, so every visible card looked like “1”.
  Use data-n — and beat ol.sentences li::before on specificity.
*/
ol.sentences.study-cards > li {
  counter-increment: none;
}

ol.sentences.study-cards > li::before {
  content: attr(data-n);
}

@media print {
  .study-toolbar {
    display: none;
  }

  .study-cards > li {
    display: block !important;
  }
}

.speech-cue ruby {
  ruby-position: over;
}

.speech-cue rt {
  font-size: 55%;
  color: var(--muted);
}

/* Real-life / casual spoken form — quieter than the study line */
.spoken {
  margin: 0.1rem 0 0.75rem;
  padding: 0.55rem 0.8rem;
  background: #f3f6f4;
  border-radius: 6px;
}

.spoken-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #5a6b5e;
  margin-bottom: 0.3rem;
  letter-spacing: 0.01em;
}

.spoken-romaji {
  font-size: 15px;
  color: var(--muted);
  font-style: italic;
  margin-bottom: 0.15rem;
}

.spoken .japanese {
  font-size: 20px;
  margin-bottom: 0;
  line-height: 2.2;
}

.spoken-note {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.45;
}

.spoken .japanese + .spoken-note {
  margin-top: 0.35rem;
}

.explain {
  font-size: 17px;
  color: #333;
  line-height: 1.6;
  background: var(--explain-bg);
  border-left: 3px solid var(--accent);
  padding: 0.75rem 0.95rem;
  border-radius: 0 4px 4px 0;
}

.explain strong {
  font-weight: 600;
  color: var(--ink);
}

footer.credit {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-size: 15px;
  color: var(--muted);
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

footer.credit a {
  color: var(--accent);
  text-decoration: none;
}

footer.credit a:hover {
  text-decoration: underline;
}

footer.credit .meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.75rem;
}

footer.credit .years {
  font-variant-numeric: tabular-nums;
}

/* ========== TABLET: window width 768px or less ========== */
@media screen and (max-width: 768px) {
  body {
    padding: 1.5rem 1rem 2.25rem;
  }

  header h1 {
    font-size: 26px;
  }

  header p {
    font-size: 15px;
  }

  header .tagline {
    font-size: 16px;
  }

  footer.credit .learner-note {
    font-size: 15px;
    padding: 0.65rem 0.8rem;
  }

  nav.site-nav {
    margin-bottom: 1.25rem;
    font-size: 14px;
  }

  .intro {
    font-size: 15px;
    padding: 0.9rem 1rem;
  }

  .how-to li {
    font-size: 15px;
  }

  .section-title {
    font-size: 20px;
  }

  .section-note {
    font-size: 15px;
  }

  .example .english {
    font-size: 15px;
  }

  .example .romaji {
    font-size: 15px;
  }

  .example .japanese {
    font-size: 18px;
  }

  .next-steps {
    font-size: 15px;
  }

  ol.sentences {
    gap: 0.85rem;
  }

  ol.sentences li {
    padding: 0.9rem 1rem 0.9rem 2.9rem;
  }

  ol.sentences li::before {
    left: 0.7rem;
    top: 0.9rem;
    width: 1.55rem;
    height: 1.55rem;
    font-size: 14px;
  }

  .english {
    font-size: 17px;
  }

  .romaji {
    font-size: 16px;
  }

  .japanese {
    font-size: 20px;
    line-height: 2.2;
  }

  .spoken {
    padding: 0.5rem 0.7rem;
  }

  .spoken-label {
    font-size: 12px;
  }

  .spoken-romaji {
    font-size: 14px;
  }

  .spoken .japanese {
    font-size: 18px;
  }

  .spoken-note {
    font-size: 14px;
  }

  .explain {
    font-size: 15px;
  }

  footer.credit {
    font-size: 14px;
  }
}

/* ========== PHONE: window width 480px or less ========== */
@media screen and (max-width: 480px) {
  body {
    padding: 1rem 0.85rem 1.75rem;
  }

  header h1 {
    font-size: 22px;
  }

  header p {
    font-size: 14px;
  }

  header .tagline {
    font-size: 15px;
  }

  footer.credit .learner-note {
    font-size: 14px;
    padding: 0.55rem 0.7rem;
    margin-top: 0.7rem;
  }

  nav.site-nav {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    font-size: 13px;
    gap: 0.4rem 0.85rem;
  }

  .intro {
    font-size: 14px;
    padding: 0.8rem 0.85rem;
    margin-bottom: 1.15rem;
  }

  .how-to li {
    font-size: 14px;
  }

  .section-title {
    font-size: 18px;
    margin-top: 1.4rem;
  }

  .section-note {
    font-size: 14px;
  }

  .example {
    padding: 0.6rem 0.7rem;
  }

  .example .english {
    font-size: 14px;
  }

  .example .romaji {
    font-size: 14px;
  }

  .example .japanese {
    font-size: 16px;
    line-height: 2;
  }

  .next-steps {
    font-size: 14px;
    padding: 0.85rem;
  }

  .study-filter button,
  .study-filter a {
    font-size: 13px;
  }

  ol.sentences {
    gap: 0.75rem;
  }

  ol.sentences li {
    padding: 0.8rem 0.85rem 0.8rem 2.55rem;
  }

  ol.sentences li::before {
    left: 0.55rem;
    top: 0.8rem;
    width: 1.4rem;
    height: 1.4rem;
    font-size: 13px;
  }

  .english {
    font-size: 16px;
  }

  .romaji {
    font-size: 15px;
  }

  .japanese {
    font-size: 18px;
    line-height: 2.1;
    margin-bottom: 0.6rem;
  }

  .spoken {
    margin-bottom: 0.6rem;
    padding: 0.45rem 0.6rem;
  }

  .spoken-romaji {
    font-size: 13px;
  }

  .spoken .japanese {
    font-size: 16px;
  }

  .spoken-note {
    font-size: 13px;
  }

  .explain {
    font-size: 14px;
    padding: 0.6rem 0.7rem;
    line-height: 1.55;
  }

  footer.credit {
    margin-top: 1.5rem;
    padding-top: 1rem;
    font-size: 13px;
  }
}

/* ========== SMALL PHONE: 360px or less ========== */
@media screen and (max-width: 360px) {
  header h1 {
    font-size: 20px;
  }

  header p {
    font-size: 13px;
  }

  header .tagline {
    font-size: 14px;
  }

  footer.credit .learner-note {
    font-size: 13px;
  }

  .english {
    font-size: 15px;
  }

  .romaji {
    font-size: 14px;
  }

  .japanese {
    font-size: 16px;
  }

  .explain {
    font-size: 13px;
  }

  footer.credit {
    font-size: 12px;
  }
}

@media print {
  body {
    background: #fff;
    padding: 0.5rem 0.75rem;
    font-size: 11pt;
  }

  header {
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #333;
  }

  header h1 {
    font-size: 16pt;
  }

  header p {
    font-size: 11pt;
  }

  header .tagline {
    font-size: 11pt;
  }

  footer.credit .learner-note {
    font-size: 10pt;
    padding: 0.4rem 0.55rem;
    background: #f5f5f5;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .japanese .chunk.particle {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  ol.sentences {
    gap: 0.5rem;
  }

  ol.sentences li {
    box-shadow: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 0.55rem 0.7rem 0.55rem 2.5rem;
    break-inside: avoid;
  }

  ol.sentences li::before {
    top: 0.55rem;
    left: 0.55rem;
    width: 1.4rem;
    height: 1.4rem;
    font-size: 0.85rem;
    background: #333;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .english {
    font-size: 12.5pt;
  }

  .romaji {
    font-size: 11.5pt;
  }

  .japanese {
    font-size: 15pt;
    margin-bottom: 0.4rem;
    line-height: 2.2;
  }

  .japanese rt {
    font-size: 0.55em;
  }

  .explain {
    font-size: 10.5pt;
    padding: 0.4rem 0.55rem;
    background: #f5f5f5;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  footer.credit {
    margin-top: 1rem;
    padding-top: 0.75rem;
    font-size: 10pt;
  }

  nav.site-nav {
    display: none;
  }
}
  
