:root {
  --badge-neutral-bg: #EDF3FB;
  --badge-neutral-text: #40516A;
  --badge-accent-bg: #E8F0FF;
  --badge-success-bg: #E4F5EE;
  --badge-warning-bg: #FFF3DF;
  --badge-error-bg: #FDEAE8;
  --callout-accent-line: #2B6BE4;
  --callout-success-line: #12915F;
  --callout-warning-line: #C77E14;
}

/* Tabs */
.tab-set {
  min-width: 0;
}

.tab-list {
  display: flex;
  max-width: 100%;
  gap: 4px;
  padding: 4px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-panel);
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.tab-list [role="tab"] {
  min-height: 42px;
  flex: 1 0 auto;
  padding: 8px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  font-weight: 650;
  white-space: nowrap;
}

.tab-list [role="tab"]:hover {
  color: var(--color-text);
}

.tab-list [role="tab"][aria-selected="true"],
.tab-list [role="tab"].is-active {
  border-color: var(--color-border);
  background: var(--color-bg);
  color: var(--color-accent-dark);
  box-shadow: var(--shadow-pill);
}

.tab-panel {
  padding-top: 28px;
}

.tab-panel[hidden] {
  display: none;
}

/* Long-page navigation */
.page-toc {
  position: sticky;
  top: 12px;
  z-index: 20;
  display: flex;
  max-width: 100%;
  gap: 6px;
  padding: 6px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text);
  box-shadow: var(--shadow-soft);
  scrollbar-width: thin;
}

.page-toc a {
  display: inline-flex;
  min-height: 40px;
  flex: 0 0 auto;
  align-items: center;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.page-toc a:hover,
.page-toc a[aria-current="location"] {
  background: var(--color-panel);
  color: var(--color-accent-dark);
}

/* FAQ */
.faq-list {
  display: grid;
  gap: 10px;
}

.faq-item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text);
  box-shadow: var(--shadow-soft);
}

.faq-item summary {
  position: relative;
  display: flex;
  min-height: 58px;
  align-items: center;
  padding: 15px 52px 15px 18px;
  cursor: pointer;
  color: var(--color-text);
  font-weight: 700;
  list-style: none;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  position: absolute;
  top: 50%;
  right: 19px;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--color-accent);
  border-bottom: 2px solid var(--color-accent);
  content: "";
  transform: translateY(-70%) rotate(45deg);
  transition: transform var(--transition-fast);
}

.faq-item[open] summary::after {
  transform: translateY(-30%) rotate(225deg);
}

.faq-answer {
  padding: 0 18px 18px;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
}

.faq-answer > :first-child {
  margin-top: 14px;
}

/* Badges */
.badge-row,
.chip-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.badge,
.chip {
  display: inline-flex;
  max-width: 100%;
  min-height: 27px;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--badge-neutral-bg);
  color: var(--badge-neutral-text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.badge-accent {
  border-color: var(--color-field-blue);
  background: var(--badge-accent-bg);
  color: var(--color-accent-dark);
}

.badge-recommended,
.badge-primary {
  border-color: var(--color-field-blue);
  background: var(--badge-accent-bg);
  color: var(--color-accent-dark);
}

.badge-success {
  background: var(--badge-success-bg);
  color: var(--color-success);
}

.badge-warning,
.badge-retired {
  background: var(--badge-warning-bg);
  color: var(--color-warning);
}

.badge-error {
  background: var(--badge-error-bg);
  color: var(--color-error);
}

/* Glossary */
.term-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.term-card {
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text);
  box-shadow: var(--shadow-soft);
}

.term-card dt {
  margin-bottom: 7px;
  color: var(--color-text);
  font-size: 18px;
  font-weight: 750;
}

.term-card dd {
  margin: 0;
  color: var(--color-text-muted);
}

.term-card .term-code {
  color: var(--color-accent-dark);
  font-family: var(--font-mono);
  font-size: 12px;
}

/* Download cards */
.download-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.download-card {
  display: flex;
  min-width: 0;
  height: 100%;
  padding: 24px;
  flex-direction: column;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg);
  color: var(--color-text);
  box-shadow: var(--shadow-soft);
}

.download-card-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.download-card-head img {
  width: 54px;
  height: 54px;
  flex: 0 0 54px;
}

.download-card-title {
  min-width: 0;
  flex: 1;
}

.download-card-title h3 {
  margin-bottom: 3px;
}

.download-card-copy {
  margin-top: 16px;
  color: var(--color-text-muted);
}

.download-options {
  display: grid;
  gap: 9px;
  margin-top: auto;
  padding-top: 20px;
}

.download-option {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 13px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-panel);
  color: var(--color-text);
  font-weight: 700;
}

.download-option:hover {
  border-color: var(--color-accent);
  color: var(--color-accent-dark);
}

.download-option small {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-weight: 500;
  overflow-wrap: anywhere;
}

/* Blog cards */
.article-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.article-card {
  display: flex;
  min-width: 0;
  height: 100%;
  padding: 22px;
  flex-direction: column;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text);
  box-shadow: var(--shadow-soft);
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.article-card:hover {
  border-color: var(--color-field-blue);
  box-shadow: var(--shadow-card);
  transform: translateY(-3px);
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

.article-card h3 {
  font-size: 19px;
}

.article-card p {
  color: var(--color-text-muted);
}

.article-link {
  margin-top: auto;
  padding-top: 10px;
  color: var(--color-accent-dark);
  font-weight: 700;
}

/* Callouts */
.callout {
  position: relative;
  padding: 18px 20px 18px 22px;
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--callout-accent-line);
  border-radius: var(--radius-md);
  background: var(--color-panel);
  color: var(--color-text);
}

.callout strong {
  color: var(--color-text);
}

.callout p,
.callout li {
  color: var(--color-text-muted);
}

.callout-success {
  border-left-color: var(--callout-success-line);
  background: var(--badge-success-bg);
  color: var(--color-text);
}

.callout-warning {
  border-left-color: var(--callout-warning-line);
  background: var(--badge-warning-bg);
  color: var(--color-text);
}

/* Article-end download guide */
.article-download-guide {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  margin-top: 48px;
  padding: 24px;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-panel);
  color: var(--color-text);
  box-shadow: var(--shadow-soft);
}

.article-download-guide p {
  color: var(--color-text-muted);
}

/* Download FAB: article pages only */
.dl-fab {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 80;
  display: inline-flex;
  max-width: min(310px, calc(100vw - 32px));
  min-height: 58px;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg);
  color: var(--color-text);
  box-shadow: var(--shadow-card);
}

.dl-fab:hover {
  border-color: var(--color-accent);
}

.dl-fab-icon {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--color-accent);
  color: var(--color-bg);
}

.dl-fab-icon svg {
  width: 18px;
  height: 18px;
}

.dl-fab-copy {
  min-width: 0;
  line-height: 1.35;
}

.dl-fab-copy strong,
.dl-fab-copy span {
  display: block;
}

.dl-fab-copy strong {
  font-size: 13px;
}

.dl-fab-copy span {
  margin-top: 2px;
  color: var(--color-text-muted);
  font-size: 11px;
}

/* Hero and product mock */
.preview-hero {
  padding-top: 40px;
  overflow-x: clip;
  text-align: center;
}

.preview-hero-copy {
  width: 100%;
  max-width: 900px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.preview-hero .eyebrow {
  margin-bottom: 18px;
}

.preview-hero h1 {
  margin-bottom: 16px;
}

.preview-hero-lead {
  max-width: 680px;
  margin-inline: auto;
  color: var(--color-text-muted);
  font-size: 16px;
}

.preview-hero-actions {
  justify-content: center;
  margin-top: 24px;
}

.preview-hero-chips {
  justify-content: center;
  margin-top: 20px;
}

.preview-hero-chips .chip {
  background: var(--color-bg);
  color: var(--color-text-muted);
  box-shadow: var(--shadow-pill);
}

.preview-stage {
  position: relative;
  width: 100%;
  max-width: calc(var(--content-width) + var(--gutter) * 2);
  margin: 34px auto 0;
  padding-inline: var(--gutter);
}

.preview-stage-field {
  position: relative;
  height: 392px;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--hero-field);
  color: var(--color-text);
  box-shadow: var(--shadow-soft);
}

.preview-platforms {
  position: absolute;
  top: 0;
  left: calc(var(--gutter) + 34px);
  z-index: 4;
  display: flex;
  max-width: calc(100% - var(--gutter) * 2 - 68px);
  gap: 9px;
  overflow-x: auto;
  transform: translateY(-50%);
  scrollbar-width: none;
}

.preview-platforms::-webkit-scrollbar {
  display: none;
}

.platform-pill {
  display: inline-flex;
  min-height: 32px;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  padding: 5px 13px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 12px;
  font-weight: 700;
  box-shadow: var(--shadow-pill);
}

.platform-pill svg {
  width: 13px;
  height: 13px;
  color: var(--color-text-muted);
}

.stage-copy {
  position: absolute;
  top: 96px;
  left: 44px;
  width: 290px;
  text-align: left;
}

.stage-copy h2 {
  margin-bottom: 10px;
  font-size: 20px;
}

.stage-copy p {
  color: var(--color-text-muted);
  font-size: 13px;
}

.stage-copy a {
  color: var(--color-accent-dark);
  font-size: 13px;
  font-weight: 700;
}

.stage-note {
  position: absolute;
  top: 15px;
  right: 20px;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.product-window {
  position: absolute;
  top: 56px;
  right: 52px;
  z-index: 2;
  width: min(620px, calc(100% - 390px));
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg);
  color: var(--color-text);
  box-shadow: var(--shadow-card);
  text-align: left;
}

.window-bar {
  display: flex;
  height: 40px;
  padding-inline: 14px;
  align-items: center;
  gap: 7px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-panel);
  color: var(--color-text);
}

.window-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-radius: 50%;
}

.window-dot-error {
  background: var(--color-error);
}

.window-dot-warning {
  background: var(--color-warning);
}

.window-dot-success {
  background: var(--color-success);
}

.window-title {
  margin-left: 7px;
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 700;
}

.window-state {
  display: inline-flex;
  margin-left: auto;
  align-items: center;
  gap: 6px;
  color: var(--color-success);
  font-family: var(--font-mono);
  font-size: 10px;
}

.window-layout {
  display: grid;
  min-height: 300px;
  grid-template-columns: 172px minmax(0, 1fr);
}

.window-side {
  display: flex;
  padding: 14px 10px;
  flex-direction: column;
  border-right: 1px solid var(--color-border);
  background: var(--color-panel);
  color: var(--color-text);
}

.window-side-label {
  padding: 0 8px 8px;
  color: var(--color-text-muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.window-side-item {
  display: flex;
  min-height: 34px;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.window-side-item.is-current {
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  box-shadow: var(--shadow-pill);
  font-weight: 700;
}

.group-dot {
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 50%;
  background: var(--color-text-muted);
}

.is-current .group-dot {
  background: var(--color-accent);
}

.window-side-add {
  margin-top: auto;
  padding: 7px 8px;
  color: var(--color-accent-dark);
  font-size: 12px;
  font-weight: 700;
}

.window-main {
  padding: 6px 20px;
}

.setting-row {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--color-border);
}

.setting-row:last-child {
  border-bottom: 0;
}

.setting-copy {
  min-width: 0;
}

.setting-copy strong,
.setting-copy span {
  display: block;
}

.setting-copy strong {
  font-size: 13px;
}

.setting-copy span {
  margin-top: 2px;
  color: var(--color-text-muted);
  font-size: 11px;
}

.segment-control {
  display: inline-flex;
  flex: 0 0 auto;
  padding: 2px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-panel-strong);
  color: var(--color-text-muted);
}

.segment-control span {
  padding: 4px 9px;
  border-radius: var(--radius-xs);
  font-size: 11px;
  white-space: nowrap;
}

.segment-control .is-selected {
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-accent-dark);
  box-shadow: var(--shadow-pill);
  font-weight: 700;
}

.mock-switch {
  position: relative;
  width: 38px;
  height: 21px;
  flex: 0 0 38px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-panel-strong);
}

.mock-switch::after {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 15px;
  height: 15px;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-bg);
  box-shadow: var(--shadow-pill);
  content: "";
}

.mock-switch.is-on {
  border-color: var(--color-accent);
  background: var(--color-accent);
}

.mock-switch.is-on::after {
  right: 2px;
  left: auto;
  border-color: var(--color-accent-dark);
}

/* Preview utilities */
.preview-block {
  padding-top: 72px;
  padding-bottom: 72px;
}

.preview-heading {
  display: flex;
  margin-bottom: 28px;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.preview-heading p {
  color: var(--color-text-muted);
}

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.swatch {
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text);
}

.swatch-color {
  height: 82px;
  border-bottom: 1px solid var(--color-border);
}

.swatch-bg {
  background: var(--color-bg);
}

.swatch-panel {
  background: var(--color-panel);
}

.swatch-panel-strong {
  background: var(--color-panel-strong);
}

.swatch-border {
  background: var(--color-border);
}

.swatch-accent {
  background: var(--color-accent);
}

.swatch-accent-dark {
  background: var(--color-accent-dark);
}

.swatch-text {
  background: var(--color-text);
}

.swatch-muted {
  background: var(--color-text-muted);
}

.swatch-success {
  background: var(--color-success);
}

.swatch-warning {
  background: var(--color-warning);
}

.swatch-error {
  background: var(--color-error);
}

.swatch-field {
  background: var(--hero-field);
}

.swatch-label {
  padding: 10px 12px;
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: 11px;
}

.type-sample {
  padding: 24px 0;
  border-bottom: 1px solid var(--color-border);
}

.type-sample:last-child {
  border-bottom: 0;
}

@media (max-width: 1040px) {
  .stage-copy {
    display: none;
  }

  .product-window {
    right: 24px;
    width: min(620px, calc(100% - 48px));
  }

  .article-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .swatch-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .page-toc {
    position: static;
  }

  .term-grid,
  .download-grid,
  .article-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .article-download-guide {
    grid-template-columns: minmax(0, 1fr);
  }

  .preview-stage-field {
    height: 420px;
  }

  .product-window {
    top: 58px;
    right: 18px;
    left: 18px;
    width: auto;
  }

  .window-layout {
    grid-template-columns: 126px minmax(0, 1fr);
  }

  .window-side {
    padding-inline: 7px;
  }

  .window-main {
    padding-inline: 14px;
  }

  .swatch-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 540px) {
  .preview-hero {
    padding-top: 32px;
  }

  .preview-hero-lead {
    font-size: 14px;
  }

  .preview-platforms {
    left: calc(var(--gutter) + 14px);
    max-width: calc(100% - var(--gutter) * 2 - 28px);
  }

  .preview-stage-field {
    height: 448px;
  }

  .product-window {
    top: 58px;
    right: 10px;
    left: 10px;
  }

  .window-layout {
    display: block;
    min-height: 350px;
  }

  .window-side {
    display: none;
  }

  .window-main {
    padding: 5px 14px;
  }

  .setting-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
  }

  .setting-row .mock-switch {
    align-self: flex-end;
    margin-top: -38px;
  }

  .segment-control {
    max-width: 100%;
    overflow-x: auto;
  }

  .stage-note {
    display: none;
  }

  .swatch-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .dl-fab {
    right: 16px;
    bottom: 16px;
    left: 16px;
    max-width: none;
  }

  .badge-row,
  .chip-row {
    flex-direction: row;
    justify-content: flex-start;
  }
}