/* workbench.css — 沉浸式 Claude Code 工作台。左邊仿工具的深色對話區，右邊是做出來的網頁。 */

.wb {
  --wb-bg: #1f1d1a; --wb-panel: #2a2724; --wb-ink: #ece6dd; --wb-dim: #a59c90; --wb-accent: #d97757; --wb-line: #3b3733;
  position: relative; border-radius: var(--radius-l); overflow: hidden; box-shadow: var(--shadow-lift);
  border: 1px solid var(--line); background: var(--card);
}
.wb-top [data-wb-reset] { border-color: var(--brand); color: var(--brand); font-weight: 800; background: var(--card); }
.wb-top [data-wb-reset]:hover { background: var(--brand-fill); color: #fff; }
.wb-top { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--paper-2); }
.wb-missions { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.wb-missions li { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; font-weight: 700; color: var(--muted); border: 1.5px solid var(--line); border-radius: 999px; padding: 3px 10px 3px 4px; background: var(--card); transition: all var(--normal) var(--ease); }
.wb-missions li span { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--paper-2); font-size: .75rem; }
.wb-missions li.is-now { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.wb-missions li.is-now span { background: var(--brand-fill); color: #fff; }
.wb-missions li.is-done { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.wb-missions li.is-done span { background: var(--ok-fill); color: #fff; font-size: 0; }
.wb-missions li.is-done span::after { content: "✓"; font-size: .75rem; }

.wb-main { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); min-height: min(560px, 74vh); }
@media (max-width: 820px) { .wb-main { grid-template-columns: 1fr; } }

.wb-chat { display: flex; flex-direction: column; background: var(--wb-bg); color: var(--wb-ink); min-width: 0; }
.wb-bar { display: flex; gap: 12px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--wb-line); font-size: .85rem; }
.wb-bar b { color: var(--wb-accent); }
.wb-bar span { color: var(--wb-dim); font-family: var(--mono); }
.wb-bar em { margin-left: auto; font-style: normal; font-size: .75rem; color: var(--wb-dim); border: 1px solid var(--wb-line); border-radius: 6px; padding: 1px 6px; }
/* 高度跟著視窗走：縮放或小螢幕時，輸入框和送出鍵一定還看得到 */
.wb-chat { max-height: min(640px, 84vh); }
.wb-log { flex: 1 1 auto; min-height: 180px; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }
.wb-input { flex: none; }
.wb-msg { animation: pop 320ms var(--ease) both; font-size: .95rem; line-height: 1.65; }
.wb-msg p { margin: 0; }
.wb-av { flex: none; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: .9rem; }
.msg-claude { display: flex; gap: 10px; align-items: flex-start; }
.msg-claude .wb-av { background: var(--wb-accent); color: #fff; }
.msg-typing { gap: 5px; padding: 8px 0 0 36px; }
.msg-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--wb-dim); animation: wb-dot 1s infinite ease-in-out; }
.msg-typing i:nth-child(2) { animation-delay: .15s; }
.msg-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes wb-dot { 50% { transform: translateY(-4px); opacity: .4; } }
.msg-you { align-self: flex-end; max-width: 85%; background: #3a4a8a; color: #eef0ff; border-radius: 14px 14px 4px 14px; padding: 8px 12px; }
.msg-coach { display: flex; gap: 10px; align-items: flex-start; border-radius: 12px; padding: 10px 12px; background: #2d3340; }
.msg-coach .wb-av { background: #3d4a66; }
.msg-coach b { display: block; font-size: .75rem; letter-spacing: .08em; color: #9fb3ff; }
.msg-coach.tone-warn { background: #3d2c1f; }
.msg-coach.tone-warn b { color: #ffb47a; }
.msg-coach.tone-good { background: #1f3a2c; }
.msg-coach.tone-good b { color: #7ee0a7; }
.msg-notify { align-self: center; width: min(100%, 360px); background: #f4f1ea; color: #2a2724; border-radius: 14px; padding: 10px 14px; box-shadow: 0 6px 18px rgb(0 0 0 / 35%); }
.msg-notify b { font-size: .8rem; color: #047a38; }
.msg-tool { border: 1px solid var(--wb-line); border-radius: 10px; background: var(--wb-panel); padding: 8px 12px; margin-left: 36px; }
.msg-tool b { font-size: .85rem; color: var(--wb-dim); }
.msg-tool pre { margin: 4px 0 0; font-family: var(--mono); font-size: .82rem; color: #9be29b; white-space: pre-wrap; }
.msg-perm { margin-left: 36px; border: 1.5px solid var(--wb-accent); border-radius: 12px; background: #2f2620; padding: 12px 14px; display: grid; gap: 8px; }
.msg-perm code { display: block; font-family: var(--mono); background: #151311; border-radius: 8px; padding: 8px 10px; color: #ffd9a8; font-size: .9rem; }
.msg-perm .muted { color: var(--wb-dim); font-size: .85rem; }
.wb-perm-btns, .msg-choose { display: flex; flex-wrap: wrap; gap: 8px; }
.msg-choose { margin-left: 36px; }
.wb .msg-choose .btn, .wb .wb-perm-btns .btn:not(.btn-ok) { background: var(--wb-panel); color: var(--wb-ink); border-color: var(--wb-line); }
.wb .msg-choose .btn:hover:not(:disabled) { border-color: var(--wb-accent); }
.wb .btn.is-picked { outline: 2px solid var(--wb-accent); outline-offset: 2px; }
.wb .btn:disabled:not(.is-picked) { opacity: .35; }
.msg-boom { background: #4a1d1b; color: #ffcfc9; border: 1.5px solid #d4483f; border-radius: 12px; padding: 10px 14px; animation: shake 400ms ease 2; }
.msg-story { align-self: center; width: min(100%, 420px); display: grid; gap: 12px; justify-items: center; padding: 8px 0; }
.wb-phone { width: 100%; background: #f4f1ea; color: #2a2724; border-radius: 18px; padding: 14px 16px; box-shadow: 0 10px 30px rgb(0 0 0 / 40%); }
.wb-phone b { font-size: .82rem; color: #047a38; }
.msg-finish { background: var(--wb-panel); border: 1.5px solid #d97757; border-radius: 14px; padding: 16px 18px; }
.msg-finish h3 { color: #fff; margin: 4px 0 8px; }
.msg-finish ul { margin: 6px 0 8px; padding-left: 1.2em; }
.msg-finish .muted { color: var(--wb-dim); }
.wb-stars { font-size: 1.8rem; letter-spacing: .1em; color: #ffcc4d; }

.wb-input { border-top: 1px solid var(--wb-line); padding: 10px 12px 12px; display: grid; gap: 6px; }
.wb-row { display: flex; gap: 8px; align-items: flex-end; }
.wb-input textarea { flex: 1; resize: none; font: inherit; font-size: .95rem; color: var(--wb-ink); background: var(--wb-panel); border: 1.5px solid var(--wb-line); border-radius: 12px; padding: 9px 12px; }
.wb-input textarea:focus { outline: none; border-color: var(--wb-accent); }
.wb-input textarea:not(:disabled) { box-shadow: 0 0 0 3px rgb(217 119 87 / 25%); }
.wb-hint-btn { justify-self: start; background: none; border: 0; color: #ffcf9e; font: inherit; font-size: .82rem; cursor: pointer; padding: 0; text-decoration: underline dotted; }

.wb-side { display: flex; flex-direction: column; background: var(--paper-2); min-width: 0; border-left: 1px solid var(--line); }
.wb-side-head { display: flex; justify-content: space-between; gap: 8px; padding: 8px 14px; font-size: .82rem; font-weight: 800; color: var(--muted); }
.wb-side-head span { color: var(--brand); animation: wb-blink 1.4s ease-in-out infinite; }
@keyframes wb-blink { 50% { opacity: .45; } }
.wb-preview { flex: 1; margin: 0 12px; border-radius: 12px; background: #fff; border: 1.5px solid var(--line); min-height: 300px; display: grid; overflow: hidden; }
.wb-preview iframe { width: 100%; height: 100%; min-height: 300px; border: 0; }
.wb-preview.is-new { animation: wb-flash 900ms var(--ease); }
.wb-preview.is-waiting { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
@keyframes wb-flash { 0% { box-shadow: 0 0 0 0 rgb(29 35 39 / 60%); } 100% { box-shadow: 0 0 0 14px rgb(29 35 39 / 0%); } }
.wb-empty { margin: auto; text-align: center; color: #666; font-size: .9rem; padding: 20px; }
.wb-files { list-style: none; margin: 0 12px 12px; padding: 8px 12px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); font-family: var(--mono); font-size: .85rem; }

.wb-toast { position: absolute; top: 58px; right: 14px; z-index: 5; width: min(300px, calc(100% - 28px)); background: #f4f1ea; color: #2a2724; border-radius: 14px; padding: 10px 14px; box-shadow: 0 12px 30px rgb(0 0 0 / 30%); animation: pop 300ms var(--ease) both; font-size: .9rem; }
.wb-toast b { display: block; font-size: .78rem; color: #047a38; }

/* =====================================================================
   視覺升級：讓它有「一個 AI 正在跟你一起工作」的現場感。
   只改外觀，不改結構；所有動態在「減少動態」設定下都會關掉。
   ===================================================================== */
.wb {
  /* 白板改版：模擬器是「投在板上的 Claude Code 畫面」，用它原本的暗色，不再加紫色霓虹 */
  --wb-bg: #1f1d1a; --wb-panel: #2a2724; --wb-ink: #ece6dd; --wb-dim: #a59c90;
  --wb-accent: #d97757; --wb-line: #3b3733;
}

/* ---------- 任務列：下面加一條進度條 ---------- */
.wb-top { position: relative; background: var(--card); }
.wb-top::after {
  content: ""; position: absolute; left: 0; bottom: -1px; height: 3px; width: var(--wb-progress, 0%);
  background: var(--brand); border-radius: 0 3px 3px 0;
  transition: width .6s var(--ease);
}
.wb-missions li.is-now { animation: wb-now 1.8s ease-in-out infinite; }
@keyframes wb-now { 50% { box-shadow: 0 0 0 6px var(--brand-soft); } }
.wb-missions li.is-done span::after { animation: wb-check .35s var(--ease); }
@keyframes wb-check { from { transform: scale(0); } to { transform: none; } }

/* ---------- 對話區：Claude Code 原本的深色畫面，不加光暈 ---------- */
.wb-chat { position: relative; isolation: isolate; background: var(--wb-bg); }
.wb-chat::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: .35;
  background-image: radial-gradient(rgb(255 255 255 / 7%) 1px, transparent 1px); background-size: 18px 18px;
}

/* 標題列：綠燈表示「在線」，思考中變黃燈快閃 */
.wb-bar { background: rgb(255 255 255 / 3%); }
.wb-bar b {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--wb-ink);
}
.wb-bar b::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: #34d399;
  box-shadow: 0 0 0 0 rgb(52 211 153 / 60%); animation: wb-online 2.4s infinite;
}
@keyframes wb-online { 70% { box-shadow: 0 0 0 7px rgb(52 211 153 / 0%); } }
.wb.is-thinking .wb-bar b::before { background: #fbbf24; animation-duration: .9s; }

/* ---------- 頭像 ---------- */
.msg-claude .wb-av {
  width: 30px; height: 30px; border-radius: 10px; font-weight: 900; color: #fff;
  background: var(--wb-accent);
}
.msg-typing .wb-av { animation: wb-breathe 1.2s ease-in-out infinite; }
@keyframes wb-breathe { 50% { transform: scale(1.06); } }

/* ---------- 訊息泡泡 ---------- */
.wb-msg { animation: wb-in .42s var(--ease) both; }
@keyframes wb-in { from { opacity: 0; transform: translateY(10px) scale(.96); } }
.msg-claude > p {
  background: rgb(255 255 255 / 5%); border: 1px solid rgb(255 255 255 / 8%);
  padding: 9px 13px; border-radius: 4px 14px 14px 14px; max-width: 92%;
}
.msg-typing { padding: 0; align-items: center; }
.wb-dots { display: inline-flex; gap: 5px; padding: 12px 14px; border-radius: 4px 14px 14px 14px; background: rgb(255 255 255 / 5%); }
.wb-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--wb-dim); animation: wb-dot 1s 3 ease-in-out; }
.wb-dots i:nth-child(2) { animation-delay: .15s; }
.wb-dots i:nth-child(3) { animation-delay: .3s; }

.msg-you {
  background: #3a4a8a; color: #fff;
  box-shadow: 0 8px 24px -8px rgb(31 79 191 / 80%); border-radius: 16px 16px 4px 16px; padding: 9px 14px;
}

.msg-coach { background: rgb(134 168 255 / 10%); border: 1px solid rgb(134 168 255 / 25%); }
.msg-coach.tone-warn { background: rgb(251 146 60 / 12%); border-color: rgb(251 146 60 / 30%); }
.msg-coach.tone-good { background: rgb(52 211 153 / 12%); border-color: rgb(52 211 153 / 30%); }

/* ---------- 工具執行：像終端機 ---------- */
.msg-tool { position: relative; overflow: hidden; background: #151311; border-color: var(--wb-line); }
.msg-tool b { color: #86a8ff; }
.msg-tool pre { color: #9be29b; }

/* ---------- 權限詢問：還沒回答前輕輕發光，提醒「輪到你決定」 ---------- */
.msg-perm {
  background: #2f2620; border-color: var(--wb-accent);
  animation: wb-in .42s var(--ease) both, wb-ask 1.8s ease-in-out .5s infinite;
}
.msg-perm:has(.is-picked) { animation: none; border-color: var(--wb-line); }
@keyframes wb-ask { 50% { box-shadow: 0 0 0 4px rgb(217 119 87 / 22%); } }
.msg-perm code { background: #0a0a18; color: #fdba74; }

/* ---------- 選項按鈕 ---------- */
.wb .msg-choose .btn, .wb .wb-perm-btns .btn:not(.btn-ok) {
  background: rgb(255 255 255 / 6%); border: 1px solid rgb(255 255 255 / 14%); color: var(--wb-ink);
  transition: transform var(--fast) var(--ease), background var(--fast), border-color var(--fast), box-shadow var(--fast);
}
.wb .msg-choose .btn:hover:not(:disabled), .wb .wb-perm-btns .btn:hover:not(:disabled) {
  transform: translateY(-2px); border-color: #86a8ff; background: rgb(134 168 255 / 16%);
  box-shadow: 0 8px 20px -10px rgb(134 168 255 / 90%);
}
.wb .wb-perm-btns .btn-ok { background: var(--ok-fill); border: 0; }
.wb .btn.is-picked { outline: 0; background: var(--brand-fill) !important; border-color: transparent !important; color: #fff !important; }
.wb .btn.is-picked::before { content: "✓ "; }

/* ---------- 出錯：紅光一閃 ---------- */
.msg-boom { background: #4a1d1b; border-color: #d4483f; }
.wb.is-hit .wb-chat::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 3;
  box-shadow: inset 0 0 0 3px rgb(212 72 63 / 80%);
  animation: wb-hit .7s ease-out forwards;
}
@keyframes wb-hit { to { opacity: 0; } }

/* ---------- 手機通知：像真的跳出來 ---------- */
.msg-notify { animation: wb-drop .5s var(--ease) both; }
@keyframes wb-drop { from { opacity: 0; transform: translateY(-16px) scale(.95); } }

/* ---------- 完成 ---------- */
.msg-finish {
  background: var(--wb-panel); border: 1px solid var(--wb-accent);
}
/* 星星一顆一顆亮起來：拿到的金色發光，沒拿到的淡淡的 */
.wb-stars span { display: inline-block; color: rgb(255 255 255 / 25%); animation: wb-stars .6s var(--ease) calc(.2s + var(--d, 0ms)) both; }
.wb-stars span.is-on {
  color: #ffcc4d;
}
@keyframes wb-stars { from { transform: scale(.2) rotate(-90deg); opacity: 0; } 70% { transform: scale(1.35) rotate(8deg); } }

/* 預覽長出新網頁時：外框亮一下就好（wb-flash） */
.wb-preview { position: relative; }

/* 彩帶已移到 course.css 的 .fx-confetti，測驗、分類卡、工作台共用 */

/* ---------- 輸入框：輪到你時整圈發光 ---------- */
.wb-input { background: rgb(255 255 255 / 3%); }
.wb-input textarea { background: #151311; border-color: var(--wb-line); }
.wb-input.is-your-turn textarea {
  border-color: transparent;
  background: #151311; border-color: var(--wb-accent);
  
}
.wb-input.is-your-turn .btn-primary { background: var(--brand-fill); border: 0; }

.wb-preview { box-shadow: 0 18px 40px -22px rgb(15 14 31 / 45%); }

@media (prefers-reduced-motion: reduce) {
  .wb-msg, .msg-notify, .wb-stars, .msg-perm, .wb-missions li.is-now, .msg-typing .wb-av,
  .wb-input.is-your-turn textarea, .wb-bar b::before, .msg-tool::after, .wb.is-hit .wb-chat::after,
  .wb-stars span, .wb-preview.is-new::after { animation: none !important; }
}

/* 任務進度只是顯示到第幾關，不能按：拿掉膠囊外框，免得看起來像按鈕 */
.wb-missions li { border: 0; background: none; padding: 3px 6px 3px 0; }
.wb-missions li.is-now { box-shadow: none; animation: none; }
.wb-bar em { border: 0; padding: 0; }

/* ---------- 白板改版（2026-09）：關掉彩虹、霓虹與漸層，按鈕回到全站的磁鐵樣式 ---------- */
:root .wb-top { background: var(--card); }
:root .wb-top::after { background: var(--brand); box-shadow: none; }
:root .wb .wb-bar b, :root .wb-finish-title { background: none; -webkit-background-clip: border-box; background-clip: border-box; color: inherit; }
:root .wb-dots i { background: var(--wb-dim); }
:root .wb .btn.is-picked { background: var(--brand-fill) !important; }
:root .wb-input.is-your-turn .btn-primary { background: var(--brand-fill); box-shadow: var(--magnet); }
:root .wb .wb-perm-btns .btn-ok { background: var(--ok-fill); box-shadow: var(--magnet); }
:root .msg-tool { background: #151311; border-color: var(--wb-line); }
:root .msg-tool b { color: #e9b99f; }
:root .msg-tool pre { color: #9be29b; text-shadow: none; }
:root .msg-perm code { background: #151311; }
:root .msg-boom { background: #4a1d1b; box-shadow: none; }
:root .msg-finish { background: var(--wb-panel); border-color: var(--wb-accent); }
:root .wb-bar b { color: var(--wb-ink); }
:root .msg-claude .wb-av { background: var(--wb-accent); box-shadow: none; }
:root .msg-you { background: #3a4a8a; box-shadow: none; }
:root .msg-finish { box-shadow: none; }
:root .wb-stars span.is-on { background: none; color: #ffcc4d; filter: none; }
:root .wb-chat { background: var(--wb-bg); }
:root .wb-input.is-your-turn textarea { background: #151311; border-color: var(--wb-accent); box-shadow: none; animation: none; }

/* ---------- 審查排序第 1 項：不要一直動 ----------
   長輩看到東西一直閃會分心、會亂點。循環動畫改成「狀態」：出現時提示一次（最多 3 下），之後靜止。 */
:root .wb-side-head span { animation: none; }
:root .wb-missions li.is-now { animation: none; box-shadow: 0 0 0 3px var(--brand-soft); }
:root .wb-bar b::before { animation: none; box-shadow: none; }
:root .msg-typing .wb-av { animation: none; }
:root .msg-typing i, :root .wb-dots i { background: var(--wb-dim); animation-iteration-count: 3; }
/* 輪到你按允許／拒絕：外框提示 3 下就停，框線保持橘色 */
:root .msg-perm { animation: wb-in .42s var(--ease) both, wb-ask-soft .9s ease-in-out .5s 3; }
:root .msg-perm:has(.is-picked) { animation: none; }
@keyframes wb-ask-soft { 50% { box-shadow: 0 0 0 4px rgb(217 119 87 / 22%); } }
/* 輪到你打字：輸入框一道實心橘框，不閃 */
:root .wb-input.is-your-turn textarea { outline: 3px solid color-mix(in srgb, var(--wb-accent) 45%, transparent); outline-offset: 1px; }
@media (prefers-reduced-motion: reduce) { :root .msg-perm, :root .msg-typing i, :root .wb-dots i { animation: none !important; } }

/* ---------- 評分修正（2026-10，第三輪）：開始前不要有一大片空白、不要假裝能打字 ---------- */
/* 預覽和檔案都還是空的時候，右邊整欄先收起來，對話區佔滿；有東西出現才展開 */
:root .wb:has(.wb-preview > .wb-empty):has(.wb-files > li.muted:only-child) .wb-side { display: none; }
:root .wb:has(.wb-preview > .wb-empty):has(.wb-files > li.muted:only-child) .wb-main { grid-template-columns: 1fr; min-height: 0; }
/* 輸入列只在輪到你打字時出現；沒輪到時是灰的、看起來像要你打字，反而讓人困惑 */
:root .wb-input:has(textarea:disabled) .wb-row { display: none; }
/* 「重來一次」等開始之後才出現，手機上不會自己孤零零佔一行 */
:root .wb:not(:has(.wb-missions li:is(.is-now, .is-done))) [data-wb-reset] { display: none; }
/* 第五輪（2026-10）：允許／拒絕兩顆一樣重，不先用綠色暗示答案；動畫一律 ≤300ms、不重複 */
:root .msg-boom { animation: shake 300ms ease 1; }
:root .wb-msg { animation: wb-in .3s var(--ease) both; }
:root .msg-perm { animation: wb-in .3s var(--ease) both; }
:root .msg-notify { animation: wb-drop .3s var(--ease) both; }
:root .wb-preview.is-new { animation: wb-flash 300ms var(--ease); }
:root .wb-stars span { animation-duration: .3s; }
:root .wb.is-hit .wb-chat::after { animation-duration: .3s; }
:root .wb-missions li.is-done span::after { animation-duration: .3s; }
