/* 第 2、3 堂(網頁課)的介面:接在 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; }
.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: #c3e88d; }

/* 網頁畫面(隔離框) */
.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; }

/* ---------- 手機、直立平板:工作台一次只放一塊(程式 / 畫面 / Console),上面的分頁切換 ---------- */
@media (max-width: 900px), (max-width: 1100px) and (orientation: portrait) {
  .tmi-lessons { right: 8px; bottom: calc(10px + var(--safe-b, 0px)); }
  .tmi-lessons a { padding: 5px 9px; font-size: 12.5px; }
  .tmi-lessons a small { 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 { 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; }
}
