* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; background: #101418; color: #eef2f6; font-family: "Noto Sans TC", Roboto, sans-serif; }
[hidden] { display: none !important; }
button, input, textarea { font: inherit; }
button { min-height: 48px; padding: 0 20px; border: 0; border-radius: 8px; background: #33404d; color: inherit; }
button:disabled { opacity: 0.5; }

#page { position: fixed; top: 0; left: 0; width: 100%; height: 100%; border: 0; }

#edit { position: fixed; z-index: 2; right: 12px; bottom: 12px; width: 52px; padding: 0; border-radius: 50%; background: rgba(51, 64, 77, 0.45); font-size: 24px; }
#edit[aria-expanded="true"] { background: #33404d; }

#status { position: fixed; left: 50%; top: 12px; transform: translateX(-50%); padding: 8px 18px; border-radius: 8px; background: #5a3a12; font-size: 18px; }

#undo-bar { position: fixed; z-index: 2; left: 50%; bottom: 12px; display: flex; align-items: center; transform: translateX(-50%); padding: 6px 8px 6px 18px; border-radius: 8px; background: #1a2027; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5); font-size: 18px; }
#undo-now { margin-left: 16px; background: #2f6fb0; }
#undo { width: 100%; margin-top: 10px; }
#reset-mode { width: 100%; margin-top: 10px; }

/* A paired tablet's simple panel (#228): .full-only shows once 展開完整設定 is pressed. Every other
   panel has no paired class and shows all of it, as before. */
.paired:not(.full-open) .full-only { display: none !important; }
.paired:not(.full-open) #fullscreen { margin-left: 0; }
#full-toggle { display: block; width: 100%; margin-top: 10px; padding: 0 12px; background: #252d36; font-size: 16px; text-align: left; }
#full-toggle::before { content: "▸"; display: inline-block; width: 1.2em; }
#full-toggle[aria-expanded="true"]::before { content: "▾"; }

/* The phone's 新增平板: the QR, the six digits and their countdown. */
#pair-new, #pair-revoke { width: 100%; margin-top: 10px; }
#pair-revoke { background: #4a2f33; }
#pair-show { margin-top: 10px; padding: 12px; border-radius: 8px; background: #252d36; text-align: center; }
#pair-qr { display: block; max-width: 100%; margin: 0 auto; background: #fff; }
#pair-code { margin: 12px 0 4px; font-size: 44px; letter-spacing: 6px; }
#pair-countdown { margin: 0 0 6px; font-size: 18px; color: #ffd28a; }
#pair-go { margin: 0; font-size: 15px; color: #c5d0da; overflow-wrap: break-word; word-break: break-word; }
#pair-message { margin: 8px 0 0; font-size: 16px; color: #c5d0da; }
#pair-message:empty { display: none; }

#preview-bar { position: fixed; z-index: 2; left: 12px; top: 12px; display: flex; align-items: center; padding: 6px 8px 6px 18px; border-radius: 8px; background: #1a2027; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5); font-size: 18px; }
#preview-bar span { margin-right: 16px; color: #ffd28a; }
#preview-bar button + button { margin-left: 8px; }
#apply { background: #2f6fb0; }
#discard { background: #4a2f33; }

#conversation { max-height: 45vh; margin: 0 0 10px; padding: 0; overflow-y: auto; list-style: none; }
#conversation li { margin-bottom: 8px; padding: 8px 12px; border-radius: 8px; font-size: 16px; overflow-wrap: break-word; word-break: break-word; white-space: pre-wrap; }
#conversation .user { margin-left: 40px; background: #2a4058; }
#conversation .agent { margin-right: 40px; background: #252d36; }
#conversation .system { background: none; color: #8496a6; font-size: 14px; }
#choices { margin-bottom: 10px; }
#choices button { display: block; width: 100%; margin-bottom: 6px; background: #2a4058; text-align: left; }
#show-draft { width: 100%; margin-bottom: 10px; }
#direct { flex: 1; }

#panel { position: fixed; z-index: 1; top: 0; right: 0; bottom: 0; width: 440px; max-width: 100%; padding: 20px 20px 76px; overflow-y: auto; background: #1a2027; box-shadow: -2px 0 12px rgba(0, 0, 0, 0.5); }
#panel h1 { margin: 0 0 12px; font-size: 24px; font-weight: 500; }
#panel h2 { margin: 20px 0 8px; font-size: 18px; font-weight: 500; color: #9fb0c0; }
#prompt { width: 100%; padding: 10px; border: 1px solid #3a4652; border-radius: 8px; background: #101418; color: inherit; font-size: 18px; resize: vertical; }
.actions { display: flex; margin-top: 10px; }
.actions button + button { margin-left: 10px; }
#submit { background: #2f6fb0; flex: 1; }
#record { flex: none; margin-right: 10px; padding: 0 16px; font-size: 20px; }
/* The gap after the microphone is its own margin, so a hidden microphone leaves none. */
.actions #record + button { margin-left: 0; }
#record[aria-pressed="true"] { background: #8a2f2f; }
#message { min-height: 24px; margin: 10px 0 0; font-size: 16px; color: #c5d0da; }

/* The component list: folded under the prompt, since an example is followed by pressing send. */
#components-toggle { display: block; width: 100%; margin-top: 10px; padding: 0 12px; background: #252d36; font-size: 16px; text-align: left; }
#components-toggle::before { content: "▸"; display: inline-block; width: 1.2em; }
#components-toggle[aria-expanded="true"]::before { content: "▾"; }
#components-box { margin-top: 8px; }
#components-note, #components-message { margin: 0 0 8px; font-size: 16px; color: #8496a6; }
#components-message:empty { display: none; }
#components { margin: 0; padding: 0; list-style: none; }
#components li { margin-bottom: 6px; padding: 8px 12px; border-radius: 8px; background: #252d36; font-size: 16px; }
.component-name { display: block; font-weight: 500; }
.component-intro { margin: 2px 0 6px; color: #c5d0da; overflow-wrap: break-word; word-break: break-word; }
.component-prompt { min-height: 40px; background: #2a4058; font-size: 16px; text-align: left; }

#history { margin: 0; padding: 0; list-style: none; }
#history button { display: block; width: 100%; margin-bottom: 6px; padding: 8px 12px; background: #252d36; font-size: 16px; text-align: left; }
#history button[aria-current="true"] { outline: 2px solid #2f6fb0; }
#history small { display: block; color: #8496a6; }

#preferences { margin: 0; padding: 0; list-style: none; }
#preferences li { display: flex; align-items: center; margin-bottom: 6px; padding: 4px 4px 4px 12px; border-radius: 8px; background: #252d36; font-size: 16px; }
#preferences span { flex: 1; margin-right: 10px; overflow-wrap: break-word; word-break: break-word; }
#preferences button { flex: none; background: #4a2f33; }
#preferences-empty { margin: 0; font-size: 16px; color: #8496a6; }
#settings { margin: 0; padding: 0; list-style: none; }
#settings li { margin-bottom: 8px; padding: 8px 12px; border-radius: 8px; background: #252d36; font-size: 16px; }
#settings .setting-line { display: block; overflow-wrap: break-word; word-break: break-word; }
#settings .setting-hint { display: block; font-size: 14px; color: #8496a6; }
#settings textarea, #settings input { display: block; box-sizing: border-box; width: 100%; margin: 6px 0; font-size: 16px; }
#settings textarea { min-height: 4.5em; }
#settings button { margin: 0 8px 4px 0; }
#settings .setting-candidates { margin-top: 4px; }
#settings .setting-note { margin-top: 4px; font-size: 14px; color: #f0c674; overflow-wrap: break-word; word-break: break-word; }
#settings-status { margin: 0 0 6px; font-size: 16px; color: #8496a6; }
#photos-count, #photos-message { margin: 0 0 8px; font-size: 16px; color: #8496a6; }
#photos-message { white-space: pre-line; }
#photos-message:empty { display: none; }
#photo-pick { width: 100%; margin-bottom: 10px; }
/* Thumbnails wrap in rows; inline-block with margins, since Chromium 70 has no flexbox gap. */
#photos { margin: 0 -6px 0 0; padding: 0; list-style: none; font-size: 0; }
#photos li { display: inline-block; width: 92px; margin: 0 6px 6px 0; vertical-align: top; }
#photos img { display: block; width: 92px; height: 92px; border-radius: 8px; background: #252d36; object-fit: cover; }
#photos button { width: 100%; min-height: 40px; margin-top: 4px; padding: 0; background: #4a2f33; font-size: 16px; }
/* The lists the user writes (#259). No flexbox gap: the panel also opens on the old tablet. */
#panel h3 { margin: 14px 0 6px; font-size: 16px; font-weight: 500; color: #c3d0dc; }
.list-count, .list-message { margin: 0 0 8px; font-size: 16px; color: #8496a6; }
.list-message { color: #f0c674; }
.list-message:empty { display: none; }
.list-add { display: flex; margin: 0 0 8px; }
.list-add input { flex: 1; min-width: 0; min-height: 48px; box-sizing: border-box; margin-right: 8px; padding: 0 12px; border: 1px solid #33404d; border-radius: 8px; background: #151b21; color: inherit; font-size: 16px; }
.list-add button { flex: none; }
.list-items { margin: 0; padding: 0; list-style: none; }
.list-items li { display: flex; align-items: center; margin-bottom: 6px; padding: 4px 4px 4px 12px; border-radius: 8px; background: #252d36; font-size: 16px; }
.list-items label { display: flex; flex: 1; align-items: center; min-width: 0; min-height: 40px; margin-right: 10px; }
.list-items input { flex: none; width: 24px; height: 24px; margin: 0 10px 0 0; }
.list-items span { flex: 1; min-width: 0; overflow-wrap: break-word; word-break: break-word; }
/* An item with no checkbox (a message) has no label around its text. */
.list-items li > span { min-height: 40px; margin-right: 10px; padding: 9px 0; box-sizing: border-box; }
.list-items span.done { color: #8496a6; text-decoration: line-through; }
.list-items button { flex: none; background: #4a2f33; }
#steps { margin: 0; padding: 0; list-style: none; }
#steps li { margin-bottom: 6px; padding: 8px 12px; border-radius: 8px; background: #252d36; font-size: 16px; }
#steps li[aria-current="true"] { outline: 2px solid #2f6fb0; }
#steps small { display: block; color: #8496a6; }
#steps button { min-height: 40px; margin-top: 6px; }

#login { position: fixed; z-index: 3; top: 0; right: 0; bottom: 0; left: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: #101418; }
#login > * + * { margin-top: 14px; }
#login h1 { margin: 0; font-size: 26px; font-weight: 500; }
#login label { width: 420px; max-width: 90%; margin-bottom: -6px; font-size: 18px; }
#login input { width: 420px; max-width: 90%; padding: 12px; border: 1px solid #3a4652; border-radius: 8px; background: #1a2027; color: inherit; font-size: 20px; }
#login-message { min-height: 24px; margin: 0; color: #ff9b9b; }

/* The choice between the tablet and the phone panel, shown once the login is passed. */
#mode-choice { position: fixed; z-index: 3; top: 0; right: 0; bottom: 0; left: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: #101418; }
#mode-choice > * + * { margin-top: 14px; }
#mode-choice h1 { margin: 0; font-size: 26px; font-weight: 500; }
#mode-choice button { width: 240px; max-width: 90%; font-size: 20px; }

/* The phone panel: the edit panel is the page and scrolls, under the layout preview. The preview is
   the live layout's iframe at the landscape tablet size 1280x610, scaled to the box's width by
   shell.js (fitPhonePreview). A transform keeps the space the iframe takes, so the iframe is out of
   the flow and the box's height is 610/1280 of its width. The tablet keeps every rule above
   unchanged; these only apply with body.mode-phone. */
body.mode-phone { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.mode-phone #phone-preview { position: relative; height: 0; padding-bottom: 47.65625%; overflow: hidden; }
.mode-phone #page { position: absolute; width: 1280px; height: 610px; transform-origin: 0 0; }
/* The bars and the waiting status float at the bottom, off the preview at the top; the panel keeps
   room under its last buttons for them. On a phone 360 CSS pixels wide the draft bar wraps to about
   108px tall, so the room is more than the tablet panel's 76px. */
.mode-phone #panel { position: static; width: auto; max-width: none; padding: 16px 16px 130px; box-shadow: none; }
.mode-phone #screen-fit { display: none; }
.mode-phone #preview-bar { top: auto; right: 12px; bottom: 12px; flex-wrap: wrap; }
.mode-phone #status { top: auto; bottom: 12px; }
