/* Web store (own port). Base tokens mirror admin.css. */
:root {
  --bg: #f4f5f7; --card: #fff; --text: #1f2328; --muted: #6b7280; --line: #e5e7eb;
  --accent: #2563eb; --accent-fill: #2563eb; --on-accent: #fff; --danger: #b91c1c; --ok: #15803d;
  --error-bg: #fef2f2; --error-line: #fecaca; --notice-bg: #f0fdf4; --notice-line: #bbf7d0;
  --tag-bg: #e0e7ff; --tag-text: #3730a3; --input-bg: #fff; --code-bg: #f4f5f7;
  --log-bg: #0f172a; --log-line: #0f172a; --shot-bg: #f4f5f7; --star: #f59e0b;
  color-scheme: light;
}
/* Dark theme: follows the system unless the visitor picked light; data-theme="dark" forces it. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --card: #171a21; --text: #e6e8eb; --muted: #9aa3ae; --line: #2a2f39;
    --accent: #7aa7ff; --accent-fill: #2563eb; --on-accent: #fff; --danger: #f87171; --ok: #4ade80;
    --error-bg: #2a1215; --error-line: #5c1d22; --notice-bg: #0f2418; --notice-line: #1f4d2e;
    --tag-bg: #1f2a47; --tag-text: #c7d2fe; --input-bg: #0f1115; --code-bg: #222733;
    --log-bg: #0a0d12; --log-line: #2a2f39; --shot-bg: #0f1115; --star: #fbbf24;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --card: #171a21; --text: #e6e8eb; --muted: #9aa3ae; --line: #2a2f39;
  --accent: #7aa7ff; --accent-fill: #2563eb; --on-accent: #fff; --danger: #f87171; --ok: #4ade80;
  --error-bg: #2a1215; --error-line: #5c1d22; --notice-bg: #0f2418; --notice-line: #1f4d2e;
  --tag-bg: #1f2a47; --tag-text: #c7d2fe; --input-bg: #0f1115; --code-bg: #222733;
  --log-bg: #0a0d12; --log-line: #2a2f39; --shot-bg: #0f1115; --star: #fbbf24;
  color-scheme: dark;
}
* { box-sizing: border-box; }
/* `hidden` always wins over component display rules (label.button, .row, …). */
[hidden] { display: none !important; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar { display: flex; align-items: center; gap: 24px; padding: 10px 24px; background: var(--card); border-bottom: 1px solid var(--line); }
.topbar .brand { font-weight: 600; color: var(--text); }
.topbar nav { display: flex; gap: 16px; flex: 1; }
.content { max-width: 1400px; margin: 24px auto; padding: 0 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 20px 24px; margin-bottom: 20px; min-width: 0; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 24px 0 12px; }
button { font: inherit; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; }
button.primary { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--on-accent); }
button.link { border: none; background: none; color: var(--accent); padding: 0; }
button.danger { background: #b91c1c; border-color: #b91c1c; color: #fff; }
button:disabled { opacity: .5; cursor: not-allowed; }
.error { color: var(--danger); background: var(--error-bg); border: 1px solid var(--error-line); padding: 8px 12px; border-radius: 6px; }
.notice { color: var(--ok); background: var(--notice-bg); border: 1px solid var(--notice-line); padding: 8px 12px; border-radius: 6px; }
.muted { color: var(--muted); }
.icon { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--line); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
progress { width: 100%; height: 10px; }
.row.between { justify-content: space-between; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.icon.placeholder { display: inline-block; }
.icon.big { width: 64px; height: 64px; border-radius: 12px; }

/* Store */
.store-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.store-tile { display: flex; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); min-width: 0; }
.store-tile:hover { border-color: var(--accent); text-decoration: none; }
.store-tile-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.store-tile-text > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Screenshots: a horizontal strip of small thumbnails; click opens the full image. */
.store-shots { display: flex; gap: 10px; overflow-x: auto; margin-top: 16px; padding-bottom: 6px; scroll-snap-type: x proximity; }
.store-shots a { flex: 0 0 auto; scroll-snap-align: start; }
.store-shots img { display: block; height: 180px; width: auto; max-width: 80vw; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: var(--shot-bg); }
@media (max-width: 600px) { .store-shots img { height: 140px; } }
.store-description { white-space: pre-line; max-width: 72ch; }
.store-steps li, .store-plan li { margin-bottom: 4px; }
.store-plan code { background: var(--code-bg); padding: 1px 6px; border-radius: 4px; word-break: break-all; }
/* App page: one tab per action (Установить / Обновить / Переустановить) with its plan and button. */
.store-tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); margin: 16px 0 0; }
.store-tabs [role=tab] { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 14px; margin-bottom: -1px; color: var(--muted); font-weight: 500; }
.store-tabs [role=tab][aria-selected=true] { color: var(--accent); border-bottom-color: var(--accent); }
.store-tabs [role=tab]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.store-tab-panel { padding-top: 4px; }
.store-tab-panel h3 { margin: 12px 0 8px; font-size: 15px; }
.action-reason { font-size: 14px; }
h3 { font-size: 15px; margin: 20px 0 8px; }
.store-log { background: var(--log-bg); border: 1px solid var(--log-line); color: #e2e8f0; border-radius: 8px; padding: 12px 14px; min-height: 160px; max-height: 480px; overflow: auto; font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-word; margin: 8px 0 0; }
.store-log .log-cmd { color: #93c5fd; }
.store-log .log-out { color: #e2e8f0; }
.store-log .log-err { color: #fca5a5; }
.store-log .log-ok { color: #86efac; }
.store-log .log-warn { color: #fcd34d; }
.store-log .log-fail { color: #f87171; font-weight: 600; }
.store-log .log-phase { color: #c4b5fd; font-weight: 600; }
.store-log .log-info { color: #94a3b8; }

/* Tags as bubbles */
.tags { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 8px 0 0; padding: 0; }
.tag { display: inline-block; padding: 2px 10px; border-radius: 6px; background: var(--tag-bg); color: var(--tag-text); font-size: 12.5px; line-height: 1.6; white-space: nowrap; }
.tags.small { margin-top: 4px; gap: 4px; flex-wrap: nowrap; overflow: hidden; }
.tags.small .tag { padding: 0 8px; border-radius: 5px; font-size: 11.5px; }
.tag.more { background: var(--line); color: var(--muted); }

/* Header button */
.topbar-button { padding: 6px 12px; border: 1px solid var(--line); border-radius: 6px; color: var(--text); font-weight: 500; white-space: nowrap; }
.topbar-button:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.topbar-button.active { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--on-accent); }
@media (max-width: 600px) {
  .topbar nav { display: none; }
  .topbar { justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 8px 16px; }
  .topbar-actions { flex-wrap: wrap; gap: 6px; }
  .topbar-button, .theme-toggle { padding: 5px 9px; font-size: 13px; }
  .content { padding: 0 12px; margin-top: 16px; }
  .card { padding: 16px; }
}

/* ADB console */
.console-output { min-height: 320px; max-height: 60vh; margin-top: 12px; }
.console-form { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.console-form input { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; background: var(--input-bg); color: var(--text); }
.console-form input:disabled { background: var(--bg); }
.console-prompt { color: var(--muted); font-size: 15px; }
.console-tools { margin-top: 10px; }
#console-presets .link { font-size: 13.5px; }

/* Theme switch in the header */
.theme-toggle { padding: 6px 12px; font-size: 14px; line-height: 1.45; white-space: nowrap; }
.topbar-button { font-size: 14px; line-height: 1.45; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* First-visit disclaimer */
label.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
.disclaimer { max-width: 560px; width: calc(100% - 32px); padding: 24px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.disclaimer::backdrop { background: rgba(10, 12, 16, .7); }
.disclaimer h2 { margin: 0 0 12px; font-size: 19px; }
.disclaimer p { margin: 0 0 10px; line-height: 1.5; }
.disclaimer-check { margin: 16px 0 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); cursor: pointer; }
.disclaimer-check input { width: 18px; height: 18px; margin: 2px 0 0; flex: 0 0 auto; }
.disclaimer-actions { margin-top: 16px; justify-content: flex-end; }

/* File manager */
.fm-panes { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(460px, 100%), 1fr)); gap: 16px; margin-top: 16px; }
.fm-pane { border: 1px solid var(--line); border-radius: 8px; min-width: 0; display: flex; flex-direction: column; }
.fm-pane.focused { border-color: var(--accent); }
.fm-head { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); min-width: 0; }
.fm-path { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-pathform { flex: 1; min-width: 0; margin: 0; }
.fm-pathform input { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--input-bg); color: var(--text); }
.fm-toolbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--line); align-items: center; }
.fm-toolbar button, .fm-toolbar .button { padding: 5px 10px; font-size: 13.5px; }
.fm-spacer { flex: 1; }
label.button { display: inline-block; padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--text); cursor: pointer; font-size: 13.5px; font-weight: 400; margin: 0; }
button.danger-outline { color: var(--danger); }
button:disabled, label.button.disabled { opacity: .5; cursor: not-allowed; }
.fm-note { margin: 8px 12px 0; font-size: 13px; }
.fm-list { height: 420px; overflow: auto; font-size: 14px; }
.fm-row { display: grid; grid-template-columns: 22px minmax(0, 1fr) 84px 128px; gap: 8px; align-items: center; padding: 4px 12px; cursor: default; user-select: none; }
.fm-row:hover { background: var(--bg); }
.fm-row.selected { background: var(--tag-bg); color: var(--tag-text); }
.fm-row .fm-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-row .fm-size, .fm-row .fm-date { color: var(--muted); font-size: 12.5px; text-align: right; white-space: nowrap; }
.fm-row.selected .fm-size, .fm-row.selected .fm-date { color: inherit; }
.fm-empty { padding: 16px 12px; color: var(--muted); }
.fm-status { margin-top: 12px; justify-content: space-between; }
.fm-user { display: flex; gap: 8px; align-items: center; margin: 0; font-weight: 400; }
.fm-user input { padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--input-bg); color: var(--text); }
.fm-log { min-height: 120px; max-height: 240px; }
@media (max-width: 600px) { .fm-row { grid-template-columns: 22px minmax(0, 1fr) 70px; } .fm-row .fm-date { display: none; } .fm-list { height: 300px; } }

/* FileManager page tabs (FileManager / Application Manager) with the connection on the right. */
.manager-head { border-bottom: 1px solid var(--line); align-items: flex-end; row-gap: 8px; }
.manager-tabs { border-bottom: none; margin: 0; }
.manager-tabs [role=tab] { font-size: 17px; font-weight: 600; padding: 8px 14px 10px; }
.manager-connection { padding-bottom: 8px; }

/* Application Manager */
.am-toolbar { margin-top: 16px; }
.am-filter { flex: 1 1 240px; min-width: 0; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--input-bg); color: var(--text); font: inherit; }
.am-options { margin-top: 10px; gap: 8px 20px; }
.am-options label.check { align-items: center; font-size: 14px; }
.am-users { margin: 8px 0 0; font-size: 13px; }
.am-users:empty { display: none; }
.am-list { margin-top: 12px; border: 1px solid var(--line); border-radius: 8px; height: 480px; overflow: auto; }
.am-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.am-row:last-child { border-bottom: none; }
.am-row:hover { background: var(--bg); }
.am-row.protected { color: var(--muted); }
.am-icon { width: 32px; height: 32px; border-radius: 7px; object-fit: cover; display: inline-flex; align-items: center; justify-content: center; font-size: 20px; }
.am-text { min-width: 0; }
.am-title { display: flex; gap: 8px; align-items: baseline; min-width: 0; overflow: hidden; white-space: nowrap; }
.am-title .am-label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.am-title a.am-label { color: var(--accent); }
.am-title .am-label + .am-package { color: var(--muted); }
.am-package { overflow: hidden; text-overflow: ellipsis; }
.am-meta { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.am-badge { display: inline-block; padding: 0 7px; border-radius: 5px; background: var(--code-bg); color: var(--muted); font-size: 11.5px; line-height: 1.7; white-space: nowrap; }
.am-badge.am-lock { background: light-dark(#fee2e2, #450a0a); color: light-dark(#991b1b, #fecaca); }
.am-badge.am-warn { background: light-dark(#fef3c7, #451a03); color: light-dark(#92400e, #fde68a); }
.am-badge.am-ok { background: light-dark(#dcfce7, #052e16); color: light-dark(#166534, #bbf7d0); }
.am-row button { padding: 5px 10px; font-size: 13.5px; }
.am-count { margin: 8px 0 0; font-size: 13px; }
@media (max-width: 600px) { .manager-tabs [role=tab] { font-size: 15px; padding: 6px 10px 8px; } .am-list { height: 380px; } }

/* Stars (average of car votes) */
.stars { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; white-space: nowrap; }
.stars.small { font-size: 12.5px; gap: 4px; }
.stars-track { position: relative; display: inline-block; color: var(--line); letter-spacing: 1px; line-height: 1; }
.stars-fill { position: absolute; inset: 0 auto 0 0; overflow: hidden; color: var(--star); white-space: nowrap; }
.stars-value { font-weight: 600; }
.stars-count, .stars.none { color: var(--muted); }
.app-rating { margin-top: 4px; }
.app-download { margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }

/* Search, sort, pins and link cards */
.catalog-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 16px; }
.catalog-tools input[type=search] { flex: 1 1 260px; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--input-bg); color: var(--text); font: inherit; }
.catalog-sort { display: flex; gap: 6px; align-items: center; color: var(--muted); margin: 0; font-weight: 400; }
.catalog-sort select { padding: 7px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--input-bg); color: var(--text); font: inherit; }
.catalog-reset { font-size: 14px; }
.catalog-count { margin: -8px 0 12px; }
.store-tile.pinned { border-color: var(--star); }
.pin-mark { font-size: 13px; }
.link-tile .link-host { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

/* Category under the icon */
.tile-media { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 0 0 auto; width: 72px; align-self: flex-start; }
.tile-category { max-width: 72px; padding: 1px 6px; border-radius: 999px; background: var(--code-bg); color: var(--muted); font-size: 11.5px; line-height: 1.5; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Footer and contacts dialog */
body.store { min-height: 100vh; display: flex; flex-direction: column; }
body.store .content { flex: 1 0 auto; width: 100%; }
.site-footer { max-width: 1400px; width: 100%; margin: 8px auto 24px; padding: 12px 16px 0; border-top: 1px solid var(--line); text-align: center; font-size: 14px; }
.footer-link { color: var(--muted); }
.footer-link:hover { color: var(--accent); }
.site-dialog { max-width: 440px; width: calc(100% - 32px); padding: 24px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.site-dialog::backdrop { background: rgba(10, 12, 16, .55); }
.site-dialog h2 { margin: 0 0 12px; font-size: 19px; }
.site-dialog p { margin: 0 0 10px; line-height: 1.5; }
.contacts-actions, .dialog-actions { margin-top: 16px; }
.button-link { display: inline-block; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-weight: 500; }
.button-link.primary { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--on-accent); }
.button-link:hover { text-decoration: none; filter: brightness(1.08); }
.footer-sep { margin: 0 10px; color: var(--muted); }
.support-button { border-color: var(--star); color: var(--text); letter-spacing: .03em; }
.support-button:hover { border-color: var(--star); color: var(--star); }

/* Telegram */
/* Same square, border and radius as the other top bar buttons, just icon-only. */
.topbar-button.topbar-icon { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; flex: 0 0 auto; }
.topbar-button.topbar-icon:hover { border-color: #229ED9; }
.topbar-icon:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tg-icon { display: block; }
.contacts-telegram a { display: inline-flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 600; }
@media (max-width: 600px) { .topbar-button.topbar-icon { width: 32px; height: 32px; } .theme-toggle { padding: 0 9px; font-size: 13px; height: 32px; } }

/* Command phases in the plan: a coloured upper-case badge per stage (light-dark() follows the theme). */
.phase-badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: .04em; line-height: 1.7; text-transform: uppercase; white-space: nowrap; vertical-align: 1px; background: var(--phase-bg); color: var(--phase-fg); }
.phase-pre { --phase-bg: light-dark(#ede9fe, #2e1065); --phase-fg: light-dark(#5b21b6, #ddd6fe); }
.phase-install { --phase-bg: light-dark(#dbeafe, #172554); --phase-fg: light-dark(#1e40af, #bfdbfe); }
.phase-post { --phase-bg: light-dark(#dcfce7, #052e16); --phase-fg: light-dark(#166534, #bbf7d0); }
.phase-uninstall { --phase-bg: light-dark(#fee2e2, #450a0a); --phase-fg: light-dark(#991b1b, #fecaca); }
.phase-check_installed { --phase-bg: light-dark(#fef3c7, #451a03); --phase-fg: light-dark(#92400e, #fde68a); }
.phase-update { --phase-bg: light-dark(#ccfbf1, #042f2e); --phase-fg: light-dark(#115e59, #99f6e4); }


/* ADB console: scenarios (admin «ADB-сценарии») picked from a list and run in order. */
.scenario-panel { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 0 0 12px; }
.scenario-controls { align-items: flex-end; }
.scenario-pick { display: grid; gap: 4px; font-weight: 600; flex: 1 1 280px; }
.scenario-pick select { font: inherit; font-weight: 400; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--input-bg); color: var(--text); }
.scenario-preview { margin-top: 10px; }
.scenario-preview p { margin: 4px 0; }
.scenario-steps { margin: 6px 0; padding-left: 26px; }
.scenario-steps li { margin: 3px 0; }
.scenario-steps code { background: var(--code-bg); padding: 1px 6px; border-radius: 4px; word-break: break-all; }
.scenario-badge { display: inline-block; padding: 0 7px; border-radius: 5px; font-size: 11px; font-weight: 700; letter-spacing: .04em; line-height: 1.7; }
.scenario-adb { background: light-dark(#fef3c7, #451a03); color: light-dark(#92400e, #fde68a); }
.scenario-store { background: light-dark(#dcfce7, #052e16); color: light-dark(#166534, #86efac); }
.scenario-message { background: light-dark(#e0e7ff, #1e1b4b); color: light-dark(#3730a3, #c7d2fe); }
.scenario-message-text { font-weight: 600; }
.scenario-warning { color: light-dark(#b45309, #fcd34d); }
.store-log .log-message { display: block; margin: 4px 0; padding: 6px 10px; border-left: 3px solid #a5b4fc; background: rgba(165, 180, 252, .14); color: #e0e7ff; font-weight: 600; }

/* ADB console, developers only (cookie developer=true): connect through the local adb server. */
.dev-adb { border: 1px dashed var(--line); border-radius: 8px; padding: 10px 14px; margin: 0 0 12px; display: grid; gap: 8px; }
.dev-adb-controls { gap: 8px; }
.dev-bridge { display: inline-flex; gap: 6px; align-items: center; }
.dev-bridge input, #dev-device { font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--input-bg); color: var(--text); }
.dev-bridge input { width: 11em; }
.dev-adb-hint { margin: 0; font-size: 13.5px; }
.manager-dev { margin-top: 12px; }
