/* ============================================================
   親手試試 · demo stage 共用樣式
   demo 舞台刻意做成「課本插圖」的乾淨紙面，
   與站體的米色紙做出層次，但不搶戲。
   ============================================================ */

.demo-figure { margin: 0; }
.demo-stage {
  position: relative;
  background: #fdfbf5;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 34px 34px 30px;
  overflow: hidden;
}
.demo-stage::before {
  content: attr(data-try);
  position: absolute; top: 10px; left: 14px;
  font-size: 11.5px; letter-spacing: 0.2em;
  color: var(--ink-3); font-family: var(--mono);
  writing-mode: horizontal-tb;
}
.demo-stage.is-interactive::before { color: var(--red-deep); }
.demo-figure figcaption {
  margin-top: 12px; text-align: center;
  font-family: var(--serif); font-size: 13.5px; color: var(--ink-3);
  letter-spacing: 0.06em;
}
.demo-figure figcaption b { color: var(--ink-2); font-weight: 700; }

/* demo 內部通用元素 —— 刻意用另一套「成品感」的元件樣式，
   讓讀者意識到：這是「做出來的網站」，不是課本本身。 */

.dw { /* demo widget 基底 */
  font-size: 15px; line-height: 1.7;
}

.dw-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: 14.5px; font-weight: 600;
  border-radius: 8px; padding: 9px 20px; cursor: pointer;
  border: 1.5px solid transparent;
  transition: all 0.15s ease;
  user-select: none;
}
.dw-btn-primary { background: #3b6ea5; color: #fff; }
.dw-btn-primary:hover { background: #2f5a8a; }
.dw-btn-secondary { background: #fff; color: #3b6ea5; border-color: #3b6ea5; }
.dw-btn-secondary:hover { background: #eef3f8; }
.dw-btn-danger { background: #b23a2a; color: #fff; }
.dw-btn-danger:hover { background: #8f2b1e; }
.dw-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.dw-btn:focus-visible { outline: 2.5px solid #3b6ea5; outline-offset: 2px; }

.dw-input {
  font: inherit; font-size: 14.5px;
  width: 100%; padding: 10px 14px;
  border: 1.5px solid #c9c2b2; border-radius: 8px;
  background: #fff; color: #333;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.dw-input:focus { outline: none; border-color: #3b6ea5; box-shadow: 0 0 0 3px rgba(59, 110, 165, 0.15); }
.dw-input.is-error { border-color: #b23a2a; box-shadow: 0 0 0 3px rgba(178, 58, 42, 0.12); }
.dw-label { display: block; font-size: 13.5px; font-weight: 600; color: #555; margin-bottom: 6px; }
.dw-error-text { font-size: 12.5px; color: #b23a2a; margin-top: 5px; min-height: 1em; }
.dw-hint { font-size: 12.5px; color: #8a8371; margin-top: 5px; }

.dw-card {
  background: #fff; border: 1.5px solid #ddd5c2; border-radius: 10px;
  box-shadow: 0 1px 3px rgba(50, 40, 15, 0.08);
}

.dw-note {
  font-size: 13px; color: #6d6350; margin-top: 18px;
  padding-top: 12px; border-top: 1px dashed #ddd2ba;
}
.dw-note b { color: #b23a2a; font-weight: 600; }

/* toast 容器 */
.dw-toast-region {
  position: absolute; right: 18px; bottom: 16px;
  display: flex; flex-direction: column; gap: 8px; z-index: 5;
  pointer-events: none;
}
.dw-toast {
  display: flex; align-items: center; gap: 10px;
  background: #2e2a22; color: #f4efe2;
  font-size: 13.5px; padding: 10px 16px; border-radius: 9px;
  box-shadow: 0 6px 20px -6px rgba(0, 0, 0, 0.4);
  opacity: 0; transform: translateY(10px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.dw-toast.show { opacity: 1; transform: none; }
.dw-toast .t-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dw-toast.t-success .t-dot { background: #7fb069; }
.dw-toast.t-error .t-dot { background: #e06550; }
.dw-toast.t-info .t-dot { background: #6aa1d0; }

/* modal */
.dw-overlay {
  position: absolute; inset: 0; z-index: 10;
  background: rgba(30, 25, 15, 0.45);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.dw-overlay.open { opacity: 1; pointer-events: auto; }
.dw-modal {
  width: min(340px, 86%); background: #fff; border-radius: 14px;
  padding: 26px 26px 20px; text-align: center;
  transform: translateY(12px) scale(0.97); transition: transform 0.2s ease;
  box-shadow: 0 24px 60px -18px rgba(0, 0, 0, 0.45);
}
.dw-overlay.open .dw-modal { transform: none; }
.dw-modal h4 { font-size: 17px; color: #2e2a22; margin-bottom: 8px; font-family: inherit; font-weight: 700; }
.dw-modal p { font-size: 14px; color: #6d6350; margin-bottom: 20px; }
.dw-modal .m-actions { display: flex; gap: 10px; justify-content: center; }

/* skeleton */
.dw-skel {
  border-radius: 6px;
  background: linear-gradient(90deg, #ece6d8 25%, #f6f1e6 45%, #ece6d8 65%);
  background-size: 240% 100%;
  animation: dw-shimmer 1.3s linear infinite;
}
@keyframes dw-shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }
@media (prefers-reduced-motion: reduce) { .dw-skel { animation: none; } }

/* 下拉選單 */
.dw-select-wrap { position: relative; width: 100%; }
.dw-select-btn {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  font: inherit; font-size: 14.5px; text-align: left;
  background: #fff; border: 1.5px solid #c9c2b2; border-radius: 8px;
  padding: 10px 14px; cursor: pointer;
}
.dw-select-btn .car { transition: transform 0.18s ease; color: #8a8371; }
.dw-select-wrap.open .dw-select-btn { border-color: #3b6ea5; }
.dw-select-wrap.open .car { transform: rotate(180deg); }
.dw-select-menu {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 6;
  background: #fff; border: 1.5px solid #c9c2b2; border-radius: 10px;
  box-shadow: 0 12px 30px -10px rgba(50, 40, 15, 0.3);
  padding: 5px; max-height: 0; overflow: hidden; opacity: 0;
  transition: max-height 0.22s ease, opacity 0.18s ease;
}
.dw-select-wrap.open .dw-select-menu { max-height: 240px; opacity: 1; overflow-y: auto; }
.dw-select-menu button {
  display: flex; width: 100%; justify-content: space-between; align-items: center;
  font: inherit; font-size: 14px; text-align: left;
  background: none; border: 0; border-radius: 7px;
  padding: 9px 12px; cursor: pointer; color: #333;
}
.dw-select-menu button:hover { background: #eef3f8; }
.dw-select-menu button[aria-selected="true"] { color: #3b6ea5; font-weight: 700; }

/* switch */
.dw-switch {
  position: relative; width: 46px; height: 26px; flex: none;
  background: #cfc8b8; border: 0; border-radius: 999px; cursor: pointer;
  transition: background-color 0.2s ease;
}
.dw-switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s cubic-bezier(0.34, 1.4, 0.64, 1);
}
.dw-switch[aria-checked="true"] { background: #3b6ea5; }
.dw-switch[aria-checked="true"]::after { transform: translateX(20px); }
.dw-switch:focus-visible { outline: 2.5px solid #3b6ea5; outline-offset: 2px; }

/* 導覽列 demo */
.dw-navbar {
  display: flex; align-items: center; gap: 18px;
  background: #2e2a22; border-radius: 10px 10px 0 0; padding: 12px 18px;
}
.dw-navbar .nv-brand { color: #f4efe2; font-weight: 800; font-size: 14.5px; }
.dw-navbar .nv-links { display: flex; gap: 4px; margin-left: auto; }
.dw-navbar .nv-links a {
  font-size: 13.5px; color: rgba(244, 239, 226, 0.72); text-decoration: none;
  padding: 5px 11px; border-radius: 6px; cursor: pointer;
}
.dw-navbar .nv-links a:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.dw-navbar .nv-links a[aria-current] { color: #ffd98a; background: rgba(255, 217, 138, 0.12); }
.dw-scroll-area {
  height: 200px; overflow-y: auto; background: #fff;
  border: 1.5px solid #ddd5c2; border-top: 0; border-radius: 0 0 10px 10px;
  padding: 18px 22px; font-size: 13.5px; color: #555;
}
.dw-scroll-area h5 { font-size: 14px; color: #2e2a22; margin: 0 0 6px; font-weight: 700; }
.dw-scroll-area h5:not(:first-child) { margin-top: 18px; }
.dw-scroll-area p { line-height: 1.8; }

/* 地址列 */
.dw-addressbar {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border: 1.5px solid #c9c2b2; border-radius: 999px;
  padding: 9px 18px; font-family: var(--mono); font-size: 13.5px;
}
.dw-addressbar .lock { color: #55805a; flex: none; }

/* 終端/回應區 */
.dw-console {
  background: #26221b; border-radius: 10px; padding: 16px 18px;
  font-family: var(--mono); font-size: 12.8px; line-height: 1.9;
  color: #d8d2c0; overflow-x: auto;
}
.dw-console .c-req { color: #8fb8dd; }
.dw-console .c-res { color: #a5c98f; }
.dw-console .c-dim { color: #7a7260; }
.dw-console .c-key { color: #e8c57a; }

/* 假裝是瀏覽器的窗 */
.dw-browser { border-radius: 10px; overflow: hidden; border: 1.5px solid #c9c2b2; background: #fff; }
.dw-browser .br-bar {
  display: flex; align-items: center; gap: 8px;
  background: #efe9db; padding: 9px 14px; border-bottom: 1.5px solid #ddd5c2;
}
.dw-browser .br-dot { width: 10px; height: 10px; border-radius: 50%; background: #cfc5ab; }
.dw-browser .br-url {
  flex: 1; background: #fff; border-radius: 999px; font-size: 12px;
  font-family: var(--mono); color: #8a8371; padding: 5px 14px;
}
.dw-browser .br-body { padding: 20px 22px; }

/* 裝置外框（RWD demo 用） */
.dw-device { margin: 0 auto; background: #fff; border: 1.5px solid #c9c2b2; border-radius: 12px; overflow: hidden; transition: max-width 0.35s ease; }
.dw-device .dv-head { background: #2e2a22; padding: 7px 12px; display: flex; gap: 6px; }
.dw-device .dv-head i { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,0.25); }
.dw-device .dv-body { padding: 16px; }

/* 標籤 chips */
.dw-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.dw-chip {
  font: inherit; font-size: 13px; font-weight: 600;
  background: #fff; color: #555;
  border: 1.5px solid #c9c2b2; border-radius: 999px;
  padding: 6px 14px; cursor: pointer;
  transition: all 0.15s ease;
}
.dw-chip:hover { border-color: #3b6ea5; color: #3b6ea5; }
.dw-chip[aria-pressed="true"] { background: #3b6ea5; border-color: #3b6ea5; color: #fff; }

/* ============ 產生器範本共用樣式 ============ */

.dw-tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.dw-tab {
  font: inherit; font-size: 13.5px; font-weight: 600;
  background: #fff; color: #555; border: 1.5px solid #c9c2b2;
  border-radius: 999px; padding: 7px 16px; cursor: pointer;
  transition: all 0.15s ease;
}
.dw-tab:hover { border-color: #3b6ea5; color: #3b6ea5; }
.dw-tab[aria-selected="true"] { background: #3b6ea5; border-color: #3b6ea5; color: #fff; }
.dw-tabpanes .dw-pane { display: none; animation: dw-fade 0.25s ease; }
.dw-tabpanes .dw-pane.on { display: block; }
@keyframes dw-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.dw-ba { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dw-ba .pane { border-radius: 10px; padding: 16px 18px; font-size: 14px; line-height: 1.8; }
.dw-ba .pane.ng { background: #f6ded8; border: 1.5px solid #e3c1b6; }
.dw-ba .pane.ok { background: #e9eddf; border: 1.5px solid #c4cdb0; }
.dw-ba .pane .p-tag { font-size: 12px; font-weight: 700; letter-spacing: 0.16em; margin-bottom: 10px; display: block; }
.dw-ba .pane.ng .p-tag { color: #8f2b1e; }
.dw-ba .pane.ok .p-tag { color: #55673a; }
@media (max-width: 560px) { .dw-ba { grid-template-columns: 1fr; } }

.dw-chat { max-width: 520px; display: flex; flex-direction: column; gap: 12px; }
.dw-chat .bubble { max-width: 86%; padding: 12px 16px; border-radius: 14px; font-size: 14px; line-height: 1.9; }
.dw-chat .bubble.user { align-self: flex-end; background: #3b6ea5; color: #fff; border-bottom-right-radius: 4px; }
.dw-chat .bubble.ai { align-self: flex-start; background: #fff; border: 1.5px solid #ddd5c2; border-bottom-left-radius: 4px; color: #3f3a30; }
.dw-chat .bubble b { font-weight: 700; }
.dw-chat .bubble.hidden { display: none; }

.dw-progress { height: 10px; background: #ece6d8; border-radius: 999px; overflow: hidden; }
.dw-progress i { display: block; height: 100%; background: #7fb069; border-radius: 999px; transition: width 0.3s ease; }
.dw-checklist { max-width: 460px; }
.dw-checklist label {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 6px; border-bottom: 1px dashed #e4dcc8;
  font-size: 14.5px; cursor: pointer; color: #444;
}
.dw-checklist input { width: 17px; height: 17px; accent-color: #3b6ea5; flex: none; }
.dw-checklist input:checked + span { color: #a09879; text-decoration: line-through; }

.dw-git { display: flex; flex-direction: column; gap: 0; max-width: 520px; }
.dw-git .commit { position: relative; padding: 0 0 18px 34px; cursor: pointer; }
.dw-git .commit::before {
  content: ""; position: absolute; left: 6px; top: 4px; bottom: -2px;
  width: 2.5px; background: #d5cdba;
}
.dw-git .commit:last-child::before { display: none; }
.dw-git .commit .dot {
  position: absolute; left: 0; top: 3px;
  width: 15px; height: 15px; border-radius: 50%;
  background: #fff; border: 3px solid #3b6ea5;
}
.dw-git .commit.on .dot { background: #3b6ea5; }
.dw-git .commit .cm-msg { font-size: 14px; font-weight: 600; color: #333; }
.dw-git .commit .cm-hash { font-family: var(--mono); font-size: 11px; color: #a09879; margin-left: 8px; }
.dw-git .commit:hover .cm-msg { color: #3b6ea5; }
.dw-git-detail {
  margin-top: 8px; background: #26221b; border-radius: 10px;
  padding: 14px 18px; font-family: var(--mono); font-size: 12.5px; line-height: 1.9;
  color: #d8d2c0; min-height: 66px;
}
.dw-git-detail .g-add { color: #a5c98f; }
.dw-git-detail .g-del { color: #e06550; }

.dw-bars { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.dw-bars .bar-row { display: grid; grid-template-columns: 92px 1fr 70px; gap: 10px; align-items: center; font-size: 13px; color: #555; }
.dw-bars .bar-track { height: 14px; background: #ece6d8; border-radius: 7px; overflow: hidden; }
.dw-bars .bar-fill { height: 100%; background: #3b6ea5; border-radius: 7px; transition: width 0.35s ease; }
.dw-bars .bar-val { font-family: var(--mono); font-size: 12.5px; text-align: right; color: #333; }

.dw-palettes { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.dw-palette {
  display: flex; border: 1.5px solid #c9c2b2; border-radius: 9px; overflow: hidden;
  cursor: pointer; background: none; padding: 0; font: inherit;
  transition: transform 0.13s ease, box-shadow 0.13s ease;
}
.dw-palette:hover { transform: translateY(-2px); box-shadow: 0 8px 18px -8px rgba(50,40,15,0.3); }
.dw-palette i { width: 26px; height: 30px; display: block; }
.dw-palette span { padding: 6px 10px; font-size: 12px; font-weight: 600; color: #555; align-self: center; }

.dw-play-preview {
  background: #fff; border: 1.5px solid #ddd5c2; border-radius: 12px;
  padding: 26px 24px; margin-bottom: 16px; min-height: 120px;
  display: flex; flex-direction: column; justify-content: center; gap: 10px;
}
.dw-play-preview .ttl { font-size: 17px; font-weight: 800; color: #2e2a22; }
.dw-play-preview .txt { font-size: 14px; color: #6d6350; line-height: 1.8; }
.dw-play-preview .btn-mock {
  align-self: flex-start; font-size: 13px; font-weight: 700; color: #fff;
  background: var(--pv-accent, #3b6ea5); border-radius: 8px; padding: 8px 18px;
}
.dw-play-controls { display: flex; gap: 16px 22px; flex-wrap: wrap; align-items: center; }
.dw-play-controls .ctl { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #555; }
.dw-play-controls input[type="range"] { accent-color: #3b6ea5; }
.dw-play-controls input[type="color"] { width: 34px; height: 26px; border: 1.5px solid #c9c2b2; border-radius: 6px; padding: 0; background: #fff; cursor: pointer; }
.dw-play-controls select { font: inherit; font-size: 13px; border: 1.5px solid #c9c2b2; border-radius: 7px; padding: 4px 8px; background: #fff; }

.dw-carousel { position: relative; overflow: hidden; border-radius: 12px; border: 1.5px solid #ddd5c2; background: #fff; }
.dw-carousel .c-track { display: flex; transition: transform 0.35s ease; }
.dw-carousel .c-slide { flex: 0 0 100%; padding: 30px 26px; text-align: center; }
.dw-carousel .c-slide .big { font-size: 40px; }
.dw-carousel .c-slide h4 { font-size: 16px; color: #2e2a22; margin: 8px 0 6px; }
.dw-carousel .c-slide p { font-size: 13.5px; color: #7a7260; }
.dw-carousel .c-nav { display: flex; justify-content: space-between; align-items: center; padding: 0 14px 14px; }
.dw-carousel .c-dots { display: flex; gap: 7px; }
.dw-carousel .c-dots i { width: 8px; height: 8px; border-radius: 50%; background: #d5cdba; cursor: pointer; transition: background-color 0.15s ease; }
.dw-carousel .c-dots i.on { background: #3b6ea5; }
.dw-carousel .c-btn { background: none; border: 1.5px solid #c9c2b2; border-radius: 999px; width: 32px; height: 32px; font-size: 15px; cursor: pointer; color: #555; }
.dw-carousel .c-btn:hover { border-color: #3b6ea5; color: #3b6ea5; }

.dw-urlout {
  display: flex; align-items: center; gap: 10px; margin-top: 14px;
  background: #26221b; border-radius: 10px; padding: 12px 16px;
  font-family: var(--mono); font-size: 12.5px; color: #e8c57a;
  word-break: break-all;
}
.dw-urlout button {
  margin-left: auto; flex: none; background: rgba(248,243,231,0.12); color: #f2ecdd;
  border: 1px solid rgba(248,243,231,0.3); border-radius: 999px;
  font-size: 12px; padding: 4px 12px; cursor: pointer;
}
.dw-urlout button:hover { background: rgba(248,243,231,0.22); }
