/* rockd 网页版。明暗两套跟着系统走 */
:root {
  color-scheme: light dark;
  --bg: #f5f6f8; --panel: #ffffff; --fg: #1d2129; --muted: #6b7280; --line: #e3e5ea;
  --accent: #2563eb; --accent-fg: #ffffff; --danger: #dc2626; --ok: #16a34a; --warn: #d97706;
  --hover: #eef2ff; --input: #ffffff; --stage: #0f1115; --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --panel: #171a21; --fg: #e6e8ec; --muted: #9aa3af; --line: #2a2f3a;
    --accent: #3b82f6; --accent-fg: #ffffff; --danger: #f87171; --ok: #4ade80; --warn: #fbbf24;
    --hover: #1f2633; --input: #11141a; --stage: #000000; --shadow: 0 1px 3px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif; }
body { display: flex; flex-direction: column; }
[hidden] { display: none !important; }

header#top { display: flex; align-items: center; gap: 12px; padding: 8px 16px; background: var(--panel);
  border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 650; font-size: 16px; white-space: nowrap; }
.brand .logo { color: var(--accent); }
.brand .sub { font-weight: 400; color: var(--muted); font-size: 13px; }
.peer { font-weight: 600; }
.pill { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--hover); color: var(--muted); margin-left: 6px; white-space: nowrap; }
.pill.relay { color: var(--warn); }
.pill.down { color: var(--danger); }
#tabs { display: flex; gap: 4px; flex-wrap: wrap; }
#tabs button { border: 0; background: transparent; color: var(--muted); padding: 6px 12px; border-radius: 6px; }
#tabs button.on { background: var(--hover); color: var(--accent); font-weight: 600; }
.spacer { flex: 1; }

main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
button, .button { font: inherit; color: var(--fg); background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 5px 12px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
button:hover:not(:disabled), .button:hover { background: var(--hover); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
button.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
button.danger { color: var(--danger); }
button.ghost { background: transparent; }
button.small { padding: 2px 8px; font-size: 12px; }
input, select, textarea { font: inherit; color: var(--fg); background: var(--input); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
textarea { width: 100%; resize: vertical; }
.muted { color: var(--muted); }
.center { text-align: center; padding: 24px; }

/* 连接页 */
#connect { padding: 32px 16px; display: flex; flex-direction: column; align-items: center; gap: 16px; overflow: auto; }
.card { width: min(440px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; box-shadow: var(--shadow); }
.card h1 { font-size: 20px; margin: 0 0 16px; }
.card h2 { font-size: 13px; color: var(--muted); font-weight: 500; margin: 20px 0 6px; }
#fConnect { display: flex; flex-direction: column; gap: 12px; }
#fConnect label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
#fConnect input, #fConnect select { font-size: 15px; color: var(--fg); }
#inId { font-family: var(--mono); letter-spacing: .5px; }
#btnConnect { justify-content: center; padding: 8px; font-size: 15px; }
.status { min-height: 1.5em; margin-top: 12px; font-size: 13px; color: var(--muted); }
.status.err { color: var(--danger); }
#recent { list-style: none; margin: 0; padding: 0; }
#recent li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
#recent li:hover { background: var(--hover); }
#recent .id { font-family: var(--mono); }
#recent .nm { color: var(--muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note { width: min(440px, 100%); color: var(--muted); font-size: 12.5px; }
.note p { margin: 0 0 8px; }

/* 页签 */
.pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.bar { display: flex; align-items: center; gap: 8px; padding: 8px 16px; flex-wrap: wrap; }
.pane > .bar { background: var(--panel); border-bottom: 1px solid var(--line); }
.bar.end { justify-content: flex-end; padding: 8px 0 0; }
.bar .grow { flex: 1; min-width: 160px; font-family: var(--mono); }
label.inline { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
label.check input { margin: 0; }

/* 远程桌面 */
.stage { flex: 1; min-height: 0; background: var(--stage); position: relative; }
#chatBox { position: absolute; right: 12px; bottom: 12px; width: min(340px, calc(100% - 24px)); max-height: 60%; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); z-index: 3; }
.chathead { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; border-bottom: 1px solid var(--line); font-weight: 600; }
#chatList { list-style: none; margin: 0; padding: 8px 10px; overflow: auto; flex: 1; min-height: 60px; font-size: 13px; }
#chatList li { margin: 4px 0; white-space: pre-wrap; word-break: break-word; }
#chatList li.me { text-align: right; color: var(--accent); }
#chatList li.sys { color: var(--muted); font-size: 12px; text-align: center; }
#fChat { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--line); }
#fChat input { flex: 1; min-width: 0; }
#btnRec.on { color: var(--danger); border-color: var(--danger); }
#viewer { width: 100%; height: 100%; border: 0; display: block; }
#deskPaused { position: absolute; inset: 0; z-index: 2; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: var(--stage); color: #d6dce8; text-align: center; cursor: pointer; }
#deskPaused .pbox { max-width: 460px; }
#deskPaused .picon { font-size: 40px; line-height: 1; color: var(--accent); }
#deskPaused p { margin: 14px 0 18px; line-height: 1.6; }
#deskPaused:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; }
#pane-desktop:fullscreen .bar { display: none; }

/* 文件 */
.list { flex: 1; min-height: 0; overflow: auto; padding: 0 16px 16px; position: relative; }
.list table { width: 100%; border-collapse: collapse; }
.list th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 8px 6px; position: sticky; top: 0; background: var(--bg); border-bottom: 1px solid var(--line); }
.list td { padding: 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.list tr:hover td { background: var(--hover); }
.list td.name { cursor: pointer; word-break: break-all; }
.list td.name .ic { display: inline-block; width: 1.4em; color: var(--muted); }
.list td.name.dir { font-weight: 550; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.list td.time { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.list td.act { white-space: nowrap; text-align: right; }
.list td.act button { padding: 1px 8px; font-size: 12px; }
#pane-files.dragging .list { outline: 2px dashed var(--accent); outline-offset: -6px; }
.drophint { text-align: center; color: var(--muted); font-size: 12px; padding: 4px 0 8px; }
#uploads { padding: 0 16px; }
.up { display: flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 4px 0; }
.up .nm { flex: 0 1 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up progress { flex: 1; height: 8px; }
.up .st { white-space: nowrap; color: var(--muted); min-width: 7em; text-align: right; }
.up.err .st { color: var(--danger); }
.up.ok .st { color: var(--ok); }

/* 终端 */
#termBox { flex: 1; min-height: 0; padding: 6px 0 0 8px; background: #101317; overflow: hidden; }
#termBox .xterm { height: 100%; }

/* 剪贴板 */
#pane-clip { overflow: auto; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; padding: 16px; }
.col { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; min-width: 0; }
.col h2 { font-size: 14px; margin: 8px 0 4px; }
.col .bar { padding: 8px 0; }
.clipview { white-space: pre-wrap; word-break: break-word; max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; padding: 8px; font-family: var(--mono); font-size: 12.5px; }
.clipview img, #clipImg img { max-width: 100%; max-height: 240px; display: block; }
#clipImg { margin-top: 6px; display: flex; align-items: flex-start; gap: 8px; }
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { border-bottom: 1px solid var(--line); padding: 8px 0; display: flex; gap: 10px; align-items: flex-start; }
.hist .meta { color: var(--muted); font-size: 12px; }
.hist .body { flex: 1; min-width: 0; }
.hist .txt { white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 12.5px; max-height: 6.2em; overflow: hidden; }
.hist .txt.full { max-height: none; }
.hist img { max-width: 120px; max-height: 90px; border: 1px solid var(--line); border-radius: 4px; }
.hist .acts { display: flex; flex-direction: column; gap: 4px; }
.hist .acts button { padding: 1px 8px; font-size: 12px; }

dialog { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--fg); width: min(460px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog h3 { margin: 0 0 8px; font-size: 16px; }
#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: #111827; color: #fff; padding: 8px 14px;
  border-radius: 8px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100vw - 32px); z-index: 10; }
#toast.on { opacity: .95; }
#toast.err { background: #991b1b; }

@media (max-width: 640px) {
  header#top { padding: 6px 10px; gap: 8px; }
  .bar { padding: 6px 10px; }
  .list { padding: 0 6px 10px; }
  .list td.time, .list th:nth-child(3) { display: none; }
  .cols { padding: 10px; }
}
