/* 共用頁首、頁尾、工作坊步驟列、投影模式 */
header.content-header, header.site-header:not([data-shell-header]),
footer.content-footer, footer.site-footer:not([data-shell-footer]) { display: none; }

.site-header[data-shell-header] { position: sticky; top: 0; z-index: 40; background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--rule); }
.sh-inner { width: min(var(--wrap), calc(100% - 48px)); height: var(--header-h); margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.sh-brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-size: 13px; line-height: 1.28; letter-spacing: .04em; white-space: nowrap; }
.sh-brand strong { font: 600 16px var(--font-serif); }
.sh-mark { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--ink); font: 600 20px var(--font-serif); }
.sh-nav { margin-left: auto; display: flex; align-items: center; gap: clamp(16px, 2.6vw, 36px); font-size: 14px; font-weight: 650; }
.sh-nav a { color: var(--ink); text-decoration: none; padding: 8px 0; border-bottom: 2px solid transparent; white-space: nowrap; }
.sh-nav a:hover { color: var(--accent); }
.sh-nav a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
.sh-tools { display: flex; align-items: center; gap: 12px; }
.sh-present { min-height: 32px; padding: 2px 10px; border: 1px solid var(--rule); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink-2); font-size: var(--fs-xs); font-weight: 600; cursor: pointer; }
.sh-present[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }

/* 工具頁（app shell） */
.site-header[data-shell-header].is-app { background: var(--surface); }
.is-app .sh-inner { height: 44px; width: calc(100% - 32px); max-width: none; font-size: 14px; }
.is-app .sh-title { font-weight: 700; }
.is-app a { color: var(--accent); text-decoration: none; font-weight: 600; white-space: nowrap; }
.is-app a:hover { text-decoration: underline; }
.is-app .sh-sub { display: flex; gap: 16px; align-items: center; }

/* 步驟列 */
.workshop-stepper { background: var(--surface); border-bottom: 1px solid var(--rule); }
.ws-inner { width: min(var(--wrap), calc(100% - 48px)); margin: 0 auto; display: flex; align-items: stretch; gap: 4px; min-height: 48px; }
.ws-steps { display: flex; gap: 4px; flex: 1; list-style: none; margin: 0; padding: 6px 0; overflow-x: auto; }
.ws-steps a { display: flex; align-items: center; gap: 8px; height: 100%; padding: 0 12px; border-radius: var(--radius); color: var(--ink-2); font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.ws-steps a:hover { background: var(--surface-2); color: var(--ink); }
.ws-steps a[aria-current="step"] { background: var(--olive); color: #fff; }
.ws-num { font-family: var(--font-mono); }
.ws-ref { position: relative; align-self: center; }
.ws-ref summary { list-style: none; cursor: pointer; padding: 6px 12px; font-size: 14px; font-weight: 600; color: var(--ink-2); border-radius: var(--radius); min-height: 36px; display: flex; align-items: center; }
.ws-ref summary::-webkit-details-marker { display: none; }
.ws-ref[open] summary, .ws-ref summary:hover { background: var(--surface-2); }
.ws-ref-menu { position: absolute; right: 0; top: 100%; z-index: 20; min-width: 260px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px; display: grid; }
.ws-ref-menu a { padding: 8px 12px; color: var(--ink); text-decoration: none; font-size: 14px; border-radius: var(--radius-sm); }
.ws-ref-menu a:hover { background: var(--surface-2); }
.ws-mobile { display: none; }

.step-pager { width: min(var(--wrap), calc(100% - 48px)); margin: 48px auto 0; padding-top: 24px; border-top: 1px solid var(--rule); display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.step-pager a { display: block; padding: 16px 20px; border: 1px solid var(--rule); border-radius: var(--radius-lg); background: var(--surface); color: var(--ink); text-decoration: none; }
.step-pager a:hover { border-color: var(--ink); }
.step-pager small { display: block; color: var(--ink-2); font-size: var(--fs-xs); }
.step-pager strong { font-size: var(--fs-md); }
.step-pager .next { text-align: right; grid-column: 2; }
.step-pager .prev { grid-column: 1; }

/* 頁尾 */
.site-footer[data-shell-footer] { margin-top: 64px; border-top: 1px solid var(--rule); background: var(--surface-2); color: var(--ink-2); font-size: 14px; }
.sf-inner { width: min(var(--wrap), calc(100% - 48px)); margin: 0 auto; padding: 40px 0 32px; display: grid; grid-template-columns: 1.2fr 1fr 1.2fr; gap: 40px; }
.sf-inner h2 { font: 600 15px var(--font-sans); color: var(--ink); margin: 0 0 10px; }
.sf-inner p { margin: 0 0 6px; }
.sf-inner ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.sf-inner a { color: var(--ink-2); }
.sf-inner a:hover { color: var(--accent); }
.sf-brand { font: 600 17px var(--font-serif); color: var(--ink); }

/* 投影模式 */
html.present { font-size: 125%; }
html.present .site-footer[data-shell-footer], html.present .jitong-floating-trigger, html.present #jitong-root { display: none !important; }
html.present .sh-inner, html.present .ws-inner, html.present .step-pager { width: min(1280px, calc(100% - 48px)); }

@media (max-width: 960px) { .sf-inner { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) {
  .site-header[data-shell-header] { position: static; }
  html { scroll-padding-top: 16px; }
  .sh-inner { width: calc(100% - 32px); height: auto; display: block; padding-top: 10px; }
  .sh-brand { min-height: 42px; }
  .sh-nav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; margin-top: 4px; }
  .sh-nav a { text-align: center; font-size: 13px; min-height: 44px; display: flex; align-items: center; justify-content: center; padding: 0; }
  .sh-tools { margin: 6px 0; }
  .is-app .sh-inner { display: flex; height: 44px; padding: 0; }
  .ws-inner { width: calc(100% - 32px); }
  .ws-steps, .ws-ref { display: none; }
  .ws-mobile { display: block; width: 100%; padding: 6px 0; }
  .ws-mobile summary { min-height: 40px; display: flex; align-items: center; justify-content: space-between; cursor: pointer; font-weight: 700; font-size: 14px; list-style: none; }
  .ws-mobile summary::-webkit-details-marker { display: none; }
  .ws-mobile ol { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 2px; }
  .ws-mobile a { display: block; padding: 10px 8px; color: var(--ink); text-decoration: none; border-radius: var(--radius-sm); font-size: 14px; }
  .ws-mobile a[aria-current="step"] { background: var(--olive); color: #fff; }
  .step-pager { width: calc(100% - 32px); grid-template-columns: 1fr; }
  .step-pager .next, .step-pager .prev { grid-column: 1; text-align: left; }
  .sf-inner { grid-template-columns: 1fr; gap: 24px; width: calc(100% - 32px); }
}

/* sticky 側欄要避開 sticky 頁首 */
.content-sidebar { top: calc(var(--header-h) + 24px); }
@media (max-width: 640px) { .content-sidebar { top: 24px; } }

/* skip link（部分工具頁沒有自己的樣式） */
.skip-link { position: absolute; top: -100px; left: 12px; z-index: 100; background: var(--surface); color: var(--ink); padding: 8px 12px; border: 1px solid var(--ink); border-radius: var(--radius-sm); }
.skip-link:focus { top: 8px; }
@media (max-width: 640px) { .sh-tools { display: none; } }

/* Data Atoms：吐司置中、避免擋到圖表角落 */
.toast-notice { left: 0 !important; right: 0 !important; bottom: 16px !important; margin-inline: auto; width: max-content; max-width: calc(100% - 32px); }
.brand-version-chip.tag { font-size: 11px; padding: 1px 8px; }
@media (max-width: 640px) { .is-app .sh-title, .is-app .sh-manual { display: none; } .is-app .sh-inner { justify-content: space-between; } }

/* V2：工具頁小螢幕提示 */
.app-gate { padding: 32px 16px; }
.app-gate .card { max-width: 440px; margin: 0 auto; }
.app-gate h1 { margin: 0 0 8px; font: 600 var(--fs-xl)/1.3 var(--font-serif); }
.app-gate p { margin: 0 0 20px; color: var(--ink-2); }
.app-gate-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.app-gate-skip { margin-top: 24px; padding: 8px 0; min-height: 44px; border: 0; background: none; color: var(--ink-2); font: var(--fs-sm) var(--font-sans); text-decoration: underline; cursor: pointer; }
html.app-gated .app-shell { display: none !important; }
html.app-gated, html.app-gated body { height: auto !important; overflow: auto !important; background: var(--paper); }
html.app-gated .toast-notice { display: none !important; }


/* ===== 水墨版頁首／頁尾 ===== */
.site-header[data-shell-header] { transition: background-color .9s ease, border-color .9s ease; }
.sh-inner { height: 72px; }
:root { --header-h: 72px; }
.sh-mark { width: 38px; height: 38px; border: 1.5px solid var(--seal); border-radius: 3px; color: var(--seal); font-size: 21px; }
html[data-theme="night"] .sh-mark { background: var(--seal); color: #fff8ec; }
.sh-brand { letter-spacing: .14em; }
.sh-brand strong { font-weight: 500; letter-spacing: .3em; }
.sh-nav { font-weight: 500; letter-spacing: .12em; font-size: 15px; }
.sh-nav a[aria-current="page"] { color: var(--seal); border-bottom-color: var(--seal); }
html[data-theme="night"] .sh-nav a[aria-current="page"] { color: var(--gold); border-bottom-color: var(--gold); }
.sh-theme { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; margin-left: 8px; padding: 0; border: 0; background: none; color: var(--ink-2); font: 13px var(--font-sans); letter-spacing: .15em; cursor: pointer; }
.sh-theme-seal { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--seal); color: #fff8ec; font: 500 17px/1 var(--font-serif); }
.ws-steps a[aria-current="step"], .ws-mobile a[aria-current="step"] { background: var(--ink); color: var(--paper); }
.step-pager a { background: transparent; }
.site-footer[data-shell-footer] { background: transparent; border-top: 1px solid var(--rule); position: relative; }
.sf-hills { display: block; width: 100%; height: 110px; color: var(--ink); }
html[data-theme="night"] .sf-hills { display: none; }
.sf-brand { font-weight: 500; letter-spacing: .2em; }
.sh-present { background: transparent; border-radius: var(--radius); }
@media (max-width: 640px) {
  .sh-inner { height: auto; }
  .sh-theme { position: absolute; top: 10px; right: 16px; }
  .sh-theme span:first-child { display: none; }
  .site-header[data-shell-header] { position: relative; }
  .sh-nav { font-size: 13px; letter-spacing: .04em; }
}
