:root {
  --color-bg: #f7fbfb;
  --color-surface: #ffffff;
  --color-surface-raised: #eef7f6;
  --color-border: #d7e5e2;
  --color-text: #203032;
  --color-muted: #64787b;
  --color-accent: #178b8b;
  --color-accent-hover: #0f6f73;
  --color-code-bg: #e8f2f0;
  --color-quote-border: #92cbc5;

  --sidebar-width: 260px;
  --header-height: 64px;
  --content-max-width: 840px;

  --font-mono: "Monaco", "Menlo", "Ubuntu Mono", monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  background: linear-gradient(180deg, #effafa 0, var(--color-bg) 18rem), var(--color-bg);
  color: var(--color-text);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", sans-serif;
  font-size: 1rem;
  line-height: 1.6;
}

.layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background-color: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--color-border);
  backdrop-filter: blur(14px);
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.75rem;
}

.site-logo {
  display: inline-flex;
  align-items: center;
  flex: 0 1 auto;
  gap: 0.65rem;
  min-width: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
  text-decoration: none;
  transition: color 0.15s ease;
}

.site-logo-mark {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  object-fit: contain;
}

.site-logo-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-logo:hover {
  color: var(--color-accent);
}

.layout-body {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  flex: 1;
}

.sidebar {
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  background-color: rgba(255, 255, 255, 0.78);
  border-right: 1px solid var(--color-border);
  padding: 1.25rem 0;
}

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

.sidebar li {
  padding: 0;
  margin: 0;
}

.sidebar a {
  display: block;
  padding: 0.55rem 1.5rem;
  color: var(--color-text);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition:
    color 0.15s ease,
    background-color 0.15s ease;
}

.sidebar a[aria-current="page"],
.sidebar a.active {
  color: var(--color-accent);
  background-color: rgba(23, 139, 139, 0.1);
  border-left: 3px solid var(--color-accent);
}

.sidebar a:hover {
  color: var(--color-accent);
  background-color: rgba(23, 139, 139, 0.06);
}

.nav-group {
  margin: 1.5rem 0;
}

.nav-group-label {
  display: block;
  padding: 0.5rem 1.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-muted);
}

.nav-group ul {
  padding-left: 0;
  margin: 0;
}

.nav-group ul li a {
  padding-left: 2rem;
}

.content {
  min-width: 0;
  padding: 2.5rem 2rem 3rem;
  max-width: var(--content-max-width);
  width: 100%;
  margin: 0 auto;
}

.site-footer {
  background-color: #f1f8f7;
  border-top: 1px solid var(--color-border);
  padding: 1.5rem;
  text-align: center;
  color: var(--color-muted);
  font-size: 0.875rem;
  margin-top: auto;
}

article {
  min-width: 0;
}

.intro-logo {
  display: flex;
  justify-content: center;
  margin: 0 0 1.25rem;
}

.intro-logo img {
  display: block;
  width: 160px;
  height: 160px;
  object-fit: contain;
}

article h1 {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 1.25rem;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.75rem;
}

article h2 {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
}

article h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
}

article h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.25rem 0 0.5rem;
}

article p {
  margin: 0 0 1rem;
  line-height: 1.7;
}

article a {
  color: var(--color-accent);
  text-decoration: underline;
  text-decoration-color: rgba(23, 139, 139, 0.35);
  text-underline-offset: 0.18em;
  transition: color 0.15s ease;
}

article a:hover,
article a:focus-visible {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

article code {
  background-color: var(--color-code-bg);
  padding: 0.1em 0.4em;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.875em;
}

article pre {
  max-width: 100%;
  background-color: #152527;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
  margin: 0 0 1rem;
  line-height: 1.5;
}

article pre code {
  background-color: transparent;
  padding: 0;
  color: #e7f4f2;
}

article blockquote {
  border-left: 4px solid var(--color-quote-border);
  margin: 0 0 1rem;
  padding: 0.5rem 1rem;
  background-color: rgba(255, 255, 255, 0.58);
  color: #53696c;
}

article table {
  border-collapse: collapse;
  display: block;
  max-width: 100%;
  width: max-content;
  overflow-x: auto;
  margin: 0 0 1rem;
}

article th,
article td {
  border: 1px solid var(--color-border);
  padding: 0.5rem 0.75rem;
  text-align: left;
}

article th {
  background-color: var(--color-surface-raised);
  font-weight: 600;
}

article li {
  margin: 0.25rem 0;
}

article ol,
article ul {
  padding-left: 1.5rem;
  margin: 0 0 1rem;
}

article hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 2rem 0;
}

.sidebar-toggle-input {
  display: none;
}

.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--color-text);
  padding: 0.25rem;
  transition: color 0.15s ease;
}

.sidebar-toggle:hover {
  color: var(--color-accent);
}

.sidebar-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background-color: currentColor;
  margin: 3px 0;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  top: var(--header-height);
  background-color: rgba(32, 48, 50, 0.28);
  z-index: 99;
}

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

@media (max-width: 768px) {
  .site-header {
    padding: 0 1rem;
    gap: 0.75rem;
  }

  .layout-body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 100;
    border-right: 1px solid var(--color-border);
  }

  #sidebar-toggle:checked ~ .layout .sidebar {
    transform: translateX(0);
  }

  #sidebar-toggle:checked ~ .layout .sidebar-backdrop {
    display: block;
  }

  .sidebar-toggle {
    display: flex;
  }

  .content {
    padding: 1.75rem 1rem 2.5rem;
  }

  article h1 {
    font-size: 1.65rem;
  }
}

@media (max-width: 480px) {
  .site-header {
    padding: 0 0.75rem;
    gap: 0.5rem;
  }

  .site-logo {
    gap: 0.5rem;
    font-size: 1.05rem;
  }

  .site-logo-mark {
    width: 28px;
    height: 28px;
    flex-basis: 28px;
  }

  .lang-btn {
    padding: 0.18rem 0.4rem;
  }

  .content {
    padding: 1.5rem 0.875rem 2.25rem;
  }

  .intro-logo img {
    width: 128px;
    height: 128px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none;
  }
}

/* Language toggle */
.lang-toggle {
  display: inline-flex;
  gap: 0;
  align-items: center;
  flex: 0 0 auto;
  margin-left: auto;
}
.lang-toggle--hidden {
  display: none;
}
.lang-btn {
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-muted);
  cursor: pointer;
  line-height: 1.5;
}
.lang-btn:first-child {
  border-radius: 4px 0 0 4px;
}
.lang-btn:last-child {
  border-radius: 0 4px 4px 0;
  border-left: none;
}
.lang-btn[aria-pressed="true"] {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}
