/* RemoteLab phone UI: dark "control room" look (see the RemoteLab redesign canvas). */
@font-face { font-family: 'Plex'; font-weight: 400; font-display: swap; src: url(/fonts/ibm-plex-sans-vietnamese-400-normal.woff2) format('woff2'); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: 'Plex'; font-weight: 500; font-display: swap; src: url(/fonts/ibm-plex-sans-vietnamese-500-normal.woff2) format('woff2'); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: 'Plex'; font-weight: 600; font-display: swap; src: url(/fonts/ibm-plex-sans-vietnamese-600-normal.woff2) format('woff2'); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: 'Plex'; font-weight: 700; font-display: swap; src: url(/fonts/ibm-plex-sans-vietnamese-700-normal.woff2) format('woff2'); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: 'Plex'; font-weight: 400; font-display: swap; src: url(/fonts/ibm-plex-sans-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Plex'; font-weight: 500; font-display: swap; src: url(/fonts/ibm-plex-sans-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Plex'; font-weight: 600; font-display: swap; src: url(/fonts/ibm-plex-sans-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Plex'; font-weight: 700; font-display: swap; src: url(/fonts/ibm-plex-sans-latin-700-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Plex Mono'; font-weight: 400; font-display: swap; src: url(/fonts/ibm-plex-mono-vietnamese-400-normal.woff2) format('woff2'); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: 'Plex Mono'; font-weight: 500; font-display: swap; src: url(/fonts/ibm-plex-mono-vietnamese-500-normal.woff2) format('woff2'); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: 'Plex Mono'; font-weight: 400; font-display: swap; src: url(/fonts/ibm-plex-mono-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Plex Mono'; font-weight: 500; font-display: swap; src: url(/fonts/ibm-plex-mono-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --bg: #121417;
  --bg-deep: #0A0B0D;
  --surface: #1B1E22;
  --surface-2: #24282D;
  --inset: #0E1013;
  --bar: #17191C;
  --border: #30353B;
  --border-2: #3A4047;
  --line: #2A2E33;
  --text: #EDEBE6;
  --text-2: #D8DCE0;
  --muted: #A3A8AE;
  --idle: #68707A;
  --accent: #8CC6FF;
  --accent-ink: #0B1622;
  --accent-soft: #1E2C3B;
  --run: #5FD08A;
  --ok-text: #9FE0B4;
  --ok-soft: #16251C;
  --wait: #F2B34B;
  --wait-text: #F2C877;
  --wait-soft: #3A2E17;
  --wait-line: #5A4520;
  --danger: #F28B82;
  --danger-soft: #381F1F;
  --danger-line: #6B3535;
  --plan: #A9D3FF;
  --ask: #D2B8F5;
  --ask-soft: #2C2438;
  --user-bubble: #24303D;
  --user-line: #34465A;
  --radius: 16px;
  --mono: 'Plex Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --sans: 'Plex', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --safe-t: env(safe-area-inset-top);
  --safe-b: env(safe-area-inset-bottom);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 var(--sans);
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
#app { height: 100dvh; display: flex; flex-direction: column; position: relative; overflow: hidden; }
svg { flex: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* Keyboard focus: a visible ring on everything (mouse and touch taps do not show it). Text fields
   show it on any focus, as a brighter border. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline-offset: -1px; border-color: var(--accent) !important; }
/* Dialogs and other containers that take focus only so that Tab starts inside them. */
.sheet[tabindex="-1"]:focus-visible { outline: none; }

/* ---------- shared bits ---------- */
.btn {
  min-height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--border-2);
  background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; line-height: 1.2;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.btn.danger { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger); }
.btn.ghost { background: none; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn svg { width: 18px; height: 18px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; border: 0; background: none; color: var(--text);
  display: inline-grid; place-items: center; flex: none; text-decoration: none;
}
.icon-btn.boxed { background: var(--surface); border: 1px solid var(--border); }
.icon-btn:active { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }
.tag { height: 22px; padding: 0 7px; border-radius: 6px; font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; flex: none; }
.tag.wait { background: var(--wait-soft); color: var(--wait-text); }
.tag.plan { background: var(--accent-soft); color: var(--plan); }
.tag.ask { background: var(--ask-soft); color: var(--ask); }
.tag.ok { background: var(--ok-soft); color: var(--ok-text); }
.tag.mute { background: var(--surface-2); color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; box-sizing: border-box; border: 2px solid var(--idle); }
.dot.running, .dot.starting { border: 0; background: var(--run); box-shadow: 0 0 0 4px rgba(95,208,138,.18); }
.dot.waiting, .dot.requires_action { border: 0; background: var(--wait); }
.dot.relay { border: 0; background: var(--accent); }
.dot.offline { border: 2px solid var(--idle); }
.empty { text-align: center; color: var(--muted); padding: 48px 24px; font-size: 14px; }
.h-sec { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.mono { font-family: var(--mono); }

/* ---------- top of the tab pages ---------- */
.top { display: flex; align-items: center; gap: 10px; padding: calc(var(--safe-t) + 12px) 16px 8px; }
.pc-chip {
  flex: 1; min-width: 0; min-height: 48px; padding: 0 12px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  display: flex; align-items: center; gap: 10px; text-align: left; text-decoration: none;
}
.pc-chip.compact { flex: none; min-height: 40px; font-size: 13px; font-weight: 600; gap: 8px; }
.pc-chip .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.pc-chip .nm { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-chip .sub { font-size: 12px; color: var(--muted); font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-chip svg { width: 16px; height: 16px; color: var(--muted); }
.page-title { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.page-title h1 { margin: 0; font-size: 24px; font-weight: 700; }
.page-title .sub { font-size: 13px; color: var(--muted); }
.conn-bar {
  margin: 0 16px 4px; min-height: 36px; padding: 0 6px 0 12px; border-radius: 10px;
  background: #2A2418; border: 1px solid var(--wait-line); color: var(--wait-text); font-size: 13px;
  display: flex; align-items: center; gap: 10px;
}
.conn-bar span { flex: 1; }
.conn-bar a { color: var(--wait-text); font-weight: 600; text-decoration: none; padding: 6px 10px; }
.searchbox { padding: 2px 16px 4px; }
.searchbox input { width: 100%; height: 44px; padding: 0 14px; border-radius: 12px; background: var(--inset); border: 1px solid var(--border-2); }

/* ---------- bottom tab bar ---------- */
.tabbar {
  flex: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px;
  padding: 6px 12px calc(var(--safe-b) + 8px); background: var(--bar); border-top: 1px solid var(--line);
}
.tabbar a {
  position: relative; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 500;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.on { color: var(--accent); font-weight: 600; }
.tabbar .badge {
  position: absolute; top: 2px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--wait); color: #1A1306; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}

/* ---------- session list ---------- */
.chips { display: flex; gap: 8px; padding: 8px 16px 6px; overflow-x: auto; scrollbar-width: none; flex: none; }
.chip {
  flex: none; height: 36px; padding: 0 14px; border-radius: 18px; font-size: 14px; font-weight: 500; white-space: nowrap;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
}
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
/* 36 px pills, 44 px to the finger: the hit area reaches into the row's padding. */
.chip, .seg button { position: relative; }
.chip::after, .seg button::after { content: ''; position: absolute; inset: -4px 0; }
.list-wrap { flex: 1; overflow-y: auto; padding: 0 8px 96px; }
.section { padding: 4px 0 2px; }
.sec-head {
  width: 100%; min-height: 44px; display: flex; align-items: center; gap: 8px; padding: 0 8px;
  background: none; border: 0; color: var(--muted); text-align: left;
}
.sec-head .chev { width: 14px; height: 14px; transition: transform .15s; transform: rotate(90deg); }
.section.collapsed .chev { transform: none; }
.section.collapsed .sec-body { display: none; }
.sec-head .sec-name { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.sec-head .sec-count { font-size: 13px; font-family: var(--mono); }
.item {
  display: flex; align-items: center; gap: 12px; padding: 10px 8px; min-height: 60px; border-radius: 12px;
  color: var(--text); text-decoration: none; cursor: pointer;
}
.item:active { background: var(--surface); }
.item .ic { width: 36px; height: 36px; flex: none; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); display: grid; place-items: center; }
.item .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.item .t { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .m { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 13px; color: var(--muted); }
.item .m > span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .time { font-size: 12px; color: var(--muted); flex: none; }
.fab {
  position: absolute; right: 16px; bottom: calc(var(--safe-b) + 84px); z-index: 4;
  height: 52px; padding: 0 20px 0 16px; border-radius: 26px; border: 0;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 15px;
  display: flex; align-items: center; gap: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.45); text-decoration: none;
}
.fab svg { width: 20px; height: 20px; }

/* ---------- inbox ---------- */
.inbox { flex: 1; overflow-y: auto; padding: 8px 16px 24px; display: flex; flex-direction: column; gap: 12px; }
.card {
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
  padding: 14px; display: flex; flex-direction: column; gap: 10px;
}
.card.flash { border: 2px solid var(--wait); }
.card.done { background: #171A1D; border-color: var(--line); }
.card .head { display: flex; align-items: center; gap: 8px; }
.card .head .src {
  flex: 1; min-width: 0; min-height: 32px; display: flex; align-items: center; gap: 4px;
  font-size: 13px; color: var(--muted); text-decoration: none; background: none; border: 0; padding: 0; text-align: left;
}
.card .head .src span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .head .src svg { width: 14px; height: 14px; }
.card .head .time { font-size: 12px; color: var(--muted); flex: none; }
.card p { margin: 0; font-size: 15px; line-height: 1.4; }
.card pre, .ask pre {
  margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--inset); border: 1px solid #262A2F;
  font: 12.5px/1.5 var(--mono); color: var(--text-2); white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow: auto;
}
.acts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.acts.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.acts .btn { min-height: 46px; padding: 0 6px; }
.decided {
  min-height: 46px; padding: 0 6px 0 14px; border-radius: 12px; background: var(--ok-soft); color: var(--ok-text);
  font-size: 14px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.decided.deny { background: var(--danger-soft); color: var(--danger); }
.decided button { height: 36px; padding: 0 12px; border-radius: 9px; background: none; border: 1px solid currentColor; color: inherit; font-size: 13px; font-weight: 600; }
.opt {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px; text-align: left;
  background: var(--surface-2); border: 1px solid var(--border-2); color: var(--text);
  display: flex; align-items: flex-start; gap: 10px;
}
.opt .ring { width: 18px; height: 18px; border-radius: 50%; flex: none; border: 2px solid var(--idle); margin-top: 1px; }
.opt.sel { background: var(--accent-soft); border-color: var(--accent); }
.opt.sel .ring { border: 5px solid var(--accent); }
.opt.multi .ring { border-radius: 5px; }
.opt .ol { font-weight: 600; font-size: 14px; }
.opt .od { font-size: 13px; color: var(--muted); }
.opt pre { margin-top: 6px; font-size: 11.5px; }
.q { display: flex; flex-direction: column; gap: 8px; }
.q .qh { font-size: 12px; color: var(--ask); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.q .qt { font-size: 15px; font-weight: 600; }
.field-in, .q input[type=text], .ask input[type=text], .ask textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px; background: var(--inset);
  border: 1px solid var(--border-2); color: var(--text);
}
.plan-body { background: var(--inset); border: 1px solid var(--line); border-radius: 10px; padding: 2px 12px; max-height: 36vh; overflow-y: auto; }
.ok-ic { width: 32px; height: 32px; border-radius: 10px; background: var(--ok-soft); display: grid; place-items: center; flex: none; }
.ok-ic svg { width: 18px; height: 18px; }

/* ---------- sheets ---------- */
.sheet-back { position: fixed; inset: 0; z-index: 30; background: rgba(4,5,6,.72); display: flex; flex-direction: column; justify-content: flex-end; }
.sheet {
  max-height: calc(100dvh - var(--safe-t) - 40px); background: var(--bg); border-top: 1px solid var(--border);
  border-radius: 22px 22px 0 0; display: flex; flex-direction: column; animation: up .18s ease-out;
}
@keyframes up { from { transform: translateY(30px); opacity: .5; } }
.sheet.tall { height: calc(100dvh - var(--safe-t) - 40px); }
/* The small "are you sure?" sheet (confirmSheet), above any other sheet. */
.dlg-back { position: fixed; inset: 0; z-index: 40; background: rgba(4,5,6,.72); display: flex; flex-direction: column; justify-content: flex-end; }
.sheet.confirm { padding-top: 14px; }
.sheet.confirm .body { flex: none; gap: 16px; }
.sheet.confirm .lead { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--border-2); margin: 8px auto 0; }
.sheet header { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 4px 18px; }
.sheet header h1 { margin: 0; font-size: 20px; font-weight: 700; }
.sheet .body { flex: 1; overflow-y: auto; padding: 6px 16px calc(var(--safe-b) + 24px); display: flex; flex-direction: column; gap: 18px; }
.group { display: flex; flex-direction: column; gap: 6px; }
.group .h-sec { margin: 0 4px 2px; }
.rows { border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); display: flex; flex-direction: column; }
.row-i { min-height: 60px; padding: 8px 8px 8px 14px; display: flex; align-items: center; gap: 12px; }
.row-i + .row-i { border-top: 1px solid var(--line); }
.row-i .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-i .txt b { font-size: 15px; font-weight: 400; }
.row-i .txt small { font-size: 12.5px; color: var(--muted); }
.switch { width: 52px; height: 32px; flex: none; border-radius: 16px; border: 0; padding: 3px; background: var(--border-2); display: flex; justify-content: flex-start; margin-right: 6px; }
.switch::after { content: ''; width: 26px; height: 26px; border-radius: 50%; background: #fff; }
.switch[aria-checked=true] { background: #4E9BE0; justify-content: flex-end; }
.pc-card { border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.pc-card .id { display: flex; align-items: center; gap: 12px; }
.pc-card .id .ic { width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; flex: none; }
.pc-card .id .ic svg { width: 22px; height: 22px; }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; }
.kv div { padding: 10px; border-radius: 10px; background: #15171A; }
.kv dt { font-size: 12px; color: var(--muted); }
.kv dd { margin: 2px 0 0; font-size: 14px; font-weight: 500; }
.note { margin: 2px 4px 0; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.adv summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 6px 4px; }
.adv .inner { display: flex; flex-direction: column; gap: 10px; padding-top: 6px; }
.adv label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.diag { display: flex; flex-direction: column; gap: 8px; }
.diag .lbl { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 4px 4px 0; }
.diag-list { margin: 0; padding: 0 4px; list-style: none; display: flex; flex-direction: column; gap: 4px; font: 12.5px/1.45 var(--mono); color: var(--text-2); word-break: break-word; }
.diag .kv dd { word-break: break-word; }
.folder { display: flex; align-items: center; gap: 4px; }
.folder .pick {
  flex: 1; min-width: 0; min-height: 60px; padding: 8px 10px; border-radius: 12px; display: flex; align-items: center; gap: 12px;
  background: none; border: 1px solid transparent; color: var(--text); text-align: left;
}
.folder .pick.sel { background: var(--accent-soft); border-color: var(--accent); }
.folder .pick .ic { width: 36px; height: 36px; flex: none; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); display: grid; place-items: center; }
.folder .pick .ic svg { width: 18px; height: 18px; color: var(--muted); }
.folder .pick .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.folder .pick b { font-size: 15px; font-weight: 600; }
.folder .pick small { font-size: 12px; color: var(--muted); font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder .pin svg { width: 18px; height: 18px; }
.folder .pin.on { color: var(--accent); }
.selrow { display: flex; gap: 8px; flex-wrap: wrap; }
.selrow select, .sel {
  height: 36px; padding: 0 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); color: var(--text-2); font-size: 13px;
}
.new-foot { border-top: 1px solid var(--line); padding: 10px 16px calc(var(--safe-b) + 12px); display: flex; flex-direction: column; gap: 8px; }
.new-foot textarea { width: 100%; min-height: 72px; max-height: 30vh; padding: 10px 12px; border-radius: 12px; background: var(--inset); border: 1px solid var(--border-2); resize: none; }
.new-foot .line { display: flex; gap: 8px; align-items: center; }
.err-text { color: var(--danger); font-size: 13px; min-height: 18px; }

/* ---------- connect / pair ---------- */
.pair { flex: 1; overflow-y: auto; padding: calc(var(--safe-t) + 40px) 20px calc(var(--safe-b) + 24px); display: flex; flex-direction: column; gap: 18px; max-width: 460px; width: 100%; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; }
.brand .logo { width: 36px; height: 36px; border-radius: 9px; background: var(--bg); border: 1px solid var(--border); display: grid; place-items: center; overflow: hidden; }
.brand .logo svg { width: 100%; height: 100%; display: block; }
.pair h1 { margin: 4px 0 0; font-size: 28px; line-height: 1.15; }
.pair .lead { margin: 0; color: var(--muted); font-size: 14px; }
.pair label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.pair input {
  height: 52px; padding: 0 14px; border-radius: 12px; background: var(--inset); border: 1px solid var(--border-2); color: var(--text); font-size: 16px;
}
.pair input.code { font: 500 22px var(--mono); letter-spacing: .14em; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ---------- chat ---------- */
.chat-top { display: flex; align-items: center; gap: 2px; padding: calc(var(--safe-t) + 8px) 6px 8px 4px; border-bottom: 1px solid #23272B; flex: none; }
.chat-top .title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.chat-top h1 { margin: 0; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-top .sub { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; }
.chat-top .sub .dot { width: 7px; height: 7px; box-shadow: none; }
.chat { flex: 1; overflow-y: auto; padding: 14px 14px 20px; overflow-anchor: none; }
/* Doubled class: wins over the vertical-margin shorthands of .md, .tool, .notice… so every item is centred. */
.chat.chat > * { max-width: 860px; margin-left: auto; margin-right: auto; }
.msg-user { display: flex; justify-content: flex-end; margin: 14px 0; }
.msg-user .bubble {
  background: var(--user-bubble); border: 1px solid var(--user-line); border-radius: 18px 18px 6px 18px; padding: 10px 14px; max-width: 86%;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg-user .imgs { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; margin-bottom: 6px; }
.msg-user img, .tool-body img, .md img { max-width: 100%; max-height: 320px; border-radius: 10px; display: block; }
.msg-user .imgs img { max-width: 160px; max-height: 160px; object-fit: cover; }
.md { margin: 10px 0; overflow-wrap: anywhere; }
.md p { margin: .55em 0; }
.md ul, .md ol { padding-left: 1.4em; margin: .5em 0; }
.md li { margin: .2em 0; }
.md h1, .md h2, .md h3, .md h4 { line-height: 1.3; margin: 1em 0 .4em; }
.md h1 { font-size: 1.3em; } .md h2 { font-size: 1.18em; } .md h3 { font-size: 1.06em; }
.md code { font-family: var(--mono); font-size: .88em; background: var(--inset); padding: .1em .35em; border-radius: 5px; }
.md pre { background: var(--inset); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; overflow-x: auto; font-size: 13px; line-height: 1.45; }
.md pre code { background: none; padding: 0; font-size: inherit; }
.md table { border-collapse: collapse; display: block; overflow-x: auto; font-size: 14px; margin: .6em 0; }
.md th, .md td { border: 1px solid var(--line); padding: 5px 8px; text-align: left; vertical-align: top; }
.md th { background: var(--surface); }
.md blockquote { margin: .5em 0; padding-left: 12px; border-left: 3px solid var(--border); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--line); }
.md a { word-break: break-all; }
.sub-msgs .md { font-size: 14px; }
details.think { margin: 8px 0; color: var(--muted); font-size: 14px; }
details.think > summary { cursor: pointer; list-style: none; display: inline-flex; gap: 6px; align-items: center; }
details.think > summary::-webkit-details-marker { display: none; }
details.think > summary svg { width: 15px; height: 15px; }
details.think .think-body { white-space: pre-wrap; border-left: 2px solid var(--border); padding: 4px 0 4px 10px; margin-top: 4px; }

.tool { border: 1px solid var(--border); background: var(--surface); border-radius: 12px; margin: 8px 0; overflow: hidden; }
.tool > .head {
  display: flex; align-items: center; gap: 10px; padding: 0 12px; min-height: 44px; cursor: pointer; font-size: 13px;
  width: 100%; background: none; border: 0; color: inherit; text-align: left;
}
.tool > .head:focus-visible { outline-offset: -2px; border-radius: 12px; }
.tool > .head .name { font-weight: 600; flex: none; color: var(--text-2); }
.tool > .head .sum { color: var(--text-2); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--mono); font-size: 12.5px; }
.tool > .head .st { flex: none; font-size: 12px; }
.tool.pending > .head .st::after { content: ''; display: inline-block; width: 12px; height: 12px; border: 2px solid var(--muted); border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
.tool.ok > .head .st::after { content: 'xong'; color: var(--ok-text); }
.tool.err > .head .st::after { content: 'lỗi'; color: var(--danger); }
@keyframes spin { to { transform: rotate(360deg); } }
.tool-body { display: none; border-top: 1px solid var(--line); padding: 8px 12px; font-size: 13px; }
.tool.open .tool-body { display: block; }
.tool-body pre { margin: 4px 0; font: 12px var(--mono); white-space: pre-wrap; word-break: break-word; background: var(--inset); border-radius: 8px; padding: 8px; max-height: 420px; overflow: auto; color: var(--text-2); }
.tool-body .lbl { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 6px; }
.diff { font: 12px/1.6 var(--mono); border-radius: 8px; overflow: auto; max-height: 460px; background: var(--inset); margin-top: 4px; }
.diff div { white-space: pre-wrap; word-break: break-word; padding: 0 8px; }
.diff .del { background: #2A1C1C; color: #F5B5AE; }
.diff .add { background: var(--ok-soft); color: #B5E8C6; }
.diff .ctx { color: var(--muted); }
.diffstat { font-family: var(--mono); font-size: 12px; flex: none; }
.diffstat .a { color: var(--ok-text); } .diffstat .d { color: var(--danger); }
.file-link { font-family: var(--mono); font-size: 12px; word-break: break-all; }
.sub-msgs { border-left: 2px solid var(--border); margin: 6px 0 2px; padding-left: 10px; }
.notice { text-align: center; color: var(--muted); font-size: 13px; margin: 10px 0; white-space: pre-wrap; }
.notice.error { color: var(--danger); }
.notice.warn { color: var(--wait-text); }
.result-chip { display: flex; justify-content: center; margin: 12px 0 18px; }
.result-chip span { font-size: 12.5px; color: var(--muted); background: var(--surface); border-radius: 999px; padding: 4px 12px; }
.result-chip.err span { color: var(--danger); }
.typing { color: var(--muted); font-size: 14px; margin: 8px 0; display: flex; gap: 6px; align-items: center; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 50% { opacity: .2; } }
.load-more { display: flex; justify-content: center; margin: 4px 0 10px; }

.tasks { margin: 10px 12px 0; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); flex: none; }
.tasks > summary { min-height: 44px; padding: 8px 12px; cursor: pointer; font-size: 13px; display: flex; gap: 10px; align-items: center; list-style: none; }
.tasks > summary::-webkit-details-marker { display: none; }
.tasks .bar-prog { flex: none; width: 60px; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.tasks .bar-prog i { display: block; height: 100%; background: var(--run); }
.tasks .cur { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tasks .chev-sm { width: 16px; height: 16px; color: var(--muted); transition: transform .15s; }
.tasks[open] .chev-sm { transform: rotate(180deg); }
.tasks ul { list-style: none; margin: 0; padding: 4px 12px 10px; max-height: 40vh; overflow-y: auto; border-top: 1px solid var(--line); }
.tasks li { display: flex; gap: 8px; align-items: center; font-size: 13px; padding: 3px 0; }
.tasks li .ck { width: 14px; height: 14px; border-radius: 50%; flex: none; border: 2px solid var(--idle); }
.tasks li.completed { color: var(--muted); }
.tasks li.completed .ck { border: 0; background: var(--run); }
.tasks li.in_progress .ck { border-color: var(--accent); }

.bottom { flex: none; border-top: 1px solid #23272B; background: #15171A; padding: 8px 12px calc(var(--safe-b) + 10px); }
.bottom > * { max-width: 860px; margin-left: auto; margin-right: auto; }
.asks { max-height: 58vh; overflow-y: auto; }
.asks:empty { display: none; }
.ask {
  background: #1E1B14; border: 1px solid var(--wait-line); border-radius: 14px; padding: 12px; margin-bottom: 8px;
  display: flex; flex-direction: column; gap: 8px;
}
.ask h3 { margin: 0; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.ask .desc { font-size: 13px; color: var(--muted); }
.banner { font-size: 13px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; margin-bottom: 8px; color: var(--muted); }
.banner b { color: var(--text); }
.queue-list { margin-top: 6px; }
.queue-list div { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--text); }
.queue-list div svg { width: 14px; height: 14px; color: var(--muted); }
.queue-list div span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mode-row { display: flex; gap: 6px; margin-bottom: 8px; overflow-x: auto; scrollbar-width: none; }
.mode-row .sel { height: 32px; font-size: 12px; }
.composer { display: flex; align-items: flex-end; gap: 8px; }
.composer textarea {
  flex: 1; min-width: 0; min-height: 44px; max-height: 108px; padding: 11px 14px; border-radius: 22px;
  background: var(--surface); border: 1px solid var(--border-2); resize: none; line-height: 1.4;
}
.round { width: 44px; height: 44px; flex: none; border-radius: 22px; border: 0; display: grid; place-items: center; }
.round svg { width: 20px; height: 20px; }
.round.attach { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.round.send { background: var(--accent); color: var(--accent-ink); }
.round.stop { background: var(--danger-soft); border: 1px solid var(--danger-line); color: var(--danger); }
.round.stop svg { width: 16px; height: 16px; }
.pill-send { height: 44px; padding: 0 14px; flex: none; border-radius: 22px; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 14px; }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.thumbs .th { position: relative; }
.thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; display: block; }
/* The remove button is 44 px to the finger; the dot drawn in it stays small. */
.thumbs button {
  position: absolute; top: -14px; right: -14px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: none; padding: 0;
  display: grid; place-items: center; color: var(--bg);
}
.thumbs button span { width: 22px; height: 22px; border-radius: 50%; background: var(--text); font-size: 13px; line-height: 22px; text-align: center; }
.thumbs .th { margin: 0 8px 8px 0; }

/* Placed by toast() above whatever bars sit at the bottom (inline bottom/top). */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-b) + 100px);
  background: var(--text); color: var(--bg); border-radius: 12px; padding: 10px 14px; font-size: 14px; z-index: 60;
  max-width: min(520px, calc(100% - 32px)); box-shadow: 0 6px 20px rgba(0,0,0,.5);
}
.toast:empty { display: none; }
.toast button { all: unset; cursor: pointer; display: block; }
.toast button:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 4px; border-radius: 4px; }
.menu {
  position: absolute; right: 10px; top: calc(var(--safe-t) + 56px); z-index: 30; min-width: 250px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.5); padding: 6px;
}
.menu button { display: block; width: 100%; min-height: 44px; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 8px; }
.menu button:active { background: var(--surface-2); }
.menu .sep { height: 1px; background: var(--line); margin: 4px 0; }
.menu .lbl { font-size: 12px; color: var(--muted); padding: 6px 10px 2px; }
.menu select { width: 100%; height: 40px; border: 1px solid var(--border); background: var(--inset); border-radius: 8px; padding: 0 8px; margin: 2px 0 6px; }

/* One-time hint for a home-screen app installed from the old shared address (showPwaHint). */
.pwa-hint {
  position: fixed; left: 12px; right: 12px; top: calc(var(--safe-t) + 8px); z-index: 50; max-width: 600px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 14px; border-radius: 14px;
  background: var(--accent-soft); border: 1px solid var(--accent); color: var(--text); font-size: 14px; line-height: 1.4;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.pwa-hint span { flex: 1; }
.pwa-hint .btn { flex: none; min-height: 44px; }
.offline .btn svg { width: 18px; height: 18px; }

/* ---------- wide screens (a PC browser): the phone layout, centred at a readable width ---------- */
@media (min-width: 900px) {
  .top, .searchbox, .chips { width: 100%; max-width: 760px; margin-left: auto; margin-right: auto; }
  .conn-bar { width: calc(100% - 32px); max-width: 728px; margin: 0 auto 4px; }
  .list-wrap > *, .inbox > * { width: 100%; max-width: 760px; margin-left: auto; margin-right: auto; }
  .item:hover, .folder .pick:hover { background: var(--surface); }
  .tool > .head:hover { background: var(--surface-2); }
  .fab { right: max(16px, calc(50% - 372px)); }
  .tabbar { padding-left: max(12px, calc(50% - 380px)); padding-right: max(12px, calc(50% - 380px)); }
  .chat-top { padding-left: max(4px, calc(50% - 440px)); padding-right: max(6px, calc(50% - 440px)); }
  .tasks { width: calc(100% - 24px); max-width: 860px; margin: 10px auto 0; }
  .menu.chat-menu { right: max(10px, calc(50% - 434px)); }
  .sheet-back, .dlg-back { justify-content: center; align-items: center; padding: 24px; }
  .sheet { width: 100%; max-width: 640px; max-height: calc(100dvh - 48px); border: 1px solid var(--border); border-radius: 22px; }
  .sheet.tall { height: min(880px, calc(100dvh - 48px)); }
  .sheet.confirm { max-width: 440px; }
  .sheet .grab { display: none; }
  .sheet .body, .new-foot { padding-bottom: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---------- remote screen ---------- */
html.scr-lock, body.scr-lock { overflow: hidden; overscroll-behavior: none; }
.scr-page { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; background: var(--bg-deep); overflow: hidden; touch-action: none; }
.scr-top { display: flex; align-items: center; gap: 6px; padding: calc(var(--safe-t) + 8px) 10px 8px 4px; flex: none; }
.scr-top .title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; line-height: 1.2; }
.scr-top h1 { margin: 0; font-size: 15px; font-weight: 600; }
.scr-top .sub { font-size: 12px; color: var(--muted); font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg { display: flex; padding: 3px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); flex: none; }
.seg button { min-height: 36px; padding: 0 10px; border-radius: 7px; border: 0; background: none; color: var(--text-2); font-size: 12px; font-weight: 600; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.scr-stage { position: relative; overflow: hidden; touch-action: none; background: #2B3542; flex: none; width: 100%; }
.scr-page.touch .scr-stage, .scr-page.no-pad .scr-stage { flex: 1; }
.scr-canvas { position: absolute; left: 0; top: 0; width: 100%; height: auto; transform-origin: 0 0; }
.scr-overlay {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: 86%;
  background: rgba(10,11,13,.82); color: #fff; padding: 10px 14px; border-radius: 12px; font-size: 14px; text-align: center; z-index: 3;
}
.scr-zoom { position: absolute; right: 10px; top: 10px; height: 26px; padding: 0 9px; border-radius: 13px; background: rgba(10,11,13,.78); font: 12px var(--mono); display: flex; align-items: center; pointer-events: none; z-index: 2; }
/* "Số liệu": live numbers measured on this side, over the top-left corner of the picture. */
.scr-stats {
  position: absolute; left: 8px; top: 8px; z-index: 2; pointer-events: none; padding: 5px 8px; border-radius: 8px;
  background: rgba(10,11,13,.78); color: #fff; font: 11.5px/1.45 var(--mono); white-space: nowrap;
}
.scr-cursor { position: absolute; left: 0; top: 0; will-change: transform; pointer-events: none; z-index: 2; filter: drop-shadow(0 0 1px rgba(0,0,0,.6)); }
.scr-pad {
  flex: 1; min-height: 156px; margin: 10px 10px 0; border-radius: 18px; background: #131518; border: 1px solid #23272B; touch-action: none;
  position: relative; display: flex; align-items: center; justify-content: center; text-align: center; padding: 0 40px;
  font-size: 13px; color: var(--muted); line-height: 1.5; user-select: none;
}
.scr-pad .wheel {
  position: absolute; right: 6px; top: 16px; bottom: 16px; width: 26px; border-radius: 13px;
  background: var(--surface); border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 6px 0;
}
.scr-pad .wheel svg { width: 12px; height: 12px; color: var(--muted); }
.scr-page.touch .scr-pad, .scr-page.no-pad .scr-pad { display: none; }
.scr-hint { flex: none; text-align: center; font-size: 12px; color: var(--muted); padding: 6px 0 0; display: none; }
.scr-page.touch .scr-hint { display: block; }
.scr-keys { margin: 8px 10px 0; padding: 10px; border-radius: 16px; background: var(--bar); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; flex: none; }
.scr-keyrow { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; touch-action: pan-x; }
.scr-keyrow button { flex: none; height: 44px; padding: 0 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border-2); font: 13px var(--mono); }
.scr-keyrow button.sys { background: #2A1C1C; border-color: var(--danger-line); color: var(--danger); }
.scr-kbline { display: flex; gap: 6px; align-items: center; }
.scr-kbline input { flex: 1; min-width: 0; height: 44px; padding: 0 12px; border-radius: 10px; background: var(--inset); border: 1px solid var(--border-2); outline: none; font-size: 15px; touch-action: manipulation; }
.scr-kbline .kb-hide { min-width: 44px; height: 44px; padding: 0 10px; gap: 4px; flex: none; }
.scr-kbline .kb-hide svg { width: 16px; height: 16px; }
.scr-tools {
  margin: 8px 10px calc(var(--safe-b) + 12px); padding: 6px; border-radius: 18px; background: var(--bar); border: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 4px; flex: none;
}
.scr-tools button {
  min-width: 44px; height: 56px; padding: 0 2px; border-radius: 12px; border: 0; background: none; color: var(--text);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; white-space: nowrap;
}
.scr-tools button svg { width: 20px; height: 20px; }
.scr-tools button.on { background: var(--accent-soft); color: var(--accent); }
.scr-tools button.mode { background: var(--surface-2); }
.scr-tools button.mode svg { color: var(--accent); }
.scr-page.touch .scr-tools .scr-pad-btn { display: none; }
.scr-tools .collapse { display: none; }
.scr-pill { display: none; }

/* While the phone's virtual keyboard is open: compact header -> full remaining stage -> keyboard tray. */
.scr-page.kb-open .scr-top { padding: calc(var(--safe-t) + 4px) 10px 4px 4px; }
.scr-page.kb-open .scr-stage { flex: 1; min-height: 96px; height: auto !important; }
.scr-page.kb-open .scr-pad,
.scr-page.kb-open .scr-hint,
.scr-page.kb-open .scr-tools,
.scr-page.kb-open .scr-pill { display: none !important; }
.scr-page.kb-open .scr-keys { margin: 6px 8px 8px; padding: 8px; gap: 6px; }

/* PC browser (mouse + keyboard): tools in the header, the whole PC screen fitted below. */
.scr-page.desk { flex-direction: column; }
.scr-page.desk .scr-top { display: flex; padding: 6px 10px 6px 4px; gap: 10px; border-bottom: 1px solid var(--line); }
.scr-page.desk .scr-stage { flex: 1; height: auto !important; outline: none; }
.scr-page.desk .scr-stage.own-cursor { cursor: none; }
/* Invisible box that reads the physical keyboard (kept at the pointer for the IME candidate list). */
.scr-sink {
  position: absolute; left: 0; top: 0; width: 2px; height: 1.2em; padding: 0; margin: 0; border: 0; outline: none;
  opacity: 0; resize: none; overflow: hidden; pointer-events: none; z-index: 1; font-size: 16px; caret-color: transparent;
}
.scr-ime { position: absolute; left: 0; top: 0; z-index: 4; padding: 3px 8px; border-radius: 6px; background: rgba(10,11,13,.86); color: #fff; font-size: 14px; pointer-events: none; white-space: pre; }
.scr-page.desk .scr-tools {
  display: flex; flex: none; width: auto; margin: 0; padding: 0; gap: 2px; border: 0; border-radius: 0; background: none;
}
.scr-page.desk .scr-tools button { flex-direction: row; height: 36px; padding: 0 10px; gap: 6px; font-size: 13px; border-radius: 8px; }
.scr-page.desk .scr-tools button svg { width: 18px; height: 18px; }
.scr-page.desk .scr-tools button:hover { background: var(--surface-2); }
.scr-page.desk .scr-tools button.on:hover { background: var(--accent-soft); }
.scr-page.desk .scr-tools .mode, .scr-page.desk .scr-tools .scr-pad-btn, .scr-page.desk .scr-tools .collapse { display: none !important; }
.scr-page.desk .seg button { min-height: 30px; }
.scr-page.desk .scr-keys { position: static; transform: none; width: auto; margin: 0 10px 10px; z-index: auto; }
.scr-page.desk .scr-keyrow { flex-wrap: wrap; overflow: visible; }
.scr-page.desk .scr-keyrow button, .scr-page.desk .scr-kbline input, .scr-page.desk .scr-kbline .btn { height: 34px !important; }
.scr-page.desk .scr-keyrow button:hover { border-color: var(--text-2); }
@media (max-width: 860px) { .scr-page.desk .scr-tools .lbl { display: none; } }

/* Landscape: the picture takes the whole height; tools sit in the black band on the right,
   or shrink to a floating pill. */
@media (orientation: landscape) and (max-height: 600px) and (min-width: 540px) {
  .scr-page { flex-direction: row; }
  .scr-top { display: none; }
  .scr-page .scr-stage, .scr-page.touch .scr-stage { flex: 1; height: 100% !important; }
  .scr-pad, .scr-hint, .scr-tools .scr-pad-btn { display: none !important; }
  .scr-tools {
    width: 103px; margin: 0; padding: 10px calc(env(safe-area-inset-right) + 8px) 10px 8px; border-radius: 0; border: 0; background: none;
    grid-template-columns: 1fr; align-content: center; gap: 6px;
  }
  .scr-tools button { height: 54px; }
  .scr-tools .collapse { display: flex; height: 44px; border: 1px solid var(--border); }
  .scr-keys { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); width: min(560px, 80vw); margin: 0; z-index: 5; }
  .scr-page.pill .scr-tools { display: none; }
  .scr-page.pill .scr-pill {
    display: flex; position: absolute; right: 14px; bottom: 14px; z-index: 6; padding: 5px; gap: 4px; border-radius: 26px;
    background: rgba(23,25,28,.86); border: 1px solid var(--border); backdrop-filter: blur(8px);
  }
  .scr-pill button { width: 44px; height: 44px; border-radius: 22px; border: 0; background: none; color: var(--text); display: grid; place-items: center; }
  .scr-pill button svg { width: 20px; height: 20px; }
  .scr-pill button.mode { background: var(--surface-2); color: var(--accent); }
  .scr-pill button.on { background: var(--accent-soft); color: var(--accent); }
  .scr-page.kb-open { flex-direction: column; }
  .scr-page.kb-open .scr-stage { height: auto !important; }
  .scr-page.kb-open .scr-keys { position: static; transform: none; width: auto; margin: 6px 8px 8px; }
}
.scr-montitle { font-weight: 500; color: var(--muted); }
.scr-vi { font: 600 11px var(--mono); padding: 1px 4px; border: 1.5px solid currentColor; border-radius: 4px; line-height: 1.2; }

/* PC screen header: "⋯" menu and the gesture/keys help over the picture. */
.scr-more { position: relative; }
.scr-menu-list { display: none; position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 280px; padding: 6px; border-radius: 12px; background: var(--bar); border: 1px solid var(--border); box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.scr-more.open .scr-menu-list { display: flex; flex-direction: column; gap: 2px; }
.scr-menu-list button { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; min-height: 44px; padding: 8px 12px; border: 0; border-radius: 8px; background: none; color: var(--text); text-align: left; font-size: 14px; }
.scr-menu-list button:hover, .scr-menu-list button:focus-visible { background: var(--surface-2); }
.scr-menu-list button.on { color: var(--accent); }
.scr-menu-list .sub { font-size: 12px; color: var(--muted); }
.scr-help { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 6; width: min(420px, calc(100% - 32px)); max-height: calc(100% - 32px); overflow: auto; padding: 18px; border-radius: 16px; background: rgba(17,19,22,.94); border: 1px solid var(--border); color: var(--text); }
.scr-help h2 { margin: 0 0 10px; font-size: 16px; }
.scr-help dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 14px; font-size: 14px; }
.scr-help dt { font-weight: 600; white-space: nowrap; }
.scr-help dd { margin: 0; color: var(--text-2); }
.scr-help .btn { width: 100%; }
