:root {
  --ink: #18333d;
  --ink-soft: #50676f;
  --indigo: #194b5b;
  --indigo-deep: #103742;
  --mineral: #2f766d;
  --vermilion: #d94a32;
  --vermilion-dark: #b93825;
  --paper: #edf3f4;
  --paper-cold: #f8fbfb;
  --paper-blue: #dfeaec;
  --line: #cbd9dc;
  --white: #ffffff;
  --shadow: 0 24px 60px rgba(16, 55, 66, 0.11);
  --text-primary: var(--ink);
  --text-muted: var(--ink-soft);
  --text-heading: var(--indigo-deep);
  --text-accent: var(--indigo);
  --surface-page: var(--paper);
  --surface-card: var(--white);
  --surface-soft: var(--paper-cold);
  --surface-tinted: var(--paper-blue);
  --surface-brand: var(--indigo);
  --surface-brand-strong: var(--indigo-deep);
  --on-brand: var(--white);
  --font-display: "Yu Mincho", "Hiragino Mincho ProN", "BIZ UDPMincho", serif;
  --font-body: "Yu Gothic UI", "Yu Gothic", "Hiragino Kaku Gothic ProN", sans-serif;
}

* {
  box-sizing: border-box;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--text-primary);
  background:
    radial-gradient(circle at 84% 12%, rgba(47, 118, 109, 0.1), transparent 25rem),
    var(--paper);
  font-family: var(--font-body);
  line-height: 1.7;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(217, 74, 50, 0.55);
  outline-offset: 3px;
}

.answer-feedback h2:focus,
.mock-review-feedback h2:focus {
  outline: 3px solid rgba(217, 74, 50, 0.55);
  outline-offset: 4px;
}

.kanji-reading {
  border-radius: 0.12em;
  text-decoration: underline dotted rgba(47, 118, 109, 0.48) 1px;
  text-underline-offset: 0.18em;
  cursor: help;
  transition: color 120ms ease, background 120ms ease, text-decoration-color 120ms ease;
}

.furigana-text {
  display: inline;
}

.kanji-reading:hover,
.kanji-reading[data-reading-open="true"] {
  color: var(--vermilion-dark);
  background: rgba(217, 74, 50, 0.08);
  text-decoration-color: var(--vermilion);
}

.reading-popover {
  position: fixed;
  z-index: 1000;
  display: grid;
  min-width: 132px;
  max-width: calc(100vw - 1.5rem);
  grid-template-columns: auto auto;
  align-items: baseline;
  gap: 0.1rem 0.65rem;
  padding: 0.7rem 0.85rem;
  color: var(--on-brand);
  background: var(--surface-brand-strong);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 0.7rem;
  box-shadow: 0 12px 28px rgba(16, 55, 66, 0.24);
  pointer-events: none;
}

.reading-popover::after {
  position: absolute;
  inset: auto 50% -5px auto;
  width: 10px;
  height: 10px;
  background: var(--surface-brand-strong);
  content: "";
  transform: translateX(50%) rotate(45deg);
}

.reading-popover[data-placement="bottom"]::after {
  inset: -5px 50% auto auto;
}

.reading-popover > span {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.58rem;
  font-weight: 800;
}

.reading-popover > strong {
  grid-row: span 2;
  color: var(--on-brand);
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  white-space: nowrap;
}

.reading-popover > small {
  color: #9dc6c2;
  font-size: 0.48rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  padding: 0.65rem 1rem;
  color: var(--on-brand);
  background: var(--surface-brand-strong);
  border-radius: 0.5rem;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  min-height: 100vh;
}

.side-nav {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  width: 104px;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 0.75rem;
  background: var(--surface-brand-strong);
  box-shadow: 12px 0 36px rgba(16, 55, 66, 0.09);
}

.brand-mark {
  position: relative;
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  padding: 0;
  color: var(--on-brand);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  cursor: pointer;
}

.brand-mark::before,
.brand-mark::after {
  position: absolute;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  content: "";
}

.brand-mark::after {
  width: 54px;
  height: 54px;
  border-style: dashed;
}

.brand-mark__kanji {
  z-index: 1;
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1;
}

.brand-mark__edition {
  position: absolute;
  right: -0.4rem;
  bottom: -0.25rem;
  z-index: 2;
  padding: 0.05rem 0.32rem;
  color: var(--on-brand);
  background: var(--vermilion);
  border-radius: 0.25rem;
  font-size: 0.62rem;
  font-weight: 800;
}

.nav-list {
  display: flex;
  width: 100%;
  flex: 1;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 3rem;
}

.nav-item {
  display: flex;
  width: 100%;
  min-height: 66px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  padding: 0.45rem;
  color: rgba(255, 255, 255, 0.58);
  background: transparent;
  border: 0;
  border-radius: 0.8rem;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease;
}

.nav-item svg {
  width: 23px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.nav-item span {
  font-size: 0.7rem;
  font-weight: 700;
}

.nav-item:hover,
.nav-item.is-active {
  color: var(--on-brand);
  background: rgba(255, 255, 255, 0.1);
}

.nav-item--settings {
  margin-top: auto;
}

.main-content {
  min-height: 100vh;
  margin-left: 104px;
  padding: 1.6rem clamp(1.25rem, 4vw, 4.5rem) 4rem;
}

.topbar {
  display: flex;
  max-width: 1320px;
  align-items: center;
  justify-content: space-between;
  margin: 0 auto 1.6rem;
}

.topbar p {
  margin: 0;
}

.topbar__edition {
  color: var(--text-accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.topbar__date {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.topbar-tools {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.reading-guide {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  color: var(--text-muted);
  font-size: 0.64rem;
  font-weight: 800;
}

.reading-guide__icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  color: var(--vermilion-dark);
  background: rgba(217, 74, 50, 0.08);
  border: 1px solid rgba(217, 74, 50, 0.22);
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 0.72rem;
}

.language-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.9rem;
  color: var(--text-heading);
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
}

.language-toggle__dot {
  width: 8px;
  height: 8px;
  background: var(--mineral);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(47, 118, 109, 0.12);
}

.language-toggle[aria-pressed="false"] .language-toggle__dot {
  background: var(--ink-soft);
  box-shadow: none;
}

.view {
  max-width: 1320px;
  margin: 0 auto;
  animation: view-in 360ms ease both;
}

.view[hidden] {
  display: none;
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
