/* RemoteLink. One design language for every screen: tokens first, then components. */
:root {
  --bg: #0e1014; --panel: #161920; --panel-2: #1d212a; --field: #0b0d11; --border: #272c37; --text: #e8eaee; --muted: #98a1b2;
  --accent: #4f8cff; --accent-ink: #ffffff; --accent-soft: rgba(79, 140, 255, .14);
  --ok: #35c877; --warn: #f5a623; --danger: #e5484d; --violet: #8b5cf6; --teal: #14b8a6;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45); --radius: 14px; --radius-s: 10px;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f3f5f9; --panel: #ffffff; --panel-2: #f0f2f7; --field: #ffffff; --border: #dde1ea; --text: #161a22; --muted: #5d6677;
  --accent: #2f6fed; --accent-soft: rgba(47, 111, 237, .1); --shadow: 0 10px 30px rgba(20, 30, 60, .14);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.45 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; overscroll-behavior: none; }
.hidden { display: none !important; }
.screen { min-height: 100%; }
svg.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Text and fields */
h1 { margin: 0 0 4px; font-size: 24px; font-weight: 650; display: flex; align-items: center; gap: 10px; letter-spacing: -.01em; }
h2 { margin: 0; font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
h2 [data-icon] { display: inline-flex; padding: 6px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); }
.hint { margin: 0; color: var(--muted); }
.small { font-size: 12.5px; }
strong { color: var(--text); font-weight: 600; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
input, select { width: 100%; padding: 11px 12px; border-radius: var(--radius-s); border: 1px solid var(--border); background: var(--field); color: var(--text); font: inherit; font-size: 15px; transition: border-color .15s, box-shadow .15s; }
input:focus-visible, select:focus-visible, button:focus-visible, .stage:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { width: auto; padding-right: 28px; }
button { font: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 14px; border-radius: var(--radius-s); border: 1px solid var(--border); background: var(--panel-2); color: var(--text); cursor: pointer; transition: background .15s, border-color .15s, transform .05s, opacity .15s; }
button:hover:not(:disabled) { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
button:active:not(:disabled) { transform: translateY(1px); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
button.primary:hover:not(:disabled) { filter: brightness(1.08); }
button.danger { background: var(--danger); color: #fff; border-color: transparent; }
button.quiet { background: none; border-color: transparent; color: var(--muted); }
button.quiet:hover:not(:disabled) { background: var(--panel-2); color: var(--text); }
button.link { background: none; border: none; padding: 4px; color: var(--accent); }
button.icon-btn { padding: 8px; }
button:disabled { opacity: .5; cursor: not-allowed; }
.status { min-height: 1.4em; margin: 0; color: var(--muted); }
.status.error { color: var(--danger); }
.banner { margin: 0 0 14px; padding: 10px 14px; border-radius: var(--radius-s); background: var(--panel); border: 1px solid var(--border); min-height: 0; }
.banner:empty { display: none; }
.net { position: fixed; z-index: 40; top: 0; left: 0; right: 0; margin: 0; padding: 8px 12px; text-align: center; background: var(--danger); color: #fff; font-weight: 600; }
.logo { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), var(--violet)); display: inline-block; flex: none; }
.chip { display: inline-block; padding: 4px 10px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--border); font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; opacity: .6; }
.dot.online { background: var(--ok); opacity: 1; box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 20%, transparent); }
.dot.warn { background: var(--warn); opacity: 1; }
.dot.busy { background: var(--danger); opacity: 1; }
.code { font: 600 17px/1 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .06em; color: var(--text); padding: 6px 10px; border-radius: 8px; background: var(--field); border: 1px solid var(--border); }

/* Cards and layout */
.centered { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; gap: 20px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: grid; gap: 14px; align-content: start; min-width: 0; }
.card.narrow { width: min(430px, 100%); padding: 26px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--field); border: 1px solid var(--border); border-radius: var(--radius-s); }
.seg button { border: none; background: none; color: var(--muted); padding: 8px; }
.seg button[aria-selected="true"] { background: var(--panel-2); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { padding: 5px 10px; border-radius: 999px; font-size: 12.5px; }

/* App shell */
.app { display: grid; grid-template-columns: 228px minmax(0, 1fr); height: 100%; }
.nav { display: flex; flex-direction: column; gap: 14px; padding: 16px 12px; background: var(--panel); border-right: 1px solid var(--border); min-height: 0; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 6px; font-weight: 650; font-size: 17px; }
.nav-list { display: grid; gap: 3px; }
.nav-list button { justify-content: flex-start; border-color: transparent; background: none; color: var(--muted); padding: 9px 10px; text-align: left; }
.nav-list button:hover { background: var(--panel-2); color: var(--text); }
.nav-list button[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-list button .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-sessions:not(:empty) { border-top: 1px solid var(--border); padding-top: 12px; }
.nav-foot { margin-top: auto; display: grid; gap: 6px; }
.main { min-width: 0; min-height: 0; overflow-y: auto; padding: 22px 26px 28px; display: flex; flex-direction: column; }
.page { display: grid; gap: 16px; align-content: start; width: 100%; max-width: 1080px; margin: 0 auto; animation: page-in .16s ease-out; }
@keyframes page-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.page-title { font-size: 22px; }

/* Lists of computers and activity */
.computers, .activity { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.computers li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-s); transition: border-color .15s; }
.computers li:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.computers .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.computers .sub { font-size: 12.5px; color: var(--muted); }
.computers .actions { display: flex; gap: 6px; align-items: center; }
.star.on { color: var(--warn); }
.star.on svg { fill: currentColor; }
.rename { padding: 7px 10px; }
.activity li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 9px 12px; border-radius: var(--radius-s); background: var(--panel-2); font-size: 14px; }
.activity time { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.activity .k { display: inline-flex; padding: 5px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); }
.activity .k.refused { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.activity .k.connected { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.this-body { display: grid; gap: 12px; }
.this-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.this-row .grow { flex: 1; min-width: 160px; }

/* Settings */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.setting { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 14px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.setting:first-of-type { border-top: none; padding-top: 0; }
.setting .name { font-weight: 550; }
.setting .desc { grid-column: 1; color: var(--muted); font-size: 12.5px; }
.setting .ctl { grid-column: 2; grid-row: 1 / span 2; }
.switch { position: relative; width: 42px; height: 24px; padding: 0; border-radius: 999px; background: var(--border); border: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .16s; box-shadow: 0 1px 3px rgba(0, 0, 0, .4); }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }
.prose p { margin: 0; color: var(--muted); }

/* Session */
.page.session { max-width: none; margin: -22px -26px -28px; width: auto; height: 100%; display: flex; flex-direction: column; gap: 0; position: relative; background: #000; animation: none; }
.session-bar { background: var(--panel); border-bottom: 1px solid var(--border); flex: none; z-index: 6; transition: transform .18s; }
.tabs-bar { display: flex; gap: 4px; padding: 6px 8px 0; overflow-x: auto; }
.tabs-bar button { border-radius: 10px 10px 0 0; border-bottom: none; background: none; color: var(--muted); padding: 7px 10px; max-width: 220px; }
.tabs-bar button[aria-selected="true"] { background: var(--panel-2); color: var(--text); }
.tabs-bar .x { padding: 0 2px; border-radius: 6px; opacity: .7; }
.tabs-bar .x:hover { background: var(--danger); color: #fff; opacity: 1; }
.toolbar { display: flex; gap: 6px; padding: 6px 8px; overflow-x: auto; align-items: center; }
.toolbar button { padding: 7px 10px; white-space: nowrap; font-size: 13.5px; flex: none; }
.toolbar button.active { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.toolbar .spacer { flex: 1; }
.health { display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; border-radius: 999px; background: var(--panel-2); font-size: 12.5px; color: var(--muted); white-space: nowrap; flex: none; }
.views { position: relative; flex: 1; min-height: 0; }
.view { position: absolute; inset: 0; }
.stage { position: absolute; inset: 0; outline: none; touch-action: none; user-select: none; -webkit-user-select: none; cursor: none; overflow: hidden; display: flex; }
.stage.show-cursor { cursor: default; }
.stage video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.stage.original { overflow: auto; }
.stage.original video { object-fit: fill; flex: none; margin: auto; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .62); color: #fff; font-size: 16px; text-align: center; padding: 16px; z-index: 3; }
.kbd { position: absolute; left: -9999px; top: 0; width: 1px; height: 1px; opacity: 0; }
.stats { position: absolute; top: 8px; left: 8px; margin: 0; padding: 8px 10px; background: rgba(0, 0, 0, .72); color: #cfd5e0; font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace; border-radius: 8px; pointer-events: none; z-index: 4; }
.menu { position: absolute; z-index: 30; display: grid; gap: 3px; padding: 6px; min-width: 220px; max-width: calc(100% - 12px); max-height: 70%; overflow-y: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.menu button { justify-content: flex-start; text-align: left; padding: 9px 12px; white-space: nowrap; border-color: transparent; background: none; }
.menu button:hover { background: var(--panel-2); }
.menu button.active { color: var(--accent); background: var(--accent-soft); }
.menu .sep { height: 1px; background: var(--border); margin: 3px 4px; }
.files { position: absolute; z-index: 20; top: 96px; right: 12px; bottom: 12px; width: min(460px, calc(100% - 24px)); display: flex; flex-direction: column; gap: 10px; padding: 14px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.files-head { display: flex; align-items: center; gap: 8px; }
.files-head .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; }
.files-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; display: grid; gap: 2px; align-content: start; }
.files-list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 7px 8px; border-radius: 8px; }
.files-list li.dir { cursor: pointer; }
.files-list li:hover { background: var(--panel-2); }
.files-list .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files-list .meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.files-list button { padding: 4px 10px; font-size: 12.5px; }
.codeform { display: grid; gap: 10px; width: min(340px, 100%); padding: 20px; border-radius: var(--radius); background: var(--panel); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow); }
.codeform p { margin: 0; }
.codeform input { text-align: center; font-size: 22px; letter-spacing: .2em; }
.group-title { list-style: none; padding: 8px 2px 0; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: none !important; border: none !important; display: block !important; }
.fs-handle { position: absolute; top: 0; left: 50%; transform: translateX(-50%); z-index: 7; padding: 2px 14px 4px; border-radius: 0 0 10px 10px; border-top: none; font-size: 12px; opacity: .55; }
.fs-handle:hover { opacity: 1; }
/* Full screen: the bar slides away and comes back from the top edge. */
.session.fs.autohide .session-bar { position: absolute; top: 0; left: 0; right: 0; transform: translateY(-100%); }
.session.fs.autohide.reveal .session-bar, .session.fs.autohide .session-bar:hover, .session.fs.autohide .session-bar:focus-within { transform: none; }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 50; background: var(--panel); border: 1px solid var(--border); padding: 10px 16px; border-radius: 12px; max-width: min(90%, 560px); box-shadow: var(--shadow); }
@media (pointer: fine) { .toolbar .touch-only { display: none; } }
/* Chat with the person at the other computer */
.chat { position: absolute; z-index: 20; top: 96px; right: 12px; bottom: 12px; width: min(360px, calc(100% - 24px)); display: flex; flex-direction: column; gap: 10px; padding: 14px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.chat-head { display: flex; align-items: center; gap: 8px; }
.chat-head .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat .hint { margin: 0; }
.chat-list { list-style: none; margin: 0; padding: 0; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.chat-list li { display: flex; flex-direction: column; gap: 2px; max-width: 86%; align-self: flex-start; }
.chat-list li.mine { align-self: flex-end; align-items: flex-end; }
.chat-list .bubble { padding: 8px 11px; border-radius: 12px; background: var(--panel-2); white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; -webkit-user-select: text; }
.chat-list li.mine .bubble { background: var(--accent); color: #fff; }
.chat-list .when { font-size: 11px; color: var(--muted); }
.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; min-width: 0; }
/* Files on their way: progress, Cancel, Try again */
.transfers { position: absolute; z-index: 19; left: 12px; bottom: 12px; width: min(380px, calc(100% - 24px)); display: grid; gap: 8px; padding: 10px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.transfer { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 8px; align-items: center; }
.transfer .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transfer .acts { display: flex; gap: 4px; }
.transfer .acts button { padding: 3px 9px; font-size: 12.5px; }
.transfer .bar { grid-column: 1 / -1; height: 5px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.transfer .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.transfer.done .bar i { background: var(--ok, #3ccf7a); }
.transfer.failed .bar i { background: var(--danger); }
.transfer .pct { font-size: 12px; color: var(--muted); }
.transfer .meta { grid-column: 2 / -1; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transfer.failed .meta { color: var(--danger); white-space: normal; }
/* A session in its own window */
body.popout { margin: 0; height: 100vh; overflow: hidden; }
.page.session.popped { margin: 0; height: 100vh; }
.session.popped .files, .session.popped .chat { top: 58px; }

/* Narrow windows and phones: navigation moves to the bottom */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .nav { order: 2; flex-direction: row; align-items: center; gap: 4px; padding: 6px max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left)); border-right: none; border-top: 1px solid var(--border); overflow-x: auto; }
  .brand, .nav-foot .chip { display: none; }
  .nav-list { display: flex; gap: 2px; }
  .nav-list button { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 9px; }
  .nav-sessions:not(:empty) { border-top: none; padding-top: 0; border-left: 1px solid var(--border); padding-left: 6px; }
  .nav-foot { margin: 0 0 0 auto; display: flex; }
  .main { padding: 14px 12px 18px; }
  .page.session { margin: -14px -12px -18px; }
  .row2 { grid-template-columns: 1fr; }
  .computers li { grid-template-columns: auto minmax(0, 1fr); }
  .computers .actions { grid-column: 1 / -1; }
  .computers .actions button.primary { flex: 1; }
  .settings-grid { grid-template-columns: 1fr; }
  .setting:has(select), .setting:has(input) { grid-template-columns: 1fr; }
  .setting:has(select) .ctl, .setting:has(input) .ctl { grid-column: 1; grid-row: auto; justify-self: start; }
}
