/* Japan Times–inspired typography & narrow column + sidebar layout */

:root {
  /* Japan Times–like: main text, headlines, Japanese, UI */
  --font-main: "Libre Baskerville", "Georgia", serif;
  --font-headline: "Playfair Display", "Libre Baskerville", "Georgia", serif;
  --font-japanese: "Noto Serif JP", "Libre Baskerville", serif;
  --font-sans: "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-serif: "Libre Baskerville", "Georgia", serif; /* legacy alias */
  --color-text: #222;
  --color-text-muted: #555;
  --color-bg: #fff;
  --color-border: #ccc;
  --color-cta: #B03030;
  --accent: #B03030;
  --color-cta-hover: #8c2828;
  --max-main: 600px;
  --sidebar-width: 240px;
  --layout-max: 1280px;
  --layout-gap: 2rem;
  --navbar-height: 303px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-main);
  font-size: 18px;
  line-height: 1.6;
  color: #222;
  background: #fafaf9;
}

body, p, li {
  font-family: var(--font-main);
  line-height: 1.6;
}

p, li {
  font-size: 18px;
}

/* Headlines: manga-edge presence (H1–H3) */
h1, h2, h3 {
  font-family: var(--font-headline);
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* Japanese text: Noto Serif JP for kanji/kana */
.japanese,
[lang="ja"] {
  font-family: var(--font-japanese);
  font-weight: 400;
}

/* Interface: nav, sidebar, buttons — modern and neutral */
nav,
.sidebar,
.nav-links,
.sidebar-title,
.sidebar-list a,
.navbar-search input,
.btn,
.link-ui {
  font-family: var(--font-sans);
  letter-spacing: 0.02em;
  font-size: 15px;
}

/* —— Navbar (Japan Times style: serif masthead, clear CTA) —— */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--navbar-height);
  background: #fff;
  border-bottom: 1px solid #e5e5e5;
  padding: 0.2rem 0;
}

.navbar-inner {
  max-width: var(--layout-max);
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 24px;
  min-width: 0;
}

.navbar-search {
  flex: 1;
  min-width: 0;
  max-width: 360px;
  margin: 0 auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

.navbar-search input {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 12px 0 36px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--color-text);
  background: var(--color-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") no-repeat 10px center;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  outline: none;
}

.navbar-search input::placeholder {
  color: var(--color-text-muted);
}

.navbar-search input:focus {
  border-color: var(--color-text-muted);
}

.navbar-search-submit {
  flex-shrink: 0;
  height: 36px;
  padding: 0 14px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  background: var(--color-accent);
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.navbar-search-submit:hover {
  filter: brightness(0.95);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--color-text);
}

.brand-logo {
  display: block;
  height: 252px;
  width: auto;
  flex-shrink: 0;
}

.brand-name {
  font-family: var(--font-headline);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.nav-links a {
  color: var(--color-text);
  text-decoration: none;
}

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

.nav-login {
  color: var(--color-text-muted);
}

/* Sign up: prominent CTA like Japan Times SUBSCRIBE */
.nav-signup {
  display: inline-block;
  padding: 10px 20px;
  background: var(--color-cta);
  color: #fff !important;
  border-radius: 4px;
  text-decoration: none !important;
  transition: background 0.2s;
}

.nav-signup:hover {
  background: var(--color-cta-hover);
  text-decoration: none;
}

.nav-links a[aria-disabled="true"] {
  cursor: default;
}

.nav-login:hover {
  text-decoration: none;
}

.nav-coming-soon {
  font-size: 0.7rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0.02em;
  color: var(--color-text-muted);
  margin-left: 0.25rem;
}

/* Japan-inspired accent for primary buttons (optional utility) */
.btn-primary {
  background: var(--color-cta);
  border: 1px solid var(--color-cta);
  border-radius: 4px;
  color: #fff;
  font-family: var(--font-sans);
  letter-spacing: 0.02em;
  font-size: 15px;
}

/* —— Layout: 2-column (left sidebar + main) —— */
.layout {
  max-width: var(--layout-max);
  margin: 0 auto;
  padding: 24px 20px 60px;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  gap: var(--layout-gap);
  column-gap: 2rem;
  align-items: start;
}

.layout > .main-column {
  grid-column: 2;
  justify-self: start;
  min-width: 0;
}

.sidebar {
  width: var(--sidebar-width);
  position: sticky;
  top: calc(var(--navbar-height) + 24px);
}

.sidebar-section {
  margin-bottom: 28px;
}

.sidebar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin: 0 0 12px 0;
}

.sidebar-title-icon {
  display: inline-flex;
  color: var(--color-text-muted);
}

.sidebar-title-link {
  color: inherit;
  text-decoration: none;
}

.sidebar-title-link:hover {
  text-decoration: underline;
}

.sidebar-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-list li {
  margin-bottom: 6px;
}

.sidebar-list a {
  color: var(--color-text);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 600;
}

.sidebar-list a:hover {
  text-decoration: underline;
}

.sidebar-badge {
  font-size: 0.7rem;
  text-transform: lowercase;
  color: var(--color-text-muted);
  font-weight: 400;
  margin-left: 0.25rem;
}

.sidebar-text {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin: 0;
}

.sidebar-explore-image {
  margin: 0 0 1rem 0;
  border-radius: 4px;
  overflow: hidden;
  line-height: 0;
}

.sidebar-explore-image img {
  display: block;
  width: 100%;
  height: auto;
  vertical-align: middle;
}

.sidebar-explore-caption {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin: 0.5rem 0 0 0;
  line-height: 1.4;
}

/* —— Main column (fixed-width center feed, Quora-like) —— */
.main-column {
  max-width: var(--max-main);
  width: 100%;
}

.main-inner {
  width: 100%;
}

.page-title {
  font-family: var(--font-headline);
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin: 0 0 12px 0;
}

.home-tagline {
  font-size: 1.1rem;
  line-height: 1.5;
  margin: 0 0 0.75rem 0;
  color: var(--color-text);
}

.lead {
  font-size: 1.05rem;
  color: var(--color-text-muted);
  margin: 0 0 28px 0;
}

.card {
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 1.25rem 1.5rem 1.25rem 2rem;
  margin-bottom: 20px;
  transition: background 0.2s, border-color 0.2s;
}

.card:hover {
  background: #fafafa;
  border-color: #dcdcdc;
}

.card h2 {
  font-family: var(--font-headline);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem 0;
  border-left: 4px solid var(--color-cta);
  padding-left: 0.75rem;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  padding-bottom: 0.35rem;
}

.article-byline {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: #999;
  margin: 0 0 1rem 0;
}

.card p,
.card ul {
  margin: 0;
  font-size: 0.98rem;
}

.card a {
  color: var(--color-cta);
  font-weight: 600;
  text-decoration: none;
}

.card a:hover {
  text-decoration: underline;
}

.pulse-light {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 0.35em;
  vertical-align: 0.2em;
  border-radius: 50%;
  background: var(--color-cta);
  box-shadow: 0 0 0 0 rgba(176, 48, 48, 0.6);
  animation: pulse-glow 1.5s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(176, 48, 48, 0.6);
    opacity: 1;
  }
  50% {
    box-shadow: 0 0 8px 4px rgba(176, 48, 48, 0.35);
    opacity: 0.9;
  }
}

.lesson-preview-text {
  margin-bottom: 12px;
}

.lesson-preview-text:last-of-type {
  margin-bottom: 16px;
}

.lesson-preview-link {
  display: inline-block;
  font-weight: 600;
  color: var(--color-cta);
  text-decoration: none;
}

.main-column a[href]:not(.nav-links a):not(.brand) {
  font-weight: 600;
}

.lesson-preview-link:hover {
  text-decoration: underline;
}

.lesson-preview .japanese,
.lesson-preview [lang="ja"] {
  color: var(--color-cta);
  font-weight: 700;
}

.lesson-back {
  margin: 0 0 16px 0;
  font-size: 0.9rem;
}

.lesson-back a {
  color: var(--color-text-muted);
  text-decoration: none;
}

.lesson-back a:hover {
  color: var(--color-text);
  text-decoration: underline;
}

.lesson-content.card .lesson-preview-text:last-of-type {
  margin-bottom: 0;
}

.about-contact {
  margin: 1.5rem 0 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}

.about-contact a {
  color: var(--color-cta);
  text-decoration: none;
  font-weight: 600;
}

.about-contact a:hover {
  text-decoration: underline;
  color: var(--color-cta-hover);
}

.about-name-explanation {
  margin-top: 1.25rem;
}

.about-name-explanation:first-of-type {
  margin-top: 1.5rem;
}

/* —— Full lesson content (Lesson 1 structure) —— */
.lesson-intro {
  font-size: 1.05rem;
  color: var(--color-text-muted);
  margin: 0 0 1.5rem 0;
}

.lesson-section {
  margin-bottom: 1.5rem;
  line-height: 1.7;
}

.lesson-section h2 {
  margin: 2.5rem 0 1rem 0;
  border-left: 4px solid var(--color-cta);
  padding-left: 0.75rem;
}

.lesson-section:first-of-type h2 {
  margin-top: 0;
}

.sentence-block {
  margin-bottom: 1.75rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--color-border);
  line-height: 1.7;
}

.sentence-block:last-child {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

.sentence-num {
  font-weight: 700;
  margin: 0 0 0.25rem 0;
  font-size: 0.95rem;
}

.lesson-section .sentence-japanese {
  font-size: 1.5rem;
  margin: 0 0 0.25rem 0;
  color: var(--color-cta);
  font-weight: 700;
}

.sentence-audio {
  margin: 0.35rem 0 0.5rem 0;
  padding-left: 0.25rem;
}

.audio-play {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem 0.3rem 1.75rem;
  color: #555;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='11 5 6 9 2 9 2 15 6 15 11 19 11 5'/%3E%3Cpath d='M15.54 8.46a5 5 0 0 1 0 7.07'/%3E%3Cpath d='M19.07 4.93a10 10 0 0 1 0 14.14'/%3E%3C/svg%3E") no-repeat 0.45rem center;
  background-size: 14px 14px;
  border: 1px solid #bbb;
  border-radius: 4px;
  cursor: pointer;
}

.audio-play:hover {
  background: var(--color-cta) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='11 5 6 9 2 9 2 15 6 15 11 19 11 5'/%3E%3Cpath d='M15.54 8.46a5 5 0 0 1 0 7.07'/%3E%3Cpath d='M19.07 4.93a10 10 0 0 1 0 14.14'/%3E%3C/svg%3E") no-repeat 0.45rem center;
  background-size: 14px 14px;
  border-color: var(--color-cta);
  color: #fff;
}

.audio-stop {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem 0.3rem 1.75rem;
  color: #555;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='6' y='6' width='12' height='12'/%3E%3C/svg%3E") no-repeat 0.45rem center;
  background-size: 14px 14px;
  border: 1px solid #bbb;
  border-radius: 4px;
  cursor: pointer;
  margin-left: 0.35rem;
}

.audio-stop:hover:not(:disabled) {
  background: var(--color-cta) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='6' y='6' width='12' height='12'/%3E%3C/svg%3E") no-repeat 0.45rem center;
  background-size: 14px 14px;
  border-color: var(--color-cta);
  color: #fff;
}

.audio-stop:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.lesson-section .sentence-natural {
  font-size: 1.25rem;
  color: #111;
  font-weight: 500;
  margin: 0 0 0.5rem 0;
}

.sentence-romaji {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: #666;
  margin: 0 0 0.25rem 0;
}

.romaji-highlight {
  background: rgba(176, 48, 48, 0.1);
  padding: 0.35rem 0.6rem;
  border-radius: 4px;
}

.sentence-meaning {
  color: #333;
  font-weight: 600;
  font-style: italic;
  margin: 0 0 0.5rem 0;
}

.breakdown-title {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin: 0.75rem 0 0.35rem 0;
}

.breakdown-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.7;
}

.breakdown-list li {
  margin-bottom: 0.25rem;
}

.grammar-item {
  margin-bottom: 1.25rem;
}

.grammar-item:last-child {
  margin-bottom: 0;
}

.grammar-item h3 {
  font-size: 1.05rem;
  margin: 0 0 0.5rem 0;
}

.grammar-item p {
  margin: 0 0 0.35rem 0;
  font-size: 0.98rem;
}

.grammar-example {
  font-weight: 600;
  margin-top: 0.5rem !important;
}

.vocab-list {
  padding-left: 1.5rem;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 2rem;
  row-gap: 0.6rem;
  font-size: 0.95rem;
}

.vocab-list li {
  margin-bottom: 6px;
  padding-left: 6px;
}

/* —— Kanji page (same structure as lesson) —— */
.kanji-block {
  margin: 0;
  padding-bottom: 0;
  line-height: 1.7;
}

.kanji-divider {
  border: none;
  border-top: 1px solid #eee;
  margin: 2rem 0;
}

.kanji-head {
  font-weight: 700;
  margin: 0 0 0.5rem 0;
  font-size: 1.1rem;
}

.kanji-char {
  font-size: 1.5rem;
  color: var(--color-cta);
  font-weight: 700;
  margin-right: 0.25rem;
}

.kanji-readings-inline {
  color: var(--color-text-muted);
  font-weight: 400;
}

.kanji-meta {
  margin: 0 0 0.25rem 0;
  font-size: 0.95rem;
}

.kanji-meta strong {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-right: 0.25rem;
}

.kanji-block .breakdown-title {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  letter-spacing: 0.5px;
}

.kanji-example-jp {
  font-size: 1.5rem;
  color: var(--color-cta);
  font-weight: 700;
  margin: 0 0 0.25rem 0;
}

.kanji-block .sentence-romaji {
  margin: 0 0 0.25rem 0;
}

.kanji-block .sentence-meaning {
  margin: 0 0 0 0;
}

.vocab-romaji {
  font-family: var(--font-sans);
  color: var(--color-text-muted);
}

@media (max-width: 600px) {
  .vocab-list {
    grid-template-columns: 1fr;
  }
}

.search-form-inline {
  display: flex;
  gap: 10px;
  align-items: center;
  max-width: 420px;
  margin: 0 0 1.75rem 0;
}

.search-form-inline-input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 14px 0 40px;
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--color-text);
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") no-repeat 12px center;
  background-size: 18px 18px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  outline: none;
}

.search-form-inline-input:focus {
  border-color: var(--color-text-muted);
}

.search-form-inline-input::placeholder {
  color: var(--color-text-muted);
}

.search-form-inline-submit {
  flex-shrink: 0;
  height: 44px;
  padding: 0 18px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: var(--color-accent);
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.search-form-inline-submit:hover {
  filter: brightness(0.95);
}

.search-results-section {
  margin-bottom: 1.25rem;
}

.search-results-placeholder {
  font-size: 0.95rem;
  color: var(--color-text-muted);
  margin: 0;
}

.search-results-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0 0;
}

.search-results-list li {
  margin-bottom: 0.5rem;
}

.search-results-list a {
  color: var(--color-cta);
  text-decoration: none;
}

.search-results-list a:hover {
  text-decoration: underline;
}

.lesson-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.lesson-list li {
  margin-bottom: 8px;
}

.lesson-list a {
  color: var(--color-text);
  text-decoration: none;
}

.lesson-list a:hover {
  text-decoration: underline;
}

/* —— Flash cards —— */
.flashcard-section {
  max-width: 420px;
}

.flashcard-deck-switcher {
  display: flex;
  gap: 8px;
  margin-bottom: 1rem;
}

.flashcard-deck-btn {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  color: var(--color-text-muted);
  background: #f5f5f5;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  cursor: pointer;
}

.flashcard-deck-btn:hover {
  color: var(--color-text);
  border-color: var(--color-text-muted);
}

.flashcard-deck-btn.is-active {
  color: #fff;
  background: var(--color-cta);
  border-color: var(--color-cta);
}

.flashcard-deck-title {
  font-family: var(--font-headline);
  font-size: 1.35rem !important;
  font-weight: 800;
  margin: 0 0 0.5rem 0 !important;
  border-left: 4px solid var(--color-cta);
  padding-left: 0.75rem;
}

.flashcard-counter {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin: 0 0 0.35rem 0;
}

.flashcard-hint {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin: 0 0 0.5rem 0;
}

.flashcard-keys {
  display: inline-block;
  margin-left: 0.25rem;
  font-size: 0.8rem;
  opacity: 0.9;
}

.flashcard-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin: 0 0 1rem 0;
  cursor: pointer;
}

.flashcard-toggle[hidden] {
  display: none !important;
}

.flashcard-toggle input {
  width: 1rem;
  height: 1rem;
}

.flashcard-container {
  margin: 0 0 1.25rem 0;
  perspective: 1000px;
  position: relative;
}

.flashcard {
  display: block;
  width: 100%;
  min-height: 260px;
  padding: 2rem 1.5rem;
  font-family: inherit;
  font-size: 1.25rem;
  text-align: center;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  cursor: pointer;
  position: relative;
  transition: box-shadow 0.2s, transform 0.35s ease;
  transform-style: preserve-3d;
}

.flashcard:hover {
  box-shadow: 0 6px 16px rgba(0,0,0,0.1);
  transform: translateY(-3px);
}

.flashcard-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 100%;
  min-height: 220px;
  transform-style: preserve-3d;
}

.flashcard-front,
.flashcard-back {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  min-height: 220px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: transform 0.4s ease;
  transform-style: preserve-3d;
}

.flashcard-front {
  font-family: var(--font-japanese);
  font-weight: 700;
  font-size: 2rem;
  color: var(--color-cta);
  line-height: 1.3;
}

.flashcard-front-romaji {
  display: block;
  font-family: var(--font-sans);
  font-size: 1rem;
  color: #777;
  margin-top: 0.5rem;
  font-weight: 400;
}

.flashcard-front-hint {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: rgba(0,0,0,0.35);
  margin-top: 1rem;
  font-weight: 400;
}

.flashcard-back {
  transform: rotateY(180deg);
  font-size: 1rem;
  color: var(--color-text);
  line-height: 1.5;
}

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

.flashcard.flipped .flashcard-back {
  transform: rotateY(0);
}

.flashcard-star {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 2rem;
  height: 2rem;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
  background: rgba(255,255,255,0.9);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  cursor: pointer;
  color: var(--color-text-muted);
  z-index: 2;
}

.flashcard-star:hover {
  color: var(--color-cta);
  border-color: var(--color-cta);
}

.flashcard-saved-toast {
  position: absolute;
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: #2a7a2a;
  background: rgba(255,255,255,0.98);
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  z-index: 3;
  transition: opacity 0.4s ease;
}

.flashcard-saved-toast-fade {
  opacity: 0;
}

.flashcard-end {
  text-align: center;
  padding: 1rem 0 0;
}

.flashcard-end-message {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 0.35rem 0;
}

.flashcard-end-sub {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--color-text-muted);
  margin: 0 0 1.25rem 0;
}

.flashcard-end-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
}

.flashcard-end-link {
  text-decoration: none;
  display: inline-block;
}

.flashcard-romaji {
  display: block;
  font-family: var(--font-sans);
  font-size: 1.1rem;
  color: var(--color-text-muted);
  margin-bottom: 0.35rem;
}

.flashcard-meaning {
  display: block;
  font-weight: 600;
}

.flashcard-kanji-char {
  font-family: var(--font-japanese);
  font-size: 3.5rem;
  font-weight: 700;
  color: var(--color-cta);
  line-height: 1.2;
}

.flashcard-kanji-primary {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.flashcard-kanji-readings {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--color-text);
  margin-bottom: 0.35rem;
}

.flashcard-kanji-readings strong {
  margin-right: 0.25rem;
}

.flashcard-kanji-ex {
  display: block;
  font-family: var(--font-japanese);
  font-size: 1.1rem;
  color: var(--color-cta);
  font-weight: 600;
  margin-top: 0.75rem;
  margin-bottom: 0.25rem;
}

.flashcard-kanji-ex-meaning {
  display: block;
  font-size: 0.95rem;
  font-style: italic;
  color: var(--color-text);
}

.flashcard-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.flashcard-btn {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  padding: 0.6rem 1.25rem;
  min-height: 44px;
  color: var(--color-cta);
  background: transparent;
  border: 1px solid var(--color-cta);
  border-radius: 6px;
  cursor: pointer;
}

.flashcard-btn:hover {
  background: var(--color-cta);
  color: #fff;
}

.flashcard-btn-shuffle {
  color: var(--color-text-muted);
  border-color: var(--color-border);
}

.flashcard-btn-shuffle:hover {
  background: var(--color-text-muted);
  border-color: var(--color-text-muted);
  color: #fff;
}

.flashcard-progress {
  margin-bottom: 1.25rem;
}

.flashcard-progress-text {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--color-text-muted);
  display: block;
  margin-bottom: 0.35rem;
}

.flashcard-progress-bar {
  height: 6px;
  background: #eee;
  border-radius: 3px;
  overflow: hidden;
}

.flashcard-progress-fill {
  display: block;
  height: 100%;
  background: var(--color-cta);
  border-radius: 3px;
  transition: width 0.25s ease;
}

.flashcard-review-later {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-border);
}

.flashcard-review-title {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text-muted);
  margin: 0 0 0.5rem 0;
}

.flashcard-review-list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.75rem 0;
  font-size: 0.9rem;
}

.flashcard-review-list li {
  margin-bottom: 0;
  padding: 0.5rem 0;
  border-bottom: 1px solid #eee;
  font-weight: 400;
}

.flashcard-review-list li:last-child {
  border-bottom: none;
}

.flashcard-review-list .japanese {
  color: var(--color-cta);
  font-weight: 700;
}

/* —— Responsive: stack sidebar below main on small screens —— */
@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
    padding-top: 20px;
  }

  .layout > .main-column {
    grid-column: 1;
  }

  .sidebar {
    width: 100%;
    position: static;
    display: flex;
    flex-wrap: wrap;
    gap: 24px 32px;
  }

  .sidebar-section {
    margin-bottom: 0;
    min-width: 160px;
  }

  .main-column {
    max-width: 100%;
  }

  .nav-links {
    gap: 16px;
    font-size: 0.8rem;
  }

  .nav-signup {
    padding: 8px 14px;
  }
}

/* —— Navbar: prevent squish/overflow on small screens —— */
@media (max-width: 640px) {
  .navbar {
    height: auto;
    min-height: var(--navbar-height);
  }

  .navbar-inner {
    padding: 0 12px;
    gap: 12px;
  }

  .navbar-search {
    display: none;
  }

  .brand-name {
    font-size: 1.2rem;
  }

  .brand-logo {
    height: 220px;
    width: auto;
  }

  .nav-links {
    gap: 8px 10px;
    font-size: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .nav-links a {
    white-space: nowrap;
  }

  .nav-signup {
    padding: 6px 12px;
  }
}

@media (max-width: 480px) {
  .nav-coming-soon {
    display: none;
  }
}

@media (max-width: 400px) {
  .navbar-inner {
    gap: 8px;
    padding: 0 10px;
  }

  .brand-name {
    font-size: 1rem;
  }

  .brand-logo {
    height: 180px;
    width: auto;
  }

  .nav-links {
    gap: 6px 8px;
    font-size: 0.7rem;
    flex-wrap: wrap;
  }

  .nav-signup {
    padding: 5px 10px;
  }
}

/* —— Footer: back to top + nav links —— */
.site-footer {
  margin-top: 3rem;
  padding: 2rem 1rem 2.5rem;
  border-top: 1px solid rgba(0,0,0,0.08);
  background: #fff;
}

.footer-inner {
  max-width: var(--layout-max);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
}

.footer-logo {
  display: block;
  line-height: 0;
}

.footer-logo img {
  display: block;
  height: 152px;
  width: auto;
  opacity: 0.85;
}

.footer-logo:hover img {
  opacity: 1;
}

.footer-tagline {
  margin: 0;
  font-family: var(--font-headline);
  font-size: 1rem;
  line-height: 1.35;
  color: var(--color-text);
}

.footer-tagline-name {
  display: block;
  font-weight: 700;
}

.footer-tagline-sub {
  display: block;
  font-size: 0.85em;
  font-weight: 400;
  color: var(--color-text-muted);
}

.footer-back {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  color: var(--color-text-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
}

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

.footer-arrow {
  font-size: 1.1em;
  opacity: 0.9;
}

.footer-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

.footer-nav a {
  color: var(--color-text-muted);
  text-decoration: none;
}

.footer-nav a:hover {
  color: var(--color-text);
}

.footer-signup {
  color: var(--color-cta) !important;
  font-weight: 600;
}

.footer-signup:hover {
  color: var(--color-cta-hover) !important;
}

@media (max-width: 480px) {
  .footer-inner {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
}
