.design-system-storybook {
  min-height: 100vh;
  padding: 32px clamp(16px, 4vw, 56px) 80px;
}

.ds-storybook-header {
  display: flex;
  width: min(100%, 1180px);
  margin: 0 auto;
  gap: 24px;
  align-items: flex-start;
  justify-content: space-between;
}

.ds-storybook-header h1 { margin-bottom: 0; }
.ds-storybook-header > .theme-toggle { flex: 0 0 auto; white-space: nowrap; }

.ds-catalog-nav {
  display: flex;
  width: min(100%, 1180px);
  margin: 28px auto 0;
  padding: 4px 0 13px;
  gap: 7px;
  overflow-x: auto;
  border-bottom: 1px solid var(--divider);
}

.ds-catalog-nav a {
  min-height: 32px;
  padding: 6px 9px;
  border-radius: var(--control-radius);
  color: var(--secondary);
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
}

.ds-catalog-nav a:hover { background: var(--soft); color: var(--ink); }
.ds-storybook-content { width: min(100%, 1180px); margin: 0 auto; }
.ds-story-section { padding: 42px 0; border-bottom: 1px solid var(--divider); }
.ds-story-section:last-child { border-bottom: 0; }
.ds-section-heading { display: grid; max-width: 760px; margin-bottom: 24px; gap: 7px; }
.ds-section-heading h2 { margin: 0; font-size: 21px; font-weight: 620; letter-spacing: -.015em; }
.ds-section-heading p { margin: 0; color: var(--secondary); font-size: 13px; line-height: 1.55; }

.ds-swatch-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.ds-swatch { min-width: 0; padding: 9px; border: 1px solid var(--divider); border-radius: var(--control-radius); background: var(--surface); }
.ds-swatch-color { display: block; height: 62px; margin-bottom: 9px; border: 1px solid var(--divider); border-radius: 9px; }
.ds-swatch strong, .ds-swatch code { display: block; }
.ds-swatch strong { font-size: 12px; font-weight: 620; }
.ds-swatch code { margin-top: 3px; overflow-wrap: anywhere; color: var(--faint); font-size: 9px; }
.ds-swatch-canvas { background: var(--canvas); }
.ds-swatch-surface { background: var(--surface); }
.ds-swatch-ink { background: var(--ink); }
.ds-swatch-secondary { background: var(--secondary); }
.ds-swatch-divider { background: var(--divider); }
.ds-swatch-accent-start { background: var(--accent-start); }
.ds-swatch-accent-middle { background: var(--accent-middle); }
.ds-swatch-accent-end { background: var(--accent-end); }
.ds-swatch-accent { background: var(--accent); }
.ds-swatch-accent-soft { background: var(--accent-soft); }
.ds-swatch-success { background: var(--success); }
.ds-swatch-warning { background: var(--warning); }
.ds-swatch-danger { background: var(--danger); }

.ds-token-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 12px; gap: 8px; }
.ds-token-row > span { display: grid; min-height: 72px; padding: 12px; place-content: center start; border: 1px solid var(--divider); border-radius: var(--control-radius); }
.ds-token-row strong { font-size: 15px; font-weight: 620; }
.ds-token-row small { margin-top: 3px; color: var(--secondary); font-size: 10px; }

.ds-type-samples { display: grid; gap: 0; border-top: 1px solid var(--divider); }
.ds-type-samples > div { display: grid; grid-template-columns: minmax(130px, 180px) minmax(0, 1fr); padding: 18px 0; gap: 20px; align-items: baseline; border-bottom: 1px solid var(--divider); }
.ds-type-samples > div > span { color: var(--faint); font-size: 10px; }
.ds-type-samples p { margin: 0; }
.ds-type-page-title { font-size: 30px; font-weight: 650; letter-spacing: -.025em; line-height: 1.15; }
.ds-type-section-title { font-size: 20px; font-weight: 620; }
.ds-type-body { max-width: 680px; font-size: 15px; line-height: 1.65; }
.ds-type-meta { color: var(--secondary); font-size: 12px; }

.ds-component-stack { display: grid; gap: 18px; }
.ds-inline-group { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ds-menu-selection { margin: -8px 0 0; color: var(--secondary); font-size: 12px; }
.ds-field-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.ds-path-picker-sample { max-width: 620px; padding: 14px; border: 1px solid var(--divider); border-radius: var(--card-radius); background: var(--surface); }

.ds-shell-sample { display: grid; min-height: 440px; grid-template-columns: minmax(220px, 260px) minmax(0, 1fr); overflow: hidden; border: 1px solid var(--divider); border-radius: var(--panel-radius); background: var(--surface); box-shadow: var(--shadow-panel); }
.ds-shell-sidebar { padding: 18px 12px; border-right: 1px solid var(--divider); background: var(--sidebar); }
.ds-shell-sidebar > .brand { display: inline-flex; min-height: 38px; margin: 0 9px 16px; align-items: center; }
.ds-shell-content { position: relative; padding: 44px clamp(24px, 6vw, 72px); }
.ds-shell-title { margin: 8px 0 12px; font-size: 30px; font-weight: 650; letter-spacing: -.025em; }
.ds-mobile-search { display: none; }
.ds-tree { gap: 2px; }
.ds-tree-row { display: grid; grid-template-columns: 26px minmax(0, 1fr); padding-left: calc(var(--ds-tree-depth) * 15px); align-items: center; }
.ds-tree-row > a { display: flex; min-height: 38px; padding: 0 8px; align-items: center; border-radius: 10px; color: var(--secondary); font-size: 13px; text-decoration: none; }
.ds-tree-row > a:hover { background: var(--soft); color: var(--ink); }
.ds-tree-row > a[aria-current="page"] { box-shadow: inset 3px 0 var(--accent); background: var(--accent-soft); color: var(--ink); font-weight: 620; }
.ds-tree-toggle { display: grid; width: 26px; min-height: 32px; padding: 0; place-items: center; border-color: transparent; background: transparent; color: var(--faint); }
.ds-tree-toggle:hover:not(:disabled) { border-color: transparent; background: var(--soft); color: var(--ink); }
.ds-tree-toggle svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.ds-tree-spacer { width: 26px; }
.ds-tree-children { display: grid; gap: 2px; }

.ds-audio-access-grid { display: grid; gap: 32px; }
.ds-audio-access-grid > section > h3 { margin: 0 0 12px; }
.ds-state-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ds-state-grid .action-card { display: grid; align-content: start; gap: 12px; }
.ds-state-grid .action-card > button { justify-self: start; }
.ds-audio-source { margin-top: 14px; }
.ds-auth-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.ds-auth-sample { min-height: 0; padding: 0; place-items: stretch; }
.ds-auth-sample > section { width: 100%; min-height: 100%; padding: 20px; align-content: center; }
.ds-auth-sample h3 { margin: 0; font-size: 1.45rem; }

.ds-note-list { border-top: 1px solid var(--divider); }
.ds-note-list .note-card-main.ds-inbox-row { grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; }
.ds-note-list .inbox-note-preview { margin-top: 0; }
.ds-note-list .note-action { grid-column: 3; margin-top: 0; }
.ds-filed-note-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: center; }
.ds-filed-note-row .note-action { grid-column: auto; margin: 0; }
.ds-subsection-grid { display: grid; gap: 32px; }
.ds-subsection-grid > section > h3 { margin: 0 0 10px; font-size: 15px; font-weight: 620; }

.ds-feedback-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: start; }
.ds-feedback-grid .fatal-error { margin: 0; }
.ds-toast-stack { display: grid; gap: 8px; }
.ds-toast-stack .toast { position: static; }
.ds-feedback-grid .empty-state { min-height: 0; padding: 24px; border: 1px dashed var(--divider-strong); border-radius: var(--card-radius); }
.ds-warning-state { border-color: color-mix(in srgb, var(--warning) 42%, var(--divider-strong)); }

.ds-detail-sample { padding: 22px; border: 1px solid var(--divider); border-radius: var(--card-radius); background: var(--surface); }
.ds-detail-sample .detail-current-title h3 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -.02em; line-height: 1.3; }
.ds-detail-sample .detail-section h4 { margin: 0 0 10px; font-size: 17px; font-weight: 500; }
.ds-detail-sample .detail-section pre { padding: 12px 0; border: 0; background: transparent; font-size: 14px; }

.ds-analysis-sample > h3 { margin: 0; font-size: 18px; font-weight: 500; }
.ds-analysis-status-heading { margin-top: 18px; align-items: center; }
.ds-analysis-status-heading time { color: var(--faint); font-size: 12px; }
.ds-analysis-sample .analysis-tab-panel { max-width: 760px; }
.ds-analysis-specimen { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--divider); }
.ds-analysis-specimen > h4 { margin: 0 0 14px; font-size: 15px; font-weight: 620; }
.ds-analysis-specimen .analysis-action-card > button { margin-top: 14px; }
.ds-status-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

.ds-system-sample { width: 100%; }
.ds-subsection-grid > .ds-system-sample + .ds-system-sample { padding-top: 32px; border-top: 1px solid var(--divider); }
.ds-system-sample .settings-section h3 { margin: 0 0 4px; font-size: 18px; font-weight: 500; }

.ds-overlay-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr); gap: 18px; align-items: start; }
.ds-command-palette { width: 100%; max-height: none; }
.ds-inline-confirmation { min-width: 0; }
.ds-inline-confirmation .action-block-header h3 { margin: 0; }
.ds-inline-confirmation .action-block-header p { margin: 5px 0 0; color: var(--secondary); font-size: 13px; line-height: 1.5; }

@media (min-width: 780px) {
  .ds-subsection-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ds-subsection-grid > .ds-system-sample + .ds-system-sample { padding-top: 0; padding-left: 32px; border-top: 0; border-left: 1px solid var(--divider); }
  .ds-audio-access-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 779px) {
  .ds-token-row, .ds-field-grid, .ds-feedback-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ds-auth-grid { grid-template-columns: 1fr; }
  .ds-overlay-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .design-system-storybook { padding-inline: 14px; }
  .ds-storybook-header { align-items: stretch; flex-direction: column; }
  .ds-storybook-header > .theme-toggle { width: fit-content; }
  .ds-token-row, .ds-field-grid, .ds-feedback-grid, .ds-state-grid { grid-template-columns: 1fr; }
  .ds-type-samples > div { grid-template-columns: 1fr; gap: 7px; }
  .ds-shell-sample { min-height: 360px; grid-template-columns: 1fr; }
  .ds-shell-sidebar { display: none; }
  .ds-shell-content { padding: 72px 20px 32px; }
  .ds-mobile-search { position: absolute; inset: 12px 12px auto; display: block; }
  .ds-mobile-search .search-trigger { position: static; width: 100%; min-height: 40px; justify-content: flex-start; border: 1px solid var(--divider); background: var(--surface); }
  .ds-note-list .note-card-main.ds-inbox-row { grid-template-columns: 24px minmax(0, 1fr); }
  .ds-note-list .note-action { grid-column: 2; margin-top: 8px; }
  .ds-filed-note-row { grid-template-columns: 1fr; }
  .ds-filed-note-row .note-action { grid-column: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .design-system-storybook *, .design-system-storybook *::before, .design-system-storybook *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
