/* 第 2~5 堂(網頁課)的介面:接在 islands.css 後面。明亮兒童風;只有程式碼區是深色(和正式站編輯器一樣)。 */

/* ---------- 換一堂課(地圖上右下角) ---------- */
.tmi-lessons { position: absolute; z-index: 21; right: 16px; bottom: 16px; display: flex; gap: 4px; padding: 5px; border-radius: 999px;
  background: rgba(255, 253, 248, .94); box-shadow: var(--shadow-s), var(--clay); }
.tmi-lessons[hidden] { display: none; }
.tmi-lessons a { display: grid; justify-items: center; gap: 1px; padding: 6px 14px; border-radius: 999px; color: var(--soft); font-size: 14px; font-weight: 900; line-height: 1.15; text-decoration: none; }
.tmi-lessons a small { font-size: 11px; font-weight: 800; white-space: nowrap; }
.tmi-lessons-k { display: none; }
.tmi-lessons a:hover { background: #fff6dc; color: var(--ink); }
.tmi-lessons a.on { background: #ffd24a; color: var(--ink); box-shadow: inset 0 -3px 0 #e8a522; }
.xp-goal-t a { color: #2f78bd; font-weight: 900; }

/* ---------- 視窗大小:程式工作台要寬、要高 ---------- */
.xq-workbench { --k: #f4b63f; }
.xq-webplay, .xq-paste, .xq-checks { --k: #f07848; }
.xq-hunt, .xq-witness, .xq-suspect { --k: #3fae7a; }
body.xv .xq-props > .xq-workbench { width: min(1180px, 100%); height: 100%; }
body.xv .xq-props > .xq-suspect, body.xv .xq-props > .xq-ai, body.xv .xq-props > .xq-webplay { width: min(720px, 100%); height: 100%; }
body.xv .xq-props > .xq-station, body.xv .xq-props > .xq-checks, body.xv .xq-props > .xq-paste { width: min(600px, 100%); }
.xq-workbench .xq-card-body, .xq-suspect .xq-card-body, .xq-ai .xq-card-body, .xq-webplay .xq-card-body { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.xq-workbench .xq-card-body { overflow: hidden; padding: 12px 14px 14px; }

/* ---------- 程式工作台 ---------- */
.tmi-wb { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.tmi-goal { flex: none; margin: 0; padding: 8px 14px; border-radius: 14px; background: #fff6d6; color: #5d4a12; font-size: 15px; font-weight: 800; line-height: 1.5; box-shadow: inset 0 0 0 2px #ffe08a; }
.tmi-goal[hidden] { display: none; }
.tmi-goal b { margin-right: 4px; }
.tmi-goal.ok { background: #e9f8ef; color: #23805a; box-shadow: inset 0 0 0 2px #9fdcb7; }
.tmi-goal.ok b::before { content: "🎉 已過關 ・ "; }
.tmi-wb-bar { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tmi-wb-bar [hidden] { display: none; }
.tmi-run { min-width: 120px; }
.tmi-wb-tabs { display: none; }
.tmi-wb-panes { flex: 1; min-height: 0; display: grid; gap: 10px; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; grid-template-areas: "code view" "code con"; }
.tmi-pane { min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.tmi-pane-code { grid-area: code; }
.tmi-pane-view { grid-area: view; }
.tmi-pane-con { grid-area: con; gap: 4px; }
.tmi-pane-k { margin: 0; font-size: 12.5px; font-weight: 900; color: var(--soft); }

/* 程式框:行號 + 不折行,長的那一行左右捲 */
.tmi-ed { position: relative; flex: 1; min-height: 160px; display: flex; border-radius: 16px; overflow: hidden; background: #1f2430; box-shadow: inset 0 0 0 3px #33393f; }
.tmi-gutter { flex: none; width: 3.1em; padding: 12px 8px 12px 0; overflow: hidden; background: #262c3a; color: #6f7a96; text-align: right; white-space: pre;
  font: 15px/1.65 Consolas, "Cascadia Mono", monospace; user-select: none; }
.xq .tmi-code { flex: 1; width: auto; min-width: 0; margin: 0; padding: 12px 14px; border: 0; border-radius: 0; background: transparent; box-shadow: none;
  color: #e6edf3; caret-color: #ffd24a; font: 15px/1.65 Consolas, "Cascadia Mono", monospace; white-space: pre; overflow: auto; resize: none; outline: none; tab-size: 2; }
.xq .tmi-code:focus { border: 0; box-shadow: none; }
.tmi-code::selection { background: rgba(255, 210, 74, .35); }
.xq .tmi-ed.ro .tmi-code { color: transparent; }
/* 11/10 上色:輸入框的字透明,底下墊 syntax.js 的上色副本;兩邊字型、行高、內距、tab 寬度要一模一樣才不會錯位 */
.tmi-code-wrap { position: relative; flex: 1; min-width: 0; display: flex; overflow: hidden; }
.xq .tmi-code-wrap > .tmi-code { position: relative; z-index: 1; color: transparent; -webkit-text-fill-color: transparent; background: transparent; }
.tmi-hl { position: absolute; inset: 0; z-index: 0; margin: 0; padding: 12px 14px; overflow: hidden; pointer-events: none; background: transparent;
  color: #e6edf3; font: 15px/1.65 Consolas, "Cascadia Mono", monospace; white-space: pre; tab-size: 2; }
.tmi-hl code { display: block; font: inherit; color: inherit; background: none; padding: 0; white-space: pre; will-change: transform; }
.tmi-ed.ro .tmi-hl { color: #c3e88d; }
.hl-com { color: #7f8bad; font-style: italic; }
.hl-str { color: #c3e88d; }
.hl-kw { color: #c792ea; }
.hl-con { color: #ff9cac; }
.hl-fn { color: #82aaff; }
.hl-bi { color: #89ddff; }
.hl-num { color: #f78c6c; }
.hl-tag { color: #f07178; }
.hl-attr { color: #ffcb6b; }
.hl-prop { color: #82aaff; }
.hl-sel { color: #ffcb6b; }
/* 觸控裝置(含 iPad)程式框一律 16px(展場版 quest.css 的防自動放大規則也會套到輸入框):行號、上色副本跟著一樣大才對得齊 */
@media (pointer: coarse) { .xq .tmi-code, .tmi-gutter, .tmi-hl { font-size: 16px !important; } }

/* 網頁畫面(隔離框) */
.tmi-screen-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 6px; }
.tmi-screen { position: relative; flex: 1; min-height: 200px; border-radius: 16px; background: #fff; box-shadow: inset 0 0 0 3px #ffd7b8, 0 4px 12px rgba(48, 78, 70, .1); overflow: hidden; }
.tmi-screen iframe { position: absolute; inset: 3px; width: calc(100% - 6px); height: calc(100% - 6px); border: 0; border-radius: 13px; background: #fff; }
.tmi-screen-empty { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: 12px; text-align: center; color: var(--soft); font-weight: 800; }
.tmi-pad { flex: none; display: flex; justify-content: center; gap: 6px; }
.tmi-pad[hidden] { display: none; }
.tmi-pad-b { width: 52px; height: 44px; border: 0; border-radius: 14px; background: #fff; font: 900 18px/1 var(--font); color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); touch-action: none; user-select: none; -webkit-user-select: none; }
.tmi-pad-b.wide { width: 74px; font-size: 14px; }
.tmi-con { margin: 0; max-height: 120px; min-height: 44px; overflow: auto; padding: 8px 12px; border-radius: 14px; background: #1f2328; color: #e8e8e8; font: 14px/1.55 Consolas, "Cascadia Mono", monospace; white-space: pre-wrap; }
.tmi-con .err { color: #ff8a80; }
.tmi-con .muted { color: #9aa4a0; }

/* 偵探:嫌疑網頁 */
.xq-suspect .tmi-screen { min-height: 180px; }
.tmi-sus-code, .tmi-ai-src { flex: none; }
.tmi-sus-code summary, .tmi-ai-src summary { cursor: pointer; font-size: 14px; font-weight: 900; color: #2d4a78; padding: 4px 0; }
.tmi-sus-code .xq-suspect-code { max-height: 200px; }
.tmi-det-note { padding: 10px 14px; border-radius: 14px; background: #eef8f2; color: #23805a; font-weight: 800; }

/* 指揮官:奇奇的網頁 */
.xq-ai .tmi-screen { min-height: 220px; }
.xq-ai .xq-console { flex: none; }
.xq-ai .xq-ai-code { max-height: 220px; }

/* 實戰:提示詞框(照正式站 PromptCopy:黃色空格可以改、固定規則鎖住) */
.tmi-prompt { display: grid; gap: 10px; margin: 14px 0; padding: 14px; border-radius: 18px; background: #fffdf6; box-shadow: inset 0 0 0 2px #f1e6c8; }
.tmi-prompt-task { font-size: 16px; line-height: 2.1; font-weight: 700; color: var(--ink); }
.tmi-prompt-task[hidden], .tmi-prompt-free[hidden], .tmi-prompt [hidden] { display: none; }
.tmi-slot { margin: 0 2px; padding: 1px 8px; border: 0; border-radius: 8px; background: #ffe58a; color: #5d3b00; font: 900 16px/1.6 var(--font); box-shadow: inset 0 -2px 0 #e8b21f; max-width: 100%; }
.tmi-slot:focus { outline: 3px solid #ffd24a; background: #fff2b8; }
.xq .tmi-prompt-free { width: 100%; font-size: 15px; }
.tmi-prompt-tech { padding: 10px 12px; border-radius: 14px; background: #eef0f2; color: #5c6670; font-size: 13.5px; line-height: 1.6; }
.tmi-prompt-tech b { display: block; margin-bottom: 4px; color: #4a5560; }
.tmi-prompt-tech p { margin: 2px 0 !important; }
.tmi-finish, .tmi-share { display: grid; gap: 8px; margin-top: 10px; }
.tmi-save { width: 100%; }
.xq-webplay .tmi-screen { min-height: 260px; }

/* ---------- 🎁 隱藏關卡(照正式站 BonusGame:陽光黃底、進度條、收藏膠囊) ---------- */
.xq-bonus, .xq-bonusplay { --k: #f4b63f; }
body.xv .xq-props > .xq-bonus { width: min(640px, 100%); }
body.xv .xq-props > .xq-bonusplay { width: min(720px, 100%); }
.xq-bonus .xq-card-body { background: linear-gradient(#fff8dc, #fff 160px); }
.tmi-bonus { display: grid; gap: 10px; }
.tmi-bonus p { margin: 0; }
.tmi-bonus-bar { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 900; color: #6b5a1e; }
.tmi-bonus-meter { flex: 1; height: 12px; border-radius: 999px; background: #fff0b8; overflow: hidden; }
.tmi-bonus-meter i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #ffd24a, #f0648a); }
.tmi-bonus-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tmi-bonus-title b { font-size: 24px; color: var(--ink); }
.tmi-bonus-new { padding: 2px 10px; border-radius: 999px; background: #e84d78; color: #fff; font-size: 13px; font-weight: 900; }
.tmi-bonus-keys { padding: 2px 10px; border-radius: 999px; background: #e3f6e9; color: #23805a; font-size: 13px; font-weight: 900; }
.tmi-bonus-prompt { font-size: 16px; }
.tmi-bonus-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tmi-bonus-chip { padding: 4px 12px; border: 2px solid #e4e4e4; border-radius: 999px; background: #fff; color: #6b6b6b; font: 900 14px/1.4 var(--font); cursor: pointer; }
.tmi-bonus-chip:hover { border-color: #ffd24a; }
.tmi-bonus-chip.on { border-color: #e8a522; background: #ffd24a; color: var(--ink); }
.xq-bonusplay .xq-card-body { display: flex; flex-direction: column; gap: 8px; }
.xq-bonusplay .tmi-screen { min-height: 240px; }
.tmi-bonus-code { min-height: 80px; }

/* ---------- 手機、直立平板:工作台一次只放一塊(程式 / 畫面 / Console),上面的分頁切換 ---------- */
@media (max-width: 900px), (max-width: 1100px) and (orientation: portrait) {
  /* 五堂擠不下「第 N 堂」:只留數字圓鈕,前面一個小標;左下的搖桿要留空間;墊高一點,不被最下面那行「示意角色」的小字蓋住 */
  .tmi-lessons { right: 8px; bottom: calc(30px + var(--safe-b, 0px)); align-items: center; gap: 3px; padding: 4px 4px 4px 10px; }
  .tmi-lessons-k { display: block; margin-right: 3px; font-size: 11.5px; font-weight: 900; color: var(--soft); white-space: nowrap; }
  .tmi-lessons a { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; font-size: 15px; }
  .tmi-lessons a small, .tmi-ln-x { display: none; }
  body.xv .xq-props > .xq-workbench, body.xv .xq-props > .xq-suspect, body.xv .xq-props > .xq-ai, body.xv .xq-props > .xq-webplay { height: 100% !important; }
  .xq-workbench .xq-card-body { padding: 8px 10px 10px; overflow: hidden !important; }
  .tmi-goal { display: none; }   /* 挑戰任務在下面探長的對話框裡就有,手機不重複佔一塊 */
  .tmi-wb { gap: 6px; }
  .tmi-wb-bar { gap: 6px; }
  .tmi-wb-bar .xq-btn.small { min-height: 36px; padding: 0 10px; font-size: 13px; }
  .xq .tmi-run { min-width: 0; min-height: 40px; padding: 0 14px; }
  .tmi-wb[data-pane="view"] .tmi-wb-bar .ghost, .tmi-wb[data-pane="con"] .tmi-wb-bar .ghost { display: none; }
  .tmi-wb-tabs { display: flex; flex: 1; min-width: 0; gap: 4px; }
  .tmi-wb-tabs .xq-tab { flex: 1; min-width: 0; height: 40px; padding: 0 4px; font-size: 13px; white-space: nowrap; }
  .tmi-wb-bar .xq-btn.ghost { order: 3; }
  .tmi-wb-panes { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); grid-template-areas: "only"; }
  .tmi-pane { grid-area: only; }
  .tmi-wb[data-pane="code"] .tmi-pane:not(.tmi-pane-code), .tmi-wb[data-pane="view"] .tmi-pane:not(.tmi-pane-view), .tmi-wb[data-pane="con"] .tmi-pane:not(.tmi-pane-con) { display: none; }
  .tmi-pane-con .tmi-con { flex: 1; max-height: none; }
  .tmi-ed { min-height: 0; }
  /* iPhone 點進小於 16px 的輸入框會自動放大畫面 */
  .xq .tmi-code, .tmi-gutter, .tmi-hl { font-size: 16px; line-height: 1.6; }
  .tmi-gutter { width: 2.6em; }
  .tmi-screen { min-height: 0; }
  .xq-suspect .xq-card-body, .xq-ai .xq-card-body, .xq-webplay .xq-card-body { overflow: auto !important; }
  .xq-suspect .tmi-screen-wrap, .xq-ai .tmi-screen-wrap { flex: none; height: max(170px, calc(100% - 130px)); }
  .xq-webplay .tmi-screen-wrap { flex: none; height: max(200px, calc(100% - 56px)); }
  .tmi-prompt-task, .tmi-slot { font-size: 15px; }
}

/* ---------- 用正式站開這一課(和「回島上」一起貼在探長對話框上緣,不佔標題列) ---------- */
.xq-topacts { position: absolute; z-index: 3; top: -20px; right: 16px; display: flex; align-items: center; gap: 8px; }
.xq-topacts .xq-leave { position: static; }
.xq-official { flex: none; display: inline-flex; align-items: center; height: 40px; padding: 0 14px; border-radius: 999px; background: #eef4fb; color: #2d4a78; font: 900 14px/1 var(--font);
  text-decoration: none; white-space: nowrap; box-shadow: inset 0 0 0 2px #cfe0f2, 0 4px 12px rgba(48, 78, 70, .18); }
.xq-official:hover { background: #fff; box-shadow: inset 0 0 0 2px #9cbfe3, 0 4px 12px rgba(48, 78, 70, .18); }
@media (min-width: 901px) and (max-height: 820px) { .xq-topacts { top: -18px; } .xq-official { height: 36px; } }

/* ---------- 🎤 語音輸入(同正式站 MicButton:平常麥克風,聽的時候紅點閃動) ---------- */
.tmi-mic { flex: none; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 2px solid var(--line); border-radius: 50%; background: #fff;
  font-size: 18px; line-height: 1; cursor: pointer; transition: border-color .15s, background-color .15s; }
@media (hover: hover) { .tmi-mic:hover { border-color: #4a97dd; background: #eef6fd; } }
.tmi-mic:focus-visible { outline: 3px solid #4a97dd; outline-offset: 2px; }
.tmi-mic.tmi-mic-sm { width: 36px; height: 36px; font-size: 16px; }
@media (pointer: coarse) { .tmi-mic, .tmi-mic.tmi-mic-sm { width: 44px; height: 44px; font-size: 19px; } }
.tmi-mic.listening { border-color: #f43f5e; background: #ffe4e9; animation: tmi-mic-pulse 1.2s ease-in-out infinite; }
@keyframes tmi-mic-pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .tmi-mic.listening { animation: none; } }
.xq-cmd-box > .tmi-mic { align-self: flex-end; }
.tmi-mic-wrap { position: relative; }
.tmi-mic-tip, .tmi-mic-ask { position: fixed; z-index: 3000; max-width: min(320px, calc(100vw - 16px)); padding: 8px 12px; border-radius: 14px; background: #fff6d6; border: 2px solid #f7c948;
  color: #3b2f05; font: 800 14px/1.5 var(--font); box-shadow: 0 8px 20px rgba(60, 50, 10, .18); }
.tmi-mic-tip { pointer-events: none; }   /* 只是說明,不擋住底下的輸入框和按鈕 */
.tmi-mic-ask { display: grid; gap: 6px; padding: 12px 14px; }
.tmi-mic-ask p { margin: 0; font-weight: 700; }
.tmi-mic-ask .xq-row { margin-top: 4px; }

/* ---------- 保留期的說明卡(同正式站 HoldNotice) ---------- */
.tmi-hold { display: grid; gap: 6px; padding: 12px 14px; border-radius: 16px; background: #fff8e6; box-shadow: inset 0 0 0 2px #f7d98a; color: #5d4a12; }
.tmi-hold[hidden] { display: none; }
.tmi-hold b { font-size: 16px; }
.tmi-hold p { margin: 0; font-size: 14.5px; line-height: 1.7; font-weight: 700; }
.xq-hold { --k: #4a97dd; }
body.xv .xq-props > .xq-hold { width: min(520px, 100%); }

/* ---------- 📦 收進作品集(程式工作台)、實戰作品名稱 ---------- */
.tmi-save-row { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 14px; background: #f1f8f3; box-shadow: inset 0 0 0 2px #cfe9d8; }
.tmi-save-row[hidden] { display: none; }
.xq .tmi-save-in { flex: 1 1 180px; min-width: 0; width: auto; padding: 6px 12px; border-radius: 999px; font-size: 15px; }
.tmi-save-msg { font-size: 14px; font-weight: 800; color: #b42318; }
.tmi-save-msg.ok { color: #23805a; }
.tmi-save-msg:empty { display: none; }
.tmi-work-name-row { display: flex; align-items: center; gap: 8px; font-weight: 900; color: #2d4a78; }
.tmi-work-name-row span { flex: none; font-size: 14px; }
.xq .tmi-work-name { flex: 1; min-width: 0; padding: 6px 12px; font-size: 15px; }
.tmi-acorns { margin: 0; }

/* ---------- 站內 AI 備援(同正式站 WorkshopBuilder:平時收合一行,助教解鎖才展開) ---------- */
.tmi-ws { margin: 12px 0; padding: 10px 14px; border-radius: 16px; border: 2px dashed #d9dde3; background: #f7f8fa; color: #4a5560; font-size: 14.5px; }
.tmi-ws.open { border: 2px solid #9fdcb7; background: #f1faf4; }
.tmi-ws [hidden] { display: none !important; }
.tmi-ws p { margin: 6px 0; }
.tmi-ws-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; font-weight: 800; color: #7a8590; }
.tmi-ws-line > span { flex: 1 1 200px; }
.tmi-ws-pinrow { margin-top: 8px; }
.xq .tmi-ws-pin { width: 8em; padding: 6px 10px; text-align: center; letter-spacing: .3em; font-weight: 900; }
.tmi-ws-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tmi-ws-title { flex: 1 1 auto; font-weight: 900; color: #34433f; }
.tmi-ws-title small { font-weight: 800; color: #7a8590; }
.tmi-ws-acts { display: flex; align-items: center; gap: 6px; }
.tmi-ws-acorn { padding: 4px 10px; border-radius: 999px; background: #fff; font-weight: 900; font-size: 13px; }
.tmi-ws-done { display: grid; gap: 8px; margin-top: 8px; padding-top: 10px; border-top: 2px dashed #9fdcb7; }
.tmi-ws-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tmi-ws-problems { margin: 0; padding-left: 1.2em; font-weight: 800; color: #6b7480; }
.tmi-ws-problems .bad { color: #c2410c; }
.tmi-ws-done .tmi-screen { min-height: 240px; }
.tmi-ws-code { max-height: 300px; overflow: auto; }
.tmi-ws-revise { display: grid; gap: 6px; padding: 10px 12px; border-radius: 14px; border: 2px dashed #f7c948; background: #fffbea; }
.tmi-ws-last { color: #23805a !important; }
.tmi-ws-probe { position: fixed; left: -9999px; top: 0; width: 900px; height: 600px; opacity: 0; pointer-events: none; border: 0; }
.tmi-ws-big { position: fixed; inset: 0; z-index: 95; display: flex; flex-direction: column; gap: 8px; padding: 12px; background: #1f2328; }
.tmi-ws-big-bar { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; color: #fff; }
.tmi-ws-big .tmi-screen-wrap { flex: 1; min-height: 0; }

@media (max-width: 900px), (max-width: 1100px) and (orientation: portrait) {
  .xq-topacts { position: static; flex: none; margin-left: auto; gap: 6px; }
  .xq-topacts .xq-leave { margin-left: 0; }
  .xq-official { height: 36px; padding: 0 10px; font-size: 15px; box-shadow: inset 0 0 0 2px #cfe0f2; }
  .xq-official-l { display: none; }   /* 手機只留 🖥️,標題列擠不下 */
  .tmi-save-row { padding: 6px 8px; }
  .xq .tmi-save-in, .xq .tmi-work-name, .xq .tmi-ws-pin { font-size: 16px; }   /* iPhone 點進小於 16px 的框會自動放大 */
}
/* 重看旅程:放在換堂按鈕上面,地圖模式才出現 */
.tmi-trip-again { position: absolute; z-index: 21; right: 16px; bottom: 76px; padding: 8px 14px; border: 0; border-radius: 999px; background: rgba(255, 255, 255, .94); color: var(--ink); font: 900 14px/1 var(--font); cursor: pointer; box-shadow: 0 4px 14px rgba(45, 74, 120, .18); }
.tmi-trip-again:hover { background: #fff6dc; }
.tmi-trip-again[hidden] { display: none; }
@media (max-width: 700px) { .tmi-trip-again { bottom: 66px; right: 10px; padding: 7px 12px; font-size: 13px; } }
