/* The app's own layout: the shell, the top bar, the list, the empty state, the detail and editor pages, the floating button, the settings sheet. */

/* 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; background: var(--bg); }
#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(--bg); border-bottom: 1px solid var(--line);
  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-title); font-weight: 700; line-height: 1.2; 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(--surface-2); } }

.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: 40px; }
.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(--s2); }
.row { display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 64px; padding: var(--s3) var(--s4); text-align: left; border-radius: var(--r-l);
  background: var(--surface); border: 1px solid var(--line); transition: transform var(--d1) var(--ease), background var(--d1); }
.row:active { transform: scale(.99); }
.row-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.row-text { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; font-weight: 500; }
.row-meta { font-size: var(--t-meta); color: var(--muted); }
.row > svg { color: var(--muted); }
@media (hover: hover) { .row:hover { background: var(--surface-2); } }
.skel-row { height: 64px; }
.empty, .notice { display: grid; justify-items: center; gap: var(--s3); text-align: center; padding: var(--s8) var(--s4); }
.empty .mark { --size: 88px; border-radius: 28px; }
.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 and editor */
.note { padding: var(--s5); border-radius: var(--r-l); background: var(--surface); border: 1px solid var(--line); font-size: 18px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.meta { font-size: var(--t-sm); color: var(--muted); }

/* ---- settings sheet */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 2px; border-radius: var(--r-m); background: var(--surface-2); }
.seg button { min-height: 40px; border-radius: 10px; font-size: var(--t-sm); font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .18); }
.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; }
.section-label { font-size: var(--t-meta); font-weight: 600; color: var(--muted); }
