/* 文件網站本身的版面（不屬於 library） */
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
.d-body { margin: 0; background: var(--sat-color-bg-page); }
code { padding: 1px 5px; border-radius: 4px; background: var(--sat-color-bg-subtle); color: var(--sat-color-text-heading); font-family: "SF Mono", Menlo, Consolas, monospace; font-size: .86em; }

.d-top {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  height: 56px; padding: 0 16px;
  border-bottom: 1px solid var(--sat-color-border);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
}
.d-brand { display: flex; align-items: center; gap: 10px; color: var(--sat-color-text-heading); font-size: 16px; font-weight: 500; text-decoration: none; }
.d-brand__mark { width: 22px; height: 22px; border-radius: 6px; background: var(--sat-color-primary); box-shadow: inset -7px -7px 0 -4px rgba(255,255,255,.9); }
.d-version { padding: 0 8px; border-radius: 40px; background: var(--sat-color-primary-subtle); color: var(--sat-color-primary); font-size: 12px; line-height: 22px; }
.d-top__figma { margin-left: auto; }
.d-menu-btn { display: none; }

.d-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); max-width: 1280px; margin: 0 auto; }
.d-nav {
  position: sticky; top: 56px; align-self: start;
  display: flex; flex-direction: column;
  height: calc(100vh - 56px); padding: 24px 12px 40px 16px;
  overflow-y: auto; border-right: 1px solid var(--sat-color-border);
}
.d-nav__group { margin: 18px 0 4px 8px; color: var(--sat-color-text-disabled); font-size: 12px; letter-spacing: .04em; }
.d-nav__group:first-child { margin-top: 0; }
.d-nav a { padding: 4px 8px; border-radius: 6px; color: var(--sat-color-text-body); font-size: 14px; line-height: 24px; text-decoration: none; }
.d-nav a:hover { background: var(--sat-color-bg-subtle); }
.d-nav a.is-current { background: var(--sat-color-primary-subtle); color: var(--sat-color-primary); }

.d-main { min-width: 0; padding: 40px 48px 80px; }
.d-sec { max-width: 920px; padding: 32px 0 40px; border-bottom: 1px solid var(--sat-color-border); }
.d-sec:first-child { padding-top: 0; }
.d-sec > p, .d-lead { max-width: 720px; }
.d-lead { color: var(--sat-color-text-body); font-size: 16px; line-height: 1.7; }
.d-h2 { margin: 0 0 8px; color: var(--sat-color-text-heading); font-size: 24px; font-weight: 500; line-height: 1.5; }
.d-h3 { margin: 28px 0 8px; color: var(--sat-color-text-heading); font-size: 16px; font-weight: 500; line-height: 1.5; }
.d-muted { color: var(--sat-color-text-caption); }
.d-list { padding-left: 20px; }
.d-list li { margin: 6px 0; }
.d-foot { padding: 40px 0 0; color: var(--sat-color-text-caption); font-size: 12px; }

.d-callout { display: flex; gap: 10px; max-width: 720px; margin: 16px 0; padding: 12px 16px; border-radius: 8px; background: var(--sat-color-primary-subtle); }
.d-callout > .sat-icon { --sat-icon-size: 20px; margin-top: 2px; color: var(--sat-color-primary); }

/* 程式碼片段 */
.d-pre, .ex__code pre {
  margin: 8px 0 0; padding: 14px 16px; overflow-x: auto;
  border-radius: 8px; background: #17191c; color: #e4e4e4;
  font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.65;
  tab-size: 2;
}
.d-pre code, .ex__code code { padding: 0; background: none; color: inherit; font-size: inherit; }
.d-snippet { position: relative; max-width: 720px; }
.d-snippet .d-pre { padding-right: 84px; white-space: pre-wrap; word-break: break-all; }
.d-copy {
  position: absolute; top: 8px; right: 8px;
  height: 28px; padding: 0 10px; border: 1px solid rgba(255,255,255,.2); border-radius: 6px;
  background: rgba(255,255,255,.08); color: #fff; font: inherit; font-size: 12px; cursor: pointer;
}
.d-copy:hover { background: rgba(255,255,255,.16); }

/* 範例區 */
.ex { margin: 12px 0 16px; overflow: hidden; border: 1px solid var(--sat-color-border); border-radius: 10px; }
.ex__preview { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; padding: 24px; background: #fff; }
.ex__preview--col { flex-direction: column; align-items: stretch; }
.ex__preview--flush { display: block; padding: 0; }
.ex__code { border-top: 1px solid var(--sat-color-border); background: var(--sat-color-bg-subtle); }
.ex__code > summary {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 16px; color: var(--sat-color-text-caption); font-size: 13px; cursor: pointer; list-style: none;
}
.ex__code > summary::-webkit-details-marker { display: none; }
.ex__code > summary::before { content: "‹/›"; font-family: monospace; }
.ex__code[open] > summary { color: var(--sat-color-text-body); }
.ex__code .d-codewrap { position: relative; padding: 0 12px 12px; }
.ex__code pre { max-height: 420px; margin: 0; }

[data-pick] .d-pickable { cursor: copy; }
[data-pick] .d-pickable:hover { outline: 2px dashed var(--sat-primary-200); outline-offset: 3px; }
.d-dark { background: #17191c; }

/* 按鈕矩陣 */
.d-matrix { width: 100%; border-collapse: collapse; }
.d-matrix-wrap { overflow-x: auto; }
.d-matrix th { padding: 10px 12px; color: var(--sat-color-text-caption); font-size: 12px; font-weight: 400; text-align: left; white-space: nowrap; }
.d-matrix thead th { border-bottom: 1px solid var(--sat-color-border); background: var(--sat-color-bg-subtle); }
.d-matrix td { padding: 12px; white-space: nowrap; }
.d-matrix tbody tr + tr td, .d-matrix tbody tr + tr th { border-top: 1px dashed var(--sat-color-border); }

/* 色票 */
.d-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.d-swatch { display: flex; flex-direction: column; padding: 0; overflow: hidden; border: 1px solid var(--sat-color-border); border-radius: 8px; background: #fff; font: inherit; text-align: left; cursor: copy; }
.d-swatch:hover { border-color: var(--sat-color-border-hover); }
.d-swatch__chip { height: 52px; }
.d-swatch__chip--alpha { background-image: linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%), linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%); background-size: 12px 12px; background-position: 0 0, 6px 6px; }
.d-swatch__meta { padding: 8px 10px; font-size: 12px; line-height: 18px; }
.d-swatch__name { color: var(--sat-color-text-heading); word-break: break-all; }
.d-swatch__val { color: var(--sat-color-text-caption); font-family: "SF Mono", Menlo, monospace; }
.d-ramp { margin: 8px 0 20px; }
.d-ramp__title { margin: 0 0 6px; color: var(--sat-color-text-caption); font-size: 13px; }
.d-ramp__row { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); overflow: hidden; border: 1px solid var(--sat-color-border); border-radius: 8px; }
.d-ramp__row .d-swatch { border: 0; border-radius: 0; }
.d-ramp__row .d-swatch__chip { height: 44px; }

/* 字級 */
.d-type { border: 1px solid var(--sat-color-border); border-radius: 10px; }
.d-type__row { display: grid; grid-template-columns: 180px minmax(0, 1fr); align-items: baseline; gap: 16px; padding: 14px 20px; border-bottom: 1px solid var(--sat-color-border); cursor: copy; }
.d-type__row:last-child { border-bottom: 0; }
.d-type__row:hover { background: var(--sat-color-bg-subtle); }
.d-type__meta { color: var(--sat-color-text-caption); font-size: 12px; line-height: 18px; }
.d-type__meta strong { display: block; color: var(--sat-color-text-heading); font-size: 13px; font-weight: 500; }
.d-type__sample { overflow: hidden; color: var(--sat-color-text-heading); text-overflow: ellipsis; white-space: nowrap; }

/* 陰影、圓角 */
.d-shadow-row { gap: 24px; padding: 32px; background: var(--sat-color-bg-subtle); }
.d-shadow-box { display: flex; flex-direction: column; justify-content: center; width: 180px; height: 110px; padding: 16px; border-radius: 8px; background: #fff; font-size: 13px; line-height: 1.6; }
.d-tokens { display: flex; flex-wrap: wrap; gap: 12px; }
.d-radius { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px; border: 1px solid var(--sat-color-border); border-radius: 8px; background: #fff; font: inherit; font-size: 12px; cursor: copy; }
.d-radius__box { width: 56px; height: 56px; border: 2px solid var(--sat-color-primary); background: var(--sat-color-primary-subtle); }

/* Icon */
.d-icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 8px; margin-top: 16px; }
.d-icon { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 6px 10px; border: 1px solid var(--sat-color-border); border-radius: 8px; background: #fff; color: var(--sat-color-text-body); font: inherit; font-size: 11px; line-height: 1.3; cursor: copy; word-break: break-all; }
.d-icon:hover { border-color: var(--sat-color-primary); color: var(--sat-color-primary); }

/* 表單排版 */
.d-form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); align-items: start; gap: 24px; }
.d-tooltip-row { gap: 32px; padding: 32px; }
.d-modal-stage { justify-content: center; padding: 40px 16px; background: var(--sat-color-overlay); }

/* Toast */
.d-toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 2000;
  padding: 8px 16px; border-radius: 8px; background: #17191c; color: #fff; font-size: 14px;
  opacity: 0; pointer-events: none; transform: translate(-50%, 8px); transition: opacity .2s, transform .2s;
}
.d-toast.is-show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1023px) {
  .d-layout { grid-template-columns: minmax(0, 1fr); }
  .d-menu-btn { display: inline-flex; margin-left: -8px; }
  .d-nav {
    position: fixed; top: 56px; left: 0; z-index: 40;
    width: 260px; height: calc(100dvh - 56px);
    background: #fff; box-shadow: var(--sat-shadow-popover);
    transform: translateX(-105%); transition: transform .25s cubic-bezier(.2,.8,.2,1);
  }
  .d-nav.is-open { transform: none; }
  .d-main { padding: 32px 24px 64px; }
}
@media (max-width: 599px) {
  .d-top__figma { font-size: 0; gap: 0; }
  .d-main { padding: 24px 16px 56px; }
  .ex__preview { padding: 20px 16px; }
  .d-type__row { grid-template-columns: minmax(0, 1fr); gap: 4px; padding: 12px 16px; }
  .d-shadow-row { padding: 20px 16px; }
  .d-shadow-box { width: calc(50% - 12px); }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }
.d-col-start { align-items: flex-start; }
