/* The app's own layout: the shell, the top bar, the list of machines, the detail page, the floating button, the settings sheet.
   The look is liquid glass: panes float over the backdrop, nothing is a flat block. */

/* The shell is as tall as the VISIBLE area (--app-h) and starts where it starts (--app-top). js/viewport.js writes both from innerHeight and
   visualViewport, not from Telegram's --tg-viewport-height: on iOS the keyboard shrinks the window or overlays it, and this follows either. */
#app { position: fixed; left: 0; right: 0; top: var(--app-top, 0px); height: var(--app-h, 100%); display: flex; flex-direction: column; }
#view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }
/* A screen arriving. animation-fill-mode is "backwards" on purpose: a finished animation of transform kept by "forwards"/"both" would stay the containing
   block of position: fixed children (the floating button, verified in Chrome and WebKit). The root screen holds the fixed button, so it only fades. */
.screen.push { animation: push var(--d3) var(--ease) backwards; }
.screen.fade { animation: fade var(--d2) var(--ease) backwards; }
@keyframes push { from { opacity: 0; transform: translateX(28px); } }
@keyframes fade { from { opacity: 0; } }

.bar { flex: none; display: flex; align-items: center; gap: var(--s2); min-height: calc(var(--bar-h) + var(--sat));
  background: var(--glass); border-bottom: 1px solid var(--line); -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%); backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  padding: var(--sat) calc(var(--sar) + var(--s3)) 0 calc(var(--sal) + var(--s4)); }
.bar.has-back { padding-left: calc(var(--sal) + var(--s2)); }
.bar h1 { flex: 1; min-width: 0; font-size: var(--t-large); font-weight: 800; letter-spacing: -.02em; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip { display: inline-flex; align-items: center; gap: var(--s2); max-width: 55%; min-height: 44px; padding: 0 var(--s3) 0 var(--s1); border-radius: var(--r-pill); }
.user-chip span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--t-sm); font-weight: 600; }
.avatar { width: 32px; height: 32px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: var(--t-sm); font-weight: 700; }
@media (hover: hover) { .user-chip:hover { background: var(--glass-strong); } }

.scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.page { width: 100%; max-width: var(--column); margin: 0 auto; display: grid; gap: var(--s4); align-content: start;
  padding: var(--s4) calc(var(--sar) + var(--s4)) calc(var(--fab) + var(--s7) + var(--sab)) calc(var(--sal) + var(--s4)); }

/* ---- home: the list and its states (loading, error, empty, loaded) */
.list-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 32px; }
.list-head h2 { font-size: var(--t-sm); font-weight: 600; color: var(--muted); }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.row { display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 72px; padding: var(--s3) var(--s4); text-align: left;
  border-radius: var(--r-l); transition: transform var(--d1) var(--ease), background var(--d1); }
.row:active { transform: scale(.985); }
.row-main { flex: 1; min-width: 0; display: grid; gap: 4px; }
.row-title { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.row-name { font-weight: 650; font-size: var(--t-body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { font-size: var(--t-meta); color: var(--muted); }
.row > svg { color: var(--muted); }
@media (hover: hover) { .row:hover { background: var(--glass-strong); } }

.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--muted); box-shadow: 0 0 0 4px rgba(120, 130, 150, .16); }
.dot.online { background: #1FA55B; box-shadow: 0 0 0 4px rgba(31, 165, 91, .18); animation: breathe 2.4s var(--ease) infinite; }
.dot.pending { background: #C98A12; box-shadow: 0 0 0 4px rgba(201, 138, 18, .18); }
.dot.revoked { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
@keyframes breathe { 50% { box-shadow: 0 0 0 7px rgba(31, 165, 91, .08); } }

.pill { font-size: var(--t-cap); font-weight: 700; letter-spacing: .01em; padding: 2px 9px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--muted); flex: none; }
.pill.online { background: rgba(31, 165, 91, .14); color: #157A43; }
.pill.pending { background: rgba(201, 138, 18, .16); color: #8A5D05; }
.pill.revoked { background: var(--danger-soft); color: var(--danger); }
:root[data-theme="dark"] .pill.online { color: #6EE7A5; }
:root[data-theme="dark"] .pill.pending { color: #F2C46B; }

.skel-row { height: 72px; }
.empty, .notice { display: grid; justify-items: center; gap: var(--s3); text-align: center; padding: var(--s8) var(--s5); border-radius: var(--r-xl); }
.empty .mark { --size: 88px; border-radius: 30px; }
.empty h2, .notice h2 { font-size: var(--t-title); line-height: 1.25; }
.empty p, .notice p { color: var(--muted); max-width: 340px; overflow-wrap: anywhere; }
.build { text-align: center; font-size: var(--t-cap); color: var(--muted); }
.build code { font-family: var(--mono); }
.fab { position: fixed; z-index: 5; bottom: calc(var(--kb, 0px) + var(--sab) + var(--s4)); right: max(calc(var(--sar) + var(--s4)), calc((100vw - var(--column)) / 2 + var(--s4)));
  min-height: var(--fab); padding: 0 var(--s6) 0 var(--s5); border-radius: var(--r-pill); box-shadow: var(--shadow); }

html[data-kb] .fab, html[data-kb] .build { display: none; }      /* data-kb is set while a keyboard is up (viewport.js): with it there is room only for the field and its buttons */

/* ---- detail */
.card { padding: var(--s5); border-radius: var(--r-xl); display: grid; gap: var(--s3); }
.card h2 { font-size: var(--t-sm); font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.status-line { display: flex; align-items: center; gap: var(--s3); font-weight: 650; font-size: var(--t-body); padding: var(--s1) var(--s1); }
.command { display: block; font: 500 var(--t-meta)/1.5 var(--mono); padding: var(--s4); border-radius: var(--r-m); background: var(--surface-2);
  border: 1px solid var(--line); overflow-wrap: anywhere; user-select: all; -webkit-user-select: all; }
.waiting { display: flex; align-items: center; gap: var(--s2); color: var(--muted); font-size: var(--t-sm); }
.meta { font-size: var(--t-sm); color: var(--muted); }
.kv { display: grid; gap: var(--s2); margin: 0; font-size: var(--t-sm); }
.kv > div { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s4); }
.kv dt { color: var(--muted); flex: none; }
.kv dd { margin: 0; min-width: 0; text-align: right; overflow-wrap: anywhere; }
.log { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); font-size: var(--t-sm); }
.log li { display: flex; justify-content: space-between; gap: var(--s3); padding-bottom: var(--s2); border-bottom: 1px solid var(--line); }
.log li:last-child { border-bottom: 0; padding-bottom: 0; }
.log code { font-family: var(--mono); font-size: var(--t-meta); }
.actions { display: grid; gap: var(--s2); }

/* ---- settings sheet */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 3px; border-radius: var(--r-m); background: var(--surface-2); }
.seg button { min-height: 44px; border-radius: 11px; font-size: var(--t-sm); font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .18); }
.section-label { font-size: var(--t-meta); font-weight: 600; color: var(--muted); }
