/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Variables */
:root {
  --primary: #8B7EC8;
  --primary-light: #A99BD9;
  --primary-dark: #6E60B0;
  --bg-base: #F9F8F6;
  --bg-warm: #F3F1EE;
  --bg-lavender: #E8E4F0;
  --accent-green: #9AAF8E;
  --accent-gold: #C4AA7C;
  --text-dark: #2C2C2E;
  --text-soft: #48484A;
  --text-gray: #8E8E93;
  --white: #FFFFFF;
  --border-light: #E5E5E7;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-base: #1A1A1E;
    --bg-warm: #2C2C32;
    --bg-lavender: #3A3345;
    --text-dark: #EBEBF0;
    --text-soft: #D1D1D6;
    --text-gray: #7E7E8F;
    --white: #1A1A1E;
    --border-light: #424245;
  }
}

/* Body */
body {
  font-family: 'Pretendard Variable', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text-dark);
  background: var(--bg-base);
  line-height: 1.6;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Container & Layout */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 24px;
}

header {
  padding: 40px 0 32px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 40px;
}

main {
  min-height: 60vh;
  padding-bottom: 40px;
}

footer,
footer.footer {
  background: var(--text-dark);
  margin-top: 60px;
  padding: 48px 0;
  color: rgba(255, 255, 255, 0.6);
}

.footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.footer-brand {
  font-size: 16px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
}

.footer-links {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  justify-content: center;
}

.footer-links a {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.65);
  transition: color 0.2s ease;
  text-decoration: none;
}

.footer-links a:hover {
  color: rgba(255, 255, 255, 0.9);
}

.footer-legal {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.42);
  line-height: 1.7;
  text-align: center;
  letter-spacing: 0.01em;
  max-width: 720px;
  padding: 0 16px;
}

.footer-legal a {
  color: rgba(255, 255, 255, 0.65);
  text-decoration: none;
  transition: color 0.2s ease;
}

.footer-legal a:hover {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: underline;
}

.footer-copy {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.60);
}

.footer-copy a {
  color: rgba(255, 255, 255, 0.70);
  transition: color 0.2s ease;
  text-decoration: none;
}

.footer-copy a:hover {
  color: rgba(255, 255, 255, 0.75);
}

/* Policy Navigation Bar (Top) */
.policy-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(44, 44, 46, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 10px 0;
}

.policy-nav__inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.policy-nav__brand {
  font-size: 15px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.95);
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.policy-nav__brand img {
  width: 24px;
  height: 24px;
  border-radius: 6px;
}

.policy-nav__links {
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
}

.policy-nav__links a {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  transition: color 0.2s ease;
  text-decoration: none;
}

.policy-nav__links a:hover {
  color: rgba(255, 255, 255, 1);
}

.policy-nav__links a.policy-nav__highlight {
  color: var(--primary-light);
  font-weight: 600;
}

.policy-nav__links a.policy-nav__highlight:hover {
  color: var(--white);
}

@media (max-width: 640px) {
  .policy-nav__inner {
    padding: 0 16px;
  }
  .policy-nav__brand span {
    display: none;
  }
  .policy-nav__links {
    gap: 12px;
  }
  .policy-nav__links a {
    font-size: 11px;
  }
}

/* Page wrapper with top padding for fixed nav */
.page-wrapper {
  padding-top: 60px;
  min-height: 100vh;
}

/* Guide Navigation (Content nav) */
nav.guide-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  overflow-x: visible;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 24px;
  padding-bottom: 8px;
  max-width: 100%;
}

nav.guide-nav::-webkit-scrollbar {
  height: 4px;
}

nav.guide-nav::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 2px;
}

nav.guide-nav a,
.nav-link {
  display: inline-block;
  padding: 6px 12px;
  background: var(--bg-warm);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  color: var(--text-dark);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s ease;
  word-break: break-word;
  flex-shrink: 0;
}

nav.guide-nav a:hover,
.nav-link:hover {
  background: var(--bg-lavender);
  border-color: var(--primary);
  color: var(--primary);
}

nav.guide-nav a.active,
.nav-link.active {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

/* Headings */
h1 {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 8px;
  line-height: 1.3;
}

h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-dark);
  margin-top: 48px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--primary);
}

h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-dark);
  margin-top: 28px;
  margin-bottom: 12px;
}

/* Typography */
p {
  margin-bottom: 16px;
  line-height: 1.8;
  color: var(--text-soft);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

strong {
  color: var(--text-dark);
  font-weight: 600;
}

em {
  font-style: italic;
  color: var(--text-soft);
}

/* Lists */
ul, ol {
  margin-bottom: 16px;
  padding-left: 24px;
  color: var(--text-soft);
}

li {
  margin-bottom: 8px;
  line-height: 1.8;
}

/* Figures & Images */
figure {
  margin: 32px 0;
  padding: 20px;
  background: var(--bg-warm);
  border-radius: 12px;
  overflow: hidden;
}

figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  margin-bottom: 12px;
}

figcaption {
  font-size: 13px;
  color: var(--text-gray);
  line-height: 1.6;
  text-align: center;
}

/* Desktop: single figures max 340px, grid figures 100% */
@media (min-width: 640px) {
  figure img {
    max-width: 340px;
    display: block;
    margin: 0 auto;
  }

  .shots figure img {
    max-width: 100%;
  }
}

/* Responsive figures grid */
@media (min-width: 768px) {
  .figures-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
  }

  .figures-grid figure {
    margin: 0;
  }
}

@media (max-width: 320px) {
  .figures-grid {
    grid-template-columns: 1fr;
  }
}

/* Code blocks */
code {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  background: var(--bg-warm);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--primary);
}

pre {
  background: var(--bg-warm);
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 16px;
  border: 1px solid var(--border-light);
}

pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  color: inherit;
  font-size: 12px;
  line-height: 1.5;
}

/* Blockquote */
blockquote {
  margin: 24px 0;
  padding: 16px 20px;
  border-left: 4px solid var(--primary);
  background: var(--bg-lavender);
  border-radius: 4px;
  font-style: italic;
  color: var(--text-soft);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 13px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  overflow: hidden;
}

table.engine-table {
  margin: 32px 0;
}

th, td {
  border: 1px solid var(--border-light);
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--bg-lavender);
  font-weight: 600;
  color: var(--text-dark);
}

td {
  color: var(--text-soft);
}

tr:nth-child(even) td {
  background: var(--bg-warm);
}

/* Table caption */
table caption {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
  text-align: left;
  padding: 8px 12px;
  background: var(--bg-lavender);
}

/* Table scrolling on mobile */
@media (max-width: 640px) {
  .table-scroll {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    margin: 24px -16px;
  }

  table {
    min-width: 100%;
    margin: 0;
    border-radius: 0;
  }

  th, td {
    padding: 8px;
    font-size: 12px;
    white-space: nowrap;
  }
}

/* Buttons & CTA */
.btn, button {
  display: inline-block;
  padding: 12px 24px;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn:hover, button:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(139, 126, 200, 0.2);
}

.btn-secondary {
  background: var(--bg-warm);
  color: var(--text-dark);
  border: 1px solid var(--border-light);
}

.btn-secondary:hover {
  background: var(--bg-lavender);
  border-color: var(--primary);
}

/* Metadata */
.metadata {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-gray);
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}

.metadata span {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Breadcrumbs */
.breadcrumb {
  font-size: 12px;
  color: var(--text-gray);
  margin-bottom: 24px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.breadcrumb a {
  color: var(--primary);
}

.breadcrumb a:hover {
  color: var(--primary-dark);
}

/* Term definitions */
.term-short {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 8px;
  margin-top: -8px;
}

.term-body {
  color: var(--text-soft);
  line-height: 1.8;
}

.term-body p {
  margin-bottom: 12px;
  font-size: 14px;
}

.term-body p:last-child {
  margin-bottom: 0;
}

/* Previous/Next Navigation */
.nav-articles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 60px;
  padding-top: 40px;
  border-top: 1px solid var(--border-light);
}

.nav-prev,
.nav-next {
  display: block;
  padding: 16px;
  background: var(--bg-warm);
  border-radius: 8px;
  border: 1px solid var(--border-light);
  transition: all 0.2s ease;
  text-decoration: none;
  color: var(--primary);
  font-weight: 600;
  font-size: 14px;
}

.nav-prev:hover,
.nav-next:hover {
  background: var(--bg-lavender);
  border-color: var(--primary);
  transform: translateX(-4px);
}

.nav-next:hover {
  transform: translateX(4px);
}

/* Hub sections */
.hub-sections {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin-top: 32px;
  margin-bottom: 32px;
}

.hub-section {
  padding: 24px;
  background: var(--bg-warm);
  border-radius: 8px;
  border: 1px solid var(--border-light);
  transition: all 0.2s ease;
}

.hub-section:hover {
  background: var(--bg-lavender);
  border-color: var(--primary);
  transform: translateY(-2px);
}

.hub-section h2 {
  margin-top: 0;
  border-bottom: none;
  padding-bottom: 0;
}

.hub-section a {
  color: inherit;
  text-decoration: none;
  display: block;
}

.hub-section a:hover {
  color: var(--primary);
}

/* CTA Section */
.cta-section {
  background: var(--bg-lavender);
  padding: 60px 24px;
  margin-top: 80px;
  margin-left: calc(-50vw + 50%);
  margin-right: calc(-50vw + 50%);
}

.cta-box {
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
}

.cta-box h2 {
  border-bottom: none;
  padding-bottom: 0;
  margin-top: 0;
  font-size: 24px;
  margin-bottom: 16px;
}

.cta-box p {
  font-size: 16px;
  margin-bottom: 24px;
  color: var(--text-soft);
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.cta-button {
  display: inline-block;
  padding: 14px 32px;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.cta-button:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(139, 126, 200, 0.3);
}

/* Utilities */
.text-center {
  text-align: center;
}

.mt-24 {
  margin-top: 24px;
}

.mt-40 {
  margin-top: 40px;
}

.mb-24 {
  margin-bottom: 24px;
}

.mb-40 {
  margin-bottom: 40px;
}

.text-gray {
  color: var(--text-gray);
}

.text-soft {
  color: var(--text-soft);
}

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

/* Print styles */
@media print {
  nav, footer, .nav-articles {
    display: none;
  }

  body {
    background: white;
  }

  a {
    text-decoration: underline;
  }
}

/* Mobile optimization */
@media (max-width: 640px) {
  .container {
    padding: 0 16px;
  }

  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 18px;
    margin-top: 32px;
  }

  h3 {
    font-size: 15px;
    margin-top: 20px;
  }

  nav.guide-nav {
    margin-bottom: 16px;
  }

  nav.guide-nav a,
  .nav-link {
    padding: 6px 12px;
    font-size: 12px;
  }

  .nav-articles {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .hub-sections {
    gap: 16px;
  }

  table {
    font-size: 12px;
  }

  th, td {
    padding: 8px;
  }

  .figures-grid {
    grid-template-columns: 1fr;
  }

  .cta-section {
    padding: 40px 16px;
    margin-top: 60px;
  }

  .cta-box h2 {
    font-size: 20px;
  }

  .cta-box p {
    font-size: 14px;
  }

  .cta-button {
    padding: 12px 24px;
    font-size: 14px;
  }
}

/* Consecutive screenshots: 2-column grid on tablet/desktop */
.shots { display: grid; grid-template-columns: 1fr; gap: 16px; margin: 16px 0; }
@media (min-width: 640px) {
  .shots { grid-template-columns: repeat(2, 1fr); align-items: start; }
  .shots figure { margin: 0; }
  .shots figure img { max-width: 100%; }
}

/* Japanese typography */
html[lang="ja"] body {
  font-family: 'Pretendard Variable','Hiragino Sans','Hiragino Kaku Gothic ProN','Noto Sans JP','Yu Gothic',-apple-system,sans-serif;
}

/* Language toggle styling */
.lang-switcher {
  display: flex;
  gap: 8px;
  margin-left: 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  padding-left: 12px;
}

.lang-dropdown {
  position: relative;
  display: inline-block;
}

.lang-dropdown-trigger {
  background: none;
  color: #fff;
  border: none;
  outline: none;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.2s ease;
}

.lang-dropdown-trigger:hover {
  background: rgba(255, 255, 255, 0.12);
}

.lang-dropdown-trigger[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.16);
}

.lang-dropdown-arrow {
  font-size: 0.75rem;
  color: #fff;
  transition: transform 0.2s ease;
}

.lang-dropdown-trigger[aria-expanded="true"] .lang-dropdown-arrow {
  transform: rotate(180deg);
}

.lang-dropdown-list {
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  min-width: 130px;
  margin-top: 0.4rem;
  z-index: 1000;
}

@media (prefers-color-scheme: dark) {
  .lang-dropdown-list {
    background: #1a1a1a;
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  }
}

.lang-dropdown-list .lang-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  background: none;
  border: none;
  padding: 0.5rem 0.75rem;
  text-align: left;
  text-decoration: none;
  color: #1a1a1a;
  cursor: pointer;
  transition: background 0.2s ease;
  font-size: 0.9rem;
}

@media (prefers-color-scheme: dark) {
  .lang-dropdown-list .lang-dropdown-item {
    color: rgba(255, 255, 255, 0.92);
  }
}

.lang-dropdown-item:first-child {
  border-radius: 0.5rem 0.5rem 0 0;
}

.lang-dropdown-item:last-child {
  border-radius: 0 0 0.5rem 0.5rem;
}

.lang-dropdown-item:hover {
  background: rgba(0, 0, 0, 0.08);
}

@media (prefers-color-scheme: dark) {
  .lang-dropdown-item:hover {
    background: rgba(255, 255, 255, 0.1);
  }
}

.lang-dropdown-item.is-current {
  font-weight: 600;
  cursor: default;
  background: rgba(0, 0, 0, 0.04);
}

@media (prefers-color-scheme: dark) {
  .lang-dropdown-item.is-current {
    background: rgba(255, 255, 255, 0.06);
  }
}
