/* Desktop title bar (Tauri only, docs/DESKTOP.md). `html.tauri-frame` is set by
   ui/titlebar.rs; the web build never gets the class, so nothing here applies there. */
html.tauri-frame { --tb-h: 32px; }
html.tauri-frame body { padding-top: var(--tb-h); }

/* full-screen layers start below the bar so it stays usable (drag, close) */
html.tauri-frame .auth-bg,
html.tauri-frame .splash,
html.tauri-frame .modal-overlay,
html.tauri-frame .lightbox,
html.tauri-frame .settings-screen,
html.tauri-frame .mobile-scrim { top: var(--tb-h); }
html.tauri-frame .modal { max-height: calc(100vh - var(--tb-h) - 32px); }

.titlebar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--tb-h, 32px); z-index: 1000;
  display: flex; align-items: stretch; background: var(--bg-rail); color: var(--text-2);
  user-select: none; -webkit-user-select: none; -webkit-app-region: drag;
}
.titlebar .tb-brand { display: flex; align-items: center; gap: 8px; padding: 0 12px; font: 700 13px/1 var(--font-head); letter-spacing: -.01em; color: var(--text); }
.titlebar.mac .tb-brand { padding-left: 76px; }
.titlebar .tb-logo { display: flex; width: 16px; height: 16px; }
.titlebar .tb-logo .logo, .titlebar .tb-logo svg { width: 16px; height: 16px; display: block; pointer-events: none; }
.titlebar .tb-drag { flex: 1; }
.titlebar .tb-controls { display: flex; -webkit-app-region: no-drag; }
.titlebar .tb-btn { width: 46px; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--text-2); transition: background var(--t-fast, 120ms) var(--ease, ease), color var(--t-fast, 120ms) var(--ease, ease); }
.titlebar .tb-btn:hover { background: var(--bg-elevated); color: var(--text); }
.titlebar .tb-btn:active { background: var(--bg-overlay); }
.titlebar .tb-btn.tb-close:hover { background: var(--red); color: #fff; }
.titlebar .tb-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
@media (prefers-reduced-motion: reduce) { .titlebar .tb-btn { transition: none; } }

/* OS blocked the microphone (native engine) */
.native-banner { position: fixed; top: var(--tb-h, 32px); left: 50%; transform: translateX(-50%); z-index: 990; margin-top: 8px;
  display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 14px; max-width: calc(100vw - 32px);
  background: var(--bg-overlay); border: 1px solid var(--red); border-radius: var(--r-md); box-shadow: var(--shadow); color: var(--text); font-size: 13px; }
.native-banner .nb-text { flex: 1; }
.native-banner .btn { white-space: nowrap; }

/* native screen picker */
.modal.native-picker { width: 720px; }
.native-picker .segmented { display: flex; margin-bottom: 14px; }
.native-picker .seg { flex: 1; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 10px; max-height: min(46vh, 380px); overflow-y: auto; margin-bottom: 18px; padding: 2px; }
.picker-empty { grid-column: 1 / -1; padding: 32px 12px; text-align: center; color: var(--text-muted); }
.picker-item { display: flex; flex-direction: column; gap: 4px; padding: 8px; border-radius: var(--r-md); background: var(--bg-elevated); border: 2px solid transparent; text-align: left; min-width: 0;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease); }
.picker-item:hover { background: var(--bg-overlay); border-color: var(--border); }
.picker-item.active { border-color: var(--accent); background: var(--accent-soft); }
.picker-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.picker-thumb { aspect-ratio: 16 / 9; border-radius: var(--r-sm); background: var(--bg-rail); display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--text-muted); }
.picker-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.picker-label { font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-sub { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 16px; }
@media (prefers-reduced-motion: reduce) { .picker-item { transition: none; } }

/* ---- tray popup (#/tray, Tauri window "tray") ---- */
html.tray-mode, html.tray-mode body { background: transparent; overflow: hidden; user-select: none; }
.tray-root { padding: 10px; }
.tray-card {
  background: var(--bg-overlay); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .32), 0 0 0 1px rgba(0, 0, 0, .12);
  padding: 6px; animation: tray-in var(--t-fast) var(--ease);
}
@keyframes tray-in { from { opacity: 0; transform: translateY(6px) scale(.985); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .tray-card { animation: none; } }
.tray-head { display: flex; align-items: center; gap: 10px; padding: 8px 8px 10px; }
.tray-head .avatar { flex: none; }
.tray-who { min-width: 0; flex: 1; }
.tray-name { font: 700 14px var(--font-head); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tray-sub { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tray-logo { flex: none; opacity: .9; display: inline-flex; }
.tray-voice {
  display: flex; align-items: center; gap: 10px; margin: 0 2px 6px; padding: 8px 8px 8px 10px;
  border-radius: 8px; background: color-mix(in srgb, var(--lime) 9%, transparent);
}
.tray-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--lime); flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--lime) 22%, transparent); }
.tray-dot.connecting { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); animation: tray-pulse 1s ease-in-out infinite alternate; }
@keyframes tray-pulse { to { opacity: .45; } }
.tray-voice-text { min-width: 0; flex: 1; }
.tray-voice-title { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--lime-text); }
.tray-voice-where { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tray-ptt { font: 700 10px var(--font-mono); padding: 1px 5px; border-radius: 4px; color: var(--text-muted); border: 1px solid var(--border); transition: all var(--t-fast); }
.tray-ptt.on { color: #10130D; background: var(--lime); border-color: var(--lime); }
.tray-leave {
  width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex: none;
  color: var(--red); background: color-mix(in srgb, var(--red) 14%, transparent); transition: background var(--t-fast);
}
.tray-leave:hover { background: var(--red); color: #fff; }
.tray-group { display: flex; flex-direction: column; }
.tray-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 6px;
  text-align: left; color: var(--text-2); transition: background var(--t-fast), color var(--t-fast);
}
.tray-item:hover, .tray-item:focus-visible { background: var(--hover); color: var(--text); outline: none; }
.tray-item:hover { background: color-mix(in srgb, var(--text) 7%, transparent); }
.tray-ic { width: 18px; height: 18px; display: inline-flex; flex: none; }
.tray-label { flex: 1; font-weight: 600; }
.tray-toggle.off .tray-ic { color: var(--red); }
.tray-switch {
  width: 30px; height: 18px; border-radius: 9px; background: var(--lime); position: relative; flex: none;
  transition: background var(--t-fast);
}
.tray-switch i { position: absolute; top: 2px; left: 14px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: left var(--t-fast) var(--ease); }
.tray-toggle.off .tray-switch { background: color-mix(in srgb, var(--text-muted) 45%, transparent); }
.tray-toggle.off .tray-switch i { left: 2px; }
.tray-item.danger { color: var(--red); }
.tray-item.danger:hover { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.tray-sep { height: 1px; background: var(--border); margin: 4px 8px; }
.tray-head + .tray-group, .tray-voice + .tray-group { border-top: 1px solid var(--border); padding-top: 4px; }
.tray-group + .tray-group { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }
html.tray-mode .tray-card { --status-hole: var(--bg-overlay); }

/* ---- auto-update (desktop) ---- */
.update-banner {
  position: fixed; right: 20px; bottom: 20px; z-index: 210; display: flex; align-items: center; gap: 10px;
  background: var(--bg-overlay); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: var(--r-md); box-shadow: var(--shadow); padding: 8px 8px 8px 12px; font-weight: 600;
  animation: rise var(--t-med) var(--ease); max-width: calc(100vw - 40px);
}
.update-ic { color: var(--accent); display: inline-flex; }
.update-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.update-x { width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; color: var(--text-muted); }
.update-x:hover { background: var(--hover); color: var(--text); }
.update-check { padding: 4px 10px 0; font-size: 12px; display: flex; flex-direction: column; gap: 2px; }
.update-link { color: var(--accent); font-weight: 700; text-align: left; font-size: 12px; }
.update-link:hover:not(:disabled) { text-decoration: underline; }
