:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --ink: #1d1d1f;
  --ink2: #6e6e73;
  --line: #d9d9de;
  --tint: #e08a1e;
  --red: #d93025;
  --term-bg: #1e1f24;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111113; --card: #1c1c1f; --ink: #f2f2f4; --ink2: #9a9aa1; --line: #2e2e33; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--ink2); }
.small { font-size: 12px; }
.msg { min-height: 1.5em; color: var(--red); margin: 12px 0 0; }
button { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 8px; padding: 6px 14px; cursor: pointer; }
button:hover { border-color: var(--ink2); }
button.primary { background: var(--tint); border-color: var(--tint); color: #fff; }
button:disabled { opacity: .5; cursor: default; }
input, select { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); width: 100%; }

.page { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; }
.card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 28px 24px; text-align: center; }
.card h1 { font-size: 20px; margin: 12px 0 6px; }
.card button { display: block; width: 100%; margin-top: 10px; padding: 10px; }
.logo { width: 52px; height: 52px; margin: 0 auto; border-radius: 14px; background: var(--tint); color: #fff; font-size: 26px; font-weight: 700; line-height: 52px; }
.code { font: 700 44px/1.2 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 10px; margin: 6px 0; }

#app { height: 100%; display: flex; flex-direction: column; }
header { display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--card); }
.brand { font-weight: 700; }
.spacer { flex: 1; }
nav { display: flex; gap: 4px; }
.tab { border: none; background: none; padding: 6px 10px; color: var(--ink2); }
.tab.active { color: var(--ink); background: var(--bg); }
main { flex: 1; min-height: 0; display: flex; }
main > section { flex: 1; min-width: 0; display: flex; }

aside { width: 240px; border-right: 1px solid var(--line); background: var(--card); display: flex; flex-direction: column; }
.aside-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; color: var(--ink2); }
.aside-head button { padding: 2px 10px; }
#sessions { list-style: none; margin: 0; padding: 0 6px 8px; overflow: auto; }
#sessions li { padding: 7px 8px; border-radius: 8px; cursor: pointer; display: flex; gap: 8px; align-items: baseline; }
#sessions li:hover { background: var(--bg); }
#sessions li.active { background: var(--bg); font-weight: 600; }
#sessions .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink2); flex: none; }
#sessions .dot.running { background: #2f9e44; }
#sessions .dot.attention { background: var(--tint); }
#sessions .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#term-wrap { flex: 1; min-width: 0; position: relative; background: var(--term-bg); }
#term { position: absolute; inset: 6px; }
.empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #8a8a92; }
.overlay { position: absolute; inset: 0; display: flex; gap: 10px; align-items: center; justify-content: center; background: rgba(0,0,0,.55); color: #fff; z-index: 5; }
.overlay input { width: 220px; }

#pane-screen { flex-direction: column; }
#screen-bar { display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-bottom: 1px solid var(--line); background: var(--card); }
#screen-wrap { flex: 1; min-height: 0; position: relative; background: #000; display: flex; align-items: center; justify-content: center; }
#screen { max-width: 100%; max-height: 100%; outline: none; cursor: default; }
#screen-input { position: absolute; left: -9999px; top: 0; width: 1px; height: 1px; opacity: 0; }

dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--ink); width: 360px; }
dialog h3 { margin: 0 0 12px; }
dialog label { display: block; margin-bottom: 10px; color: var(--ink2); }
dialog .row { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 700px) {
  aside { width: 150px; }
  header .small, #left { display: none; }
}

/* 屏幕第二排放修饰键，小屏自动换行。 */
#screen-tools { display:flex; flex-wrap:wrap; align-items:center; gap:8px; padding:6px 12px; }
#screen-tools [aria-pressed="true"] { background:var(--tint); color:white; outline:2px solid currentColor; }
#screen-bar { flex-wrap:wrap; }
#screen { touch-action:none; }

/* 窗口列表限高，标题换行；保留画面和选屏入口。 */
#screen-other { display: flex; align-items: center; gap: 8px; padding: 6px; flex-wrap: wrap; }
#screen-windows, #screen-apps { max-height: 35vh; overflow: auto; padding: 6px; }
.screen-window-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0; }
.screen-window-row button:first-of-type { flex: 1; text-align: left; white-space: normal; overflow-wrap: anywhere; }
.screen-window-row strong { flex-basis: 100%; }
#screen-windows-error, #screen-apps-error { color: #d85b45; }
