:root {
  --bg: #0e1013;
  --panel: #14171c;
  --panel-2: #1a1e24;
  --line: #262b33;
  --text: #e8eaed;
  --muted: #9aa3b0;
  --accent: #4b8fe6;
  --accent-text: #061a33;
  --ok: #4caf7d;
  --warn: #e0a030;
  --bad: #e0552f;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 22px; margin: 0 0 14px; }
h2 { font-size: 17px; margin: 0; }
[hidden] { display: none !important; }

button, .button, select, input {
  font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 12px;
}
button, .button { cursor: pointer; text-decoration: none; display: inline-block; text-align: center; }
button:hover, .button:hover { border-color: var(--accent); }
button:disabled { opacity: 0.5; cursor: wait; }
button.primary, .button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.link { background: none; border: none; color: var(--accent); padding: 4px 6px; }
button.link.danger { color: var(--bad); }
input:focus, select:focus, button:focus-visible, canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); }
label.inline { flex-direction: row; align-items: center; gap: 6px; }
label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--text); }

.top {
  display: flex; align-items: center; gap: 16px; padding: 10px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 700; text-decoration: none; font-size: 17px; }
.brand img { width: 22px; height: 22px; }
.top nav { margin-left: auto; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

main { padding: 20px 16px; max-width: 1200px; margin: 0 auto; }
main.narrow { max-width: 380px; padding-top: 60px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.card.dim, .phone-card.dim { opacity: 0.75; }
.muted { color: var(--muted); margin: 0; }
.hint { color: var(--warn); margin: 0; font-size: 14px; }
.error { color: var(--bad); margin: 0; }
.watchers { color: var(--ok); margin: 0; font-size: 14px; }
.badge { background: var(--panel-2); border: 1px solid var(--line); border-radius: 99px; padding: 2px 10px; font-size: 13px; color: var(--muted); }
.badge.warn { color: var(--warn); border-color: var(--warn); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.phone-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.phone-card .button { margin-top: auto; }
.phone-card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.online { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.connecting, .dot.checking { background: var(--warn); }
.dot.offline, .dot.unauthorized { background: var(--bad); }

.admin section { margin-bottom: 34px; }
.stack { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-form { flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.row-form h2 { width: 100%; }
.setup summary { cursor: pointer; color: var(--accent); }
.steps ol { padding-left: 20px; margin: 10px 0; display: flex; flex-direction: column; gap: 12px; }
.steps li .row { margin-top: 8px; }
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }

.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: 8px; padding: 10px 14px; }
.toast.error { border-left-color: var(--bad); }

/* --- Phone screen page --- */
.viewer-page { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.viewer-page .top { flex: none; }
.viewer-page .back { text-decoration: none; }
.viewer-page .title { display: flex; flex-direction: column; min-width: 0; }
.viewer-page .watchers { margin-left: auto; }
.viewer { flex: 1; display: flex; min-height: 0; gap: 12px; padding: 12px; }
.stage { flex: 1; min-width: 0; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; }
#screen { background: #000; border-radius: 14px; touch-action: none; cursor: pointer; max-width: 100%; max-height: 100%; }
.overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center;
  text-align: center; padding: 20px; color: var(--muted); background: rgba(15, 20, 32, 0.6); pointer-events: auto;
}
.drop { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(75, 143, 230, 0.2); border: 2px dashed var(--accent); border-radius: 14px; font-size: 18px; pointer-events: none; }
.tools { flex: none; display: flex; flex-direction: column; gap: 6px; width: 150px; overflow-y: auto; }
.tools button { width: 100%; text-align: left; }
.typebar { flex: none; display: flex; gap: 8px; padding: 0 12px 12px; }
.typebar input { flex: 1; min-width: 0; }
.clip { flex: none; margin: 0 12px 12px; padding: 8px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; max-height: 5em; overflow-y: auto; }
body.view-only .tools .tools-buttons button, body.view-only .typebar { display: none; }
.tools.view-only .tools-buttons button, .tools.view-only .tools-type { display: none; }
.tools-head { font-size: 14px; overflow-wrap: anywhere; padding: 2px 2px 4px; }
.viewer-page .tools-head { display: none; }
.tools-buttons { display: flex; flex-direction: column; gap: 6px; }
.tools-type { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.tools-type input { width: 100%; min-width: 0; }
.tools > * { flex: none; }
.tools button { padding: 7px 10px; }
.tools-screens { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.tools-screens:empty { display: none; }
.tools-label { color: var(--muted); font-size: 13px; }
.tools .screen-link.active { border-color: var(--accent); background: rgba(75, 143, 230, 0.14); }
.tools button.link { padding: 4px 2px; }

@media (max-width: 720px) {
  .viewer { flex-direction: column; padding: 8px; }
  .tools { width: auto; overflow: visible; }
  .tools-buttons, .tools-screens { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
  .tools-label, .tools-head { grid-column: 1 / -1; }
  .tools button { width: auto; padding: 6px 4px; font-size: 13px; line-height: 1.2; text-align: center; }
  .typebar { padding: 0 8px 8px; }
  .viewer-page .watchers { display: none; }
}

/* --- Login steps, help, guides --- */
.small { font-size: 13px; }
.qr { display: block; width: 210px; height: 210px; margin: 10px 0; background: #fff; border-radius: 8px; }
.enroll { padding-left: 20px; display: flex; flex-direction: column; gap: 12px; margin: 0; }
.enroll input { margin-top: 6px; width: 100%; }
code { background: var(--panel-2); padding: 2px 6px; border-radius: 4px; overflow-wrap: anywhere; }
.guide ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.help { max-width: 820px; display: flex; flex-direction: column; gap: 16px; }
.help h2 { font-size: 19px; }
.help h3 { font-size: 15px; margin: 8px 0 0; }
.help ul, .help ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.help p { margin: 0; }
.toc { display: flex; flex-wrap: wrap; gap: 8px 16px; }

.linkcode { font-size: 18px; margin: 0; }
.linkcode strong { font-size: 24px; letter-spacing: 2px; color: var(--ok); }
.inline-details { display: inline-block; margin-left: 6px; }
.inline-details summary { cursor: pointer; color: var(--accent); }

/* --- Front page: log in + downloads --- */
main.landing { max-width: 980px; padding-top: 40px; }
.landing-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.landing-col { display: flex; flex-direction: column; gap: 16px; }
.downloads .dl { display: flex; flex-direction: column; gap: 8px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.downloads .dl .button, .downloads .dl button { align-self: flex-start; }
.downloads p { margin: 0; }
@media (max-width: 760px) { .landing-grid { grid-template-columns: 1fr; } main.landing { padding-top: 16px; } }

.getapps { margin-top: 24px; }

/* Phones page: heading row and the get-the-app card */
.home-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.home-head h1 { margin: 0; }
.home-head .button { margin-left: auto; }
.getapps-card { margin-top: 24px; }
.getapps-card .row { gap: 10px; }

/* --- Wall: every phone's screen at once --- */
:root { --tile: 260px; }
.wall-page { min-height: 100dvh; }
.wall-layout { display: flex; gap: 14px; align-items: flex-start; padding: 16px; }
.wall-main { flex: 1; min-width: 0; }
.wall-bar { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.wall-bar .title { display: flex; flex-direction: column; min-width: 0; margin-right: auto; }
.wall-bar h1 { margin: 0; }
.wall-hint { margin: 6px 0 12px; }
.wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--tile), 1fr)); gap: 14px; }
.wall-tools { position: sticky; top: 16px; max-height: calc(100dvh - 32px); }
.tile { color: var(--text); display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tile-frame { position: relative; background: #000; border: 2px solid var(--line); border-radius: 10px;
              overflow: hidden; aspect-ratio: 9 / 16; display: flex; align-items: center; justify-content: center; }
.tile:hover .tile-frame { border-color: #4a5d88; }
.tile.selected .tile-frame { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(75, 143, 230, 0.35); }
.tile-screen { width: 100%; height: 100%; object-fit: contain; display: block; cursor: pointer; }
.tile-screen:focus-visible { outline: none; }
.tile.selected .tile-screen { touch-action: none; }
.tile-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
                background: rgba(15, 20, 32, 0.75); color: var(--muted); font-size: 14px; text-align: center; padding: 10px; }
.tile-name { font-size: 14px; display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.tile-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.tile-open { font-size: 13px; flex: none; }
.wall-empty { text-align: center; padding: 40px 16px; }
@media (max-width: 760px) {
  .wall-layout { flex-direction: column; align-items: stretch; padding: 8px; }
  .wall-tools { position: sticky; top: auto; bottom: 0; max-height: 45dvh; overflow-y: auto; background: var(--bg, #0e1013);
                border-top: 1px solid var(--line); padding: 8px 0; }
}

/* --- Pick an app to open on a screen --- */
.picker { position: fixed; inset: 0; background: rgba(8, 11, 18, 0.72); display: flex;
          align-items: center; justify-content: center; padding: 20px; z-index: 60; }
.picker-box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
              padding: 18px; width: min(520px, 100%); max-height: 80vh; display: flex;
              flex-direction: column; gap: 12px; }
.picker-box h2 { margin: 0; }
.app-list { overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.app-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; }

.screens { display: flex; flex-direction: column; gap: 6px; margin-top: 8px;
           border-top: 1px solid var(--line); padding-top: 8px; }
.screen-row { gap: 8px; }
.button.small { padding: 5px 10px; font-size: 14px; }

/* --- App shell: the sidebar on every signed-in page (like Tessera) --- */
:root { --side: 232px; --side-small: 64px; }
.side { position: fixed; inset: 0 auto 0 0; width: var(--side); background: var(--panel);
        border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 40; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 12px 10px 16px; }
.side .brand span { white-space: nowrap; }
.side-toggle, .side-open { background: none; border: none; padding: 6px; color: var(--muted); }
.side-toggle svg, .side-open svg, .side-link svg, .side-user svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
.side-nav { display: flex; flex-direction: column; gap: 2px; padding: 6px 8px; flex: 1; overflow-y: auto; }
.side-link { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px;
             color: var(--text); text-decoration: none; background: none; border: none; font: inherit;
             text-align: left; width: 100%; cursor: pointer; }
.side-link:hover { background: var(--panel-2); }
.side-link.active { background: var(--panel-2); color: var(--accent); }
.side-link span { white-space: nowrap; overflow: hidden; }
.side-foot { border-top: 1px solid var(--line); padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.side-user { display: flex; align-items: center; gap: 12px; padding: 8px 12px; color: var(--muted); }
.side-user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user small { color: var(--accent); }
body.with-side { padding-left: var(--side); }
body.with-side > header.top-when-signed-out { display: none; }
body.side-small { --side: var(--side-small); }
body.side-small .side .brand span, body.side-small .side-link span, body.side-small .side-user span { display: none; }
body.side-small .side-head { flex-direction: column; padding: 12px 8px; }
body.side-small .side-link, body.side-small .side-user { justify-content: center; padding: 10px 0; }
.side-open, .side-scrim { display: none; }

@media (max-width: 760px) {
  body.with-side, body.with-side.side-small { padding-left: 0; }
  .side { transform: translateX(-100%); transition: transform .18s ease; width: 260px; }
  body.side-drawer .side { transform: none; }
  body.side-small .side .brand span, body.side-small .side-link span, body.side-small .side-user span { display: inline; }
  body.side-small .side-link, body.side-small .side-user { justify-content: flex-start; padding: 9px 12px; }
  body.side-small .side-head { flex-direction: row; }
  .side-toggle { display: none; }
  .side-open { display: block; position: fixed; top: 8px; left: 8px; z-index: 41; background: var(--panel);
               border: 1px solid var(--line); border-radius: 8px; }
  body.side-drawer .side-scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 39; }
  body.with-side main { padding-top: 56px; }
}

/* --- Plain content pages inside the shell --- */
main.page { max-width: 900px; display: flex; flex-direction: column; gap: 16px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.enroll-box { display: flex; flex-direction: column; gap: 10px; }
main.page.wide { max-width: 1200px; }
td.nowrap { white-space: nowrap; }

/* --- Clone space in the app picker --- */
.app-group { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; margin-top: 6px; }
.space-badge { margin-left: 8px; font-size: 12px; font-weight: 400; color: var(--accent); border: 1px solid var(--accent);
               border-radius: 99px; padding: 0 8px; vertical-align: 1px; }
.picker-foot { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.picker-foot p { margin: 0 0 4px; }

/* --- "PhoneDesk has a new version" bar --- */
.update-bar { position: fixed; z-index: 80; left: 50%; bottom: 20px; transform: translateX(-50%);
              width: min(520px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--accent);
              border-radius: 12px; padding: 14px 16px; display: flex; gap: 14px; align-items: center;
              justify-content: space-between; flex-wrap: wrap; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); }

/* --- Install SableOS --- */
.steps li { margin-bottom: 6px; }
.install-step { display: flex; align-items: center; justify-content: space-between; gap: 16px;
                padding: 10px 0; border-bottom: 1px solid var(--line); }
.install-step p { margin: 4px 0 0; }
.install-step button { flex: none; }
.install-step.done strong::after { content: "  done"; color: #3ecf8e; font-weight: 400; font-size: 13px; }
.progress { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin-top: 12px; }
.progress .bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.keep-data { margin: 4px 0 8px; font-size: 14px; }

/* --- Our products --- */
.products { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.product-card { display: flex; gap: 14px; align-items: flex-start; padding: 16px; background: var(--panel); border: 1px solid var(--line);
                border-radius: 12px; color: var(--text); text-decoration: none; }
.product-card:hover { border-color: var(--accent); }
.product-card img { width: 52px; height: 52px; border-radius: 12px; flex: none; }
.product-card p { margin: 4px 0 8px; }
.product-site { color: var(--accent); font-size: 13px; }

/* --- Users: each with its own screen or a switch --- */
.user-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
            padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.user-row.active { border-color: var(--accent); }
.user-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.user-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.unlock-form { display: flex; gap: 8px; flex-wrap: wrap; }
.unlock-form input { flex: 1 1 180px; min-width: 0; }

/* --- Language switch (EN | RU), under the menu and on the login page --- */
.lang-switch { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); align-self: flex-start; margin: 4px 12px; }
.lang-switch button { background: none; border: 0; border-radius: 6px; padding: 4px 10px; color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer; min-height: 0; }
.lang-switch button.active { background: var(--accent); color: var(--accent-text); }
header.top .lang-switch { margin: 0 0 0 12px; align-self: center; }
body.side-small .side .lang-switch { flex-direction: column; margin: 4px auto; }

/* --- "Our products" stands out in the menu --- */
.side-link.featured { margin: 6px 0; color: #fff; font-weight: 600;
  background: linear-gradient(135deg, #4b8fe6 0%, #7b5cf0 100%);
  box-shadow: 0 2px 12px rgba(75, 143, 230, 0.35); }
.side-link.featured:hover { background: linear-gradient(135deg, #5c9bea 0%, #8a6df3 100%); }
.side-link.featured.active { color: #fff; outline: 2px solid rgba(255, 255, 255, 0.5); outline-offset: -2px; }
body.side-small .side-link.featured { padding: 10px 0; }

/* --- Unlock form: its own box, nothing clipped --- */
.unlock-form { display: flex; gap: 8px; flex-wrap: wrap; padding: 4px; }
.unlock-form input { flex: 1 1 200px; min-width: 0; box-sizing: border-box; -webkit-appearance: none; appearance: none; }
.unlock-saved { margin: 0 4px; }

/* --- Phone users (owner) --- */
.pu-users { display: grid; gap: 12px; }
.pu-user { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--panel-2); display: grid; gap: 10px; }
.pu-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pu-field { display: grid; gap: 4px; }
.pu-pin { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.pu-pin input { flex: 1 1 220px; min-width: 0; max-width: 360px; box-sizing: border-box; }
.pu-dots { font-family: ui-monospace, monospace; letter-spacing: 2px; }
.pu-vas { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.pu-va { display: inline-flex; align-items: center; gap: 6px; }
.pu-user textarea { width: 100%; box-sizing: border-box; resize: vertical; }

/* --- Ask for an email on the Phones page --- */
.notice-email { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; border-color: var(--accent); }
label.check { display: inline-flex; align-items: center; gap: 8px; margin-top: 10px; }
.pu-vas label.pu-va { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; margin: 0; }
.pu-va input[type="checkbox"] { width: auto; margin: 0; }
.pu-user textarea { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 12px; font: inherit; font-size: 15px; line-height: 1.45; }
.pu-user textarea::placeholder { color: var(--muted); }
