/* EX Desk Admin Console — iOS-style design.
   Apple's system palette (text shades adjusted for 4.5:1 contrast), grouped inset lists, large
   titles, translucent bars and sheets. Light and dark themes. */
:root {
  --bg: #f2f2f7; --bg2: #ffffff; --cell: #ffffff; --cell-hover: #f5f5f8; --fill: rgba(118,118,128,.12); --fill2: rgba(118,118,128,.08);
  --surface: var(--cell); --surface-2: var(--fill2);
  --sep: rgba(60,60,67,.18); --line: rgba(60,60,67,.18); --line-strong: rgba(60,60,67,.29);
  --text: #000000; --muted: #5c5c63; --tertiary: #8a8a8e;
  --accent: #0066d6; --accent-ink: #ffffff; --accent-soft: rgba(0,122,255,.12);
  --ok: #1a7f37; --ok-soft: rgba(52,199,89,.15); --warn: #a15c00; --warn-soft: rgba(255,149,0,.16);
  --danger: #d70015; --danger-soft: rgba(255,59,48,.12); --info: #0066d6; --info-soft: rgba(0,122,255,.12); --off: #6c6c70;
  --bar: rgba(249,249,251,.82); --side: rgba(242,242,247,.92); --shadow: 0 8px 30px rgba(0,0,0,.12);
  --radius: 12px; --focus: 0 0 0 3px rgba(0,122,255,.35);
  --ease: cubic-bezier(.32,.72,0,1);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Inter, "Noto Sans Bengali", "Nirmala UI", "Noto Sans Devanagari", "Noto Naskh Arabic", "Noto Nastaliq Urdu", system-ui, sans-serif;
  font-size: 15px; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
[data-theme="dark"] {
  --bg: #000000; --bg2: #1c1c1e; --cell: #1c1c1e; --cell-hover: #2c2c2e; --fill: rgba(118,118,128,.24); --fill2: rgba(118,118,128,.16);
  --sep: rgba(84,84,88,.6); --line: rgba(84,84,88,.6); --line-strong: rgba(120,120,128,.7);
  --text: #ffffff; --muted: #aeaeb2; --tertiary: #8e8e93;
  --accent: #3d9bff; --accent-ink: #ffffff; --accent-soft: rgba(10,132,255,.2);
  --ok: #34d058; --ok-soft: rgba(48,209,88,.18); --warn: #ffb340; --warn-soft: rgba(255,159,10,.18);
  --danger: #ff6961; --danger-soft: rgba(255,69,58,.18); --info: #3d9bff; --info-soft: rgba(10,132,255,.2); --off: #98989d;
  --bar: rgba(22,22,24,.8); --side: rgba(18,18,20,.94); --shadow: 0 10px 40px rgba(0,0,0,.6);
  --focus: 0 0 0 3px rgba(10,132,255,.5);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); }
svg.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; background: var(--fill); color: var(--accent);
  padding: 0 16px; min-height: 40px; border-radius: 12px; cursor: pointer; white-space: nowrap; font-weight: 600; font-size: 15px;
  transition: transform .2s var(--ease), background .15s, opacity .15s; -webkit-tap-highlight-color: transparent; }
.btn:hover { background: var(--fill2); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); background: var(--danger-soft); }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.icon { width: 40px; padding: 0; border-radius: 50%; color: var(--text); }
.btn.icon.sm { width: 34px; min-height: 34px; }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn > svg { width: 1.15em; height: 1.15em; }

/* ---------- form controls ---------- */
input[type=text], input[type=password], input[type=number], input[type=search], input[type=date], select, textarea {
  border: 0; background: var(--fill); border-radius: 10px; padding: 0 12px; min-height: 42px; width: 100%; font-size: 15px; color: var(--text); }
textarea { resize: vertical; min-height: 88px; padding: 10px 12px; }
select { appearance: none; -webkit-appearance: none; padding-inline-end: 34px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
[dir="rtl"] select { background-position: 18px 50%, 13px 50%; }
input::placeholder, textarea::placeholder { color: var(--tertiary); }
label.field { display: grid; gap: 6px; margin-bottom: 14px; font-size: 13px; font-weight: 500; color: var(--muted); }
label.field > input, label.field > select, label.field > textarea { color: var(--text); font-weight: 400; }
label.field small { font-weight: 400; color: var(--tertiary); }
.field { margin-bottom: 14px; }
.check { display: flex; gap: 10px; align-items: center; margin: 8px 0; min-height: 30px; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
input[type=checkbox][role=switch] { appearance: none; -webkit-appearance: none; width: 51px; height: 31px; border-radius: 16px; background: var(--fill); position: relative; cursor: pointer; transition: background .2s; }
input[type=checkbox][role=switch]::after { content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.25); transition: transform .25s var(--ease); }
input[type=checkbox][role=switch]:checked { background: #34c759; }
input[type=checkbox][role=switch]:checked::after { transform: translateX(20px); }
[dir="rtl"] input[type=checkbox][role=switch]:checked::after { transform: translateX(-20px); }

/* segmented control */
.seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: 9px; background: var(--fill); }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 7px; padding: 0 14px; min-height: 32px; font-size: 14px; color: var(--text); cursor: pointer; white-space: nowrap; transition: background .2s var(--ease); }
.seg button.on { background: var(--bg2); font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,.14); }
[data-theme="dark"] .seg button.on { background: #636366; }

/* search field */
.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; inset-inline-start: 10px; width: 17px; height: 17px; color: var(--tertiary); pointer-events: none; }
.search input { padding-inline-start: 34px; min-height: 38px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login { width: 100%; max-width: 400px; background: var(--cell); border-radius: 22px; padding: 32px 28px; box-shadow: var(--shadow); animation: rise .45s var(--ease); }
.login h1 { font-size: 24px; margin: 0 0 4px; font-weight: 700; }
.login h3 { font-size: 17px; margin: 18px 0 10px; }
.login p.sub { color: var(--muted); margin: 0 0 22px; }
.login .btn.primary { min-height: 48px; font-size: 16px; border-radius: 14px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--side); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-inline-end: 1px solid var(--sep); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; }
.side .brand { display: flex; justify-content: flex-start; padding: 2px 8px 14px; }
.nav { display: flex; align-items: center; gap: 12px; padding: 0 12px; min-height: 40px; border-radius: 10px; cursor: pointer; color: var(--text); border: 0; background: none; text-align: start; width: 100%; font-size: 15px; transition: background .15s; }
.nav svg { width: 21px; height: 21px; color: var(--accent); }
.nav:hover { background: var(--fill2); }
.nav.active { background: var(--accent); color: #fff; font-weight: 600; }
.nav.active svg { color: #fff; }
.side .spacer { flex: 1; }
.me-card { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: var(--fill2); margin-top: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(180deg, #8e8e93, #636366); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.me-card .nm { font-weight: 600; font-size: 14px; line-height: 1.25; }
.me-card .rl { font-size: 12.5px; color: var(--muted); }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 8px; padding: 10px 28px; position: sticky; top: 0; z-index: 5; min-height: 56px;
  background: var(--bar); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid transparent; transition: border-color .2s; }
.top.scrolled { border-bottom-color: var(--sep); }
.top .ttl-sm { flex: 1; font-weight: 600; font-size: 17px; opacity: 0; transition: opacity .2s; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top.scrolled .ttl-sm { opacity: 1; }
.content { padding: 4px 28px 40px; max-width: 1320px; width: 100%; }
.large-title { font-size: 34px; line-height: 1.15; font-weight: 700; margin: 6px 0 4px; letter-spacing: -.01em; }
.subtitle { color: var(--muted); margin: 0 0 18px; font-size: 15px; }
.who { color: var(--muted); font-size: 13px; }
.langsel { width: auto !important; min-height: 34px !important; font-size: 14px; border-radius: 10px; }
.tabbar { display: none; }

/* ---------- grouped lists (iOS inset grouped) ---------- */
.cap { font-size: 13px; color: var(--muted); margin: 22px 16px 7px; text-transform: uppercase; letter-spacing: .02em; }
.cap.first { margin-top: 8px; }
.foot { font-size: 13px; color: var(--muted); margin: 7px 16px 0; line-height: 1.45; }
.grp { background: var(--cell); border-radius: var(--radius); overflow: hidden; }
.cell { display: flex; align-items: center; gap: 12px; padding: 8px 16px; min-height: 52px; width: 100%; border: 0; background: transparent; color: var(--text);
  text-align: start; font-size: 15.5px; position: relative; text-decoration: none; cursor: default; }
button.cell, a.cell { cursor: pointer; transition: background .15s; }
button.cell:hover, a.cell:hover { background: var(--cell-hover); }
button.cell:active { background: var(--fill); }
.cell + .cell::before { content: ""; position: absolute; top: 0; inset-inline-start: 60px; inset-inline-end: 0; border-top: 1px solid var(--sep); }
.grp.plain-cells .cell + .cell::before { inset-inline-start: 16px; }
.cell.sel { background: var(--accent-soft); }
.cell .ic { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; color: #fff; flex: none; background: #8e8e93; }
.cell .ic svg { width: 19px; height: 19px; }
.cell .tx { flex: 1; min-width: 0; }
.cell .t1 { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell .t2 { display: block; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell .val { color: var(--muted); font-size: 15px; text-align: end; max-width: 62%; overflow-wrap: anywhere; }
.cell .chev { width: 14px; height: 14px; color: var(--tertiary); stroke-width: 2.6; }
[dir="rtl"] .cell .chev { transform: scaleX(-1); }
.cell.destructive { color: var(--danger); justify-content: center; font-weight: 600; }
.cell.accent { color: var(--accent); }
.cell:disabled { opacity: .4; cursor: not-allowed; }
.ic.green { background: #34c759; } .ic.gray { background: #8e8e93; } .ic.blue { background: #0a84ff; } .ic.indigo { background: #5e5ce6; }
.ic.teal { background: #0f8f86; } .ic.orange { background: #e07800; } .ic.red { background: #ff3b30; } .ic.purple { background: #af52de; } .ic.yellow { background: #d69a00; }

/* split view: device list + details */
.split { display: grid; grid-template-columns: minmax(320px, 430px) minmax(0, 1fr); gap: 28px; align-items: start; }
.split > .detail { position: sticky; top: 72px; }
.listbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.listbar .search { flex: 1 1 220px; }
.hero { display: flex; align-items: center; gap: 14px; padding: 10px 2px 4px; }
.hero-tx { min-width: 0; }
.hero .big { flex: none; width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; color: #fff; background: linear-gradient(180deg, #aeaeb2, #8e8e93); }
.hero .big.on { background: linear-gradient(180deg, #4cd964, #28a745); }
.hero .big svg { width: 28px; height: 28px; stroke-width: 1.7; }
.hero h2 { margin: 0; font-size: 21px; font-weight: 700; overflow-wrap: anywhere; }
.hero .st { font-size: 14px; font-weight: 600; color: var(--off); }
.hero .st.on { color: var(--ok); }
.detail-empty { display: grid; place-items: center; align-content: center; min-height: 360px; color: var(--tertiary); text-align: center; gap: 10px; }
.detail-empty svg { width: 56px; height: 56px; stroke-width: 1.3; }
.fade-in { animation: fade .3s var(--ease); }

/* ---------- panels & tables (other pages) ---------- */
.panel { background: var(--cell); border-radius: var(--radius); margin-bottom: 22px; overflow: hidden; }
.panel > header { display: flex; align-items: center; gap: 10px; padding: 14px 16px; flex-wrap: wrap; }
.panel > header h3 { margin: 0; font-size: 17px; font-weight: 600; flex: 1; }
.panel > header select, .panel > header input { width: auto; min-width: 160px; }
.panel .body { padding: 16px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: 11px 16px; vertical-align: middle; font-size: 14.5px; }
th { font-size: 12.5px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; border-bottom: 1px solid var(--sep); }
tbody tr + tr td { border-top: 1px solid var(--sep); }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--cell-hover); }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 12.5px; word-break: break-all; }
.empty { padding: 34px 16px; text-align: center; color: var(--tertiary); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--cell); border-radius: var(--radius); padding: 14px 16px; }
.stat .n { font-size: 28px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 13px; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: var(--fill); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.off { color: var(--off); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.dev-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.dev-name { font-weight: 600; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.steps { counter-reset: s; display: grid; gap: 12px; }
.step { border-radius: var(--radius); padding: 14px 16px; background: var(--fill2); }
.step h4 { margin: 0 0 10px; font-size: 15px; display: flex; gap: 8px; align-items: center; }
.step h4::before { counter-increment: s; content: counter(s); width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 12px; }
.printer-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.pcard { border: 2px solid transparent; border-radius: 14px; padding: 12px 14px; cursor: pointer; background: var(--fill2); color: var(--text); text-align: start; transition: border-color .15s, background .15s, transform .2s var(--ease); }
.pcard:active { transform: scale(.98); }
.pcard.sel { border-color: var(--accent); background: var(--accent-soft); }
.pcard .pn { font-weight: 600; }
.pcard:disabled { opacity: .45; cursor: not-allowed; }
.pcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin-bottom: 14px; }
.pcard strong > svg, .modal > header h3 > svg { width: 1.1em; height: 1.1em; vertical-align: -0.18em; }
.preview { border-radius: 12px; background: var(--fill2); min-height: 220px; display: grid; place-items: center; overflow: hidden; }
.preview iframe { width: 100%; height: 420px; border: 0; background: #fff; }
.preview img { max-width: 100%; max-height: 420px; }
.preview.mono iframe, .preview.mono img { filter: grayscale(1); }
.progress { height: 6px; background: var(--fill); border-radius: 99px; overflow: hidden; min-width: 90px; }
.progress > i { display: block; height: 100%; background: var(--accent); transition: width .3s var(--ease); }
.crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.crumbs button { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.crumbs span { color: var(--muted); }
.hint { background: var(--info-soft); color: var(--info); padding: 11px 13px; border-radius: 12px; font-size: 13.5px; margin-bottom: 12px; }
.warnbox { background: var(--warn-soft); color: var(--warn); padding: 11px 13px; border-radius: 12px; font-size: 13.5px; margin-bottom: 12px; }
.errbox { background: var(--danger-soft); color: var(--danger); padding: 11px 13px; border-radius: 12px; font-size: 13.5px; margin-bottom: 12px; }
details.wake { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--sep); }
details.wake summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.wakeout { margin-top: 8px; font-size: 13.5px; }
ul.plain { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.selrow td { background: var(--accent-soft); }

.dropzone.over { outline: 2px dashed var(--accent); outline-offset: -4px; background: var(--accent-soft); }
.dropbanner { display: flex; align-items: center; gap: 14px; border: 2px dashed var(--line-strong); border-radius: 14px; padding: 14px 18px; margin: 0 0 10px; cursor: pointer; background: var(--fill2); transition: border-color .15s, background .15s; }
.dropbanner:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropbanner .db-ico { font-size: 26px; color: var(--accent); line-height: 1; }
.dropbanner .db-title { font-weight: 650; }
.dropbanner .db-sub { color: var(--muted); font-size: 12.5px; word-break: break-all; }
.dropoverlay { position: absolute; inset: 0; z-index: 5; display: none; align-items: center; justify-content: center; border-radius: 14px; background: color-mix(in srgb, var(--accent) 16%, transparent); border: 3px dashed var(--accent); pointer-events: none; }
.dropoverlay.show { display: flex; }
.dropoverlay > div { background: var(--accent); color: var(--accent-ink); padding: 12px 22px; border-radius: 999px; font-weight: 650; font-size: 18px; }

/* ---------- sheets (dialogs) ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.32); display: grid; place-items: center; z-index: 50; padding: 18px; animation: fade .25s ease; }
.modal { background: var(--bg2); border-radius: 18px; width: 100%; max-width: 580px; max-height: 92vh; overflow: auto; box-shadow: var(--shadow); animation: pop .38s var(--ease); }
.modal.wide { max-width: 1080px; }
.modal > header { display: flex; align-items: center; padding: 14px 16px 12px 20px; gap: 10px; position: sticky; top: 0; z-index: 1;
  background: color-mix(in srgb, var(--bg2) 86%, transparent); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-bottom: 1px solid var(--sep); }
.modal > header h3 { margin: 0; font-size: 17px; font-weight: 600; flex: 1; display: flex; align-items: center; gap: 8px; }
.modal > header .btn.ghost { width: 30px; min-height: 30px; padding: 0; border-radius: 50%; background: var(--fill); color: var(--muted); font-size: 13px; }
.modal .body { padding: 18px 20px; }
.modal footer { padding: 12px 20px 16px; display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.modal-bg.closing { animation: fadeout .2s ease forwards; }
.modal-bg.closing .modal { animation: drop .2s ease forwards; }

/* ---------- toasts ---------- */
#toasts { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 100; width: min(440px, calc(100vw - 24px)); pointer-events: none; }
.toast { background: var(--bar); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); padding: 12px 16px; border-radius: 16px; box-shadow: var(--shadow); font-size: 14.5px; font-weight: 500; animation: drop-in .4s var(--ease); pointer-events: auto; }
.toast.err { color: var(--danger); }

/* ---------- screen viewer (always dark) ---------- */
.viewer { position: fixed; inset: 0; background: #0b0d0c; z-index: 60; display: flex; flex-direction: column; color: #e7ebe5; }
.viewer .vbar { display: flex; gap: 8px; align-items: center; padding: 8px 12px; background: rgba(28,28,30,.92); backdrop-filter: blur(20px); border-bottom: 1px solid #2c2c2e; flex-wrap: wrap; }
.viewer .vbar .btn { background: #2c2c2e; color: #fff; min-height: 34px; padding: 0 12px; font-size: 14px; border-radius: 9px; }
.viewer .vbar .btn.primary { background: #0a84ff; color: #fff; }
.viewer .vbar select { width: auto; background-color: #2c2c2e; color: #fff; min-height: 34px; font-size: 14px; }
.viewer .stage { flex: 1; min-height: 0; overflow: hidden; display: flex; position: relative; }
.viewer .stage.scroll { overflow: auto; }
.viewer canvas { margin: auto; flex: none; image-rendering: auto; outline: none; display: block; }
.viewer canvas.control { cursor: default; }
.viewer .stage.kbd canvas { box-shadow: 0 0 0 3px #30d158, 0 0 24px rgba(48,209,88,.35); }
.viewer .kbadge { position: absolute; left: 12px; bottom: 12px; z-index: 3; background: #12361f; color: #c4f2d0; border: 1px solid #2e7a47; padding: 6px 10px; border-radius: 10px; font-size: 12px; pointer-events: none; }
.viewer .kbadge.off { background: #3a2c10; color: #ffd27a; border-color: #6b5a22; }
.viewer .kcatch { position: absolute; left: 12px; bottom: 12px; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; resize: none; overflow: hidden; pointer-events: none; }
.viewer .vtxt { width: 170px; min-height: 34px; background: #2c2c2e; color: #fff; border-radius: 9px; }
.viewer .vbar .btn.on { background: #0a84ff; }
.viewer .vbar :focus-visible, .viewer .vhandle:focus-visible { outline: 2px solid #0a84ff; outline-offset: 2px; }
.viewer .vhandle { display: none; }
.viewer.full .vbar { position: absolute; top: 0; left: 0; right: 0; z-index: 4; box-shadow: 0 6px 18px rgba(0,0,0,.45); transition: transform .18s ease-out, opacity .18s ease-out; }
.viewer.full .vbar.hidden { transform: translateY(-100%); opacity: 0; pointer-events: none; }
.viewer.full .vhandle { display: block; position: absolute; top: 0; left: 50%; transform: translateX(-50%); z-index: 3; background: #1c1c1e; color: #aeaeb2; border: 1px solid #2c2c2e; border-top: 0; border-radius: 0 0 10px 10px; padding: 0 14px; font-size: 12px; cursor: pointer; opacity: .8; }
.viewer .vmsg { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); background: rgba(58,44,16,.95); color: #ffd27a; padding: 8px 14px; border-radius: 10px; font-size: 13px; }
.mode-pill { padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.mode-pill.view { background: rgba(10,132,255,.2); color: #64b5ff; }
.mode-pill.control { background: rgba(255,69,58,.2); color: #ff8a80; }
[dir="rtl"] .viewer .stage, [dir="rtl"] .mono { direction: ltr; }
[dir="rtl"] .mono { text-align: start; unicode-bidi: plaintext; }

/* ---------- logo ---------- */
.logo { display: inline-block; line-height: 0; flex: none; }
.logo img { height: 100%; width: auto; display: block; user-select: none; }
.logo .on-dark, [data-theme="dark"] .logo .on-light { display: none; }
[data-theme="dark"] .logo .on-dark { display: block; }
.logo-auth { display: block; height: 84px; width: fit-content; margin: 0 auto 18px; }
.login > h1, .login > p.sub { text-align: center; }
.logo-side { height: 52px; }
.logo-top { display: none; height: 30px; }
.credit { margin-top: 12px; padding: 8px; font-size: 11.5px; color: var(--tertiary); line-height: 1.5; }

/* ---------- motion ---------- */
@keyframes fade { from { opacity: 0; } }
@keyframes fadeout { to { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(10px); } }
@keyframes drop { to { opacity: 0; transform: scale(.97) translateY(14px); } }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }
@keyframes drop-in { from { opacity: 0; transform: translateY(-18px) scale(.96); } }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes sheet-down { to { transform: translateY(100%); } }

/* ---------- tablet / phone ---------- */
@media (max-width: 1100px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .split > .detail { display: none; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .logo-top { display: inline-block; }
  .top { padding: 8px 14px; }
  .content { padding: 4px 16px calc(96px + env(safe-area-inset-bottom)); }
  .large-title { font-size: 32px; }
  .grid2 { grid-template-columns: 1fr; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; justify-content: space-around; align-items: flex-start;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: var(--bar); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-top: 1px solid var(--sep); }
  .tab { display: flex; flex-direction: column; align-items: center; gap: 3px; border: 0; background: none; color: var(--tertiary); font-size: 10.5px; min-width: 60px; min-height: 48px; padding: 2px 4px; cursor: pointer; }
  .tab svg { width: 25px; height: 25px; }
  .tab.active { color: var(--accent); font-weight: 600; }
  /* dialogs become bottom sheets */
  .modal-bg { place-items: end stretch; padding: 0; }
  .modal { max-width: none !important; max-height: 94vh; border-radius: 16px 16px 0 0; animation: sheet-up .42s var(--ease); padding-bottom: env(safe-area-inset-bottom); }
  .modal > header::before { content: ""; position: absolute; top: 6px; left: 50%; width: 38px; height: 5px; margin-left: -19px; border-radius: 3px; background: var(--line-strong); }
  .modal > header { padding-top: 20px; }
  .modal-bg.closing .modal { animation: sheet-down .22s ease forwards; }
  .modal footer .btn { flex: 1 1 auto; min-height: 46px; }
  .panel > header select, .panel > header input { width: 100%; }
}
@media (max-width: 560px) {
  .top .who { display: none; }
  .logo-auth { height: 70px; }
  .login { padding: 26px 18px; border-radius: 18px; }
  .seg button { padding: 0 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
svg.i.fi { width: 18px; height: 18px; vertical-align: -4px; color: var(--accent); }
.viewer .stage.dropping { outline: 3px dashed #0a84ff; outline-offset: -6px; background: rgba(10,132,255,.08); }

/* ---- chat with an office PC (Message dialog) ---- */
.chat-wrap { display: flex; flex-direction: column; gap: 10px; }
.chat { display: flex; flex-direction: column; gap: 6px; min-height: 180px; max-height: 50vh; overflow-y: auto; padding: 12px; border-radius: 16px; background: var(--fill2); scroll-behavior: smooth; }
.chat-empty { margin: auto; color: var(--tertiary); font-size: 14px; }
.bubble { max-width: 78%; padding: 8px 12px 6px; border-radius: 18px; line-height: 1.4; animation: bubble-in .25s var(--ease); }
.bubble .bt { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; }
.bubble .bm { font-size: 11.5px; margin-top: 3px; opacity: .75; }
.bubble.me { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 6px; }
.bubble.them { align-self: flex-start; background: var(--cell); color: var(--text); border-bottom-left-radius: 6px; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
[dir="rtl"] .bubble.me { border-bottom-right-radius: 18px; border-bottom-left-radius: 6px; }
[dir="rtl"] .bubble.them { border-bottom-left-radius: 18px; border-bottom-right-radius: 6px; }
@keyframes bubble-in { from { opacity: 0; transform: translateY(6px) scale(.98); } }
@media (prefers-reduced-motion: reduce) { .bubble { animation: none; } .chat { scroll-behavior: auto; } }
.chat-opts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.chat-opts .check { margin: 0; }
.chat-compose { display: flex; align-items: flex-end; gap: 8px; background: var(--fill); border-radius: 22px; padding: 6px 6px 6px 14px; }
[dir="rtl"] .chat-compose { padding: 6px 14px 6px 6px; }
.chat-compose:focus-within { box-shadow: var(--focus); }
.chat-in { flex: 1; border: 0 !important; background: transparent !important; box-shadow: none !important; resize: none; min-height: 34px; max-height: 140px; padding: 7px 0 !important; font: inherit; color: var(--text); outline: none; line-height: 1.35; }
.chat-send { flex: none; width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; cursor: pointer; transition: transform .15s var(--ease), opacity .15s; }
.chat-send:hover { transform: scale(1.06); } .chat-send:disabled { opacity: .5; cursor: default; transform: none; }
.chat-send svg { width: 18px; height: 18px; }
.chat-hint { font-size: 12px; text-align: end; margin-top: -4px; }

/* ---- a computer's actions: one compact row of small buttons ---- */
.qa-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 4px; }
.qa { flex: 0 0 auto; width: 84px; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px 8px; border: 0; border-radius: 14px;
  background: var(--cell); color: var(--text); font: inherit; cursor: pointer; transition: background .15s, transform .15s var(--ease); }
.qa:hover:not(:disabled) { background: var(--cell-hover); transform: translateY(-1px); }
.qa:active:not(:disabled) { transform: scale(.97); }
.qa:disabled { opacity: .45; cursor: default; }
.qa:focus-visible { outline: none; box-shadow: var(--focus); }
.qa .ic { width: 34px; height: 34px; border-radius: 10px; margin: 0; display: grid; place-items: center; color: #fff; }
.qa .ic svg { width: 19px; height: 19px; }
.qa .ql { font-size: 12px; line-height: 1.25; text-align: center; overflow-wrap: anywhere; }

/* ---- compact desktop sizes (owner: "no big buttons"); phones keep finger-sized targets ---- */
@media (min-width: 861px) {
  .btn { min-height: 34px; padding: 0 14px; font-size: 14px; border-radius: 10px; }
  .btn.sm { min-height: 30px; padding: 0 10px; font-size: 13px; border-radius: 9px; }
  .btn.icon { width: 34px; min-height: 34px; }
  .btn.icon.sm { width: 30px; min-height: 30px; }
  .cell { min-height: 44px; padding: 6px 14px; font-size: 14.5px; gap: 10px; }
  .cell .ic { width: 28px; height: 28px; border-radius: 7px; }
  .cell .ic svg { width: 17px; height: 17px; }
  .cell .t2 { font-size: 12.5px; }
  .cell .val { font-size: 14px; }
  .cell + .cell::before { inset-inline-start: 52px; }
  .grp.plain-cells .cell { min-height: 38px; }
  .large-title { font-size: 28px; }
  .cap { margin: 18px 14px 6px; font-size: 12px; }
  .qa { width: 76px; padding: 8px 4px 7px; }
  .qa .ic { width: 30px; height: 30px; border-radius: 9px; }
  .qa .ic svg { width: 17px; height: 17px; }
  .qa .ql { font-size: 11.5px; }
}
.hero .hero-edit { margin-inline-start: auto; }
@media (min-width: 861px) {
  input[type=text], input[type=password], input[type=number], input[type=search], input[type=date], select { min-height: 36px; font-size: 14px; border-radius: 9px; }
  textarea { font-size: 14px; }
  input[type=checkbox], input[type=radio] { width: 18px; height: 18px; }
  input[type=checkbox][role=switch] { width: 44px; height: 26px; }
  input[type=checkbox][role=switch]::after { width: 22px; height: 22px; }
  input[type=checkbox][role=switch]:checked::after { transform: translateX(18px); }
}
.chat-opts { flex-wrap: nowrap; }
.chat-opts input[type=number] { width: 64px !important; min-height: 30px; padding: 0 8px; flex: none; }
.chat-opts .muted { white-space: nowrap; }
