:root {
  --bg: #F2F2F7; --card: #FFFFFF; --card2: #F7F7FA; --text: #0B0B0F; --muted: #6E6E76; --sep: rgba(60,60,67,.14);
  --blue: #0A6CFF; --green: #1DB954; --orange: #FF9500; --red: #FF3B30; --indigo: #5856D6; --gray: #8E8E93;
  --bar: rgba(249,249,251,.82); --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(20,20,40,.06);
  --btn: #F1F1F5; --btn-text: #1C1C1E; --radius: 22px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --card: #1C1C1E; --card2: #2C2C2E; --text: #F5F5F7; --muted: #98989F; --sep: rgba(84,84,88,.55);
    --blue: #3A8BFF; --green: #30D158; --orange: #FF9F0A; --red: #FF453A; --indigo: #7D7AFF;
    --bar: rgba(22,22,24,.78); --shadow: none; --btn: #2C2C2E; --btn-text: #F5F5F7;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; overscroll-behavior-y: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
#app.booting { opacity: 0; }
#app { transition: opacity .25s ease; }

/* ---------- 登入 ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: calc(env(safe-area-inset-top) + 24px) 24px calc(env(safe-area-inset-bottom) + 24px); }
.login-inner { width: 100%; max-width: 360px; text-align: center; }
.login-icon { width: 96px; height: 96px; border-radius: 22px; box-shadow: 0 10px 30px rgba(10,60,200,.25); }
.login h1 { font-size: 30px; letter-spacing: .02em; margin: 18px 0 4px; }
.login form { margin-top: 28px; display: grid; gap: 12px; }
.field input { width: 100%; height: 52px; border-radius: 14px; border: 1px solid var(--sep); background: var(--card); color: var(--text); padding: 0 16px; font-size: 17px; outline: none; transition: border-color .2s, box-shadow .2s; }
.field input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue) 18%, transparent); }
.btn-primary { height: 52px; width: 100%; border-radius: 14px; background: var(--blue); color: #fff; font-size: 17px; font-weight: 600; transition: transform .1s, opacity .2s; }
.btn-primary:active { transform: scale(.98); opacity: .9; }
.btn-primary[disabled] { opacity: .5; }
.btn-secondary { height: 48px; width: 100%; border-radius: 14px; background: var(--btn); color: var(--blue); font-size: 17px; font-weight: 600; }
.err { color: var(--red); min-height: 20px; margin: 0; font-size: 14px; }
.fine { font-size: 12.5px; color: var(--muted); margin-top: 28px; line-height: 1.5; }

/* ---------- 版面 ---------- */
.screen { min-height: 100dvh; }
.topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 20; height: calc(env(safe-area-inset-top) + 48px); padding: env(safe-area-inset-top) 12px 0;
  display: flex; align-items: center; justify-content: center; background: transparent; transition: background .2s, border-color .2s; border-bottom: .5px solid transparent; }
.topbar.scrolled { background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-bottom-color: var(--sep); }
.topbar-title { font-weight: 600; font-size: 17px; opacity: 0; transition: opacity .2s; }
.topbar.scrolled .topbar-title { opacity: 1; }
.icon-btn { position: absolute; right: 10px; bottom: 4px; width: 40px; height: 40px; border-radius: 20px; display: grid; place-items: center; color: var(--blue); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.views { max-width: 720px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 48px) 16px calc(env(safe-area-inset-bottom) + 96px); }
.large-title { padding: 2px 4px 14px; }
.large-title h1 { font-size: 34px; line-height: 1.15; margin: 0; font-weight: 700; letter-spacing: .01em; }
.large-title p { margin: 4px 0 0; font-size: 15px; }

/* ---------- 電腦卡片 ---------- */
.cards { display: grid; gap: 14px; }
@media (min-width: 900px) { .views { max-width: 1100px; } .cards { grid-template-columns: repeat(3, 1fr); } }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; overflow: hidden; }
.card-head { display: flex; gap: 14px; align-items: center; }
.dev-ico { flex: none; width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; color: #fff; background: linear-gradient(160deg, #5E9BFF, #1F5BFF); }
.dev-ico.mac { background: linear-gradient(160deg, #A0A6B4, #5B606D); }
.dev-ico.desktop { background: linear-gradient(160deg, #6E7BFF, #3A2FE0); }
.dev-ico svg { width: 30px; height: 30px; }
.card.off .dev-ico { filter: saturate(.25) brightness(.95); }
.dev-meta { min-width: 0; flex: 1; }
.dev-name { font-size: 19px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.dev-sub { font-size: 13.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { flex: none; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 5px 10px; border-radius: 999px; background: var(--card2); color: var(--muted); }
.pill i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.online { color: var(--green); background: color-mix(in srgb, var(--green) 14%, transparent); }
.pill.online i { box-shadow: 0 0 0 0 currentColor; animation: pulse 2.2s ease-out infinite; }
.pill.sleeping { color: var(--indigo); background: color-mix(in srgb, var(--indigo) 14%, transparent); }
.pill.unpaired { color: var(--orange); background: color-mix(in srgb, var(--orange) 14%, transparent); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--green) 55%, transparent); } 70%,100% { box-shadow: 0 0 0 7px transparent; } }
.status-line { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--card2); font-size: 14px; display: flex; gap: 10px; align-items: center; line-height: 1.35; }
.status-line.ok { color: var(--green); }
.status-line.bad { color: var(--red); }
.status-line .spinner { flex: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid color-mix(in srgb, currentColor 25%, transparent); border-top-color: currentColor; animation: spin .8s linear infinite; }
.status-line .txt { flex: 1; color: var(--text); }
.status-line.ok .txt, .status-line.bad .txt { color: inherit; }
.status-line .link { color: var(--blue); font-weight: 600; font-size: 14px; }
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.act { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; height: 70px; border-radius: 16px; background: var(--btn); color: var(--btn-text); font-size: 13px; font-weight: 600; transition: transform .12s ease, opacity .2s, background .2s; }
.act svg { width: 24px; height: 24px; }
.act:active:not([disabled]) { transform: scale(.95); }
.act[disabled] { opacity: .35; cursor: default; }
.act.sleep svg { color: var(--indigo); }
.act.restart svg { color: var(--orange); }
.act.shutdown svg { color: var(--red); }
.act.wake svg { color: var(--green); }
.act.wake.hl { background: color-mix(in srgb, var(--green) 16%, var(--btn)); }
.card-foot { margin-top: 12px; font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.card-foot button { color: var(--blue); font-size: 12.5px; font-weight: 600; }
.cta { margin-top: 14px; }
.footnote { text-align: center; font-size: 12.5px; color: var(--muted); margin: 18px 12px 0; line-height: 1.5; }
.banner { display: flex; gap: 12px; align-items: flex-start; background: var(--card); border-radius: 16px; padding: 12px 14px; margin-bottom: 14px; font-size: 14px; line-height: 1.45; box-shadow: var(--shadow); }
.banner-x { font-size: 22px; line-height: 1; color: var(--muted); padding: 0 4px; }
.share-ico { display: inline-block; width: 14px; height: 16px; vertical-align: -2px; border: 1.6px solid var(--blue); border-top: 0; border-radius: 0 0 3px 3px; position: relative; margin: 0 2px; }
.share-ico::before { content: "↑"; position: absolute; top: -9px; left: 1px; color: var(--blue); font-weight: 700; font-size: 12px; }

/* ---------- 清單群組 ---------- */
.group-h { font-size: 13px; font-weight: 500; text-transform: uppercase; color: var(--muted); margin: 22px 16px 7px; letter-spacing: .03em; }
.group { background: var(--card); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.group-f { font-size: 13px; color: var(--muted); margin: 7px 16px 0; line-height: 1.45; }
.center { text-align: center; margin-top: 28px; }
.row { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 10px 16px; text-align: left; position: relative; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 60px; right: 0; border-top: .5px solid var(--sep); }
.row.noico + .row::before, .row.noico::before { left: 16px; }
.row-link:active { background: var(--card2); }
.row-main { flex: 1; min-width: 0; font-size: 16px; }
.row-main small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.row-ico { flex: none; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-size: 16px; background: var(--blue); }
.row-ico svg { width: 19px; height: 19px; }
.ico-indigo { background: var(--indigo); } .ico-green { background: var(--green); } .ico-gray { background: var(--gray); } .ico-orange { background: var(--orange); } .ico-red { background: var(--red); }
.chev { width: 8px; height: 8px; border-right: 2px solid var(--gray); border-top: 2px solid var(--gray); transform: rotate(45deg); opacity: .6; }
.row .val { color: var(--muted); font-size: 15px; }
.danger .row-main { color: var(--red); text-align: center; }
.log-row { align-items: flex-start; }
.log-row .row-main { font-size: 15px; line-height: 1.35; }
.log-time { flex: none; font-size: 13px; color: var(--muted); padding-top: 1px; font-variant-numeric: tabular-nums; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

/* ---------- 分頁列 ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; gap: 0; padding: 6px 8px calc(env(safe-area-inset-bottom) + 4px);
  background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-top: .5px solid var(--sep); }
.tab { flex: 1; max-width: 160px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; font-weight: 500; color: var(--gray); padding: 2px 0; }
.tab svg { width: 26px; height: 26px; }
.tab.active { color: var(--blue); }

/* ---------- 底部面板 ---------- */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.35); opacity: 0; transition: opacity .25s; }
.scrim.show { opacity: 1; }
.sheet { position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px; max-height: 88dvh; overflow: auto; background: var(--bg); border-radius: 22px 22px 0 0;
  padding: 8px 18px calc(env(safe-area-inset-bottom) + 18px); transform: translateY(105%); transition: transform .32s cubic-bezier(.2,.9,.25,1); box-shadow: 0 -10px 40px rgba(0,0,0,.18); }
.sheet.show { transform: none; }
@media (min-width: 700px) { .sheet { bottom: auto; top: 50%; border-radius: 22px; transform: translateY(-40%) scale(.96); opacity: 0; transition: transform .25s, opacity .25s; } .sheet.show { transform: translateY(-50%); opacity: 1; } }
.grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--sep); margin: 0 auto 12px; }
.sheet-title { font-size: 20px; margin: 4px 0 10px; text-align: center; }
.sheet-ico { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; margin: 6px auto 10px; color: #fff; }
.sheet-ico svg { width: 34px; height: 34px; }
.sheet p { line-height: 1.55; }
.sheet .lead { text-align: center; color: var(--muted); margin: 0 6px 18px; font-size: 15px; }
.sheet .stack { display: grid; gap: 10px; }
.btn-danger { height: 52px; width: 100%; border-radius: 14px; background: var(--red); color: #fff; font-size: 17px; font-weight: 600; }
.btn-warn { height: 52px; width: 100%; border-radius: 14px; background: var(--orange); color: #fff; font-size: 17px; font-weight: 600; }
.btn-indigo { height: 52px; width: 100%; border-radius: 14px; background: var(--indigo); color: #fff; font-size: 17px; font-weight: 600; }
.prose { font-size: 15px; }
.prose ul { padding-left: 20px; } .prose li { margin: 8px 0; line-height: 1.5; }
.code-box { background: var(--card); border-radius: 14px; padding: 14px; margin: 10px 0; }
.code-big { font: 600 28px/1.2 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .08em; text-align: center; }
.cmd { font: 12.5px/1.45 ui-monospace, "SF Mono", Menlo, Consolas, monospace; word-break: break-all; user-select: all; -webkit-user-select: all; background: var(--card2); border-radius: 10px; padding: 10px; margin: 8px 0; }
.steps { padding-left: 22px; margin: 6px 0; } .steps li { margin: 6px 0; line-height: 1.5; font-size: 15px; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--card2); color: var(--muted); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; margin: 6px 0 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-all; }

/* ---------- 提示 ---------- */
.toast { position: fixed; z-index: 60; left: 50%; top: calc(env(safe-area-inset-top) + 10px); transform: translate(-50%, -140%); background: var(--card); color: var(--text); padding: 11px 18px; border-radius: 999px;
  font-size: 14.5px; font-weight: 600; box-shadow: 0 8px 30px rgba(0,0,0,.18); transition: transform .35s cubic-bezier(.2,.9,.25,1.2); max-width: calc(100% - 32px); text-align: center; }
.toast.show { transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
