:root {
  --bg: #fff;
  --text: #111827;
  --muted: #4b5563;
  --threat: #ef4444;
  --threat-soft: #fee2e2;
  --meaning: #10b981;
  --meaning-soft: #ecfdf5;
  --warning: #f59e0b;
  --warning-soft: #fef3c7;
  --card: #fff;
  --border: #e5e7eb;
  --shadow: 0 10px 30px rgba(17, 24, 39, 0.06);
  --rel-root-bg: #e0ecff;
  --rel-root-text: #2563eb;
  --rel-reinf-bg: #d9f5ff;
  --rel-reinf-text: #0891b2;
  --rel-down-bg: #dff7f2;
  --rel-down-text: #0f766e;
  --rel-contrast-bg: #e6f7ec;
  --rel-contrast-text: #16a34a;
  --rel-exit-bg: #fff2cc;
  --rel-exit-text: #d97706;
  --content-frame-width: 1180px;
  --sidebar-width: 320px;
  --sidebar-gap: 24px;
  --reading-progress-h: 4px;
}
* {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
}
body {
  margin: 0;
  font-family:
    Inter,
    system-ui,
    -apple-system,
    sans-serif;
  font-optical-sizing: auto;
  background: var(--bg);
  color: var(--text);
  transition:
    background 0.6s ease,
    color 0.2s ease;
}

.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--reading-progress-h);
  background: transparent;
  z-index: 999;
  pointer-events: none;
}
.reading-progress > .reading-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--threat), rgba(252, 165, 165, 0.95));
  transform-origin: left center;
  transition: width 0.12s linear;
}
body.meaning .reading-progress > .reading-progress-bar {
  background: linear-gradient(90deg, var(--meaning), rgba(52, 211, 153, 0.9));
}

.sidebar {
  position: fixed;
  top: 64px;
  left: 50%;
  transform: translateX(calc(-1 * var(--content-frame-width) / 2));
  width: var(--sidebar-width);
  padding: 16px;
  border-radius: 16px;
  background: rgba(249, 250, 251, 0.75);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  z-index: 10;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 96px);
}
.sidebar-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
}
.sidebar-sub {
  margin: 6px 0 18px;
  font-size: 16px;
  color: var(--muted);
  line-height: 1.35;
}
.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding-right: 6px;
}
.sidebar-scroll::-webkit-scrollbar {
  width: 10px;
}
.sidebar-scroll::-webkit-scrollbar-thumb {
  background: rgba(17, 24, 39, 0.12);
  border-radius: 999px;
  border: 3px solid rgba(249, 250, 251, 0.75);
}
.sidebar-scroll::-webkit-scrollbar-track {
  background: transparent;
}
#sidebar {
  list-style: none;
  padding: 0;
  margin: 0;
}
#sidebar a {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 12px;
  padding: 10px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--muted);
  position: relative;
  transition: all 0.25s ease;
}
#sidebar a:hover {
  background: rgba(255, 255, 255, 0.55);
  transform: translateX(2px);
}
#sidebar a.active {
  color: var(--text);
  font-weight: 700;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(209, 213, 219, 0.9);
  transition: all 0.35s ease;
}
#sidebar a:hover .dot {
  background: rgba(156, 163, 175, 0.95);
  transform: scale(1.12);
}
#sidebar a.active .dot {
  background: var(--threat);
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15);
}
#sidebar a.exit.unlocked {
  background: var(--meaning-soft);
  color: var(--meaning);
}
#sidebar a.exit.unlocked .dot {
  background: var(--meaning);
  box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.22);
}
.bar {
  position: absolute;
  bottom: 4px;
  left: 28px;
  right: 12px;
  height: 2px;
  background: linear-gradient(90deg, var(--threat), rgba(252, 165, 165, 0.95));
  border-radius: 2px;
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 0.2s linear;
}
body.meaning .bar {
  background: linear-gradient(90deg, var(--meaning), rgba(52, 211, 153, 0.9));
}

.article {
  position: relative;
  left: 50%;
  transform: translateX(calc(-1 * var(--content-frame-width) / 2 + (var(--sidebar-width) + var(--sidebar-gap))));
  padding: 80px 64px;
  max-width: 70ch;
  line-height: 1.7;
  font-size: 19px;
}
h1 {
  font-size: 42px;
  margin: 0 0 14px;
  letter-spacing: -0.02em;
}
h2 {
  font-size: 30px;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
  color: rgba(15, 23, 42, 0.98);
}
.lead {
  font-size: 19px;
  color: rgba(55, 65, 81, 0.95);
  font-weight: 500;
  max-width: 68ch;
}

.article-path {
  position: static;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 14px;
  padding: 0;
  font-size: 14px;
  font-weight: 400;
  background: none;
  border: none;
  border-radius: 0;
  backdrop-filter: none;
}
.article-path a {
  color: #6b7280;
  text-decoration: none;
  font-weight: 400;
}
.article-path a:hover {
  text-decoration: underline;
}
.article-path .sep {
  color: #9ca3af;
}
.article-path .current {
  color: #6b7280;
  font-weight: 400;
}

.meta-bar {
  position: sticky;
  top: 0;
  z-index: 9;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
  margin: 0 0 22px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.meta-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
}
.meta-label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.2px;
}
.meta-value {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
}
.meta-inline {
  margin: 6px 0 22px;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.meta-inline-item strong {
  font-weight: 600;
  color: var(--text);
}
.meta-inline-sep {
  opacity: 0.6;
}

.hero-img {
  width: 100%;
  max-width: 800px;
  height: 400px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(249, 250, 251, 0.9), rgba(255, 255, 255, 0.9));
  box-shadow: var(--shadow);
  overflow: hidden;
  margin: 0 0 22px;
  position: relative;
}
.hero-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.hero-img img[src^='{{'] {
  display: none;
}

.section {
  padding-bottom: 48px;
  scroll-margin-top: 96px;
}
.section:not(.intro) > div {
  margin-left: 16px;
  padding-left: 16px;
  border-left: 2px solid transparent;
}
.section:not(.intro) > div > p:first-child {
  margin-left: -16px;
}
.section p {
  margin: 0 0 18px;
}
.section ul,
.section ol {
  margin: 6px 0 14px 20px;
  padding: 0;
}
.section li {
  margin: 0 0 6px;
}
blockquote {
  margin: 16px 0;
  padding: 14px 16px;
  border-left: 4px solid var(--border);
  background: rgba(255, 255, 255, 0.45);
  border-radius: 12px;
  color: rgba(17, 24, 39, 0.92);
}

.section:not(.intro):not(.exit-section)::after {
  content: '';
  display: block;
  height: 1px;
  max-width: 680px;
  margin: 40px 0 0;
  background: linear-gradient(to right, transparent, rgba(17, 24, 39, 0.08), transparent);
}

.exit-section {
  border: 1px solid rgba(16, 185, 129, 0.22);
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.06), rgba(255, 255, 255, 0) 70%);
  border-radius: 18px;
  padding: 22px 18px 96px;
}
.exit-section > h2 {
  margin-top: 0;
}
.exit-section > div {
  margin-left: 16px;
  padding-left: 16px;
  border-left: 2px solid rgba(16, 185, 129, 0.2);
}

.section.arrive {
  animation: arriveCue 0.7s ease-out;
}
@keyframes arriveCue {
  0% {
    transform: translateY(2px);
  }
  45% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(0);
  }
}
.section.arrive > h2 {
  position: relative;
}
.section.arrive > h2::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -10px;
  height: 2px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.1);
  animation: arriveLine 0.65s ease-out;
}
@keyframes arriveLine {
  0% {
    transform: scaleX(0.18);
    opacity: 0;
  }
  100% {
    transform: scaleX(1);
    opacity: 1;
  }
}

.ref-link {
  font-size: 0.7em;
  color: #6b7280;
  font-weight: 500;
  text-decoration: none;
  vertical-align: baseline;
  white-space: nowrap;
  opacity: 0.9;
}

.dojo-cta {
  position: relative;
  max-width: 800px;
  height: 400px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin: 28px 0 18px;
  isolation: isolate;
}
.dojo-cta-bg {
  position: absolute;
  inset: 0;
  background-image: var(--cta-bg);
  background-size: cover;
  background-position: center;
  filter: blur(18px);
  transform: scale(1.1);
  z-index: 0;
}
.dojo-cta::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
  z-index: 1;
}
.dojo-cta-content {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 36px 42px;
  gap: 32px;
}
.dojo-cta-text {
  max-width: 420px;
  color: #fff;
}
.dojo-cta-text h3 {
  margin: 0 0 16px;
  font-size: 24px;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.dojo-cta-button {
  margin-top: 60px;
  display: inline-block;
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--meaning);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 10px 24px rgba(16, 185, 129, 0.35);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}
.dojo-cta-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(16, 185, 129, 0.45);
}
.dojo-cta-playstore {
  margin-top: 12px;
  background: linear-gradient(135deg, #4285f4, #34a853) !important;
  box-shadow: 0 10px 24px rgba(66, 133, 244, 0.35);
}
.dojo-cta-playstore:hover {
  box-shadow: 0 14px 32px rgba(66, 133, 244, 0.45);
}
.dojo-cta-phone {
  flex: 0 0 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dojo-cta-phone img {
  width: 180px;
  max-height: 320px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 18px 40px rgba(0, 0, 0, 0.45));
}

.related-wrap,
.related-art-wrap,
.legend {
  margin-top: 18px;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}
.related-title,
.related-art-title {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}
.related-grid,
.related-art-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.topic-card,
.art-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.art-card {
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}
.art-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 34px rgba(17, 24, 39, 0.08);
}
.topic-img,
.art-img {
  width: 100%;
  aspect-ratio: 5/6;
  background: linear-gradient(180deg, rgba(249, 250, 251, 0.9), rgba(255, 255, 255, 0.9));
  position: relative;
  overflow: hidden;
}
.topic-img img,
.art-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}
.topic-img img[src^='{{'],
.art-img img[src^='{{'] {
  display: none;
}
.topic-body,
.art-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.art-body {
  gap: 8px;
}
.rel-swatch {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  border: 1px solid rgba(17, 24, 39, 0.1);
  background: rgba(209, 213, 219, 0.6);
}
.topic-title {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.35;
}
.art-name {
  margin: 0;
  font-size: 14px;
  font-weight: 900;
  color: var(--text);
  line-height: 1.35;
}
.art-desc {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
}

.legend h4 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 900;
}
.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.legend-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  border: 1px solid transparent;
}

.callout {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  margin: 16px 0;
  background: var(--card);
}
.callout.meaning {
  border-color: rgba(16, 185, 129, 0.35);
  background: var(--meaning-soft);
}

.hl-threat,
.hl-meaning,
.hl-warning {
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
  padding: 0 3px;
  border-radius: 6px;
}
.hl-threat {
  background: var(--threat-soft);
}
.hl-meaning {
  background: var(--meaning-soft);
}
.hl-warning {
  background: var(--warning-soft);
}
.hl-animate {
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity 0.6s ease,
    transform 0.6s ease;
  transition-delay: 0.08s;
  will-change: opacity, transform;
}
.hl-animate.visible {
  opacity: 1;
  transform: translateY(0);
}

.supporting-references {
  margin-top: 28px;
  font-size: 12px;
  color: var(--muted);
}
.reference-list {
  padding-left: 18px;
}
.reference-list li {
  margin-bottom: 6px;
  line-height: 1.5;
}
.reference-list a {
  font-weight: 600;
  font-size: 12px;
}

.theory-to-practice {
  max-width: 800px;
  margin: 36px 0 18px;
  padding: 14px 20px;
  border-radius: 999px;
  border: 1px solid rgba(16, 185, 129, 0.25);
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.08), rgba(255, 255, 255, 0.85));
  text-align: center;
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.12);
}
.theory-to-practice p {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #065f46;
  letter-spacing: 0.1px;
}

.topic-card-link,
.art-card-link {
  display: block;
  color: inherit;
  text-decoration: none;
}
.topic-card-link:focus-visible,
.art-card-link:focus-visible,
.dojo-cta-button:focus-visible,
#sidebar a:focus-visible {
  outline: 3px solid rgba(59, 130, 246, 0.55);
  outline-offset: 4px;
  border-radius: 16px;
}

@media (max-width: 980px) {
  .sidebar {
    display: none;
  }
  .article {
    padding: 24px 16px 80px;
    left: 0;
    transform: none;
    max-width: 70ch;
  }
  .meta-bar {
    grid-template-columns: 1fr;
  }
  .hero-img {
    height: 220px;
  }
  .dojo-cta {
    height: auto;
  }
  .dojo-cta-content {
    flex-direction: column;
    text-align: center;
    padding: 28px 22px;
  }
  .dojo-cta-phone {
    flex: 0 0 auto;
    margin-top: 16px;
  }
  .dojo-cta-phone img {
    width: 150px;
    max-height: 260px;
  }
  .related-grid,
  .related-art-grid {
    grid-template-columns: 1fr;
  }
  .theory-to-practice {
    margin: 28px 0 16px;
    padding: 12px 16px;
  }
  .theory-to-practice p {
    font-size: 13.5px;
  }
}

@media print {
  .sidebar,
  .dojo-cta,
  .related-wrap,
  .related-art-wrap,
  .legend,
  .reading-progress {
    display: none !important;
  }
  body {
    background: #fff !important;
    color: #000 !important;
  }
  .article {
    left: 0 !important;
    transform: none !important;
    padding: 0 !important;
    max-width: 100% !important;
  }
  .meta-bar {
    position: static !important;
    box-shadow: none !important;
    background: #fff !important;
  }
  a {
    color: #000 !important;
    text-decoration: underline !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  #sidebar a,
  .dot,
  .bar,
  .dojo-cta-button,
  .reading-progress > .reading-progress-bar {
    transition: none !important;
  }
  .hl-animate {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  .section.arrive {
    animation: none !important;
  }
  .section.arrive > h2::after {
    animation: none !important;
  }
}
