/* Open Backup Vault – modeled after the Drime UI: soft gray canvas, white surfaces, green accent.
   Layers: --page (canvas) < --surface (cards, menus, dialogs) > --inset (quiet fills inside a surface). */
:root {
  --primary: 86 225 108;
  --primary-dark: 60 178 82;
  --accent-text: #0e7537; /* the green as text: readable on --surface and --page */
  --fg: 0 38 29;
  --page: #eceeed;
  --surface: #ffffff;
  --inset: #f2f4f3;
  --field: #ffffff;
  --chip: #e3e7e5;
  --text: rgb(var(--fg) / .88);
  --muted: rgb(var(--fg) / .68);
  --faint: rgb(var(--fg) / .5);
  --divider: rgb(var(--fg) / .1);
  --border: rgb(var(--fg) / .2);
  --hover: rgb(var(--fg) / .05);
  --selected: rgb(var(--primary) / .22);
  --danger: #d2353a;
  --danger-bg: #fde4e4; --danger-fg: #b42323;
  --warn: #f5a524;
  --warn-bg: #fdf0d0; --warn-fg: #7a5000;
  --info: #2f7de1;
  --info-bg: #e1edfc; --info-fg: #1c5fb8;
  --ok-bg: rgb(var(--primary) / .2); --ok-fg: var(--accent-text); /* chips: a quiet fill and a readable text on it */
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgb(0 38 29 / .05);
  --shadow: 0 1px 2px rgb(0 38 29 / .05), 0 10px 30px rgb(0 38 29 / .08);
  --sidebar: 264px;
  color-scheme: light;
}
/* Dark: chips and notes get translucent fills at low alpha and desaturated text – no pastel blocks. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fg: 226 244 236; --accent-text: rgb(86 225 108);
    --page: #0b110f; --surface: #151d1a; --inset: #1d2723; --field: #0f1613; --chip: rgb(226 244 236 / .08);
    --danger: #ff7a7e; --danger-bg: rgb(229 72 77 / .14); --danger-fg: #ee9a9d;
    --warn-bg: rgb(245 165 36 / .13); --warn-fg: #d9b46a;
    --info-bg: rgb(47 125 225 / .16); --info-fg: #9dbdea;
    --ok-bg: rgb(86 225 108 / .13); --ok-fg: #8fd9a0;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / .3);
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 30px rgb(0 0 0 / .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fg: 226 244 236; --accent-text: rgb(86 225 108);
  --page: #0b110f; --surface: #151d1a; --inset: #1d2723; --field: #0f1613; --chip: rgb(226 244 236 / .08);
  --danger: #ff7a7e; --danger-bg: rgb(229 72 77 / .14); --danger-fg: #ee9a9d;
  --warn-bg: rgb(245 165 36 / .13); --warn-fg: #d9b46a;
  --info-bg: rgb(47 125 225 / .16); --info-fg: #9dbdea;
  --ok-bg: rgb(86 225 108 / .13); --ok-fg: #8fd9a0;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .3);
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 30px rgb(0 0 0 / .4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--page); color: var(--text);
  font: 14px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }

.app { display: flex; height: 100vh; height: 100dvh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar); flex: none; display: flex; flex-direction: column;
  border-right: 1px solid var(--divider); background: var(--page); padding: 16px 12px; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 17px; padding: 4px 10px 18px; color: rgb(var(--fg)); }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: rgb(var(--primary)); display: grid; place-items: center; }
.brand-mark svg { width: 20px; height: 20px; fill: #00261d; stroke: none; }
.brand-mark .brand-lock { fill: none; stroke: rgb(var(--primary)); stroke-width: 1.6; }
.nav a, .device-link {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 999px;
  color: var(--text); font-weight: 500; cursor: pointer;
}
.nav a:hover, .device-link:hover { background: var(--hover); }
.nav a.active, .device-link.active { background: var(--selected); color: rgb(var(--fg)); }
.nav a svg { color: var(--muted); }
.nav a.active svg { color: var(--accent-text); }
.badge { margin-left: auto; background: rgb(var(--primary)); color: #00261d; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 0 8px; height: 20px; line-height: 1; display: inline-flex; align-items: center; }
.nav-title { font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--muted); text-transform: uppercase; padding: 20px 12px 6px; }
.device-link { gap: 11px; padding: 7px 12px; }
.device-link .dev-ico { width: 32px; height: 32px; border-radius: 8px; background: var(--surface); box-shadow: var(--shadow-sm); display: grid; place-items: center; color: var(--muted); position: relative; }
.device-link .dev-ico svg { width: 18px; height: 18px; }
.device-link .dev-text { min-width: 0; display: flex; flex-direction: column; }
.device-link .dev-name { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device-link .dev-sub { font-size: 12px; color: var(--muted); white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--page); position: absolute; right: -2px; bottom: -2px; background: var(--faint); }
.dot.ok { background: rgb(var(--primary)); } .dot.late { background: var(--warn); } .dot.missing, .dot.error { background: var(--danger); }
.sidebar-foot { margin-top: auto; display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); padding: 16px 12px 4px; }
.sidebar-foot svg { width: 16px; height: 16px; }
.empty-nav { font-size: 13px; color: var(--muted); padding: 6px 12px; }

/* Main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; min-height: 68px; }
.icon-btn.menu-btn { display: none; }
.search { flex: 1; min-width: 0; max-width: 640px; display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 999px; padding: 0 16px; height: 44px; border: 1px solid var(--divider); }
.search:focus-within { border-color: var(--accent-text); box-shadow: 0 0 0 3px rgb(var(--primary) / .3); }
.search svg { color: var(--muted); }
.search input { flex: 1; border: 0; outline: 0; background: transparent; font: inherit; color: var(--text); min-width: 0; }
.search input:disabled { cursor: default; }
.version-picker { position: relative; margin-left: auto; }
.pill { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--divider); background: var(--surface); cursor: pointer; font-weight: 500; white-space: nowrap; }
.pill:hover { background: var(--inset); }
.pill .chev { width: 16px; height: 16px; color: var(--muted); }
.menu { position: absolute; right: 0; top: 46px; z-index: 30; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--divider); width: 300px; max-height: 60vh; overflow-y: auto; padding: 6px; }
.menu .menu-group { font-size: 12px; color: var(--faint); font-weight: 600; padding: 10px 10px 4px; }
.menu button { display: flex; width: 100%; justify-content: space-between; gap: 10px; border: 0; background: none; padding: 9px 10px; border-radius: 8px; cursor: pointer; text-align: left; }
.menu button:hover { background: var(--hover); }
.menu button.active { background: var(--selected); font-weight: 600; }
.menu button small { color: var(--muted); }

.content { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px 24px 40px; }
h1 { font-size: 22px; font-weight: 650; margin: 8px 0 4px; color: rgb(var(--fg)); letter-spacing: -.01em; }
.lead { color: var(--muted); margin: 0 0 24px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 550; white-space: nowrap; }
.btn:hover { background: var(--inset); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: rgb(var(--primary)); border-color: transparent; color: #00261d; }
.btn-primary:hover { background: rgb(var(--primary-dark)); }
.btn-danger { color: var(--danger); }
.btn-light { background: rgb(255 255 255 / .12); border-color: transparent; color: #fff; }
.btn-light:hover { background: rgb(255 255 255 / .2); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: none; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.light { color: #fff; } .icon-btn.light:hover { background: rgb(255 255 255 / .12); }

/* Toolbar + Breadcrumbs */
.toolbar { display: flex; align-items: center; gap: 8px; margin: 6px 0 14px; min-height: 40px; flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; gap: 2px; font-size: 18px; font-weight: 600; min-width: 0; flex-wrap: wrap; color: rgb(var(--fg)); }
.crumbs a, .crumbs span { padding: 4px 8px; border-radius: 8px; white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.crumbs a { color: var(--muted); font-weight: 500; }
.crumbs a:hover { background: var(--hover); color: var(--text); }
.crumbs .sep { color: var(--faint); padding: 0; }
.crumbs .sep svg { width: 16px; height: 16px; }
.toolbar .spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--divider); border-radius: 999px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; width: 40px; height: 36px; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.seg button.active { background: var(--selected); color: rgb(var(--fg)); }
.seg svg { width: 18px; height: 18px; }

/* File list */
.files { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--divider); border-radius: 16px; overflow: hidden; }
.files tbody tr:last-child td { border-bottom: 0; }
.files th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--divider); white-space: nowrap; }
.files td { padding: 0 12px; height: 52px; border-bottom: 1px solid var(--divider); white-space: nowrap; }
.files tr.row { cursor: pointer; }
.files tr.row:hover td { background: var(--hover); }
.files td.name { width: 100%; max-width: 0; }
.files .name-cell { display: flex; align-items: center; gap: 14px; min-width: 0; }
.files .name-cell span { overflow: hidden; text-overflow: ellipsis; font-weight: 500; color: rgb(var(--fg)); }
.files .name-cell small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.files .name-stack { display: flex; flex-direction: column; min-width: 0; }
.files td.meta { color: var(--muted); font-size: 13px; }
.files td.act { width: 1%; text-align: right; }
.files td.act .icon-btn { opacity: 0; width: 34px; height: 34px; }
.files tr.row:hover td.act .icon-btn, .files td.act .icon-btn:focus { opacity: 1; }

.ficon { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.ficon svg { width: 20px; height: 20px; }
.ficon.dir { background: rgb(var(--primary) / .18); color: rgb(var(--primary-dark)); }
.ficon.dir svg { fill: rgb(var(--primary) / .55); stroke: rgb(var(--primary-dark)); }
.ficon.image { color: #d6336c; }
.ficon.video { color: #7a55ea; }
.ficon.audio { color: #e8590c; }
.ficon.pdf { color: #e03131; }
.ficon.doc { color: #1c7ed6; }
.ficon.sheet { color: #2b8a3e; }
.ficon.code { color: var(--muted); background: var(--inset); }
.ficon.archive { color: #b7791f; }
.ficon.file, .ficon.link { background: var(--inset); color: var(--muted); }
.ficon.image, .ficon.video, .ficon.audio, .ficon.pdf, .ficon.doc, .ficon.sheet, .ficon.archive { background: color-mix(in srgb, currentColor 13%, transparent); }

/* Grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 14px; }
.grid .tile { border: 1px solid var(--divider); border-radius: var(--radius); overflow: hidden; cursor: pointer; background: var(--surface); display: flex; flex-direction: column; }
.grid .tile:hover { box-shadow: var(--shadow); }
.tile .thumb { aspect-ratio: 4 / 3; background: var(--inset); display: grid; place-items: center; overflow: hidden; }
.tile .thumb img { width: 100%; height: 100%; object-fit: cover; }
.tile .thumb .ficon { width: 56px; height: 56px; border-radius: 14px; }
.tile .thumb .ficon svg { width: 28px; height: 28px; }
.tile .cap { padding: 10px 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .cap small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card { border: 1px solid var(--divider); border-radius: 16px; padding: 18px; background: var(--surface); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 14px; cursor: pointer; transition: box-shadow .15s; }
.card:hover { box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 12px; }
.card-head .dev-ico { width: 44px; height: 44px; border-radius: 12px; background: var(--inset); display: grid; place-items: center; color: var(--muted); position: relative; }
.card-head .dev-ico .dot { width: 12px; height: 12px; border-color: var(--surface); }
.card-head b { font-size: 16px; color: rgb(var(--fg)); display: block; }
.card-head small { color: var(--muted); }
.card-stats { display: flex; gap: 20px; font-size: 13px; color: var(--muted); }
.card-stats b { display: block; white-space: nowrap; color: rgb(var(--fg)); font-size: 15px; font-weight: 600; }
/* chips: a fixed height and line-height 1 put the text on the optical middle; no vertical padding */
.status-chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; line-height: 1; font-size: 12px; font-weight: 600; padding: 0 10px; border-radius: 999px; background: var(--chip); color: var(--muted); align-self: center; white-space: nowrap; }
.status-chip svg { width: 14px; height: 14px; }
.chips .status-chip { align-self: flex-start; }
.status-chip.ok { background: var(--ok-bg); color: var(--ok-fg); }
.status-chip.late { background: var(--warn-bg); color: var(--warn-fg); }
.status-chip.missing, .status-chip.error { background: var(--danger-bg); color: var(--danger-fg); }
.status-chip.note { background: var(--chip); color: var(--text); font-weight: 550; }

.banner { display: flex; align-items: center; gap: 14px; border-radius: 16px; padding: 16px 18px; background: linear-gradient(rgb(var(--primary) / .16), rgb(var(--primary) / .16)) var(--surface); margin-bottom: 20px; flex-wrap: wrap; }
.banner b { color: rgb(var(--fg)); }
.banner .spacer { flex: 1; }
.code { font: 700 18px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; background: var(--inset); padding: 8px 12px; border-radius: 10px; color: rgb(var(--fg)); border: 1px solid var(--divider); }

.section-title { font-size: 15px; font-weight: 650; margin: 28px 0 12px; color: rgb(var(--fg)); }
.list { border: 1px solid var(--divider); border-radius: 16px; overflow: hidden; background: var(--surface); }
.list-row { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--divider); flex-wrap: wrap; }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 180px; }
.list-row small { color: var(--muted); display: block; }
.howto { background: var(--surface); border: 1px solid var(--divider); border-radius: 16px; padding: 18px 20px; }
.howto code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.cmd { display: flex; align-items: center; gap: 8px; background: var(--inset); border: 1px solid var(--divider); border-radius: 10px; padding: 6px 6px 6px 14px; margin: 10px 0 4px; }
.cmd code { flex: 1; overflow-x: auto; white-space: nowrap; }

/* States */
.empty { text-align: center; padding: 72px 20px; color: var(--muted); }
.empty .big { width: 64px; height: 64px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-sm); display: grid; place-items: center; margin: 0 auto 16px; }
.empty .big svg { width: 30px; height: 30px; }
.empty b { display: block; color: rgb(var(--fg)); font-size: 16px; margin-bottom: 4px; }
.loading { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 72px 20px; color: var(--muted); flex-direction: column; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--chip); border-top-color: rgb(var(--primary)); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 50; background: rgb(0 20 15 / .45); display: grid; place-items: center; padding: 16px; }
.modal-card { width: 100%; max-width: 520px; background: var(--surface); border-radius: 22px; box-shadow: var(--shadow); padding: 28px; max-height: 90vh; overflow-y: auto; }
.modal-card h2 { margin: 0 0 8px; font-size: 20px; letter-spacing: -.01em; color: rgb(var(--fg)); }
.modal-card p { color: var(--muted); margin: 0 0 18px; font-size: 14.5px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input, .field textarea { width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font: inherit; background: var(--field); color: var(--text); outline: 0; }
.field input::placeholder, .field textarea::placeholder { color: var(--faint); }
.field textarea { min-height: 96px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--accent-text); box-shadow: 0 0 0 3px rgb(var(--primary) / .3); }
.field small { color: var(--muted); display: block; margin-top: 4px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* Viewer */
.viewer { position: fixed; inset: 0; z-index: 60; background: #0b0f0e; display: flex; flex-direction: column; color: #fff; }
.viewer-bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; }
.viewer-title { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-body { flex: 1; min-height: 0; display: grid; place-items: center; padding: 0 16px 16px; }
.viewer-body img, .viewer-body video { max-width: 100%; max-height: 100%; border-radius: 8px; }
.viewer-body iframe { width: 100%; height: 100%; border: 0; border-radius: 8px; background: #fff; }
.viewer-body pre { width: 100%; height: 100%; margin: 0; overflow: auto; background: #111816; color: #d7e7df; border-radius: 8px; padding: 16px; font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.viewer-body audio { width: min(560px, 100%); }
.viewer-body .noprev { text-align: center; color: #b7c4bf; }
.viewer-body .noprev .ficon { margin: 0 auto 14px; width: 72px; height: 72px; border-radius: 18px; }
.viewer-body .noprev .ficon svg { width: 34px; height: 34px; }

/* Toasts */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; width: calc(100% - 32px); max-width: 480px; }
.toast { background: #1d2a25; border: 1px solid rgb(255 255 255 / .08); color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow); font-size: 14px; }
.toast.err { background: #c92a2a; }

/* Mobile */
.scrim { display: none; }
@media (max-width: 860px) {
  .sidebar { position: fixed; z-index: 40; inset: 0 auto 0 0; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgb(0 20 15 / .35); }
  .icon-btn.menu-btn { display: grid; }
  .topbar { padding: 10px 16px; gap: 8px; }
  .content { padding: 4px 16px 32px; }
  .files th.hide-m, .files td.hide-m { display: none; }
  .files td.act .icon-btn { opacity: 1; }
  .pill { padding: 0 11px; }
  #versionLabel, .pill .chev, .btn .lbl { display: none; }
  .btn:has(.lbl) { padding: 0 11px; }
  .toolbar { flex-wrap: nowrap; }
  .crumbs { flex-wrap: nowrap; overflow: hidden; }
  .crumbs a, .crumbs span { max-width: 140px; }
  .crumbs > :not(:nth-last-child(-n+3)) { display: none; }
  .list-row .btn { height: 34px; padding: 0 12px; }
  .crumbs { font-size: 16px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
.muted { color: var(--muted); }

/* lock state */
.lock-pill svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.lock-pill.unlocked { background: linear-gradient(rgb(var(--primary) / .2), rgb(var(--primary) / .2)) var(--surface); border-color: transparent; color: var(--accent-text); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; justify-content: inherit; }
.empty .actions { justify-content: center; }
.banner.warn { background: linear-gradient(var(--warn-bg), var(--warn-bg)) var(--surface); color: var(--text); }
.banner.warn .muted { color: var(--warn-fg); overflow-wrap: anywhere; }
.banner.warn svg { color: var(--warn-fg); }
.wizard-steps { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 4px; }
.wizard-steps .btn { justify-content: center; height: 46px; }

/* running backups */
.dot.running { background: var(--info); animation: pulse 1.6s ease-in-out infinite; }
.dot.new { background: var(--muted); }
.status-chip.running { background: var(--info-bg); color: var(--info-fg); }
.status-chip.new { background: var(--hover); color: var(--muted); }
@keyframes pulse { 50% { opacity: .35; } }
.bar { height: 6px; border-radius: 99px; background: var(--hover); overflow: hidden; margin: 10px 0 2px; }
.bar i { display: block; height: 100%; border-radius: 99px; background: var(--info); transition: width .6s ease; }
/* indeterminate: while the agent is still counting, a short segment travels – no percentage exists yet */
.bar.indet i { width: 30%; animation: slide 1.4s ease-in-out infinite; transition: none; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.run-progress { margin-top: 6px; font-size: 13px; }
.run-done { margin-top: 10px; font-size: 13px; }
.card-run { display: flex; flex-direction: column; gap: 2px; }
.card-run .bar { margin: 0 0 8px; }
.card-run-text b { display: block; color: rgb(var(--fg)); font-size: 13.5px; font-weight: 600; }
.card-run-text small { color: var(--muted); font-size: 12.5px; }
.run-panel { border: 1px solid var(--divider); border-radius: 16px; padding: 18px 20px; margin-bottom: 22px; background: var(--surface); }
.run-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.run-head .spacer { flex: 1; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--info); animation: pulse 1.6s ease-in-out infinite; }
.run-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 14px; color: var(--muted); font-size: 13px; }
.run-stats b { display: block; color: rgb(var(--fg)); font-size: 17px; font-weight: 600; }
.run-current { margin-top: 12px; font-size: 12.5px; color: var(--muted); }
.run-current div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: rtl; text-align: left; }
.parts { margin-top: 14px; border-top: 1px solid var(--divider); padding-top: 10px; max-height: 220px; overflow: auto; }
.part { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: 13.5px; }
.part .grow { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.part small { color: var(--muted); } .part .num { min-width: 70px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pdot { width: 8px; height: 8px; border-radius: 50%; background: var(--divider); flex: none; }
.part.done .pdot { background: rgb(var(--primary)); } .part.running .pdot { background: var(--info); animation: pulse 1.6s ease-in-out infinite; }
.part.pending { color: var(--muted); }

/* drives */
.src-row.clickable { cursor: pointer; } .src-row.clickable:hover { background: var(--hover); }
/* the bar takes its own line below name and chip, so the chip stays centred on the text */
.list-row .full { flex-basis: 100%; }
.src-row .bar { max-width: 360px; margin: 0 0 2px; }
.src-row .grow b { display: block; }
.ficon.disk { background: rgb(var(--primary) / .16); color: rgb(var(--primary-dark)); }
.chev-r svg { width: 18px; height: 18px; stroke: var(--muted); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.list.versions { max-height: 50vh; overflow: auto; }
.loading.small { padding: 20px 0; }
td.act { white-space: nowrap; }
td.act .icon-btn { display: inline-flex; }
@media (max-width: 720px) { .run-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* selects, checkboxes */
.field select { width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font: inherit; background: var(--field); color: var(--text); outline: 0; }
.field select { appearance: none; -webkit-appearance: none; padding-right: 38px; background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a8a85' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E"); }
.field select:focus { border-color: var(--accent-text); box-shadow: 0 0 0 3px rgb(var(--primary) / .3); }
.field input:disabled, .field select:disabled { opacity: .6; }
.list-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: rgb(var(--primary)); }
.list.choose { max-height: 52vh; overflow: auto; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
button.link { border: 0; background: none; padding: 0; font: inherit; color: var(--accent-text); font-weight: 550; cursor: pointer; }
button.link:hover { text-decoration: underline; }
.sidebar-foot .link { margin-left: auto; font-size: 12px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- pages without the app frame: setup assistant, sign-in ---------- */
body.bare .sidebar, body.bare .topbar, body.bare .scrim { display: none; }
body.bare .content { padding: 0 16px; }
.auth-page { min-height: 100%; display: flex; flex-direction: column; align-items: center; gap: 24px; padding: clamp(28px, 8vh, 84px) 0 32px; }
.auth-card { width: 100%; max-width: 460px; background: var(--surface); border: 1px solid var(--divider); border-radius: 24px; box-shadow: var(--shadow); padding: 40px 32px 32px; display: flex; flex-direction: column; gap: 20px; }
.auth-card.wide { max-width: 780px; }
.auth-head { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; margin-bottom: 6px; }
.auth-head h1 { margin: 8px 0 0; font-size: 26px; line-height: 1.2; font-weight: 680; letter-spacing: -.02em; color: rgb(var(--fg)); text-wrap: balance; }
.auth-head .lead { margin: 0; font-size: 15px; line-height: 1.5; text-wrap: balance; }
.hero { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; background: rgb(var(--primary) / .18); color: var(--accent-text); }
.hero svg { width: 30px; height: 30px; stroke-width: 1.6; }
.hero.mark, .hero.done { background: rgb(var(--primary)); color: #00261d; box-shadow: 0 8px 20px rgb(var(--primary) / .35); }
.hero.mark svg { width: 36px; height: 36px; fill: #00261d; stroke: none; }
.hero.mark .brand-lock { fill: none; stroke: rgb(var(--primary)); stroke-width: 1.6; }
.hero.done svg { stroke-width: 2.2; }
.auth-card .field { margin: 0; }
.auth-card .field input, .auth-card .field select { height: 48px; border-radius: 12px; padding: 0 14px; font-size: 15px; }
.auth-page.solo { padding-top: clamp(40px, 15vh, 160px); }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-actions { display: flex; flex-direction: column; align-items: stretch; gap: 14px; }
.auth-foot { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; }
.auth-foot svg { width: 14px; height: 14px; }
.auth-since { text-align: center; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--divider); padding-top: 16px; margin-top: 4px; }
.btn-lg { height: 50px; font-size: 15.5px; font-weight: 650; justify-content: center; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.link.quiet { color: var(--muted); font-size: 13.5px; font-weight: 500; align-self: center; padding: 4px 6px; border-radius: 6px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--border); }
.link.quiet:hover { color: var(--text); text-decoration-color: currentColor; }
.code-input { letter-spacing: .08em; text-transform: uppercase; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.note { display: flex; align-items: center; gap: 10px; background: var(--inset); border-radius: 12px; padding: 11px 14px; font-size: 13.5px; color: var(--muted); }
.note svg { width: 18px; height: 18px; color: var(--accent-text); }
.note b { color: var(--text); }
.note.warn { background: linear-gradient(var(--warn-bg), var(--warn-bg)) var(--surface); color: var(--warn-fg); flex-wrap: wrap; overflow-wrap: anywhere; }
.note.warn svg { color: inherit; }
.note.warn .link { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.note .spinner { width: 16px; height: 16px; border-width: 2px; }
.note.strip { margin-bottom: 12px; }
.content > .note { margin-bottom: 14px; }
.link.quiet .count { margin-left: 5px; font-size: 11.5px; color: var(--faint); }
.small { font-size: 12.5px; }
details.more { font-size: 13px; color: var(--muted); }
details.more summary { cursor: pointer; width: fit-content; border-radius: 6px; padding: 2px 4px; margin-left: -4px; }
details.more summary:hover { color: var(--text); }
details.raw { margin-top: 6px; }
details.raw pre { margin: 6px 0 0; padding: 8px 10px; font-size: 11.5px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; user-select: all;
  background: var(--divider); border-radius: 8px; color: var(--text); max-height: 160px; overflow: auto; }
details.more p { margin: 8px 0 0; max-width: 60ch; }

/* first paint and entrances. The card rises a short way and fades in; tall cards (the assistant)
   move less and slower than the compact sign-in card. Only a card that changed gets .enter. */
.boot { display: none; }
body.booting .boot { position: fixed; inset: 0; display: grid; place-items: center; }
body.booting .boot .hero { opacity: 0; animation: fade-in .4s ease-out .7s forwards; }
body.booting .sidebar, body.booting .main, body.booting .topbar, body.booting .scrim { display: none; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes card-in { from { opacity: 0; transform: translateY(var(--travel)); } to { opacity: 1; transform: none; } }
.auth-card { --travel: 10px; --enter: 520ms; }
.auth-card.wide { --travel: 8px; --enter: 560ms; }
.auth-card.compact { --travel: 16px; --enter: 420ms; }
.auth-card.enter { animation: card-in var(--enter) cubic-bezier(.22, .61, .36, 1) both; }
.enter-fade { animation: fade-in 400ms ease-out both; }
@media (prefers-reduced-motion: reduce) {
  .auth-card.enter, .enter-fade, body.booting .boot .hero { animation: none; }
  .pulse, .dot.running, .part.running .pdot { animation: none; }
  .tiles .tile, .sidebar { transition: none; }
}

/* numbered steps above the card */
.stepper { list-style: none; display: flex; margin: 0; padding: 0; width: 100%; max-width: 460px; }
.stepper li { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); position: relative; text-align: center; }
.stepper li::before { content: ""; position: absolute; top: 13px; right: calc(50% + 20px); width: calc(100% - 40px); height: 2px; border-radius: 2px; background: var(--border); }
.stepper li:first-child::before { display: none; }
.stepper li.done::before, .stepper li.current::before { background: rgb(var(--primary-dark)); }
.step-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 650; font-size: 13px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); color: var(--muted); }
.step-dot svg { width: 15px; height: 15px; stroke-width: 2.2; }
.stepper li.current { color: rgb(var(--fg)); font-weight: 600; }
.stepper li.current .step-dot { background: rgb(var(--fg)); color: var(--page); box-shadow: none; }
.stepper li.done .step-dot { background: rgb(var(--primary)); color: #00261d; box-shadow: none; }

/* a row that offers one thing to set up (second way in, a device waiting for approval) */
.options { display: flex; flex-direction: column; gap: 10px; }
.option { display: flex; align-items: center; gap: 12px; border: 1px solid var(--divider); border-radius: 16px; padding: 14px; }
.option > .btn { height: 36px; padding: 0 14px; font-size: 13.5px; }
.option b { display: block; color: rgb(var(--fg)); font-size: 14.5px; overflow-wrap: break-word; hyphens: auto; }
.option small { display: block; color: var(--muted); font-size: 13px; }
.option .grow { flex: 1; min-width: 0; }
.option-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--inset); color: var(--muted); }
.option.done { background: rgb(var(--primary) / .1); border-color: rgb(var(--primary-dark) / .35); }
.option.done .option-ico { background: rgb(var(--primary)); color: #00261d; }
.option.done .option-ico svg { stroke-width: 2.2; }
.waiting { display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--muted); padding: 6px; }
.waiting .spinner { width: 18px; height: 18px; border-width: 2.5px; }
.auth-card .cmd { margin: 0; padding: 14px 16px 10px; border-radius: 14px; flex-direction: column; align-items: stretch; gap: 10px; }
.auth-card .cmd .btn { align-self: flex-end; height: 34px; padding: 0 14px; font-size: 13.5px; }
.auth-card .cmd code { flex: none; white-space: normal; overflow-wrap: anywhere; font-size: 13px; line-height: 1.5; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* codes to read and compare */
.code-box { display: flex; justify-content: center; background: var(--inset); border-radius: 16px; padding: 20px 16px; margin-bottom: 20px; }
.code-box .code { font-size: 28px; background: none; border: 0; padding: 0; }
.recovery-box { display: flex; flex-direction: column; align-items: center; gap: 14px; background: var(--inset); border-radius: 16px; padding: 22px 16px 16px; }
code.recovery { display: grid; grid-template-columns: repeat(4, auto); gap: 6px 0; font: 600 17px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .04em; color: rgb(var(--fg)); }

/* storage destinations */
.badge-mark { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex: none; font-weight: 700; font-size: 13px; letter-spacing: -.02em;
  color: var(--mark); background: color-mix(in srgb, var(--mark) 14%, transparent); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.tiles .tile { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; text-align: left; padding: 16px; border: 1px solid var(--divider); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-sm); cursor: pointer; transition: border-color .12s, box-shadow .12s, transform .12s; }
.tiles .tile:hover { border-color: rgb(var(--primary-dark)); box-shadow: var(--shadow); transform: translateY(-1px); }
.tiles .tile b { color: rgb(var(--fg)); font-size: 14.5px; }
.tiles .tile small { color: var(--muted); line-height: 1.35; }
.auth-card .tiles .tile { box-shadow: none; }
.dest-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.dest-card { border: 1px solid var(--divider); border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 14px; background: var(--surface); box-shadow: var(--shadow-sm); }
.dest-head { display: flex; align-items: center; gap: 12px; }
.dest-head .grow { flex: 1; min-width: 0; }
.dest-head b { display: block; color: rgb(var(--fg)); font-size: 15px; }
.dest-head small { color: var(--muted); }
.dest-facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; font-size: 13px; }
.dest-facts dt { color: var(--muted); }
.dest-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; display: flex; align-items: center; gap: 8px; }
.dest-facts .dot { width: 8px; height: 8px; border-radius: 50%; background: rgb(var(--primary)); }
.dest-facts .dot.running { background: var(--info); }
.dest-actions { display: flex; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--divider); padding-top: 14px; }
.dest-form-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.dest-form-head h2 { margin: 0; font-size: 19px; color: rgb(var(--fg)); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 14px; }
.form-grid .field { grid-column: 1 / -1; margin: 0; }
.form-grid .field.half { grid-column: auto; }
.dest-form > p { margin: 14px 0 0; }
.modal-card.wide { max-width: 640px; }
.modal.top { z-index: 60; }
@media (max-width: 560px) {
  .form-grid .field.half { grid-column: 1 / -1; }
  .auth-page { gap: 18px; padding-top: 24px; }
  .auth-card { padding: 28px 20px 24px; border-radius: 20px; }
  .auth-head h1 { font-size: 23px; }
  .stepper li:not(.current) span:last-child { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .option { flex-wrap: wrap; }
  .option > .btn { flex: 1 1 100%; justify-content: center; }
  .modal-card { padding: 22px 20px; }
  code.recovery { font-size: 15px; grid-template-columns: repeat(2, auto); }
}

/* setup checklist */
.checklist { border: 1px solid var(--divider); border-radius: 16px; padding: 16px 18px; margin: 0 0 22px; display: flex; flex-direction: column; gap: 4px; background: var(--surface); box-shadow: var(--shadow-sm); }
.checklist > b { margin-bottom: 6px; }
.check-row { display: flex; align-items: center; gap: 12px; padding: 8px 6px; border-radius: 10px; color: var(--text); text-decoration: none; }
a.check-row[href]:hover { background: var(--hover, rgb(var(--primary) / .06)); }
.check-row.done { color: var(--muted); }
.check-row.next { font-weight: 600; }
.check-row small { display: block; font-weight: 400; color: var(--muted); }
.check-dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--divider); display: grid; place-items: center; flex: none; }
.check-row.done .check-dot { background: rgb(var(--primary)); border-color: rgb(var(--primary)); color: #00261d; }
.check-row.next .check-dot { border-color: rgb(var(--primary)); }
.check-dot svg { width: 14px; height: 14px; }
