:root {
  --bg: #f6f3ee; --card: #fffdf9; --fg: #23201c; --muted: #6b655d; --line: #e4ded4;
  --hover: #efe9df; --accent: #2f5d8a; --accent-soft: #e3eaf2; --on-accent: #ffffff;
  --ok: #3e8e5a; --warn: #93621c; --danger: #b8443a;
  --bar: rgba(255, 253, 249, 0.94);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #22272e; --card: #2d333b; --fg: #cdd9e5; --muted: #909dab; --line: #444c56;
    --hover: #373e47; --accent: #4184e4; --accent-soft: #1d3150; --on-accent: #ffffff;
    --ok: #57ab5a; --warn: #c69026; --danger: #e5534b;
    --bar: rgba(45, 51, 59, 0.94);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--fg);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); min-height: 1.2em; margin: 10px 0 0; }

/* ---------- home */
#home {
  min-height: 100%; display: flex; align-items: center; justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}
.card {
  width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px 22px 20px; text-align: center;
}
.logo { width: 64px; height: 64px; border-radius: 14px; }
h1 { font-size: 22px; margin: 12px 0 2px; }
#host-detail { margin: 0 0 18px; }
.field { display: block; text-align: start; margin: 12px 0; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field input {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); outline: none; font-size: 17px;
}
.field input:focus { border-color: var(--accent); }
#pin { letter-spacing: 3px; text-align: center; font-size: 22px; font-variant-numeric: tabular-nums; }
details { text-align: start; margin: 10px 0 4px; color: var(--muted); font-size: 14px; }
details summary { cursor: pointer; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details b { color: var(--fg); font-weight: 600; }
.whats-new { margin-top: 8px; max-height: 50vh; overflow-y: auto; color: var(--fg); }
.whats-new h3 { font-size: 14px; margin: 12px 0 2px; }
.whats-new h3 span { color: var(--muted); font-weight: 400; margin-inline-start: 6px; }
.whats-new ul { margin: 2px 0 0; padding-inline-start: 18px; }
.whats-new li { margin: 3px 0; line-height: 1.35; }
button.link { background: none; border: 0; color: var(--accent); padding: 4px 0; cursor: pointer; font-size: 14px; }
button.primary, .primary {
  width: 100%; margin-top: 14px; padding: 12px; border: 0; border-radius: 10px;
  background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 16px; cursor: pointer;
}
button.primary:disabled { opacity: .5; cursor: default; }
button.secondary {
  width: 100%; margin-top: 10px; padding: 11px; border: 1px solid var(--accent); border-radius: 10px;
  background: none; color: var(--accent); font-weight: 600; font-size: 16px; cursor: pointer;
}
.hint { font-size: 13px; margin: 14px 0 0; }

/* ---------- session */
#session { position: fixed; inset: 0; background: #000; overflow: hidden; touch-action: none; }
#stage { position: absolute; inset: 0; overflow: hidden; }
#screen { position: absolute; left: 0; top: 0; image-rendering: auto; background: #000; }
#waiting { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; text-align: center; padding: 0 24px; }
#show-picture { width: auto; padding: 10px 18px; }
/* Pictures a second, in the bar (Tools, Show speed). */
#fps {
  padding: 0 10px; font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer;
  font-variant-numeric: tabular-nums; color: var(--accent); border-inline-start: 1px solid var(--line);
}
#cursor {
  position: absolute; width: 18px; height: 18px; margin: -2px 0 0 -2px; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M2 2l5 14 2.2-5.8L15 8z' fill='white' stroke='black' stroke-width='1.3' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat;
}
#session.mouse #stage { cursor: none; }
#kbd { position: absolute; left: -1000px; top: 0; width: 10px; height: 10px; opacity: 0; font-size: 16px; }

#bar {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: max(10px, env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 2px;
  background: var(--bar); border: 1px solid var(--line); border-radius: 14px; padding: 4px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 6px 24px rgba(0,0,0,.25);
  max-width: calc(100% - 20px); transition: opacity .2s;
}
@media (pointer: fine) {
  #bar { top: 10px; bottom: auto; opacity: .35; }
  #bar:hover, #bar.open { opacity: 1; }
}
#bar .peer { display: flex; align-items: center; gap: 6px; padding: 0 10px 0 8px; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
#bar .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
#bar button {
  width: 40px; height: 40px; border: 0; border-radius: 10px; background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; color: var(--fg); flex: none;
}
#bar button:hover, #bar button.on { background: var(--hover); }
#bar button.on { color: var(--accent); }
#bar button.danger { color: var(--danger); }
#bar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 420px) { #bar .peer { display: none; } }
@media (pointer: fine) { .touch-only { display: none !important; } }

#keys {
  position: absolute; left: 0; right: 0; bottom: calc(max(10px, env(safe-area-inset-bottom)) + 56px);
  padding: 0 8px; display: flex; flex-direction: column; align-items: center; gap: 6px;
}
@media (pointer: fine) { #keys { top: 62px; bottom: auto; } }
#keys .row {
  display: flex; gap: 4px; overflow-x: auto; background: var(--bar); border: 1px solid var(--line);
  border-radius: 12px; padding: 4px; max-width: 100%; scrollbar-width: none;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
#keys .row::-webkit-scrollbar { display: none; }
#keys button {
  min-width: 42px; height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); cursor: pointer; white-space: nowrap; font-size: 14px; flex: none;
}
#keys button.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

#sheet {
  position: absolute; inset: 0; background: rgba(0,0,0,.35); display: flex;
  align-items: flex-end; justify-content: center; touch-action: auto;
}
@media (pointer: fine) { #sheet { align-items: center; } }
.sheet-card {
  width: 100%; max-width: 440px; max-height: 80vh; overflow: auto; background: var(--card);
  border-radius: 16px 16px 0 0; padding: 14px 16px max(16px, env(safe-area-inset-bottom));
}
@media (pointer: fine) { .sheet-card { border-radius: 16px; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.sheet-head b { font-size: 17px; }
.close { border: 0; background: var(--hover); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; }
.panel p { margin: 4px 0 10px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid button, .buttons button {
  padding: 12px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
  cursor: pointer; font-weight: 500;
}
.grid button:hover, .buttons button:hover { background: var(--hover); }
.buttons { display: flex; gap: 8px; margin: 8px 0 12px; }
.buttons button { flex: 1; margin: 0; }
.buttons button.primary { border: 0; font-size: 15px; }
textarea {
  width: 100%; border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
  padding: 10px; resize: vertical; outline: none; font-size: 16px;
}
textarea:focus { border-color: var(--accent); }
.label { font-size: 13px; font-weight: 600; color: var(--muted); margin: 14px 0 6px !important; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  flex: 1 0 auto; padding: 9px 12px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--bg); cursor: pointer;
}
.seg button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.file-pick { display: block; text-align: center; }
#transfers { list-style: none; padding: 0; margin: 12px 0 0; }
#transfers li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
#transfers li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#transfers a { color: var(--accent); }

#toasts {
  position: absolute; left: 0; right: 0; top: max(12px, env(safe-area-inset-top));
  display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none;
}
@media (pointer: fine) { #toasts { top: 70px; } }
.toast {
  background: var(--bar); color: var(--fg); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 14px; font-size: 14px; max-width: 90%; pointer-events: auto;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 4px 16px rgba(0,0,0,.2);
}
.toast button { margin-inline-start: 10px; border: 0; background: none; color: var(--accent); font-weight: 600; cursor: pointer; }

/* ---------- phone app: list of computers */
#computer-list { text-align: start; margin-bottom: 4px; }
#computer-list h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin: 14px 0 6px; }
.computer {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; margin: 0 0 8px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg); cursor: pointer; text-align: start;
}
.computer .os { width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; flex: none; }
.computer .os svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.computer .text { flex: 1; min-width: 0; }
.computer b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.computer small { color: var(--muted); }
.computer .forget { border: 0; background: none; color: var(--muted); font-size: 18px; padding: 4px 6px; cursor: pointer; }
/* ---------- phone link (Android app, web/phonelink.js) */
#phone-link { text-align: start; margin-bottom: 4px; }
#phone-link h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin: 14px 0 6px; }
.link-card { padding: 12px; margin: 0 0 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.link-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.link-head b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-head small.ok { color: var(--ok); font-weight: 600; }
.link-head small.muted { color: var(--muted); }
.link-where { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; font-size: 14px; color: var(--muted); }
.seg { display: flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { flex: 1; width: auto; margin: 0; border: 0; background: none; padding: 8px 6px; font-size: 14px; cursor: pointer; color: var(--fg); }
.seg button + button { border-inline-start: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.link-media { display: flex; justify-content: space-between; margin-top: 10px; }
.link-media button.icon { width: 44px; height: 40px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--fg); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.link-media button.icon:active { background: var(--hover); }
.link-media svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.link-acts { display: flex; gap: 8px; }
.link-acts button.secondary { font-size: 14px; padding: 9px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-share { padding: 12px; margin: 0 0 8px; border-radius: 12px; background: var(--accent-soft); }
.link-share p { margin: 0 0 4px; font-weight: 600; }
.link-opts { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 8px; font-size: 14px; }
.link-opts label.check { display: flex; gap: 8px; align-items: flex-start; }
.link-opts input { margin-top: 3px; }
#back { margin-top: 10px; }

#qr-scan {
  position: fixed; inset: 0; z-index: 50; background: #000; color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 16px;
}
#qr-scan[hidden] { display: none; }
#qr-scan video { width: 100%; max-width: 520px; max-height: 70vh; object-fit: cover; border-radius: 12px; background: #111; }
#qr-scan p { text-align: center; margin: 0; }
#qr-scan button { max-width: 520px; }

/* Tools sheet: icon tiles in groups. */
.group { margin: 10px 2px 6px; font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.grid.tools { grid-template-columns: repeat(3, 1fr); }
.grid.tools button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 72px; font-size: 13px; }
.grid.tools svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.grid.tools button.on { background: var(--accent-soft); color: var(--accent); }

/* Language switch (Arabic / English) on the first screen. */
#lang-btn { display: block; margin: 10px auto 0; }
/* Addresses, codes and PINs read left to right in Arabic too. */
[dir="rtl"] #pin, [dir="rtl"] #manual-ip, [dir="rtl"] #code { direction: ltr; }

/* Something the computer doesn't let this device do. */
.denied { display: none !important; }
#view-only { font-size: 11px; font-weight: 600; color: var(--warn, #d29922); border: 1px solid currentColor; border-radius: 8px; padding: 1px 6px; }
