:root {
  --ts-blue: #007afe;
  --ts-ink: #081122;
  --ts-body: #52525b;
  --ts-surface: #ffffff;
  --ts-subtle: #f7f9fd;
  --ts-border: #e2e8ee;
  --ts-success: #0d957a;
  --ts-warning: #ff9c00;
  --ts-error: #ff3b30;
  --font-body: "DM Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sidebar-w: 268px;
  --topbar-h: 60px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ts-body);
  background: var(--ts-subtle);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body.modal-open {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

code {
  padding: 2px 5px;
  border-radius: 6px;
  background: rgba(8, 17, 34, 0.06);
  color: var(--ts-ink);
  font-family: var(--font-mono);
  font-size: 0.88em;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 32px;
  background: var(--ts-ink);
  color: white;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: block;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.1;
}

.brand small {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
  font-weight: 500;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
}

.topbar-nav a {
  padding: 8px 12px;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.74);
}

.topbar-nav a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  padding: 28px 20px;
  overflow: auto;
  border-right: 1px solid var(--ts-border);
  background: white;
}

.sidebar a {
  display: block;
  padding: 11px 12px;
  border-radius: 10px;
  color: #4a4a4e;
  font-size: 14px;
  font-weight: 700;
}

.sidebar a:hover {
  background: #eef6ff;
  color: var(--ts-blue);
}

.main {
  min-width: 0;
  width: min(1180px, 100%);
  margin-inline: auto;
  padding: 40px;
}

.hero {
  min-height: 280px;
  display: grid;
  align-content: end;
  padding: 44px;
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(0, 122, 254, 0.14), rgba(13, 149, 122, 0.12)),
    white;
  border: 1px solid rgba(0, 122, 254, 0.16);
}

.hero h1,
.section-head h2 {
  margin: 0;
  color: var(--ts-ink);
  letter-spacing: 0;
}

.hero h1 {
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1;
}

.hero p:last-child {
  max-width: 760px;
  margin: 18px 0 0;
  font-size: 17px;
  line-height: 1.65;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--ts-blue);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.doc-section {
  min-width: 0;
  scroll-margin-top: 88px;
  margin-top: 42px;
  padding: 32px;
  border: 1px solid var(--ts-border);
  border-radius: 20px;
  background: white;
}

.section-head {
  margin-bottom: 24px;
}

.section-head h2 {
  font-size: 30px;
}

.guidance-grid,
.component-grid,
.skill-grid {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: 16px;
}

.guidance-card,
.component-card,
.maintenance-card,
.skill-card,
.token-group {
  border: 1px solid var(--ts-border);
  border-radius: 14px;
  background: #fff;
}

.guidance-card,
.skill-card {
  padding: 18px;
}

.guidance-card h3,
.component-card h3,
.skill-card h3,
.token-group h3 {
  margin: 0;
  color: var(--ts-ink);
  font-size: 17px;
}

.guidance-card ul {
  margin: 12px 0 0;
  padding-left: 18px;
  line-height: 1.55;
}

.skill-card p {
  margin: 10px 0 0;
  line-height: 1.55;
}

.skill-paths {
  display: grid;
  gap: 6px;
  margin-top: 16px;
}

.skill-paths span {
  color: #6e6e72;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.prompt-block {
  margin: 14px 0 0;
  padding: 14px;
  border: 1px solid var(--ts-border);
  border-radius: 12px;
  background: #f8fafc;
  color: var(--ts-ink);
  overflow-x: auto;
  white-space: pre-wrap;
}

.prompt-block code {
  padding: 0;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
}

.token-group {
  min-width: 0;
  margin-top: 16px;
  padding: 18px;
}

.two-col {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin-top: 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
  font-size: 13px;
}

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

th {
  color: var(--ts-ink);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: #f8fafc;
}

tr:last-child td {
  border-bottom: 0;
}

.swatch {
  display: inline-block;
  width: 34px;
  height: 24px;
  margin-right: 6px;
  border: 1px solid rgba(8, 17, 34, 0.14);
  border-radius: 7px;
  background: var(--swatch-color);
  vertical-align: middle;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.swatch-alpha {
  background:
    linear-gradient(var(--swatch-color), var(--swatch-color)),
    conic-gradient(#ffffff 25%, #dbe3eb 0 50%, #ffffff 0 75%, #dbe3eb 0);
  background-size: auto, 8px 8px;
}

.alpha-note {
  display: block;
  margin-top: 4px;
  color: #6e6e72;
  font-family: var(--font-mono);
  font-size: 11px;
}

.color-section {
  margin-top: 22px;
}

.color-section h3 {
  margin: 0 0 12px;
  color: var(--ts-ink);
}

.whitelabel-panel {
  padding: 18px;
  border: 1px solid var(--ts-border);
  border-radius: 14px;
  background: #fff;
}

.whitelabel-head {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.whitelabel-head h3 {
  margin: 0;
  color: var(--ts-ink);
  font-size: 17px;
}

.whitelabel-head p {
  margin: 6px 0 0;
  line-height: 1.5;
}

.color-control-stack {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.color-control-label {
  display: block;
  margin-bottom: 7px;
  color: #6e6e72;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.whitelabel-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  overflow: visible;
  padding-bottom: 4px;
}

.color-mode-selector {
  display: inline-flex;
  gap: 6px;
  width: fit-content;
  max-width: 100%;
  padding: 3px;
  border: 1px solid var(--ts-border);
  border-radius: 999px;
  background: #f8fafc;
  overflow-x: auto;
}

.whitelabel-tab,
.color-mode-tab {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  padding: 7px 11px;
  border: 1px solid var(--ts-border);
  border-radius: 999px;
  background: #f8fafc;
  color: #4a4a4e;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.color-mode-tab {
  min-width: 84px;
  justify-content: center;
  border-color: transparent;
  background: transparent;
}

.whitelabel-tab[aria-selected="true"],
.color-mode-tab[aria-selected="true"] {
  border-color: rgba(0, 122, 254, 0.32);
  background: #eef6ff;
  color: var(--ts-blue);
}

.whitelabel-tab:focus-visible,
.color-mode-tab:focus-visible {
  outline: 3px solid rgba(0, 122, 254, 0.28);
  outline-offset: 2px;
}

.whitelabel-dot {
  width: 14px;
  height: 14px;
  border: 1px solid rgba(8, 17, 34, 0.18);
  border-radius: 50%;
  background: var(--dot-color);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

.whitelabel-summary {
  display: grid;
  grid-template-columns: minmax(180px, 0.5fr) minmax(0, 1fr);
  gap: 16px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--ts-border);
  border-radius: 12px;
  background: #f8fafc;
}

.whitelabel-summary span {
  display: block;
  color: #6e6e72;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.whitelabel-summary strong {
  display: block;
  margin-top: 5px;
  color: var(--ts-ink);
  font-size: 20px;
}

.whitelabel-summary p {
  margin: 6px 0 0;
  line-height: 1.5;
}

.source-reference-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.source-reference {
  min-width: min(100%, 210px);
  display: grid;
  gap: 4px;
  padding: 8px 10px;
  border: 1px solid var(--ts-border);
  border-radius: 10px;
  background: white;
}

.source-reference span {
  color: #6e6e72;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.source-reference code {
  padding: 0;
  background: transparent;
  font-size: 12px;
}

.component-card {
  min-width: 0;
  overflow: hidden;
}

.component-preview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  padding: 10px;
  background: #081122;
  border-bottom: 1px solid var(--ts-border);
}

.component-shot {
  position: relative;
  margin: 0;
  overflow: hidden;
  border-radius: 10px;
  background: #eef2f6;
}

.preview-trigger {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.preview-trigger:focus-visible {
  outline: 3px solid var(--ts-blue);
  outline-offset: -3px;
}

.preview-trigger img,
.component-shot > img {
  display: block;
  width: 100%;
  aspect-ratio: 9 / 14;
  object-fit: contain;
  object-position: top center;
}

.component-shot figcaption {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(8, 17, 34, 0.74);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
}

.preview-unavailable {
  min-height: 210px;
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  padding: 24px;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.06) 0 8px, transparent 8px 16px),
    #101112;
  color: #fff;
  text-align: center;
}

.preview-unavailable strong,
.preview-unavailable span {
  display: block;
}

.preview-unavailable span {
  max-width: 360px;
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  line-height: 1.45;
}

.component-body {
  min-width: 0;
  padding: 16px;
}

.component-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  flex-wrap: wrap;
}

.component-title-row h3 {
  min-width: 0;
  overflow-wrap: anywhere;
}

.component-id {
  min-width: 0;
  color: #6e6e72;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.component-body p {
  margin: 10px 0 0;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.source-list {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.source-list code,
.api-list code,
.status,
.chip {
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.meta-list {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
}

.chip {
  padding: 5px 8px;
  border-radius: 999px;
  background: #eef6ff;
  color: #0051a9;
  font-size: 12px;
  font-weight: 800;
}

.status {
  margin-top: 12px;
  color: #6e6e72;
  font-size: 12px;
}

.api-list {
  min-width: 0;
  margin-top: 14px;
  color: var(--ts-ink);
}

.api-list summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.api-list div {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.maintenance-card {
  padding: 20px;
}

.maintenance-card > p {
  margin: 0;
  max-width: 760px;
  line-height: 1.6;
}

.readme-panel {
  margin-top: 18px;
  border: 1px solid var(--ts-border);
  border-radius: 12px;
  overflow: hidden;
  background: #f8fafc;
}

.readme-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  padding: 10px 14px;
  color: var(--ts-ink);
  font-weight: 800;
}

.readme-actions {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  flex: 0 0 auto;
}

.readme-download {
  color: var(--ts-blue);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.readme-download:hover {
  text-decoration: underline;
}

.readme-download:focus-visible {
  border-radius: 6px;
  outline: 3px solid rgba(0, 122, 254, 0.28);
  outline-offset: 3px;
}

.readme-switch {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ts-ink);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  user-select: none;
  flex: 0 0 auto;
}

.switch-track {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #c2cfdb;
  transition: background 160ms ease;
}

.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 4px rgba(8, 17, 34, 0.22);
  transition: transform 160ms ease;
}

.readme-switch[aria-checked="true"] .switch-track {
  background: var(--ts-blue);
}

.readme-switch[aria-checked="true"] .switch-thumb {
  transform: translateX(18px);
}

.readme-switch:focus-visible .switch-track {
  outline: 3px solid rgba(0, 122, 254, 0.32);
  outline-offset: 2px;
}

.readme-content,
.readme-rendered {
  display: block;
  width: 100%;
  max-height: 680px;
  min-height: 620px;
  margin: 0;
  padding: 18px;
  border: 0;
  border-top: 1px solid var(--ts-border);
  background: white;
  color: var(--ts-ink);
  overflow: auto;
}

.readme-content[hidden],
.readme-rendered[hidden] {
  display: none;
}

.readme-content {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
}

.readme-rendered {
  padding: 8px 18px 22px;
  font-size: 14px;
  line-height: 1.62;
}

.readme-rendered h1,
.readme-rendered h2,
.readme-rendered h3 {
  margin: 18px 0 8px;
  color: var(--ts-ink);
  line-height: 1.18;
}

.readme-rendered h1 {
  font-size: 24px;
}

.readme-rendered h2 {
  font-size: 18px;
}

.readme-rendered h3 {
  font-size: 15px;
}

.readme-rendered p {
  margin: 8px 0 12px;
  max-width: none;
}

.readme-rendered ul,
.readme-rendered ol {
  margin: 8px 0 16px;
  padding-left: 22px;
}

.readme-rendered li {
  margin: 5px 0;
}

.readme-rendered pre {
  margin: 12px 0 16px;
  padding: 12px;
  border: 1px solid var(--ts-border);
  border-radius: 10px;
  background: #f8fafc;
  overflow-x: auto;
}

.readme-rendered pre code {
  padding: 0;
  background: transparent;
  font-size: 12px;
}

.readme-rendered .markdown-table {
  margin: 12px 0 18px;
  overflow-x: auto;
}

.readme-rendered table {
  min-width: 820px;
}

.readme-loading,
.readme-load-error {
  padding: 14px;
  border: 1px solid var(--ts-border);
  border-radius: 10px;
  background: #f8fafc;
}

.readme-load-error h3 {
  margin-top: 0;
}

.readme-error-detail {
  color: #6e6e72;
  font-family: var(--font-mono);
  font-size: 12px;
}

.preview-modal[hidden] {
  display: none;
}

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 28px;
}

.preview-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(8, 17, 34, 0.74);
  cursor: zoom-out;
}

.preview-modal-card {
  position: relative;
  z-index: 1;
  width: min(94vw, 620px);
  max-height: calc(100vh - 56px);
  margin: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border-radius: 14px;
  background: #101112;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

.preview-modal-card img {
  display: block;
  width: 100%;
  max-height: calc(100vh - 142px);
  object-fit: contain;
  background: #f8fafc;
}

.preview-modal-card figcaption {
  padding: 12px 16px;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.preview-close {
  justify-self: end;
  margin: 10px 10px 0;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.preview-close:focus-visible {
  outline: 3px solid #55a6fe;
  outline-offset: 2px;
}

@media (max-width: 920px) {
  .topbar {
    padding: 0 18px;
  }

  .topbar-nav {
    display: none;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    position: sticky;
    top: var(--topbar-h);
    z-index: 9;
    height: auto;
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    overflow-x: auto;
    background: white;
    border-right: 0;
    border-bottom: 1px solid var(--ts-border);
    scrollbar-width: thin;
  }

  .sidebar a {
    white-space: nowrap;
  }

  .main {
    width: 100%;
    padding: 20px;
  }

  .hero,
  .doc-section {
    padding: 24px;
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .whitelabel-head,
  .whitelabel-summary {
    grid-template-columns: 1fr;
  }

  .readme-content,
  .readme-rendered {
    min-height: 520px;
  }

  .preview-modal {
    padding: 14px;
  }

  .preview-modal-card {
    width: 100%;
    max-height: calc(100vh - 28px);
  }

  .preview-modal-card img {
    max-height: calc(100vh - 116px);
  }
}
