:root {
  --bg: #f8fafb;
  --bg-accent: radial-gradient(circle at top left, rgba(96, 125, 139, 0.12), transparent 28%), linear-gradient(135deg, #f5f7fa 0%, #eef2f7 45%, #e8eef5 100%);
  --surface: rgba(255, 255, 255, 0.88);
  --surface-muted: rgba(248, 250, 253, 0.92);
  --text: #0f172a;
  --text-soft: #475569;
  --border: rgba(15, 23, 42, 0.12);
  --primary: #2563eb;
  --primary-strong: #1e40af;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f172a;
    --bg-accent: radial-gradient(circle at top left, rgba(100, 116, 139, 0.15), transparent 28%), linear-gradient(135deg, #0f172a 0%, #1e293b 52%, #1a2540 100%);
    --surface: rgba(20, 28, 48, 0.88);
    --surface-muted: rgba(25, 35, 55, 0.92);
    --text: #e2e8f0;
    --text-soft: #94a3b8;
    --border: rgba(226, 232, 240, 0.08);
    --primary: #3b82f6;
    --primary-strong: #2563eb;
    --shadow: 0 22px 55px rgba(0, 0, 0, 0.44);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg-accent), var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Noto Sans", Arial, sans-serif;
  line-height: 1.45;
  position: relative;
}

a {
  color: inherit;
}

.app-shell {
  width: min(1320px, calc(100vw - 24px));
  margin: 12px auto;
  padding: 16px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #fff;
}

.brand-badge-icon {
  background: var(--surface-muted);
  border: 1px solid var(--border);
}

.brand-badge-icon img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  display: block;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-badge-icon img {
    filter: invert(1);
  }
}

:root[data-theme="dark"] .brand-badge-icon img {
  filter: invert(1);
}

.brand-copy h1 {
  margin: 0;
  font-size: clamp(1.1rem, 2.2vw, 1.7rem);
}

.brand-copy p {
  display: none;
}

.product-placeholder {
  width: 100%;
  height: 250px;
  border-radius: 14px;
  border: 1px solid var(--border);
  overflow: hidden;
  background: linear-gradient(120deg, rgba(37, 99, 235, 0.1), rgba(30, 64, 175, 0.05));
  margin-bottom: 6px;
}

.product-placeholder img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

h2 {
  margin-bottom: 0px;
}

.theme-switch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.theme-switch > span:first-child {
  display: none;
}

.theme-switch input {
  display: none;
}

.theme-track {
  width: 44px;
  height: 24px;
  background: linear-gradient(135deg, #d1d5db, #e5e7eb);
  border-radius: 999px;
  position: relative;
  transition: background 220ms ease, box-shadow 220ms ease;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.14);
}

.theme-track::before {
  content: "☀";
  position: absolute;
  top: 3px;
  left: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  color: #6b7280;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  transition: transform 220ms ease, color 220ms ease, background 220ms ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.theme-track::after {
  content: none;
}

.theme-switch input:checked + .theme-track {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.45);
}

.theme-switch input:checked + .theme-track::before {
  transform: translateX(20px);
  content: "☾";
  color: #cbd5e1;
  background: #111827;
}

.global-theme-switch {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 160ms ease;
}

html.theme-ready .global-theme-switch {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.page-card {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 10px 14px;
  text-decoration: none;
  font: inherit;
  border: 1px solid transparent;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #fff;
}

.btn-secondary {
  background: var(--surface-muted);
  color: var(--text);
  border-color: var(--border);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.card-option {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.card-option:hover {
  transform: translateY(-2px);
  border-color: rgba(37, 99, 235, 0.35);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.1);
}

.card-option:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.docs-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.doc-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.github-mark {
  width: 18px;
  height: 18px;
  display: inline-flex;
}

.github-mark svg {
  width: 100%;
  height: 100%;
  display: block;
  fill: currentColor;
}

.console-brand {
  margin: 8px 0 0;
  text-align: center;
  color: var(--text-soft);
  font-weight: 600;
  font-size: 0.92rem;
}

/* === Top-right controls group (language toggle + theme switch) === */
.top-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 160ms ease;
}

html.theme-ready .top-controls {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Theme switch inside the wrapper: reset the standalone fixed positioning */
.top-controls .theme-switch {
  position: static;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* === Language toggle pill === */
.lang-toggle {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  overflow: hidden;
  padding: 0;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--text);
  transition: opacity 160ms ease;
}

.lang-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.lang-seg {
  padding: 5px 10px;
  background: transparent;
  color: var(--text);
  transition: background 150ms ease, color 150ms ease;
  font-weight: 600;
  line-height: 1;
  user-select: none;
}

.lang-seg.active {
  background: var(--primary);
  color: #fff;
}

@media (max-width: 980px) {
  .card-grid {
    grid-template-columns: 1fr;
  }

  .docs-grid {
    grid-template-columns: 1fr;
  }

  .global-theme-switch {
    top: 8px;
    right: 8px;
    padding: 8px 10px;
    font-size: 0.85rem;
  }
}
