/* Shared components (PB 3.0-3.12). Screens use these; they never restyle them. */

/* ---- 3.0 classic nav bar (tabs and sheets) ---- */
.nav { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; flex: none; min-height: var(--hit); padding: 0 var(--s2); }
.main > .nav { padding-top: env(safe-area-inset-top); min-height: calc(var(--hit) + env(safe-area-inset-top)); }
.nav h1 { margin: 0; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; font-weight: 600; }
.nav-btn { min-width: var(--hit); height: var(--hit); padding: 0 var(--s2); color: var(--blue); text-align: left; display: inline-flex; align-items: center; gap: 4px; }
.nav-btn.end { justify-self: end; justify-content: flex-end; text-align: right; }
.nav-btn.strong { font-weight: 600; }
.nav-btn.plus { font-size: 30px; font-weight: 300; line-height: 1; }
.nav-btn .chev { border-color: var(--blue); opacity: 1; transform: rotate(-135deg); margin-right: 2px; }
.nav-end { justify-self: end; display: flex; align-items: center; gap: var(--s2); padding-right: var(--s2); font-size: 15px; color: var(--label-2); font-variant-numeric: tabular-nums; }

/* ---- 3.1 Liquid Glass ---- */
.glass { background: var(--mat); -webkit-backdrop-filter: var(--glass); backdrop-filter: var(--glass);
  box-shadow: var(--mat-shadow),
              0 0 0 0.5px var(--mat-line),
              inset 0 0.5px 0.5px var(--mat-hi),
              inset 0 0 0 0.5px color-mix(in srgb, var(--mat-hi) 40%, transparent);
}
.glass-lite { background: var(--mat); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); box-shadow: 0 0 0 0.5px var(--mat-line); }

/* ---- 3.2 floating header cluster (full-screen pages) ---- */
.page { --t-top: calc(env(safe-area-inset-top) + 60px); position: fixed; inset: 0; z-index: 5; display: flex; flex-direction: column;
  max-width: var(--col); margin: 0 auto; background: var(--bg); }
.t-nav { position: absolute; top: 0; left: 0; right: 0; z-index: 2; padding: calc(env(safe-area-inset-top) + 8px) 8px 0;
  display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; justify-items: center; gap: var(--s2);
  pointer-events: none; }
.t-nav > * { pointer-events: auto; }
.t-nav::before { content: ""; position: absolute; left: 0; right: 0; top: 0; z-index: -1; height: calc(var(--t-top) + 14px); pointer-events: none;
  background: linear-gradient(to bottom, var(--bg) 0%, color-mix(in srgb, var(--bg) 92%, transparent) 60%, transparent 100%); }
.t-fab { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; color: var(--label); position: relative; }
.t-fab:active { transform: scale(0.94); }
.t-fab:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.t-more svg { width: 24px; height: 24px; fill: currentColor; }
.chev { flex: none; width: 8px; height: 8px; border-top: 2px solid var(--label-2); border-right: 2px solid var(--label-2); opacity: 0.6; transform: rotate(45deg); }
.t-fab .back-chev { width: 11px; height: 11px; margin: 0 0 0 5px; border-width: 2.5px; border-color: var(--label); opacity: 1; transform: rotate(-135deg); }
.t-mid { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; min-width: 0; }
.t-title { display: flex; align-items: center; justify-content: center; gap: 7px; flex: 0 1 auto; min-width: 0; height: 44px; padding: 0 var(--s4); border-radius: 22px; }
.t-title h1 { margin: 0; min-width: 0; font-size: 16px; line-height: 22px; font-weight: 600; }
.t-ended { flex: none; font-size: 12px; font-weight: 600; color: var(--label-2); }
.t-live { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: t-live-pulse 3.2s ease-in-out infinite; }
@keyframes t-live-pulse { 50% { opacity: 0.5; } }
.t-badge { position: absolute; top: 9px; right: 9px; width: 6px; height: 6px; border-radius: 3px; background: var(--label-2); opacity: 0.55; }
.t-scroll { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; padding: var(--t-top) var(--s4) calc(var(--dock-h, 64px) + var(--s2)); overscroll-behavior: contain; }

.t-menu { position: absolute; z-index: 4; top: calc(env(safe-area-inset-top) + 58px); right: var(--s2); min-width: 290px; max-width: calc(100% - 16px); overflow: hidden;
  border-radius: 14px; background: var(--card); box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25), 0 0 0 0.5px var(--sep); }
.t-menu-row { display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: var(--hit); padding: 0 var(--s4); text-align: left; font-size: 17px; position: relative; }
.t-menu-row + .t-menu-row::before { content: ""; position: absolute; top: 0; left: var(--s4); right: 0; border-top: 0.5px solid var(--sep); }
.t-menu-row.danger { color: var(--red); }
.t-menu-count { margin-left: auto; font-size: 15px; color: var(--label-2); font-variant-numeric: tabular-nums; }
.t-menu-shade { position: absolute; inset: 0; z-index: 3; }

/* ---- 3.3 rings capsule + popover ---- */
.t-rings { flex: none; display: flex; align-items: center; gap: 6px; height: 44px; padding: 0 12px; border-radius: 22px; color: var(--label-2); }
.t-rings:active { transform: scale(0.96); }
.ring { position: relative; display: block; width: 24px; height: 24px; }
.ring svg { display: block; width: 24px; height: 24px; }
.ring circle { fill: none; stroke-width: 3; }
.ring .rt { stroke: var(--fill); }
.ring .ra { stroke: var(--blue); stroke-linecap: round; transition: stroke-dasharray 0.4s ease; }
.ring.warn .ra { stroke: var(--orange); }
.ring.crit .ra { stroke: var(--red); }
.ring-k { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 700; color: var(--label-2); }
.t-pop { position: absolute; z-index: 4; top: calc(env(safe-area-inset-top) + 58px); right: 8px; width: 264px;
  display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border-radius: 20px;
  background: color-mix(in srgb, var(--card) 86%, transparent); }
.pop-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) 38px 50px; align-items: center; gap: 8px; font-size: 14px; line-height: 18px; }
.pop-k { color: var(--label-2); }
.pop-row b { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pop-row.warn b { color: var(--orange); }
.pop-row.crit b { color: var(--red); }
.pop-r { font-size: 12px; color: var(--label-2); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---- 3.4 bottom sheet + action sheet ---- */
.overlay { position: fixed; inset: 0; z-index: 20; display: flex; justify-content: center; align-items: flex-end; visibility: hidden; background: transparent;
  overscroll-behavior: contain; transition: background 0.25s, visibility 0s 0.3s; }
.overlay.open { visibility: visible; background: color-mix(in srgb, var(--backdrop) calc(var(--fade, 1) * 100%), transparent); transition: background 0.25s; }
.sheet { position: relative; display: flex; flex-direction: column; width: 100%; max-width: var(--col);
  max-height: calc(100dvh - env(safe-area-inset-top) - var(--s2)); padding-bottom: env(safe-area-inset-bottom);
  border-radius: 14px 14px 0 0; background: var(--bg);
  transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1); touch-action: pan-y; }
.overlay.open .sheet { transform: none; }
.sheet.dragging { user-select: none; -webkit-user-select: none; }
.sheet:not(.action)::before { content: ""; position: absolute; top: 4px; left: 50%; width: 36px; height: 4px; margin-left: -18px;
  border-radius: 3px; background: var(--sep); pointer-events: none; }
.sheet:not(.action) > .nav { padding-top: 6px; }
.sheet.tall { height: calc(100dvh - env(safe-area-inset-top) - var(--s2)); }
.sheet-body { display: flex; flex-direction: column; gap: var(--s3); min-height: 0; padding: 0 var(--s4) var(--s3); overflow-y: auto; overflow-x: hidden; }
.sheet.tall .sheet-body { flex: 1; }
.sheet.action { background: transparent; }
.sheet.action .sheet-body { padding-bottom: var(--s2); }
@media (prefers-reduced-motion: reduce) { .sheet, .overlay { transition: none !important; } }

/* ---- 3.5 grouped inset list ---- */
.group { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.group + .group { margin-top: var(--s3); }
.header { margin: 20px 0 6px; padding: 0 var(--s4); font-size: 13px; text-transform: uppercase; color: var(--label-2); }
.header:first-child { margin-top: 4px; }
.row { display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: var(--hit); padding: 0 var(--s4); text-align: left; cursor: pointer; }
.row + .row { position: relative; }
.row + .row::before { content: ""; position: absolute; top: 0; left: var(--s4); right: 0; border-top: 0.5px solid var(--sep); }
.row.two { min-height: 60px; }
.row:active:not(.note) { background: var(--fill); }
.grow { flex: 1; min-width: 0; }
.title { font-size: 17px; }
.sub { font-size: 13px; color: var(--label-2); }
.sub .bad { color: var(--red); }
.val { flex: 1; min-width: 0; border: 0; background: none; outline: none; text-align: right; color: var(--label-2); font-size: 17px; }
input.val { color: var(--label); }
input.val::placeholder { color: var(--label-2); opacity: 0.6; }
.picker { position: relative; }
.picker select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; font-size: 16px; }
.link-row, .strong-row { color: var(--blue); }
.strong-row { justify-content: center; font-weight: 600; }
.danger-row { justify-content: center; color: var(--red); }
.note { justify-content: center; color: var(--label-2); font-size: 13px; cursor: default; }
.badge { min-width: 28px; padding: 1px 6px; border-radius: 6px; background: var(--fill); font-size: 12px; font-weight: 600; text-align: center; color: var(--label-2); }
.badge.none { background: rgba(255, 59, 48, 0.14); color: var(--red); }
.dot { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--grey); }
.dot.active { background: var(--green); }
.dot.live { background: var(--green); animation: t-live-pulse 3.2s ease-in-out infinite; }
.dot.unread { background: var(--blue); }
.group.scroll-fill { flex: 1; min-height: 0; overflow-y: auto; }
.check { flex: none; width: 20px; height: 20px; fill: none; stroke: var(--blue); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* iOS switch */
.switch { position: relative; flex: none; width: 51px; height: 31px; margin-left: auto; border-radius: 16px; background: var(--fill); transition: background 0.2s; }
.switch i { position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25); transition: transform 0.2s; }
.switch.on { background: var(--green); }
.switch.on i { transform: translateX(20px); }
.switch::before { content: ""; position: absolute; inset: -7px -3px; }

/* ---- 3.6 segmented control ---- */
.seg { display: flex; padding: 2px; border-radius: 9px; background: var(--fill); }
.seg button { flex: 1; height: 32px; border-radius: 7px; font-size: 14px; font-weight: 500; transition: background 0.15s; position: relative; }
.seg button::before { content: ""; position: absolute; inset: -6px 0; }
.seg button.on { background: var(--thumb); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); font-weight: 600; }
.seg-row { min-height: 0; padding-top: var(--s2); padding-bottom: var(--s2); }
.seg-hint { font-size: 15px; color: var(--label-2); font-variant-numeric: tabular-nums; }

/* ---- 3.7 dock (floating composer area) ---- */
.t-dock { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; display: flex; flex-direction: column; align-items: stretch;
  padding: 0 var(--s2) calc(var(--s2) + env(safe-area-inset-bottom)); pointer-events: none; touch-action: none; overscroll-behavior: none; }
.t-dock > * { pointer-events: auto; }
.t-above { position: relative; }
.t-composer { display: flex; flex-direction: column; justify-content: center; min-height: 44px; padding: 6px; border-radius: 22px; }
.t-row { display: flex; align-items: center; gap: var(--s1); }
.t-send, .t-lock, .t-mic, .t-mx { position: relative; flex: none; display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; }
.t-send::before, .t-lock::before, .t-mic::before, .t-mx::before { content: ""; position: absolute; inset: -6px; }
.t-send { background: var(--blue); color: #fff; transition: background 0.15s, opacity 0.15s; }
.t-send:disabled { background: var(--fill); color: var(--label-2); opacity: 0.8; }
.t-send svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.t-mic, .t-mx { color: var(--label-2); }
.t-jump { position: absolute; left: 50%; bottom: 100%; margin: 0 0 10px -18px; width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; color: var(--label);
  opacity: 0; visibility: hidden; transform: translateY(6px); transition: opacity 0.2s, transform 0.2s, visibility 0s 0.2s; }
.t-jump.on { opacity: 1; visibility: visible; transform: none; transition: opacity 0.2s, transform 0.2s; }
.t-jump svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.t-jump-dot { position: absolute; top: 1px; right: 1px; width: 10px; height: 10px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 2px var(--card); }
.t-send-err { align-self: center; max-width: 100%; margin-bottom: var(--s1); padding: 3px 12px; border-radius: 12px; font-size: 0.75rem; font-weight: 600; color: var(--red); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-note { align-self: center; margin-bottom: var(--s1); padding: 6px 14px; border-radius: 16px; font-size: 0.8125rem; color: var(--label-2); }
.t-note.warn { color: var(--orange); }
/* Round action buttons (Test tab, live dock) */
.fab { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 64px; height: 64px; border-radius: 50%; color: #fff; }
.fab.sm { width: 44px; height: 44px; }
.fab.green { background: var(--green); }
.fab.red { background: var(--red); }
.fab.glass { color: var(--label); }
.fab:active { transform: scale(0.94); }
.fab svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.fab.sm svg { width: 22px; height: 22px; }

/* ---- 3.9 meters ---- */
.ubar { position: relative; display: block; height: 4px; border-radius: 2px; overflow: hidden; background: var(--fill); }
.ubar i { display: block; height: 100%; width: var(--w, 0%); border-radius: 2px; background: var(--blue); transition: width 0.4s ease, background 0.2s; }
.ubar[data-level="warn"] i { background: var(--orange); }
.ubar[data-level="crit"] i { background: var(--red); }
.urow { display: grid; grid-template-columns: 52px 1fr 40px 66px; align-items: center; column-gap: var(--s3); min-height: var(--hit); padding: 0 var(--s4); position: relative; }
.pct { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 15px; text-align: right; }
.pct.warn { color: var(--orange); }
.pct.crit { color: var(--red); }
.uleft { font-size: 13px; color: var(--label-2); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.caption-r { font-size: 13px; color: var(--label-2); font-variant-numeric: tabular-nums; padding-right: var(--s4); }
.caption-r.warn { color: var(--orange); }
.ctx { flex: none; display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--label-2); font-variant-numeric: tabular-nums; }
.ctx svg { width: 14px; height: 14px; }
.ctx circle { fill: none; stroke-width: 2.5; }
.ctx .track { stroke: var(--fill); }
.ctx .arc { stroke: var(--blue); stroke-linecap: round; }
.ctx.warn, .ctx.crit { font-weight: 600; }
.ctx.warn { color: var(--orange); }
.ctx.crit { color: var(--red); }
.ctx.warn .arc { stroke: var(--orange); }
.ctx.crit .arc { stroke: var(--red); }

/* ---- 3.10 toast ---- */
.toast { position: fixed; z-index: 30; left: 50%; bottom: calc(70px + env(safe-area-inset-bottom)); max-width: 90%; padding: var(--s2) var(--s4);
  border-radius: 18px; background: rgba(60, 60, 67, 0.92); color: #fff; font-size: 14px; opacity: 0; pointer-events: none; transform: translateX(-50%); transition: opacity 0.2s; }
.toast.show { opacity: 1; }

/* ---- 3.11 empty, loading, error ---- */
.empty { margin: 48px 0; text-align: center; color: var(--label-2); }
.t-state { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 96px var(--s4) 0; text-align: center; color: var(--label-2); }
.t-state svg { width: 44px; height: 44px; margin-bottom: var(--s2); fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.t-state-title { font-size: 17px; color: var(--label); }
.t-state-sub { font-size: 0.8125rem; }
.t-skel-card, .t-skel-line { border-radius: 8px; background: var(--fill); animation: t-pulse 1.4s ease-in-out infinite; }
.t-skel-card { height: 72px; border-radius: var(--radius); margin-bottom: var(--s4); }
.t-skel-line { height: 14px; margin-bottom: 10px; }
.t-spin { width: 24px; height: 24px; border-radius: 50%; border: 2.5px solid var(--sep); border-top-color: var(--label-2); animation: t-spin 0.8s linear infinite; }
.t-spin.small { width: 14px; height: 14px; border-width: 2px; }
.t-working { display: flex; align-items: center; padding: var(--s3) 0 var(--s2); font-size: 0.75rem; color: var(--label-2); }
.t-dots i { font-style: normal; opacity: 0; animation: t-dot 2.4s steps(1, end) infinite; }
.t-dots i:nth-child(2) { animation-name: t-dot2; }
.t-dots i:nth-child(3) { animation-name: t-dot3; }
@keyframes t-dot { 0%, 100% { opacity: 1; } }
@keyframes t-dot2 { 0% { opacity: 0; } 33%, 100% { opacity: 1; } }
@keyframes t-dot3 { 0% { opacity: 0; } 66%, 100% { opacity: 1; } }
@keyframes t-pulse { 50% { opacity: 0.35; } }
@keyframes t-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .t-dots i { animation: none; opacity: 1; } }
.btn { display: inline-flex; align-items: center; justify-content: center; min-width: 140px; min-height: var(--hit); padding: 0 var(--s4); border-radius: 22px; background: var(--blue); color: #fff; font-weight: 600; margin-top: var(--s3); }
.btn:active { opacity: 0.7; }
.btn.tinted { background: color-mix(in srgb, var(--blue) 14%, transparent); color: var(--blue); }

/* ---- 3.12 tab bar ---- */
.tabbar { display: flex; flex: none; padding-bottom: env(safe-area-inset-bottom); border-top: 0.5px solid var(--sep);
  background: var(--bar); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
.tabbar button { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 49px; font-size: 10px; color: var(--grey); }
.tabbar button.on { color: var(--blue); }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar .tdot { position: absolute; top: 5px; left: calc(50% + 10px); width: 6px; height: 6px; border-radius: 3px; background: var(--label-2); opacity: 0.55; }

/* ---- 3.14 reading content (turns) ---- */
.turn-caller { padding: 12px 14px; border-radius: var(--radius); background: var(--user-bg); font-size: 17px; font-weight: 500; line-height: 1.41; margin: var(--s3) 0; }
.turn-bot { font-size: 16px; line-height: 1.5; margin: var(--s3) 0; }
.turn-meta { font-size: 12px; color: var(--label-2); text-align: right; font-variant-numeric: tabular-nums; }
.turn-sep { display: flex; align-items: center; gap: var(--s3); margin: var(--s4) 0; font-size: 12px; color: var(--label-2); font-variant-numeric: tabular-nums; }
.turn-sep::before, .turn-sep::after { content: ""; flex: 1; border-top: 0.5px solid var(--sep); }
.code { margin: 0; padding: 10px 12px; border-radius: var(--radius); background: var(--code-bg); font: 12.5px/1.45 var(--mono); white-space: pre; overflow-x: auto; overscroll-behavior-x: contain; }

/* ---- login (templates/login.html) ---- */
.login { max-width: 360px; margin: 0 auto; padding: 22vh var(--s4) var(--s4); }
.login h1 { margin: 0 0 var(--s4); font-size: 22px; font-weight: 600; text-align: center; }
.login .row { cursor: text; }
.login .row > span { flex: none; width: 96px; }
.login .val { text-align: left; color: var(--label); }
.login .strong-row { appearance: none; -webkit-appearance: none; }
.field-err { margin: var(--s2) var(--s4) 0; font-size: 13px; color: var(--red); }

/* ---- icons ---- */
.ic { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---- dev gallery (/mock#/__components only) ---- */
.gal-box { position: relative; height: 150px; margin-bottom: var(--s3); overflow: hidden; border-radius: 14px; background: var(--bg); box-shadow: 0 0 0 0.5px var(--sep); }
.gal-ico { display: inline-flex; padding: var(--s2); color: var(--label); }
.gal-row { flex-wrap: wrap; gap: 0; }
