/* NIICHI — premium visual layer for the main app (index.html).
   Loaded after the page's own <style> blocks. Visual only: it retunes the design tokens and
   polishes shared components (header, menus, buttons, cards, inputs, bottom tabs, homepage).
   No layout logic, routes or class names change. Delete the <link> to roll back. */

/* ── 1. Tokens ─────────────────────────────────────────────────────────────
   One brand red across the app (the logo red), a deeper ink and navy, softer warm
   neutrals, larger radii and layered, low-contrast shadows. The homepage keeps its own
   :root:has(.nh-home) tokens, which win on specificity. */
:root {
  --color-bg: #FAF9F7;
  --color-surface: #FFFFFF;
  --color-text: #14161B;
  --color-muted: #5C6069;
  --color-neutral-700: #5C6069;
  --color-neutral-400: #D6D3CD;
  --color-neutral-300: #E8E5E0;
  --color-neutral-200: #F1EFEB;
  --color-neutral-100: #F7F6F3;
  --color-divider: #ECE9E4;
  --color-border: #E5E2DC;
  --color-accent: #DC1F2E;
  --color-accent-100: #FDEEEF;
  --color-accent-200: #FAD8DB;
  --color-accent-300: #F2B3B9;
  --color-accent-400: #E5646F;
  --color-accent-500: #DC1F2E;
  --color-accent-600: #BF1926;
  --color-accent-700: #A1141F;
  --color-accent-2: #22324C;
  --color-indigo: #22324C;
  --color-indigo-100: #EDF0F5;
  --color-success: #2E7650;
  --color-success-100: #E7F2EB;
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --shadow-sm: 0 1px 2px rgba(17, 19, 26, 0.05), 0 1px 1px rgba(17, 19, 26, 0.02);
  --shadow-md: 0 1px 2px rgba(17, 19, 26, 0.04), 0 8px 20px -6px rgba(17, 19, 26, 0.10);
  --shadow-lg: 0 2px 6px rgba(17, 19, 26, 0.04), 0 24px 48px -16px rgba(17, 19, 26, 0.22);
  --shadow-card: 0 0 0 1px rgba(17, 19, 26, 0.015), 0 1px 2px rgba(17, 19, 26, 0.04), 0 14px 34px -18px rgba(17, 19, 26, 0.16);
  --font-heading: 'Inter', 'Anek Bangla', 'Noto Sans Bengali', system-ui, -apple-system, sans-serif;
  --font-body: 'Inter', 'Noto Sans Bengali', system-ui, -apple-system, sans-serif;
  --font-jp: 'Noto Sans JP', 'Inter', 'Noto Sans Bengali', sans-serif;
  --pm-ease: cubic-bezier(.2, .7, .2, 1);
  --pm-ring: 0 0 0 4px rgba(220, 31, 46, 0.16);
  --pm-glass: rgba(250, 249, 247, 0.78);
}
:root:has(.nh-home) { --pm-glass: rgba(255, 255, 255, 0.8); --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.05), 0 24px 48px -16px rgba(0, 0, 0, 0.25); }

/* ── 2. Base ───────────────────────────────────────────────────────────── */
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }
body { background: var(--color-bg); font-feature-settings: "cv11", "ss01"; }
::selection { background: var(--color-accent-200); color: var(--color-text); }
h1, h2, h3, h4 { letter-spacing: -0.022em; text-wrap: balance; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--color-accent); outline-offset: 2px; box-shadow: var(--pm-ring);
}
a { text-underline-offset: 3px; text-decoration-thickness: 1px; }

/* ── 3. Buttons ────────────────────────────────────────────────────────── */
.btn {
  border-radius: var(--radius-sm); font-weight: 500; letter-spacing: -0.005em;
  transition: background-color 180ms var(--pm-ease), border-color 180ms var(--pm-ease), color 180ms var(--pm-ease),
              box-shadow 220ms var(--pm-ease), transform 220ms var(--pm-ease);
}
.btn-primary {
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0) 60%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 1px 2px rgba(120, 10, 18, 0.22), 0 6px 16px -8px rgba(220, 31, 46, 0.55);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 2px 4px rgba(120, 10, 18, 0.20), 0 12px 24px -10px rgba(220, 31, 46, 0.6);
}
.btn-secondary { border-color: var(--color-border); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--color-surface); border-color: var(--color-neutral-400); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn-ghost:hover { background: rgba(17, 19, 26, 0.05); }
.btn:active, .btn-primary:active, .btn-secondary:active { transform: translateY(0) scale(0.985); }
.btn[disabled], .btn:disabled { box-shadow: none; transform: none; }

/* ── 4. Fields and segmented controls ──────────────────────────────────── */
.input { border-color: var(--color-border); box-shadow: inset 0 1px 2px rgba(17, 19, 26, 0.04); transition: border-color 160ms ease, box-shadow 160ms ease; }
.input:hover { border-color: var(--color-neutral-400); }
.input:focus, .input:focus-visible { outline: none; border-color: var(--color-accent); box-shadow: var(--pm-ring); }
.seg { border-radius: 14px; background: var(--color-neutral-200); border-color: transparent; box-shadow: inset 0 1px 2px rgba(17, 19, 26, 0.05); }
.seg-opt { border-radius: 10px; transition: background-color 180ms var(--pm-ease), color 180ms var(--pm-ease), box-shadow 180ms var(--pm-ease); }

/* ── 5. Sticky header (frosted glass) ──────────────────────────────────── */
header.no-print[style*="sticky"] {
  background: var(--pm-glass) !important;
  -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
  border-bottom-color: rgba(17, 19, 26, 0.07) !important;
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  header.no-print[style*="sticky"] { background: var(--color-bg) !important; }
}
header.no-print .desk-nav .btn-ghost { border-radius: 999px; }

/* Drop-down menus in the header (levels, mock tests): soft card instead of a hard black box */
header [role="menu"] {
  border: 1px solid var(--color-border) !important; border-radius: 18px; overflow: hidden;
  box-shadow: var(--shadow-lg) !important; background: var(--color-surface) !important;
  animation: pm-pop 180ms var(--pm-ease);
}
header [role="menu"] > span { border-color: var(--color-divider) !important; border-right-width: 1px !important; }
header [role="menu"] [role="menuitem"] { border-top-width: 1px !important; border-top-color: var(--color-divider) !important; transition: background-color 140ms ease; }
@keyframes pm-pop { from { opacity: 0; transform: translateY(-6px) scale(0.985); } }

/* Account pop-over and dialogs */
.acct-pop { border-radius: 18px !important; box-shadow: var(--shadow-lg) !important; }
.dialog-backdrop { background: rgba(14, 16, 22, 0.5) !important; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.dialog-backdrop > * { border-radius: 22px; box-shadow: var(--shadow-lg); animation: pm-pop 200ms var(--pm-ease); }

/* Side drawer (phone / tablet menu) */
[role="dialog"][aria-label="Menu"] > nav { border-right: 1px solid var(--color-border) !important; box-shadow: var(--shadow-lg); animation: pm-slide 240ms var(--pm-ease); }
[role="dialog"][aria-label="Menu"] > nav > div:first-child { border-bottom: 1px solid var(--color-divider) !important; }
@keyframes pm-slide { from { transform: translateX(-24px); opacity: 0.4; } }

/* ── 6. Bottom tab bar (phone) ─────────────────────────────────────────── */
.bottom-nav {
  background: var(--pm-glass) !important;
  -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
  border-top-color: rgba(17, 19, 26, 0.07) !important;
  box-shadow: 0 -10px 30px -18px rgba(17, 19, 26, 0.25) !important;
}
.bottom-nav > button { position: relative; transition: color 160ms ease; }
.bottom-nav > button[aria-current="true"]::before {
  content: ""; position: absolute; top: 0; left: 50%; width: 28px; height: 3px; margin-left: -14px;
  border-radius: 0 0 3px 3px; background: var(--color-accent);
}
.bottom-nav > button:active { transform: scale(0.96); }

/* ── 7. Cards and surfaces (inline-styled in the app; matched on their tokens) ── */
[style*="box-shadow: var(--shadow-card)"], [style*="box-shadow: var(--shadow-sm)"] { border-color: var(--color-border); }
button[style*="border: 1px solid var(--color-border)"][style*="border-radius: 16px"],
a[style*="border: 1px solid var(--color-border)"][style*="border-radius: 16px"],
button[style*="border: 1px solid var(--color-border)"][style*="border-radius: 14px"],
button[style*="border: 1px solid var(--color-border)"][style*="border-radius: 12px"] {
  transition: transform 220ms var(--pm-ease), box-shadow 220ms var(--pm-ease), border-color 180ms ease, background-color 180ms ease;
}
@media (hover: hover) {
  button[style*="border: 1px solid var(--color-border)"][style*="border-radius: 16px"]:not(:disabled):hover,
  a[style*="border: 1px solid var(--color-border)"][style*="border-radius: 16px"]:hover,
  button[style*="border: 1px solid var(--color-border)"][style*="border-radius: 14px"]:not(:disabled):hover {
    transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--color-neutral-400) !important;
  }
}
progress, [role="progressbar"] { border-radius: 999px; overflow: hidden; }
/* Muted grey notes inside a selected (red) item, e.g. the active level in the header menu */
[style*="background: var(--color-accent);"] [style*="color: var(--color-neutral-700)"],
[style*="background: var(--color-accent);"] [style*="color: var(--color-muted)"] { color: rgba(255, 255, 255, 0.84) !important; }
/* Language toggle on the dark lesson header bars: the unselected option was dark ink on navy */
[style*="border: 1px solid rgba(255, 255, 255, 0.4)"] > button[style*="background: transparent"] { color: rgba(255, 255, 255, 0.88) !important; }

/* ── 8. Homepage (.nh-home) — keeps the black / white / red editorial look, softened ── */
.nh-home { --nh-tint: #F4F4F2; --nh-line: #E8E8E6; --nh-ink: #0B0B0C; }
.nh-home h1, .nh-home h2, .nh-home h3 { letter-spacing: -0.02em; }
.nh-h1 { letter-spacing: -0.03em; }
.nh-lead, .nh-sub { color: #2B2B2E; }

.nh-btn {
  border-radius: 14px; border-width: 1.5px; background: var(--nh-ink); border-color: var(--nh-ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18), 0 10px 22px -12px rgba(0, 0, 0, 0.55);
  transition: background-color 180ms var(--pm-ease), border-color 180ms var(--pm-ease), color 180ms var(--pm-ease),
              box-shadow 240ms var(--pm-ease), transform 240ms var(--pm-ease);
}
.nh-btn:hover { transform: translateY(-1px); box-shadow: 0 2px 4px rgba(150, 10, 20, 0.2), 0 14px 28px -12px rgba(220, 31, 46, 0.6); }
.nh-btn:active { transform: translateY(0) scale(0.985); }
.nh-btn-line { background: #fff; border-color: rgba(0, 0, 0, 0.85); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06); }
.nh-btn-line:hover { background: var(--nh-ink); border-color: var(--nh-ink); box-shadow: 0 14px 28px -14px rgba(0, 0, 0, 0.5); }

/* Live kanji card */
.nh-kcard {
  border-radius: 28px; background: radial-gradient(120% 90% at 50% 20%, #FFFFFF 0%, #F4F3F1 55%, #ECEBE8 100%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05), 0 30px 60px -36px rgba(0, 0, 0, 0.35);
  transition: box-shadow 300ms var(--pm-ease), transform 300ms var(--pm-ease);
}
.nh-kcard::after { height: 8px; }
@media (hover: hover) { .nh-kcard:hover { transform: translateY(-2px); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06), 0 40px 70px -36px rgba(0, 0, 0, 0.42); } }
.nh-kread span { border-radius: 999px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06); }
.nh-ktap { opacity: 0.6; }
.nh-sq { border-radius: 12px; border-width: 1.5px; transition: background-color 160ms ease, color 160ms ease, transform 160ms ease; }
.nh-sq:active { transform: scale(0.95); }

/* Level and contents panel */
.nh-box { border-radius: 20px; background: var(--nh-tint); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04); }
.nh-lv { border-radius: 10px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); }
.nh-lv.on { box-shadow: 0 6px 14px -8px rgba(0, 0, 0, 0.6); }

/* Section illustrations */
.nh-frame { border-radius: 28px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04); }
.nh-rows { border-top-width: 1.5px; }
.nh-row i { background: var(--nh-red); }

/* "What makes NIICHI different" tiles: separate rounded cards instead of a ruled grid */
.nh-grid { border: 0; gap: 16px; }
.nh-tile {
  border: 1px solid var(--nh-line); border-radius: 22px; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: background-color 240ms var(--pm-ease), color 240ms var(--pm-ease), border-color 240ms var(--pm-ease),
              box-shadow 300ms var(--pm-ease), transform 300ms var(--pm-ease);
}
.nh-tile .nh-glyph { color: #F0F0EE; }
.nh-tile:hover { border-color: var(--nh-red); transform: translateY(-3px); box-shadow: 0 26px 50px -24px rgba(220, 31, 46, 0.55); }
.nh-tile.new::after { border-radius: 999px; padding: 2px 10px; }

/* 30 minutes a day */
.nh-step { border-top-width: 3px; }

/* Your path */
.nh-path { border-top-width: 1.5px; }
.nh-prow { border-bottom-color: var(--nh-line); border-radius: 0; }
.nh-prow.now { border-radius: 18px; border-bottom-color: transparent; box-shadow: 0 18px 40px -22px rgba(0, 0, 0, 0.6); }

/* Closing call to action: a dark panel */
.nh-end {
  border: 0; border-radius: 28px; padding: clamp(28px, 5vw, 56px);
  background: radial-gradient(120% 140% at 100% 0%, #2A0A0E 0%, #0B0B0C 55%);
  box-shadow: 0 40px 80px -40px rgba(0, 0, 0, 0.6);
}
.nh-end .nh-h2, .nh-home .nh-end h2 { color: #fff; }
.nh-end .nh-btn { background: var(--nh-red); border-color: var(--nh-red); color: #fff; }
.nh-end .nh-btn:hover { background: #fff; border-color: #fff; color: var(--nh-ink); }

/* ── 9. Gentle scroll-in for homepage sections (only where supported) ── */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .nh-sec, .nh-end { animation: pm-rise linear both; animation-timeline: view(); animation-range: entry 0% entry 35%; }
  }
}
@keyframes pm-rise { from { opacity: 0.001; transform: translateY(24px); } }

/* ── 10. Small screens ─────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .nh-kcard, .nh-frame { border-radius: 22px; }
  .nh-grid { gap: 12px; }
  .nh-end { border-radius: 22px; }
}

/* ── 11. Reduced motion: no lifts, pops or slides ─────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .btn:hover, .btn-primary:hover, .btn-secondary:hover, .nh-btn:hover, .nh-tile:hover, .nh-kcard:hover,
  button[style*="border-radius: 16px"]:hover, a[style*="border-radius: 16px"]:hover, button[style*="border-radius: 14px"]:hover { transform: none !important; }
  header [role="menu"], .dialog-backdrop > *, [role="dialog"][aria-label="Menu"] > nav { animation: none !important; }
}

/* ── 12. Print stays plain ─────────────────────────────────────────────── */
@media print {
  header.no-print, .bottom-nav { -webkit-backdrop-filter: none; backdrop-filter: none; }
  .btn-primary, .btn-secondary { box-shadow: none; background-image: none; }
}
