:root {
  /* Tell the browser the app is dark-themed so native widgets (form
   * controls, scrollbars, text-selection highlights, browser chrome)
   * render dark by default. Without this, Chrome/Android Safari paint
   * these in light mode even on a dark app, which can flash light when
   * inputs focus or the keyboard appears. */
  color-scheme: dark;

  /* Background */
  --color-bg: #060d10;
  --color-bg-chat: #0a1014;
  --color-bg-elevated: #141e26;

  /* Text */
  --color-text-primary: var(--text-1);

  /* Accent */
  --color-accent: #00e5a0;
  --color-accent-dark: var(--accent-strong);
  --color-accent-hover: #33f0ba;
  --color-accent-sky: var(--info);

  /* Semantic */
  --color-danger: var(--danger);
  --color-danger-dark: #d4293e;
  --color-warning: #fbbf24;
  --color-warning-dark: #d97706;

  /* Neutrals */
  --color-white: #FFFFFF;
  --color-black: #000000;

  /* UI */
  --color-nav-inactive: #C6C6C6;
  --color-border: #DEDEDE;
  --color-row-alt: #EFEFEF;
  --color-badge: #ff0000;
  --color-dev: #818cf8;
  --color-night: #818cf8;

  /* Message time backgrounds */
  --color-msg-time-right: #092a25;
  --color-msg-time-left: #11191f;

  /* Toast */
  --color-toast-error: #ffd8df;
  --color-toast-warn: #ffeed1;
  --color-toast-info: #d9fff0;

  /* ===== Vello UI design tokens =====
   * Every new or restyled rule draws from this scale; nothing below should
   * invent its own radius / text alpha / surface tint. */

  /* Type */
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --fs-2xs: 11px;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-body: 15px;
  --fs-input: 16px;   /* >= 16px: iOS zooms into smaller inputs on focus */
  --fs-md: 17px;
  --fs-lg: 20px;
  --fs-xl: 24px;
  --fs-title: 28px;
  --fs-hero: 40px;

  /* Surfaces (translucent: the aurora glows through) */
  --surface-1: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.065);
  --surface-3: rgba(255, 255, 255, 0.10);
  --surface-solid: #0d161b;
  --surface-sheet: rgba(15, 23, 29, 0.94);
  --surface-bar: rgba(6, 13, 16, 0.78);
  --hairline: rgba(255, 255, 255, 0.07);
  --hairline-strong: rgba(255, 255, 255, 0.12);
  --scrim: rgba(3, 8, 10, 0.62);
  --blur-bar: saturate(170%) blur(22px);
  --blur-sheet: saturate(150%) blur(28px);

  /* Text */
  --text-1: #f2f6f8;
  --text-2: rgba(226, 236, 240, 0.68);
  --text-3: rgba(226, 236, 240, 0.46);
  --text-4: rgba(226, 236, 240, 0.30);

  /* Accent + semantic */
  --accent: #00e5a0;
  --accent-strong: #00c98c;
  --accent-ink: #03140e;
  --accent-soft: rgba(0, 229, 160, 0.12);
  --accent-line: rgba(0, 229, 160, 0.30);
  --danger: #ff5a73;
  --danger-soft: rgba(255, 90, 115, 0.12);
  --danger-line: rgba(255, 90, 115, 0.32);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.12);
  --info: #38bdf8;
  --info-soft: rgba(56, 189, 248, 0.12);

  /* Radii — rounded squares, never circles (50% is for dots only) */
  /* ONE corner radius for everything (buttons, inputs, cards, sheets, images, chips, bubbles).
     The --r-* names are kept as aliases so every existing reference resolves to it.
     50% stays for true circles only (dots, spinners, toggle knobs). */
  --radius: 12px;
  --r-chip: var(--radius);
  --r-sm: var(--radius);
  --r-md: var(--radius);
  --r-control: var(--radius);
  --r-card: var(--radius);
  --r-sheet: var(--radius);
  --r-pill: var(--radius);

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;

  /* Elevation */
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow-2: 0 10px 30px rgba(0, 0, 0, 0.38);
  --shadow-3: 0 28px 70px rgba(0, 0, 0, 0.55);
  --inset-hi: inset 0 1px 0 rgba(255, 255, 255, 0.04);

  --grad-primary: linear-gradient(180deg, #1df2b4 0%, var(--accent) 45%, var(--accent-strong) 100%);

  /* Motion */
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-spring: cubic-bezier(0.32, 1.32, 0.6, 1);
  --dur-1: 120ms;
  --dur-2: 200ms;
  --dur-3: 320ms;

  /* Solid chrome colour: top bar, tab bar, composer and both safe-area fills
     must all be this exact opaque colour (iOS extends it into the status bar). */
  --bar-solid: #060d10;

  /* Control sizes */
  --h-control: 44px;
  --h-control-sm: 36px;
  --h-iconbtn: 32px;
  --h-appbar: 56px;
  --h-tabbar: 56px;  /* = --h-appbar: top and bottom bars match */
}

* {
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  font-family: var(--font-ui);
  touch-action: pan-y;
}
*:focus {
  outline: none;
}
*::-webkit-scrollbar {
  display: none;
}

html, body {
  margin: 0px;
  padding: 0px;
  border: 0px;
  box-sizing: border-box;

  position: relative;
  vertical-align:top;
  font-family: var(--font-ui);
  overflow:hidden;
  background-color: var(--color-bg);

  -webkit-overscroll-behavior: none;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-overflow-scrolling: touch;

  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
    -webkit-user-select: none;
     -khtml-user-select: none;
       -moz-user-select: none;
        -ms-user-select: none;
            user-select: none;
}

html {
  height: 100%;
  width: 100%;
}

/* <body> starts at the top safe-area inset and must end at the bottom one, so
 * its height subtracts BOTH. With an opaque status bar the top inset is 0 and
 * the two formulas agree, but iOS sometimes launches the standalone app
 * full-bleed (page under a see-through status bar, inset-top ~59-62px) despite
 * the `black` status-bar style. Subtracting only the bottom inset then put the
 * body's bottom edge one top-inset below the safe-area line, which is where the
 * 70px bottom nav / chat composer live: under the home-indicator strip that
 * body::after paints, and off the screen. viewport.js's keyboard layout sizes
 * html to the visual viewport and subtracts only the top inset (the keyboard,
 * not the home indicator, is its bottom edge) -- keep the two in step. */
body {
  position:absolute;
  top:env(safe-area-inset-top, 0);
  left:0px;

  width:100%;
  height:100%;
  height:calc(100% - env(safe-area-inset-top, 0) - env(safe-area-inset-bottom, 0));
}

/* ===== Safe-area fill ================================================
 * <body> is offset by env(safe-area-inset-top/bottom) so the page
 * gradient doesn't spill into the notch / home-indicator zones on
 * iPhone. The zones themselves then fall through to <html>'s solid
 * background. On iOS Safari PWA that can still visually leak (WebKit
 * paints body's gradient slightly outside its box around transitions /
 * translucent status bar).
 *
 * Paint opaque strips directly over both safe-area zones so nothing
 * leaks regardless of platform. On devices with no safe-area insets
 * (most Androids, desktop PWA) env() resolves to 0 and the strips
 * collapse to zero height — inert.
 *
 * Base colour is --color-bg (#060d10) which matches the near-opaque
 * rgba(6,13,16,0.97) used by the top bar / bottom nav on every page,
 * and the rgba(6,13,16,0.9) composer bar on the chat page. */
body::before,
body::after {
  content: '';
  position: fixed;
  left: 0;
  right: 0;
  background: var(--color-bg);
  pointer-events: none;
  /* Above the top bar (z:10) / bottom nav (z:9) so even if a
     background ever bleeds into the strip, this still covers it.
     Below the loading bar (z:999999) and modals so overlays remain
     on top. */
  z-index: 100;
}
body::before {
  top: 0;
  height: env(safe-area-inset-top, 0);
}
body::after {
  bottom: 0;
  height: env(safe-area-inset-bottom, 0);
}

/* ===== App canvas: one aurora for every signed-in page ===== */
body {
  color: var(--text-1);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
  background:
    radial-gradient(120% 70% at 85% -10%, rgba(0, 229, 160, 0.10) 0%, transparent 55%),
    radial-gradient(90% 60% at -10% 30%, rgba(14, 165, 233, 0.10) 0%, transparent 60%),
    radial-gradient(100% 70% at 60% 115%, rgba(99, 102, 241, 0.12) 0%, transparent 60%),
    var(--color-bg);
}

a {
  text-decoration:none;
  color:inherit;
}
pre {
  margin:0px;
  padding:0px;
  white-space: pre-wrap;
  white-space: -moz-pre-wrap;
  white-space: -pre-wrap;
  white-space: -o-pre-wrap;
  word-wrap: break-word;
}

img {
    -webkit-transition: opacity 342ms ease;
    transition: opacity 342ms ease;
}
img[data-src] {
    opacity: 0;
    pointer-events: none;

    min-width: 1px;
    min-height: 1px;
}
img.img_loaded {
    opacity: 1;
    pointer-events: auto !important;
}

.pending_invites_cont {
    margin-bottom:20px !important;
}

/* ===== App bar icon buttons =====
   .hb_button (single action) and .hb_button_multi (inside .hbbm_cont) share
   one look: a quiet glass rounded square that lights mint on hover/press. */
.hb_button,
.hb_button_multi,
.cti_right,
.chat_back_button {
    box-sizing: border-box;
    color: var(--text-1);
    font-size: 16px;
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    background: var(--surface-2);
    border: 1px solid var(--hairline);
    box-shadow: var(--inset-hi);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin: 0px;
    padding: 0px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out), transform var(--dur-1) var(--ease-out);
}
.hb_button i,
.hb_button_multi i,
.cti_right i { font-size: 16px; }
.chat_back_button i { font-size: 20px; }
@media (hover: hover) {
  .hb_button:hover,
  .hb_button_multi:hover,
  .cti_right:hover,
  .chat_back_button:hover {
    background: var(--accent-soft);
    border-color: var(--accent-line);
    color: var(--accent);
  }
}
.hb_button:active,
.hb_button_multi:active,
.cti_right:active,
.chat_back_button:active {
  transform: scale(0.94);
  background: var(--surface-3);
}
.hbbm_cont {
  display:flex;
  gap: var(--sp-2);
}

#mop_wrap {
  position:absolute;
  top:0px;
  left:0px;
  width:100%;
  height:100%;

  display:none;
  z-index:999;
}
#message_options_popup {
  position:absolute;
  top:50%;
  left:50%;
  transform:translate(-50%, -50%);
  padding:20px;
  width:60%;
  height:auto;
  background-color:var(--color-bg-elevated);
  color:var(--color-text-primary);
  border-radius:var(--radius);
  display:none;

  z-index:9999;

  align-items: center;
  justify-content: center;
  text-align: center;
  flex-direction: column;
}
.mop_title {
  font-size:20px;
  text-align:center;
  font-weight:bold;
}

#attachments_wrap {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 1090;
    background: transparent;
}
#attachments_popup {
    position: fixed;
    display: none;
    z-index: 1091;
}

#mop_message {
  border:0px;
  background-color:var(--color-bg-elevated);
  color:var(--color-bg);
  width:100%;
  margin:0px;
  padding:0px;
  opacity:0;
  height:20px;
}
.mop_button {
  border-radius:var(--radius);
  border:0px;
  background-color:var(--color-white);
  color:var(--color-bg);
  width:100px;
  margin:0px;
  padding:10px 10px;
  font-weight:bold;
  font-size:14px;
}
.mop_buttons_cont {
  display:flex;
  justify-content: center;
  text-align: center;
  align-items: center;
}
#delete_message {
  margin-left:30px;
}
#chats_list_cont,
#getContacts_API {
  contain: layout style;
}
.cm_finder {
  contain: layout style paint;
}

.chat_cont {
  display:flex;
  align-items: center;
  position:relative;
  margin-bottom:20px;
  padding-top:20px;
  border-top:1px solid var(--color-border);
  content-visibility: auto;
  contain-intrinsic-size: auto 80px;
}
.chat_cont_first {
  border-top:0px;
  padding-top:0px;
}

.chat_cont_picture {
  width:60px;
  height:60px;
}
.chat_cont_picture img {
  object-fit:cover;
  object-position: center;
  border-radius: var(--radius);
  width:100%;
  height:100%;
}

.contact_pic {
  width:150px;
  height:150px;
  margin-left:auto;
  margin-right:auto;
  margin-bottom:20px;
}
.contact_pic img {
  width:100%;
  height:100%;
  border-radius: var(--radius);
  object-fit:cover;
  object-position: center;
}
.contact_name {
  text-align:center;
  font-size:24px;
  font-weight:bold;
  width:100%;
  height:auto;
}

.fr_list_cont {
  margin-top:20px;
  margin-bottom:20px;
}

.pending_fr_banner {
  background-color:var(--color-bg-elevated);
  color:var(--color-text-primary);
  display:flex;
  justify-content: space-between;
  align-items: center;
  height:auto;
  border-radius:var(--radius);
  font-weight:bold;
  padding:10px 20px;
  margin-bottom:20px;
}

.contact_options {
  display:flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  margin-top:30px;
  margin-bottom:20px;
  width:100%;
  gap:40px;
}
.contact_option_indv {
  text-align: center;
  background-color:var(--color-bg-elevated);
  color:var(--color-text-primary);
  padding:10px 20px;
  border-radius:var(--radius);
  border:0px;

  height:100px;
  width:100px;

  display:flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  justify-content: center;
}
.option_icon {
  font-size:30px;
  text-align: center;
}
.single_co {
  margin-right:0px !important;
}
.option_title {
  font-size:12px;
  text-align: center;
  font-weight:bold;
  margin-top:10px;
}

.chat_name_sub {
  font-size:12px;
  width:100%;
  font-weight:normal;
  margin: 0px;
  padding: 0px;

  word-wrap: break-word;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;

  overflow: hidden;
  text-overflow: ellipsis;
}
.chat_cont_name {
  margin-left:20px;
  width: calc(100% - 154px);
}
.chat_name_title {
  font-size:16px;
  font-weight:bold;
  width:100%;
}
.chat_unread_messages {
  border-radius:50%;
  background-color:var(--color-bg-elevated);
  width:25px;
  height:25px;
  display:flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color:var(--color-white);
  font-weight:bold;
  margin-top:5px;
  float:right;
}
.chat_right_info {
  position:absolute;
  right:0px;
  top:50%;
  transform: translateY(-50%);
  font-size:12px;
  text-align:right;
}
.chat_right_dt {
  color:var(--color-black);
}

.bottom_message {
  position:relative;
  bottom:0px;
  left:0px;
  min-height:30px;
  height:auto;
  padding:20px;
  width:calc(100% - 40px);
  background-color:var(--color-bg-elevated);
  display: flex;
  align-items: center;

  overflow-y:visible;
  overflow-x:visible;
  overscroll-behavior: none;

  touch-action: pan-y;
  z-index:8;
}

.message_process {
  position:absolute;
  top:0px;
  left:0px;
  width:100%;
  height:100%;
  display:flex;
  text-align: center;
  justify-content: center;
  align-items: center;
  z-index:1000000000;
  font-weight:bold;
  font-size:20px;
  color:var(--color-white);
  background-color:var(--color-bg-elevated);
  display:none;
}

/* Sub-page app bar: back chevron + compact title */
.header_top--sub { justify-content: flex-start; }
.header_top--sub .header_text {
  font-size: var(--fs-md);
  font-weight: 650;
  letter-spacing: -0.01em;
}
.header_top--sub .header_button,
.header_top--sub .hb_button { margin-left: auto; }
a.chat_back_button { text-decoration: none; }

/* ===== Tab bar =====
   Glass bar of icons (no labels; each tab's name is its aria-label), each
   centred in an equal share of the bar. Markup: inc/config/bottom_nav.php. */
.bottom_nav {
  height: var(--h-tabbar);
  justify-content: center;
  background: var(--surface-bar);
  -webkit-backdrop-filter: var(--blur-bar);
  backdrop-filter: var(--blur-bar);
  border-top: 1px solid var(--hairline);
  color: var(--text-3);
  padding: 0px;
  margin: 0px;
  width: 100% !important;
  z-index: 9;
}
.bnm_inner {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-around;
  text-align: center;
  background: transparent;
}
.bnm_item {
  flex: 1 1 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-3);
}
.bnm_item a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  line-height: 1;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.bnm_icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 30px;
  border-radius: var(--radius);
  font-size: 19px;
  transition: background-color var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out), transform var(--dur-1) var(--ease-out);
}
.bnm_item a:active .bnm_icon { transform: scale(0.92); }
.bnm_selected { color: var(--accent); }
.bnm_selected .bnm_icon { background: var(--accent-soft); }
@media (hover: hover) {
  .bnm_item:not(.bnm_selected) a:hover { color: var(--text-1); }
}

.bottom_message #user_message {
  display: block;
  max-height:100px;
  overflow-x: hidden;
  overflow-y: hidden;
  width:calc(100% - 110px);
  resize:none;
  min-height: 20px;
  line-height: 20px;
  background-color:var(--color-white);
  color:var(--color-black);
  margin:0px;
  padding:5px;
  font-size:14px;
  height:20px;
  border:0px;
  border-radius:var(--radius);
  margin-left:50px;

  /* NO overscroll-behavior — textarea has overflow:hidden so wheel events
     should bubble to the parent chat scroll container. Setting
     overscroll-behavior:none here captured wheels over the input strip
     and dropped them on the floor. */
  touch-action: manipulation;
  -webkit-overflow-scrolling: touch;
}

.bottom_message button {
  position:absolute;
  bottom:20px;
  margin:0px;
  padding:0px;
  border:0px;
  height:30px;
  width:30px;
  background-color:var(--color-white);
  border-radius: var(--radius);
  color:var(--color-bg);
  font-size:16px;
  display:flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.bottom_message #attach_message {
  left:20px;
}
.bottom_message #send_message {
  right:20px;
  font-size:24px;
}

.indv_message {
  border-radius:var(--radius);
  margin-bottom:20px;
  padding:10px;
  padding-right:46px;
  width:auto;
  max-width:80%;
  position:relative;

  display:flex;
  flex-direction: column;

  clear:both;
  text-align:left;
  color:var(--color-white);
  overflow:hidden;
  font-size:14px;
}
.indv_message pre a {
  text-decoration: underline;
}

.indv_message_name {
  font-weight:bold;
  margin-bottom:5px;
}

.indv_message_hidden_st {
  display:none;
}

.date_line {
  height:auto;
  width:50%;
  text-align:center;
  padding:10px;
  font-size:14px;
  font-weight:bold;
  clear:both;
  margin-bottom:20px;
  background-color:var(--color-bg-elevated);
  color:var(--color-text-primary);
  border-radius:var(--radius);
  margin-left:auto;
  margin-right:auto;
}
.system_line {
  width:80%;
}

.indv_message_info_cont {
  width:26px;
  height: calc(100% - 20px);
  position:absolute;
  top:10px;
  right:10px;
  text-align:right;
}

.indv_message_info {
  position:absolute;
  font-size:10px;
  text-align:right;
  bottom:0px;
  right:0px;
  z-index:2;
  min-height:20px;
  width:100%;

  display:flex;
  align-items: flex-end;
  justify-content: flex-end;
}

.indv_message_moreinfo {
  position:absolute;
  font-size:14px;
  font-weight:900;
  letter-spacing: 1.5px;
  line-height: 10px;
  text-align:right;
  top:0px;
  right:0px;
  z-index:1;
  width:100%;

  display:flex;
  align-items: flex-start;
  justify-content: flex-end;
}

.message_right {
  float:right;
  background-color:var(--color-bg-elevated);
}
.message_left {
  float:left;
  background-color:var(--surface-2);
}

.chat_top_info {
  position:relative;
  top:0px;
  left:0px;
  height:24px;
  width:calc(100% - 40px);
  padding:20px;
  background: var(--surface-bar);
  -webkit-backdrop-filter: var(--blur-bar);
  backdrop-filter: var(--blur-bar);
  border-bottom: 1px solid var(--hairline);
  color: var(--text-1);

  font-weight: 700;
  font-size: var(--fs-xl);
  letter-spacing: -0.02em;
  z-index:10;

  display: flex;
  align-items: center;

  /* NO overflow / overscroll-behavior here — if we set overflow:hidden,
     browsers (Chromium especially) treat the header as a scroll container
     and capture wheel events over the top 60px strip. Combined with
     overscroll-behavior:none, wheel events die there instead of
     propagating to .chats_cont. Content fits by design (fixed 24px height
     + 20px padding), so overflow isn't needed. */

  touch-action: pan-y;
}

.cti_cont {
  justify-content: space-between;
}
.cti_left {
  display:flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  gap: 12px;
}
.cti_right a {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.header_top {
  justify-content: space-between;
  gap: var(--sp-3);
  color: var(--text-1);
}

.header_text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.header_button {
  flex-shrink: 0;
}

.chat_other_name {
  color: var(--color-white);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.25;
  max-width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

/* Live presence: muted by default (last seen / offline). The poll's onlineStatus()
   toggles is-online / is-away; "Online" lights up mint plus a tiny mint
   rounded-square — a pixel of aurora light, not a round dot. Typing never
   renders here: the in-flow typing bubble is the sole typing indicator. */
#chat_online_status {
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-text-primary);
  opacity: 0.5;
}
/* Empty (no presence yet / hidden) => zero height so the name sits centered next
   to the avatar; it only stacks above the status once the poll fills a value. */
#chat_online_status:empty {
  display: none;
}
#chat_online_status.is-online {
  color: var(--color-accent);
  opacity: 1;
}
#chat_online_status.is-online::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: var(--radius);
  margin-right: 6px;
  vertical-align: middle;
  background: var(--color-accent);
}
.chat_back_button a {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* Header identity: avatar + name/presence stack, links to /info (the WhatsApp-style
   header tap). flex:1;min-width:0 down the chain lets the name ellipsis-truncate. */
.cti_identity {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: inherit;
}
.cti_avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.cti_avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: var(--radius);
}
.cti_nameblock {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Tap-down feedback on the header identity before a hard cross-document nav. */
.cti_identity {
  transition: transform var(--dur-1) var(--ease-out);
}
a.cti_identity:active {
  transform: scale(0.97);
}
@media (prefers-reduced-motion: reduce) {
  .chat_back_button:active,
  .cti_right:active,
  .hb_button:active,
  .hb_button_multi:active,
  a.cti_identity:active { transform: none; }
}

.chats_cont {
  position:relative;
  background: transparent;
  color: var(--text-1);

  padding:20px;
  width:calc(100% - 40px);

  overflow-y: scroll;
  overflow-x: hidden;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
  transform: translateZ(0);

  padding-top: 40px;
  padding-bottom: 40px;
  height: calc(100% - 214px);
  font-size: 18px;
}

.chat_page {
  padding-bottom:20px;
  height: calc(100% - 194px);
}

.settings_page {
  padding:20px;
  padding-top:40px;
  padding-bottom:40px;
  height:calc(100% - 214px);
  font-size:18px;
}

.contacts_page {
  padding-bottom:20px;
  height: calc(100% - 194px);
}

.settings_item {
  margin-bottom:20px;
}
.settings_item form {
  display:flex;
}
.settings_item input {
  font-size:17px;
  margin:0px;
  padding:15px;
  width:calc(100% - 122px);
  margin-right:10px;
  border-radius:var(--radius);
  border:1px solid var(--hairline-strong);
}
.settings_item button {
  font-size:17px;
  font-weight:bold;
  padding:15px;
  text-align:center;
  height:auto;
  margin:0px;
  border:0px;
  border-radius:var(--radius);
  background-color:var(--color-bg-elevated);
  border:1px solid var(--hairline-strong);
  color:var(--color-text-primary);
  width:100px;
}

.uds_table {
    font-size:12px;
    border-radius:var(--radius);
    border:1px solid var(--hairline-strong);
}
.uds_table_row {
    text-align:left;
    padding:10px;
    border-bottom:1px solid var(--hairline);
    display:flex;
    justify-content: space-between;
    align-items:center;
}
.uds_table_row:last-child {
    border-bottom:0px;
}
.udstr_right {
    font-size:24px;
    margin-left:20px;
}
.udstr_right button {
    color: var(--color-text-primary);
    font-size:18px;
    width:32px;
    height:32px;
    border-radius: var(--radius);
    background-color: var(--color-bg-elevated);

    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;

    margin: 0px;
    padding: 0px;
    border: 0px;
}

.settings_item_title {
  font-weight:bold;
  margin-bottom:10px;
  font-size:20px;
  line-height:0.9;
}
.ap_inner {
  display:flex;
  align-items: center;
}
.ap_inner button {
  margin-left:10px;
}
.ap_inner img {
  border-radius: var(--radius);
  object-fit:cover;
  height:53px;
  width:53px;
}
.ap_choose_file {
  margin-bottom:0px;
}
.ap_choose_file .settings_item_title {
  margin-bottom:20px;
}
.ap_choose_file form {
  display:block;
}
.ap_choose_file input {
  display:block;
  border:0px;
  margin:0px;
  padding:0px;
  border-radius:0px;
}
.ap_choose_file button {
  display:block;
  margin-top:20px;
  width:100%;
}

.change_number form {
  display:block;
}
.change_number input {
  margin-top:5px;
  margin-right:0px;
  width:calc(100% - 12px);
  margin-bottom:20px;
}
.change_number button {
  width:100%;
}
.cn_subtext {
  font-size: var(--fs-sm);
  line-height: 1.5;
  color: var(--text-3);
  margin-bottom: 20px;
}

#new_messages_button {
    position:absolute;
    top:-60px;
    right:20px;
    background-color:var(--color-bg-elevated);
    color:var(--color-text-primary);
    height:40px;
    width:40px;
    border-radius:var(--radius);
    display: flex;
    align-items: center;
    text-align:center;
    justify-content: center;
}
#new_messages_button i {
    font-size:30px;
    line-height:1;
}

#chatbox {
  position:relative;

  padding:20px;
  padding-bottom:0px;

  width:calc(100% - 40px);
  height:calc(100% - 160px);

  min-height:calc(100% - 240px);
  max-height:calc(100% - 160px);

  overflow-y: scroll;
  overflow-x: hidden;
  overscroll-behavior: none;
  overflow-anchor: none; /* chat.js anchors by hand (iOS has no native anchoring) */

  background-color:var(--color-white);
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
}
.chatbox_long {
  height:calc(100% - 84px) !important;
  min-height:calc(100% - 84px) !important;
  max-height:calc(100% - 84px) !important;
}

.chatbox_loading {
  position:fixed;
  inset:0;
  top:env(safe-area-inset-top, 0);

  text-align: center;
  display:flex;
  vertical-align:middle;
  justify-content: center;
  align-items: center;

  background-color: var(--color-bg);
  z-index:9;

  font-size:24px;
  font-weight:bold;
  color:var(--color-white);
}
.chatbox_loading_inner {
  display:flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  vertical-align: middle;
  text-align: center;
}
.cli_spin {
  display:flex;
  justify-content: center;
  align-items: center;
  vertical-align: middle;
  text-align: center;

  font-size:48px;
}
.cli_text {
  display:flex;
  justify-content: center;
  align-items: center;
  vertical-align: middle;
  text-align: center;

  margin-top:20px;
}

.chat_info_cont {
  position:relative;
  background: transparent;
  color: var(--text-1);

  padding:40px;
  padding-left:20px;
  padding-right:20px;
  width:calc(100% - 40px);
  height:calc(100% - 144px);
  overflow-y: scroll;
  overflow-x: hidden;
  overscroll-behavior: none;
}

/* ==========================================================================
   VELLO UI — shared components
   One definition per component; pages compose these instead of restyling
   them under their own scope.
   ========================================================================== */

/* ---- Section label (Settings groups, Contacts lists, Alarm sections) ---- */
.moo-settings__section,
.fr_list_title {
  font-size: var(--fs-2xs);
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-3);
  padding: 0 4px;
  margin: 0 0 10px;
}
.moo-settings__section:not(:first-of-type) { margin-top: 28px; }

/* ---- Card ---- */
.moo-settings-card {
  box-sizing: border-box;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--inset-hi);
  padding: 18px;
  margin-bottom: 12px;
  color: var(--text-1);
}
.moo-settings-card:last-child,
.moo-settings-card:last-of-type,
.moo-form-card:last-child,
.moo-form-card:last-of-type,
.settings_item_last {
  margin-bottom: 0;
}

.moo-settings-card .settings_item_title {
  color: var(--text-1);
  font-size: var(--fs-md);
  font-weight: 650;
  letter-spacing: -0.01em;
  margin-bottom: 0;
  line-height: 1.25;
}
.moo-settings-card .cn_subtext,
.moo-settings-card__desc {
  font-size: var(--fs-sm);
  line-height: 1.5;
  color: var(--text-3);
  margin: 0 0 14px;
}
.moo-settings-card__header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.moo-settings-card__icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 14px;
  flex-shrink: 0;
}
/* Inline card forms: field + action on one row */
.moo-settings-card form:not(.ap_inner):not(.ld_buttons):not(.moo-form-stack) {
  display: flex;
  gap: 8px;
}
.moo-settings-card .ap_inner {
  display: flex;
  align-items: center;
  gap: 14px;
}
.moo-settings-card .ap_inner img {
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
  object-fit: cover;
  box-shadow: 0 0 0 1px var(--hairline);
  flex-shrink: 0;
}

/* ---- Form card (single-purpose pages: add contact, new group, new medication…) ---- */
.moo-form-card,
.settings_item.moo-form-card { margin-bottom: 12px; }
.moo-form-card {
  box-sizing: border-box;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--inset-hi);
  padding: 28px 22px 24px;
  color: var(--text-1);
}
.moo-form-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
}
.moo-form-card .settings_item_title {
  color: var(--text-1);
  font-size: var(--fs-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 8px;
}
.moo-form-card .cn_subtext,
.moo-tools .moo-form-card .cn_subtext {
  margin-top: 0;
  font: inherit;
  color: var(--text-2);
  font-size: var(--fs-body);
  line-height: 1.55;
  margin-bottom: 24px;
}
.moo-form-card form { display: block; }
.cn_input_title {
  display: block;
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  margin: 18px 0 8px 2px;
}
.moo-form-card .cn_input_title:first-of-type { margin-top: 0; }
.moo-form-card form button[type="submit"],
.moo-form-card form .moo-btn { margin-top: 24px; }

/* ---- Text inputs + select ---- */
.moo-input,
.moo-settings-card input[type="text"],
.moo-settings-card input[type="tel"],
.moo-settings-card input[type="number"],
.moo-settings-card input[type="email"],
.moo-settings-card input[type="password"],
.moo-settings-card input[type="date"],
.moo-settings-card input[type="time"],
.moo-form-card input[type="text"],
.moo-form-card input[type="tel"],
.moo-form-card input[type="number"],
.moo-form-card input[type="email"],
.moo-form-card input[type="password"],
.moo-form-card input[type="date"],
.moo-form-card input[type="time"],
.moo-nickname-form input[type="text"],
.moo-settings-card select,
.moo-form-card select {
  box-sizing: border-box;
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  height: var(--h-control);
  margin: 0;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  color: var(--text-1);
  font-family: var(--font-ui);
  font-size: var(--fs-input);
  font-weight: 500;
  -webkit-appearance: none;
  appearance: none;
  user-select: text;
  -webkit-user-select: text;
  touch-action: manipulation;
  transition: border-color var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out), background-color var(--dur-2) var(--ease-out);
}
.moo-input::placeholder,
.moo-settings-card input::placeholder,
.moo-form-card input::placeholder,
.moo-nickname-form input::placeholder {
  color: var(--text-4);
}
.moo-input:focus,
.moo-settings-card input:focus,
.moo-settings-card select:focus,
.moo-form-card input:focus,
.moo-form-card select:focus,
.moo-nickname-form input:focus {
  border-color: var(--accent-line);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.moo-settings-card input[readonly]:not(.moo-tap-edit),
.moo-form-card input[readonly]:not(.moo-tap-edit) {
  color: var(--text-3);
  background: transparent;
  border-color: var(--hairline);
  box-shadow: none;
}
.moo-settings-card select,
.moo-form-card select {
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23a9b8bf' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 15px center;
  cursor: pointer;
}
.moo-settings-card select option,
.moo-form-card select option {
  background: var(--surface-solid);
  color: var(--text-1);
}

/* ---- Buttons ----
   .moo-btn + modifier for new markup; the legacy selectors map onto the
   same three looks: primary (mint), secondary (glass), danger. */
.moo-btn,
.moo-form-card button[type="submit"],
.moo-settings-card button:is(:not([class]), .moo-btn-danger-outline),
.moo-nickname-form button,
.push_button button,
.ld_buttons button,
.cln_button {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--h-control);
  margin: 0;
  padding: 0 18px;
  border-radius: var(--radius);
  border: 1px solid var(--hairline-strong);
  background: var(--surface-2);
  color: var(--text-1);
  font-family: var(--font-ui);
  font-size: var(--fs-body);
  font-weight: 600;
  letter-spacing: -0.005em;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out), transform var(--dur-1) var(--ease-out), box-shadow var(--dur-2) var(--ease-out), opacity var(--dur-2) var(--ease-out);
}
.moo-btn i,
.moo-form-card button[type="submit"] i,
.moo-settings-card button:is(:not([class]), .moo-btn-danger-outline) i { font-size: 0.9em; }
@media (hover: hover) {
  .moo-btn:hover,
  .moo-settings-card button:is(:not([class]), .moo-btn-danger-outline):hover,
  .moo-nickname-form button:hover,
  .push_button button:hover {
    background: var(--accent-soft);
    border-color: var(--accent-line);
    color: var(--accent);
  }
}
.moo-btn:active,
.moo-form-card button[type="submit"]:active,
.moo-settings-card button:is(:not([class]), .moo-btn-danger-outline):active,
.moo-nickname-form button:active,
.push_button button:active,
.ld_buttons button:active,
.cln_button:active {
  transform: scale(0.98);
}
.moo-btn:disabled,
.moo-form-card button:disabled,
.moo-settings-card button:is(:not([class]), .moo-btn-danger-outline):disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}
/* Primary */
.moo-btn--primary,
.moo-form-card button[type="submit"],
.cln_button {
  background: linear-gradient(180deg, #1df2b4 0%, var(--accent) 45%, var(--accent-strong) 100%);
  border-color: transparent;
  color: var(--accent-ink);
  font-weight: 700;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset, 0 8px 22px rgba(0, 229, 160, 0.18);
}
@media (hover: hover) {
  .moo-btn--primary:hover,
  .moo-form-card button[type="submit"]:hover,
  .cln_button:hover {
    background: linear-gradient(180deg, #3bf6c2 0%, #12ecac 45%, var(--accent) 100%);
    color: var(--accent-ink);
    border-color: transparent;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset, 0 10px 28px rgba(0, 229, 160, 0.26);
  }
}
/* Danger */
.moo-btn--danger,
.moo-btn-danger-outline,
.ld_buttons button {
  background: var(--danger-soft) !important;
  border: 1px solid var(--danger-line) !important;
  color: var(--danger) !important;
}
@media (hover: hover) {
  .moo-btn--danger:hover,
  .moo-btn-danger-outline:hover,
  .ld_buttons button:hover {
    background: rgba(255, 90, 115, 0.2) !important;
    color: var(--danger) !important;
  }
}
.moo-btn--block,
.moo-form-card button[type="submit"],
.ld_buttons button { width: 100%; }
.moo-btn--sm { height: var(--h-control-sm); padding: 0 14px; font-size: var(--fs-sm); border-radius: var(--radius); }

/* ---- Toggle ---- */
.moo-toggle {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
  cursor: pointer;
}
.moo-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.moo-toggle__track {
  position: absolute;
  inset: 0;
  background: var(--surface-3);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px var(--hairline);
  transition: background-color var(--dur-2) var(--ease-out);
}
.moo-toggle__track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  background: #e8eef0;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  transition: transform var(--dur-3) var(--ease-spring), background-color var(--dur-2) var(--ease-out);
}
.moo-toggle input:checked + .moo-toggle__track {
  background: var(--accent);
}
.moo-toggle input:checked + .moo-toggle__track::after {
  transform: translateX(20px);
  background: #ffffff;
}
.moo-toggle input:disabled + .moo-toggle__track {
  opacity: 0.35;
  cursor: not-allowed;
}
.moo-toggle:has(input:disabled) {
  cursor: not-allowed;
}
.moo-toggle input:focus-visible + .moo-toggle__track {
  box-shadow: 0 0 0 3px var(--accent-soft), inset 0 0 0 1px var(--accent-line);
}

/* ---- Inline notice (post-action result) ---- */
.settings_returnMessage {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  color: var(--text-1);
  padding: 14px 16px;
  margin-bottom: 12px;
  font-size: var(--fs-body);
  font-weight: 500;
  line-height: 1.45;
  text-align: left;
}
.settings_returnMessage i {
  color: var(--accent);
  font-size: 17px;
  flex-shrink: 0;
}

/* ---- Grouped list (Settings, Chat info, Contact profile, Tools) ----
   <div class="moo-list"> holds .moo-row items (a | button | div). Rows get an
   inset hairline between them, an optional icon tile, title + sub, a trailing
   value / control / chevron. */
.moo-list {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--inset-hi);
  overflow: hidden;
  margin: 0 0 12px;
}
.moo-list form { margin: 0; display: contents; }
.moo-row {
  box-sizing: border-box;
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  margin: 0;
  padding: 10px 14px;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: var(--text-1);
  font: inherit;
  font-size: var(--fs-body);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur-2) var(--ease-out);
}
.moo-row + .moo-row::before,
.moo-row + form > .moo-row::before,
form + .moo-row::before,
form + form > .moo-row::before {
  content: '';
  position: absolute;
  top: 0;
  left: 58px;
  right: 0;
  height: 1px;
  background: var(--hairline);
}
.moo-list--plain .moo-row + .moo-row::before { left: 14px; }
@media (hover: hover) {
  .moo-row:not(.moo-row--static):hover { background: rgba(255, 255, 255, 0.03); }
}
.moo-row:not(.moo-row--static):active { background: var(--surface-2); }
.moo-row--static { cursor: default; }
.moo-row__icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 14px;
}
.moo-row__icon--danger { background: var(--danger-soft); color: var(--danger); }
.moo-row__icon--warning { background: var(--warning-soft); color: var(--warning); }
.moo-row__icon--info { background: var(--info-soft); color: var(--info); }
.moo-row__icon--muted { background: var(--surface-2); color: var(--text-2); }
.moo-row__body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.moo-row__title {
  font-size: var(--fs-body);
  font-weight: 550;
  color: var(--text-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.moo-row__sub {
  font-size: var(--fs-xs);
  line-height: 1.4;
  color: var(--text-3);
}
.moo-row__value {
  flex-shrink: 0;
  min-width: 0;
  max-width: 45%;
  font-size: var(--fs-sm);
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.moo-row__value--on { color: var(--accent); font-weight: 600; }
.moo-row__chev {
  flex-shrink: 0;
  color: var(--text-4);
  font-size: 12px;
}
.moo-row--danger .moo-row__title { color: var(--danger); }
.moo-row--center { justify-content: center; }
.moo-row--center .moo-row__title { flex: 0 1 auto; }
.moo-row[disabled],
.moo-row--disabled { cursor: default; }
.moo-row[disabled] .moo-row__title,
.moo-row--disabled .moo-row__title { color: var(--text-3); }
/* Armed (data-moo-arm): the icon gives way to its question, which grows out
   over the row (app.js keeps its 34px place) so the row's text never shifts. */
.moo-row__action[data-armed="1"] { position: relative; z-index: 1; width: auto; padding: 0 12px; font-family: inherit; font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; }
.moo-row__action--danger[data-armed="1"] { background: color-mix(in srgb, var(--danger) 16%, var(--surface-1)); border-color: var(--danger-line); color: var(--danger); box-shadow: -14px 0 10px -4px var(--surface-1); }
.moo-row__action {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: background-color var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out);
}
.moo-row__action--danger:hover,
.moo-row__action--danger:active { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger); }

/* ---- Chip (inline tag: "This device", "Shared", "Admin"…) ---- */
.moo-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.02em;
  vertical-align: middle;
  white-space: nowrap;
}
.moo-chip--accent { background: var(--accent-soft); color: var(--accent); }
.moo-chip--info { background: var(--info-soft); color: var(--info); }
.moo-chip--warning { background: var(--warning-soft); color: var(--warning); }
.moo-chip--danger { background: var(--danger-soft); color: var(--danger); }

/* ---- Profile hero (Settings top, Contact profile) ---- */
.moo-profile-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  margin-bottom: 24px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--inset-hi);
}
.moo-profile-hero__avatar {
  position: relative;
  width: 68px;
  height: 68px;
  flex-shrink: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius);
}
.moo-profile-hero__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px var(--hairline-strong);
}
.moo-profile-hero__badge {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 26px;
  height: 26px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 3px var(--color-bg);
}
.moo-profile-hero__body { min-width: 0; flex: 1; }
.moo-profile-hero__name {
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.moo-profile-hero__handle {
  margin-top: 3px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--accent);
}

/* ---- Inline row form (nickname, group name) ---- */
.moo-nickname-form {
  display: flex;
  gap: 8px;
}
.moo-nickname-form input[type="text"] { width: auto; }
/* With both Update and Remove, the field takes its own row */
.moo-nickname-form:has(> :nth-child(3)) { flex-wrap: wrap; }
.moo-nickname-form:has(> :nth-child(3)) input[type="text"] { flex: 1 1 100%; }
.moo-nickname-form:has(> :nth-child(3)) button { flex: 1 1 0; }

/* ---- Sheet / menu options ---- */
.moo-modal__title {
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  margin-bottom: 18px;
  color: var(--text-1);
}
.moo-modal__options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}
.moo-modal__option {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 52px;
  box-sizing: border-box;
  padding: 0 16px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  color: var(--text-1);
  font-size: var(--fs-body);
  font-weight: 600;
  text-decoration: none;
  transition: background-color var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out);
}
@media (hover: hover) {
  .moo-modal__option:hover {
    background: var(--accent-soft);
    border-color: var(--accent-line);
  }
}
.moo-modal__option:active { background: var(--surface-3); }
.moo-modal__option i {
  color: var(--accent);
  font-size: 16px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

/* ===== AUTH PAGE ===== */
.moo-auth {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: none;
  background: var(--color-bg);
  z-index: 1;
}
.moo-auth::before,
.moo-auth::after {
  content: '';
  flex: 1 0 24px;
}

.moo-auth__bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.moo-auth__orb {
  position: absolute;
  border-radius: 50%;
  will-change: transform;
}
.moo-auth__orb--1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(14, 165, 233, 0.5) 0%, transparent 70%);
  top: -10%;
  right: -5%;
  animation: mooOrb1 20s ease-in-out infinite;
}
.moo-auth__orb--2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.45) 0%, transparent 70%);
  bottom: -15%;
  left: -10%;
  animation: mooOrb2 25s ease-in-out infinite;
}
.moo-auth__orb--3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(244, 63, 94, 0.35) 0%, transparent 70%);
  top: 40%;
  left: 50%;
  margin-left: -200px;
  animation: mooOrb3 30s ease-in-out infinite;
}

@keyframes mooOrb1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(80px, -120px) scale(1.1); }
  50% { transform: translate(-40px, -60px) scale(0.9); }
  75% { transform: translate(60px, 40px) scale(1.05); }
}
@keyframes mooOrb2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(-100px, 80px) scale(1.15); }
  66% { transform: translate(60px, -100px) scale(0.95); }
}
@keyframes mooOrb3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  20% { transform: translate(100px, 50px) scale(0.9); }
  40% { transform: translate(-60px, 120px) scale(1.1); }
  60% { transform: translate(-120px, -40px) scale(1.05); }
  80% { transform: translate(40px, -80px) scale(0.95); }
}

.moo-auth__noise {
  position: absolute;
  inset: 0;
  opacity: 0.035;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* Glass card */
.moo-auth__card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 420px;
  flex-shrink: 0;
  padding: 48px 40px;
  box-sizing: border-box;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.03),
    0 24px 80px rgba(0, 0, 0, 0.4);
  animation: mooCardIn 0.6s ease-out forwards;
}

@keyframes mooCardIn {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Staggered entrance */
.moo-auth__card > * {
  opacity: 0;
  animation: mooFadeUp 0.5s ease-out forwards;
}
.moo-auth__card > *:nth-child(1) { animation-delay: 0.08s; }
.moo-auth__card > *:nth-child(2) { animation-delay: 0.14s; }
.moo-auth__card > *:nth-child(3) { animation-delay: 0.2s; }
.moo-auth__card > *:nth-child(4) { animation-delay: 0.26s; }
.moo-auth__card > *:nth-child(5) { animation-delay: 0.32s; }
.moo-auth__card > *:nth-child(6) { animation-delay: 0.38s; }
.moo-auth__card > *:nth-child(7) { animation-delay: 0.44s; }

@keyframes mooFadeUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Logo */
.moo-auth__logo {
  text-align: center;
  margin-bottom: 32px;
}
.moo-auth__logo a {
  display: inline-block;
  text-decoration: none;
  transition: transform 0.3s ease;
}
.moo-auth__logo a:hover {
  transform: scale(1.05);
}
.moo-auth__logo img {
  width: 88px;
  height: 88px;
  border-radius: var(--radius);
  box-shadow: 0 0 40px rgba(0, 229, 160, 0.15), 0 0 0 1px rgba(255, 255, 255, 0.08);
}
/* Title + Subtitle */
.moo-auth__title {
  font-size: 28px;
  font-weight: 800;
  color: var(--color-text-primary);
  margin: 0 0 8px;
  letter-spacing: -0.5px;
}
.moo-auth__subtitle {
  font-size: 15px;
  font-weight: 400;
  color: var(--text-3);
  margin: 0 0 32px;
  line-height: 1.5;
}

/* Form fields — boxed, floating label, icon inset (the app-wide input look) */
.moo-auth__field {
  position: relative;
  margin-bottom: 12px;
}
.moo-auth__field-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-4);
  font-size: 15px;
  width: 20px;
  text-align: center;
  transition: color var(--dur-2) var(--ease-out);
  pointer-events: none;
  z-index: 1;
}
.moo-auth__field input {
  width: 100%;
  height: 58px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  color: var(--text-1);
  padding: 20px 14px 6px 46px;
  font-size: var(--fs-input);
  font-weight: 500;
  font-family: var(--font-ui);
  transition: border-color var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out), background-color var(--dur-2) var(--ease-out);
  box-sizing: border-box;
  -webkit-appearance: none;
  user-select: text;
  -webkit-user-select: text;
  touch-action: manipulation;
}
.moo-auth__field input:focus {
  border-color: var(--accent-line);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.moo-auth__field label {
  position: absolute;
  left: 46px;
  top: 19px;
  color: var(--text-3);
  font-size: var(--fs-input);
  font-weight: 500;
  pointer-events: none;
  transition: top var(--dur-2) var(--ease-out), font-size var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out);
}
.moo-auth__field input:focus + label,
.moo-auth__field input:not(:placeholder-shown) + label {
  top: 9px;
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--accent);
}
.moo-auth__field input:not(:focus):not(:placeholder-shown) + label { color: var(--text-3); }
.moo-auth__field:has(input:focus) .moo-auth__field-icon { color: var(--accent); }
.moo-auth__field:has(input:not(:placeholder-shown)) .moo-auth__field-icon { color: var(--text-3); }
.moo-auth__field + .moo-auth__btn,
.moo-auth__field + button { margin-top: 12px; }

/* Submit button */
.moo-auth__btn {
  width: 100%;
  white-space: nowrap;
  padding: 16px 20px;
  margin-top: 8px;
  background: var(--grad-primary);
  border: none;
  border-radius: var(--radius);
  color: var(--color-bg);
  font-weight: 700;
  font-size: 16px;
  font-family: var(--font-ui);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  touch-action: manipulation;
}
.moo-auth__btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 229, 160, 0.25);
}
.moo-auth__btn:active {
  transform: translateY(0) scale(0.98);
}
.moo-auth__btn i {
  font-size: 14px;
  transition: transform 0.3s;
}
.moo-auth__btn:hover i {
  transform: translateX(3px);
}
.moo-auth__btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.6s ease;
}
.moo-auth__btn:hover::before {
  left: 100%;
}
.moo-auth__btn:disabled {
  opacity: 0.7;
  cursor: default;
}
.moo-auth__btn:disabled:hover {
  transform: none;
  box-shadow: none;
}
.moo-auth__btn:disabled::before {
  display: none;
}

/* Switch link (login <-> register) */
.moo-auth__switch {
  margin-top: 28px;
  text-align: center;
  font-size: 14px;
  color: var(--text-3);
  font-weight: 500;
}
.moo-auth__switch a {
  color: var(--color-accent);
  font-weight: 700;
  margin-left: 4px;
  transition: color 0.2s;
  text-decoration: none;
}
.moo-auth__switch a:hover {
  color: var(--color-accent-hover);
}

/* Account deleted banner */
.moo-auth__deleted-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: rgba(244, 63, 94, 0.08);
  border: 1px solid rgba(244, 63, 94, 0.15);
  color: rgba(244, 63, 94, 0.85);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 24px;
}
.moo-auth__deleted-banner i {
  font-size: 16px;
  flex-shrink: 0;
}

/* Password + recovery key save-prove ritual (register, recover, settings modals) */
.moo-rk-step {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: rgba(0, 229, 160, 0.55);
  margin-bottom: 8px;
}
.moo-rk-warn {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: rgba(251, 191, 36, 0.07);
  border: 1px solid rgba(251, 191, 36, 0.18);
  margin-bottom: 16px;
  text-align: left;
}
.moo-rk-warn i {
  color: var(--color-warning);
  font-size: 15px;
  flex-shrink: 0;
  margin-top: 2px;
}
.moo-rk-warn div {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-2);
  font-weight: 500;
}
.moo-rk-warn strong {
  color: var(--color-warning);
  font-weight: 700;
}
.moo-rk-confirm__input {
  width: 100%;
  box-sizing: border-box;
  display: block;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: var(--color-accent);
  font-family: 'Courier New', Courier, monospace;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.7;
  letter-spacing: 1px;
  text-align: center;
  word-break: break-all;
  resize: none;
  outline: none;
  transition: border-color 160ms ease;
}
.moo-rk-confirm__input::placeholder {
  color: var(--text-4);
  font-family: var(--font-ui);
  font-weight: 500;
  letter-spacing: 0;
}
.moo-rk-confirm__input:focus { border-color: rgba(0, 229, 160, 0.35); }
.moo-rk-confirm__input--err,
.moo-rk-confirm__input--err:focus { border-color: rgba(244, 63, 94, 0.55); }
.moo-rk-confirm__input--ok,
.moo-rk-confirm__input--ok:focus { border-color: rgba(0, 229, 160, 0.6); }
.moo-rk-confirm__status {
  margin: 8px 2px 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  text-align: center;
  min-height: 16px;
}
.moo-rk-confirm__status--err { color: var(--color-danger); }
.moo-rk-confirm__status--ok { color: var(--color-accent); }
.moo-auth__btn.moo-auth__btn--locked,
.moo-auth__btn.moo-auth__btn--locked:hover {
  opacity: 0.4;
  cursor: default;
  transform: none;
  box-shadow: none;
}
.moo-auth__btn.moo-auth__btn--locked::before { display: none; }
.moo-auth__btn.moo-auth__btn--locked:hover i { transform: none; }

/* Invite-only notice */
.moo-auth__invite-note {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  margin-top: 24px;
}
.moo-auth__invite-note > i {
  color: var(--text-4);
  font-size: 14px;
  margin-top: 2px;
  flex-shrink: 0;
}
.moo-auth__invite-note strong {
  display: block;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
}
.moo-auth__invite-note p {
  margin: 0;
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.5;
}

/* Auth mobile responsive */
@media (max-width: 480px) {
  .moo-auth::before,
  .moo-auth::after {
    flex: 1 0 16px;
  }
  .moo-auth__card {
    padding: 32px 24px;
    border-radius: var(--radius);
    max-width: calc(100% - 32px);
  }
  .moo-auth__title {
    font-size: 24px;
  }
  .moo-auth__field input {
    font-size: 15px;
  }
  .moo-auth__orb--1 { width: 300px; height: 300px; }
  .moo-auth__orb--2 { width: 350px; height: 350px; }
  .moo-auth__orb--3 { width: 250px; height: 250px; margin-left: -125px; }
}

/* ===== CONTACTS PAGE OVERHAUL ===== */

/* Content area — transparent so aurora shows through */
.contacts_page {
  background: transparent !important;
  color: var(--color-text-primary);
  padding-top: 20px !important;
  padding-bottom: 20px !important;
  height: calc(100% - 174px) !important;
}

/* Contact list rows share the chat-list row style (see CHATS LIST). */
.contacts_page #getContacts_API:empty,
.contacts_page #getContacts_API:not(:has(.chat_cont)) {
  color: var(--text-3);
  text-align: center;
  padding: 60px 0;
  font-size: var(--fs-body);
}
.contacts_page .fr_list_cont { margin: 0 0 24px; }

/* Pending friend requests — an accent row above the list */
.contacts_page .pending_fr_banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  box-sizing: border-box;
  margin: 0 0 16px;
  padding: 0 14px 0 16px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  color: var(--text-1);
  font-size: var(--fs-body);
  font-weight: 600;
  transition: background-color var(--dur-2) var(--ease-out);
}
.contacts_page .pending_fr_banner:active { background: rgba(0, 229, 160, 0.18); }
.contacts_page .pending_fr_banner .pfr_number {
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  box-sizing: border-box;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xs);
  font-weight: 700;
}

/* ---- Profile (individual contact) ---- */
.moo-profile-card {
  position: relative;
  padding: 8px 8px 4px;
  text-align: center;
  margin-bottom: 18px;
}
.contacts_page .contact_pic {
  width: 112px;
  height: 112px;
  margin: 0 auto 16px;
}
.contacts_page .contact_pic img {
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px var(--hairline-strong), 0 18px 50px rgba(0, 229, 160, 0.10);
}
.contacts_page .contact_name {
  color: var(--text-1);
  font-size: var(--fs-title);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
}
.contacts_page .contact_real_name {
  font-size: var(--fs-body);
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text-3);
  margin-top: 4px;
}
.contacts_page .contact_mn_display {
  color: var(--accent);
  font-size: var(--fs-body);
  font-weight: 600;
  letter-spacing: 0;
  margin-top: 6px;
}
.contacts_page .contact_last_online,
.contacts_page .contact_timezone {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text-3);
}
.contacts_page .contact_timezone { display: flex; justify-content: center; margin-top: 6px; }
.contacts_page .contact_last_online--now { color: var(--accent); }
.contacts_page .contact_last_online--now::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: var(--radius);
  background: var(--accent);
}

/* Contact actions: equal-width tiles (icon over label) */
.contacts_page .contact_options {
  display: flex;
  gap: 10px;
  margin: 16px 0 0;
}
.contacts_page .co_contact_form {
  display: flex;
  gap: 10px;
  width: 100%;
}
.contacts_page .contact_option_indv {
  flex: 1 1 0;
  width: auto;
  height: 72px;
  margin: 0 !important;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--inset-hi);
  color: var(--text-1);
  font-family: var(--font-ui);
  cursor: pointer;
  transition: background-color var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out), transform var(--dur-1) var(--ease-out);
}
@media (hover: hover) {
  .contacts_page .contact_option_indv:hover { background: var(--surface-2); }
}
.contacts_page .contact_option_indv:active { transform: scale(0.97); }
.contacts_page .option_icon { font-size: 18px; color: var(--accent); }
.contacts_page .option_title {
  margin: 0;
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 600;
}
.contacts_page .moo-btn-danger .option_icon,
.contacts_page .moo-btn-danger .option_title { color: var(--danger); }
.contacts_page .moo-btn-success {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.moo-invite-code {
  font-family: 'SF Mono', ui-monospace, Menlo, Consolas, monospace;
  font-weight: 650;
  letter-spacing: 0.06em;
  color: var(--accent);
}
.moo-settings__section--spaced { margin-top: 28px !important; }
.contacts_page .moo-settings-card { margin-top: 0; }
.contacts_page .moo-contact-nick { margin-top: 12px; }

/* ===== SETTINGS PAGE OVERHAUL ===== */

/* Content area */
.moo-settings {
  background: transparent !important;
  color: var(--color-text-primary);
  padding-top: 20px !important;
  padding-bottom: 20px !important;
  height: calc(100% - 174px) !important;
}

/* Account picture */
.moo-settings .moo-ap-buttons {
  display: flex;
  gap: 8px;
}

/* Push notifications */
.moo-settings .push_box {
  margin-top: 0;
}
.moo-pn-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 14px;
}
.moo-pn-enabled {
  background: rgba(0, 229, 160, 0.08);
  border: 1px solid rgba(0, 229, 160, 0.15);
  color: var(--color-accent);
}
.moo-pn-disabled {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  color: var(--text-3);
}
.moo-settings .push_button {
  display: flex;
  gap: 8px;
}

/* Account devices table */
.moo-settings .uds_table {
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
}
.moo-settings .uds_table_row {
  border-bottom: 1px solid var(--hairline);
  padding: 14px 16px;
  color: var(--text-2);
  font-size: 12px;
}
.moo-settings .uds_table_row:last-child {
  border-bottom: 0;
}
.moo-settings .uds_table_row b {
  color: var(--text-1);
}
.moo-settings .udstr_right button {
  background: rgba(244, 63, 94, 0.1) !important;
  border: 1px solid rgba(244, 63, 94, 0.2) !important;
  color: var(--color-danger) !important;
  border-radius: var(--radius) !important;
  width: 32px !important;
  height: 32px !important;
  padding: 0 !important;
  font-size: 16px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: opacity 0.2s, background-color 0.2s;
  cursor: pointer;
}
.moo-settings .udstr_right button:hover {
  background: rgba(244, 63, 94, 0.2) !important;
}

/* Privacy toggles */
.moo-privacy-toggles {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.moo-privacy-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--hairline);
}
.moo-privacy-toggle:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.moo-privacy-toggle:first-child {
  padding-top: 0;
}
.moo-privacy-toggle__text {
  flex: 1;
  min-width: 0;
}
.moo-privacy-toggle__label {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-primary);
}
.moo-privacy-toggle__desc {
  font-size: 12px;
  color: var(--text-4);
  margin-top: 2px;
}
/* Sub-pages (change picture, verify number) — reuse moo-form-card from contacts */
.moo-settings .moo-form-card input[type="file"] {
  background: var(--surface-1);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  color: var(--text-2);
  padding: 14px;
  font-size: 14px;
  font-family: var(--font-ui);
  width: calc(100% - 30px);
  margin-bottom: 24px;
  cursor: pointer;
}

/* Bug report modal — frosted glass */
body:has(.moo-settings) #br_popup_wrap {
  background: rgba(6, 13, 16, 0.6);
  animation: mooOverlayIn 0.2s ease-out;
}
body:has(.moo-settings) #br_popup {
  background: rgba(20, 30, 38, 0.85);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 32px;
  width: min(360px, 80%);
  color: var(--color-text-primary);
  animation: mooModalIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
body:has(.moo-settings) .br_popup_title {
  color: var(--color-text-primary);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.3px;
  margin-bottom: 20px;
}
body:has(.moo-settings) .br_form {
  gap: 12px;
}
body:has(.moo-settings) .br_selectbox {
  background: var(--surface-1);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  color: var(--color-text-primary);
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 500;
  font-family: var(--font-ui);
}
body:has(.moo-settings) .br_selectbox option {
  background: var(--color-bg-elevated);
  color: var(--color-text-primary);
}
body:has(.moo-settings) .br_textarea {
  background: var(--surface-1);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  color: var(--color-text-primary);
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 500;
  font-family: var(--font-ui);
  min-height: 100px;
  user-select: text;
  -webkit-user-select: text;
  touch-action: manipulation;
}
body:has(.moo-settings) .br_textarea::placeholder {
  color: var(--text-4);
  font-weight: 400;
}
body:has(.moo-settings) .br_submit_button {
  background: var(--grad-primary) !important;
  color: var(--color-bg) !important;
  border: none !important;
  border-radius: var(--radius) !important;
  padding: 16px 24px !important;
  font-weight: 700 !important;
  font-size: 16px !important;
  font-family: var(--font-ui);
  width: 100% !important;
  cursor: pointer;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
body:has(.moo-settings) .br_submit_button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 229, 160, 0.25);
}

/* Styled file picker (replaces native file input) */
.moo-file-input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}
.moo-file-picker {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--surface-1);
  border: 2px dashed var(--hairline-strong);
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity 0.2s, background-color 0.2s, border-color 0.2s;
  margin-bottom: 0;
}
.moo-file-picker:hover {
  background: rgba(0, 229, 160, 0.04);
  border-color: rgba(0, 229, 160, 0.2);
}
.moo-file-picker:active {
  background: rgba(0, 229, 160, 0.08);
}
.moo-file-picker__icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: rgba(0, 229, 160, 0.1);
  border: 1px solid rgba(0, 229, 160, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-accent);
  font-size: 18px;
  flex-shrink: 0;
}
.moo-file-picker__text {
  flex: 1;
  min-width: 0;
}
.moo-file-picker__label {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.moo-file-picker__hint {
  font-size: 12px;
  color: var(--text-4);
  margin-top: 2px;
}

/* ===== IMAGE CROP MODAL ===== */
#moo_crop_wrap {
  position: fixed;
  inset: 0;
  background: rgba(6, 13, 16, 0.8);
  z-index: 100000;
  animation: mooOverlayIn 0.2s ease-out;
}
#moo_crop_modal {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  background: var(--color-bg);
  color: var(--color-text-primary);
}
.moo-crop__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  padding-top: calc(16px + env(safe-area-inset-top, 0));
  flex-shrink: 0;
}
.moo-crop__title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.3px;
}
#moo_crop_cancel {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--hairline-strong);
  color: var(--text-3);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  margin: 0;
}
.moo-crop__stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
  position: relative;
  touch-action: none;
}
.moo-crop__img-area {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
#moo_crop_img {
  position: absolute;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
  will-change: transform;
  opacity: 1 !important;
}
.moo-crop__frame {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius);
  box-shadow: 0 0 0 9999px rgba(6, 13, 16, 0.65);
  z-index: 2;
  pointer-events: none;
}
.moo-crop__corner {
  position: absolute;
  width: 20px;
  height: 20px;
  border-color: var(--color-accent);
  border-style: solid;
  border-width: 0;
}
.moo-crop__corner--tl { top: -2px; left: -2px; border-top-width: 3px; border-left-width: 3px; border-radius: var(--radius) 0 0 0; }
.moo-crop__corner--tr { top: -2px; right: -2px; border-top-width: 3px; border-right-width: 3px; border-radius: 0 var(--radius) 0 0; }
.moo-crop__corner--bl { bottom: -2px; left: -2px; border-bottom-width: 3px; border-left-width: 3px; border-radius: 0 0 0 var(--radius); }
.moo-crop__corner--br { bottom: -2px; right: -2px; border-bottom-width: 3px; border-right-width: 3px; border-radius: 0 0 var(--radius) 0; }

.moo-crop__controls {
  padding: 12px 24px;
  flex-shrink: 0;
}
.moo-crop__zoom {
  display: flex;
  align-items: center;
  gap: 14px;
}
.moo-crop__zoom button {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--hairline-strong);
  color: var(--color-text-primary);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: opacity 0.2s, background-color 0.2s, color 0.2s, border-color 0.2s;
}
.moo-crop__zoom button:active {
  background: rgba(0, 229, 160, 0.15);
  border-color: rgba(0, 229, 160, 0.3);
  color: var(--color-accent);
}
.moo-crop__zoom-track {
  flex: 1;
  height: 4px;
  background: var(--surface-2);
  border-radius: var(--radius);
  overflow: hidden;
}
.moo-crop__zoom-fill {
  height: 100%;
  width: 0%;
  background: var(--color-accent);
  border-radius: var(--radius);
  transition: width 0.15s ease;
}

.moo-crop__actions {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0));
  flex-shrink: 0;
}
.moo-crop__btn-secondary {
  flex: 0.8;
  padding: 16px;
  background: var(--surface-2);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  color: var(--text-2);
  font-weight: 600;
  font-size: 15px;
  font-family: var(--font-ui);
  cursor: pointer;
}
.moo-crop__btn-primary {
  flex: 1.2;
  padding: 16px;
  background: var(--grad-primary);
  border: none;
  border-radius: var(--radius);
  color: var(--color-bg);
  font-weight: 700;
  font-size: 15px;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s, box-shadow 0.2s;
}
.moo-crop__btn-primary:disabled {
  opacity: 0.7;
  cursor: default;
}

/* Upload progress overlay */
#moo_crop_uploading {
  position: absolute;
  inset: 0;
  background: rgba(6, 13, 16, 0.8);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 5;
}
.moo-crop__upload-spinner {
  font-size: 36px;
  color: var(--color-accent);
}
.moo-crop__upload-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-primary);
}

/* Crop upload error state — inline retry panel (no more alerts). Sits over
 * the crop stage exactly like #moo_crop_uploading but with danger-themed icon
 * and a retry button that reuses the already-cropped blob. */
.moo-crop__error {
  position: absolute;
  inset: 0;
  background: rgba(6, 13, 16, 0.88);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 32px 28px;
  z-index: 6;
  text-align: center;
}
.moo-crop__error-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius);
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: var(--color-danger);
  box-shadow: 0 10px 28px rgba(244, 63, 94, 0.15);
}
.moo-crop__error-text {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-primary);
  max-width: 300px;
  line-height: 1.4;
}
.moo-crop__error-retry {
  margin-top: 4px;
  padding: 11px 22px;
  height: 42px;
  border-radius: var(--radius);
  border: none;
  background: var(--grad-primary);
  color: var(--color-bg);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.02em;
  box-shadow: 0 8px 24px rgba(0, 229, 160, 0.25);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.moo-crop__error-retry:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(0, 229, 160, 0.35);
}
.moo-crop__error-retry:active { transform: translateY(0); }

/* Settings responsive */
/* ===== TOOLS PAGE OVERHAUL ===== */

/* Content area */
.moo-tools {
  background: transparent !important;
  color: var(--color-text-primary);
  padding-top: 20px !important;
  padding-bottom: 20px !important;
  height: calc(100% - 174px) !important;
}

/* ---- Tool pages (Medication, Time Tracker) ---- */
.moo-tools__empty {
  color: var(--text-3);
  text-align: center;
  padding: 60px 0;
  font-size: 15px;
}

/* ---- Medication list items ---- */
.moo-tools__med-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--inset-hi);
  color: var(--text-1);
  text-decoration: none;
  margin-bottom: 10px;
  transition: background-color var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out), transform var(--dur-1) var(--ease-out);
}
.moo-tools__med-item:last-child,
.moo-tools__med-item:last-of-type { margin-bottom: 0; }
.moo-tools__med-item:active { background: var(--surface-2); transform: scale(0.99); }
.moo-tools__med-item.moo-med-due {
  border-color: var(--accent-line);
  background: linear-gradient(135deg, rgba(0, 229, 160, 0.10), rgba(0, 229, 160, 0.03));
}
.moo-tools__med-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: var(--radius);
  background: rgba(251, 113, 133, 0.13);
  color: #fb8396;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
}
.moo-med-due .moo-tools__med-icon { background: var(--accent-soft); color: var(--accent); }
.moo-tools__med-info {
  flex: 1;
  min-width: 0;
}
.moo-tools__med-name {
  font-size: var(--fs-md);
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.moo-tools__med-detail {
  font-size: var(--fs-sm);
  color: var(--text-3);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.moo-tools__med-time {
  flex-shrink: 0;
  font-size: var(--fs-md);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
}
.moo-med-due .moo-tools__med-time { color: var(--accent); }
.moo-med-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.moo-med-due-badge,
.moo-med-reorder-badge,
.moo-med-reorder-badge--overdue {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--radius);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.02em;
  text-transform: none;
}
.moo-med-due-badge { background: var(--accent); color: var(--accent-ink); }

/* Medication detail hero */
.moo-med-hero {
  padding: 18px;
  margin-bottom: 14px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--inset-hi);
}
.moo-med-hero--due {
  border-color: var(--accent-line);
  background: linear-gradient(160deg, rgba(0, 229, 160, 0.12), rgba(0, 229, 160, 0.02) 60%);
}
.moo-med-hero--due .moo-tools__med-icon { background: var(--accent-soft); color: var(--accent); }
.moo-med-hero__top { display: flex; align-items: center; gap: 14px; }
.moo-med-hero__id { min-width: 0; flex: 1; }
.moo-med-hero__name {
  font-size: var(--fs-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.moo-med-hero__sub { margin-top: 2px; font-size: var(--fs-sm); color: var(--text-3); }
.moo-med-hero__stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}
.moo-med-hero__stat {
  padding: 12px 14px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--hairline);
}
.moo-med-hero__stat-label {
  font-size: var(--fs-2xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
}
.moo-med-hero__stat-value {
  margin-top: 4px;
  font-size: var(--fs-body);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--text-1);
}
.moo-med-hero--due .moo-med-hero__stat:first-child .moo-med-hero__stat-value { color: var(--accent); }
.moo-med-hero__cta { margin-top: 14px; }

/* Stack of labelled inline forms inside one card */
.moo-field-stack { padding: 6px 18px; }
.moo-field { padding: 14px 0; }
.moo-field + .moo-field { border-top: 1px solid var(--hairline); }
.moo-field .cn_input_title { margin-top: 0; }
.moo-btn-row { display: flex; gap: 8px; }
.moo-btn-row > button, .moo-btn-row > .moo-btn { flex: 1 1 0; }
.moo-med-reorder-date {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-size: var(--fs-body);
  color: var(--text-2);
}
.moo-med-reorder-date i { color: var(--warning); }
.moo-med-reorder-date strong { color: var(--text-1); font-weight: 650; }

/* Medication taken banner */
.moo-med-taken-banner {
  margin-bottom: 16px;
}
.moo-med-taken-banner button {
  width: 100%;
  height: 52px;
  padding: 0 24px;
  background: linear-gradient(180deg, #1df2b4 0%, var(--accent) 45%, var(--accent-strong) 100%);
  border: none;
  border-radius: var(--radius);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: var(--fs-md);
  font-family: var(--font-ui);
  cursor: pointer;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.moo-med-taken-banner button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 229, 160, 0.25);
}
.moo-med-taken-banner button:active {
  transform: translateY(0) scale(0.98);
}

/* Medication reorder banner */
.moo-med-reorder-banner {
  margin-bottom: 14px;
  background: var(--warning-soft);
  border: 1px solid rgba(251, 191, 36, 0.28);
  border-radius: var(--radius);
  padding: 14px;
}
.moo-med-reorder-banner__label {
  color: var(--warning);
  font-size: var(--fs-body);
  font-weight: 650;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.moo-med-reorder-banner button {
  width: 100%;
  height: var(--h-control-sm);
  padding: 0 18px;
  background: rgba(251, 191, 36, 0.16);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: var(--radius);
  color: var(--warning);
  font-weight: 650;
  font-size: var(--fs-sm);
  font-family: var(--font-ui);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color var(--dur-2) var(--ease-out), transform var(--dur-1) var(--ease-out);
}
.moo-med-reorder-banner button:active { transform: scale(0.98); }

/* Medication reorder list badges */
.moo-med-reorder-badge { background: var(--warning-soft); color: var(--warning); }
.moo-med-reorder-badge--overdue { background: var(--danger-soft); color: var(--danger); }
.moo-tools__med-item.moo-med-reorder-due {
  border-color: rgba(251, 191, 36, 0.2);
  background: rgba(251, 191, 36, 0.04);
}

/* Medication date input */
.moo-tools .moo-settings-card input[type="date"],
.moo-tools .moo-form-card input[type="date"] {
  color-scheme: dark;
}

/* Medication custom date picker */
.moo-med-datepicker {
  margin-top: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 12px;
  animation: mooCalIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  box-sizing: border-box;
}
@keyframes mooCalIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.moo-med-datepicker__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.moo-med-datepicker__nav {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  color: var(--text-1);
  font-size: 13px;
  font-family: var(--font-ui);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s, background-color 0.2s, border-color 0.2s, transform 0.2s;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
.moo-med-datepicker__nav:active {
  background: rgba(0, 229, 160, 0.12);
  border-color: rgba(0, 229, 160, 0.25);
  transform: scale(0.92);
}
.moo-med-datepicker__nav--disabled {
  opacity: 0.15;
  pointer-events: none;
}
.moo-med-datepicker__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text-primary);
}
.moo-med-datepicker__weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  margin-bottom: 4px;
}
.moo-med-datepicker__weekday {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-4);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 0;
}
.moo-med-datepicker__days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-gap: 4px;
  gap: 4px;
}
.moo-med-datepicker__day {
  height: 36px;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-primary);
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity 0.15s, background-color 0.15s, color 0.15s, border-color 0.15s, transform 0.15s;
  border: 1px solid transparent;
  background: none;
  padding: 0;
  font-family: var(--font-ui);
  -webkit-tap-highlight-color: transparent;
}
.moo-med-datepicker__day:active:not(.moo-med-datepicker__day--past):not(.moo-med-datepicker__day--empty) {
  transform: scale(0.88);
  background: rgba(0, 229, 160, 0.15);
}
.moo-med-datepicker__day--empty {
  cursor: default;
}
.moo-med-datepicker__day--past {
  color: var(--text-4);
  opacity: 0.5;
  cursor: default;
}
.moo-med-datepicker__day--today {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
  font-weight: 700;
}
.moo-med-datepicker__day--selected {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  border-color: transparent;
}
/* Override generic button styles on datepicker day cells */
.moo-med-datepicker__day {
  padding: 0 !important;
  margin: 0 !important;
  height: 38px !important;
}

/* Medication detail cards — reuse settings card styles */
.moo-tools .moo-settings-card__value {
  color: var(--text-3);
  font-size: 15px;
}


/* ALM-061(d): generic tool-wide subtext helper, relocated here from the alarm
   block where it was mis-filed. Applies to ALL tools (not alarm-specific). */
.moo-tools .cn_subtext {
  color: var(--text-3);
  font: 500 12px/1.45 var(--font-ui);
  margin-top: 12px;
}


/* Delete confirm modal — reuses .moo-nc-modal__ shell */
#med_del_wrap {
  position: absolute;
  inset: 0;
  background: rgba(6, 13, 16, 0.6);
  z-index: 999;
  animation: mooOverlayIn 0.2s ease-out;
}
#med_del_modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  flex-direction: column;
  background: var(--surface-sheet);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  width: min(380px, calc(100% - 48px));
  max-height: calc(100vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 48px);
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 48px);
  z-index: 9999;
  color: var(--color-text-primary);
  animation: mooModalIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}
.moo-da-modal__msg {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.55;
  text-align: center;
}
.moo-da-modal__msg strong {
  color: var(--color-text-primary);
  font-weight: 700;
  word-break: break-word;
}
#med_del_modal .moo-da-modal__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
}



/* Note lock screen */
.moo-note-lock {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  height: 100%;
  min-height: 0;
  padding: 40px 24px;
}
.moo-note-lock__icon {
  width: 72px;
  height: 72px;
  border-radius: var(--radius);
  background: rgba(0, 229, 160, 0.06);
  border: 1px solid rgba(0, 229, 160, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: var(--color-accent);
  margin-bottom: 20px;
  box-shadow: 0 0 40px rgba(0, 229, 160, 0.08);
}
.moo-note-lock__title {
  font-size: 20px;
  font-weight: 800;
  color: var(--color-text-primary);
  letter-spacing: -0.3px;
  margin-bottom: 6px;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.moo-note-lock__subtitle {
  font-size: 13px;
  color: var(--text-4);
  margin-bottom: 28px;
}
.moo-note-lock__form {
  width: 100%;
  max-width: 280px;
}
.moo-pw-mask {
  -webkit-text-security: disc;
  text-security: disc;
}
.moo-note-lock__input {
  width: calc(100% - 36px);
  background: var(--surface-1);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  color: var(--color-text-primary);
  padding: 16px 18px;
  font-size: 16px;
  font-weight: 500;
  font-family: var(--font-ui);
  outline: none;
  text-align: center;
  letter-spacing: 2px;
  -webkit-appearance: none;
  transition: border-color 0.2s;
}
.moo-note-lock__input:focus {
  border-color: rgba(0, 229, 160, 0.4);
}
.moo-note-lock__input::placeholder {
  color: var(--text-4);
  letter-spacing: 0;
}
.moo-note-lock__error {
  font-size: 12px;
  color: var(--color-danger);
  font-weight: 600;
  margin-top: 8px;
}
.moo-note-lock__error:empty {
  display: none;
}
.moo-note-lock__btn {
  width: 100%;
  padding: 16px;
  background: var(--grad-primary);
  border: none;
  border-radius: var(--radius);
  color: var(--color-bg);
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}
.moo-note-lock__btn:active {
  transform: scale(0.97);
}

/* ===== CHAT PASSWORD ENCRYPTION ===== */

/* Chat lock screen — fills chat content area below header */
.moo-chat-lock {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
  height: calc(100% - 84px);
  min-height: 0;
  box-sizing: border-box;
}
.moo-chat-lock .moo-note-lock__icon {
  flex-shrink: 0;
  min-width: 72px;
  min-height: 72px;
  box-shadow: 0 0 60px rgba(0, 229, 160, 0.1);
}

/* Pending-access banner — sits above the composer when a send is rejected
   because our share is still pending (stale cached DEK after a re-invite).
   Neutral surface, not mint: this is a calm waiting state, not a CTA or an
   error. Hourglass mirrors the full-screen pending lock so both surfaces read
   as one thing. */
.moo-chat-access-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 12px 0;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  z-index: 5;
}
.moo-chat-access-banner__icon {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: var(--radius);
  background: rgba(0, 229, 160, 0.12);
  color: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.moo-chat-access-banner__text {
  flex: 1;
  min-width: 0;
}
.moo-chat-access-banner__title {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-primary);
  letter-spacing: -0.01em;
}
.moo-chat-access-banner__desc {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
  line-height: 1.4;
}
.moo-chat-access-banner__btn {
  flex-shrink: 0;
  padding: 8px 14px;
  border: none;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.10);
  color: var(--color-text-primary);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}
.moo-chat-access-banner__btn:hover {
  background: rgba(255, 255, 255, 0.16);
}
.moo-chat-access-banner__btn:active {
  transform: scale(0.94);
}

/* Composer dimmed + inert while access is pending (draft stays readable). */
#moo_chat_input_row.moo-input-locked {
  opacity: 0.5;
  pointer-events: none;
}

/* Chat migration overlay — shown while a legacy chat is being upgraded to E2EE.
   Same vertical rhythm as the lock screen, but with a pulsing shield halo to
   signal activity + a rotating status line that updates as phases complete. */
.moo-chat-migrate {
  position: absolute;
  inset: 0;
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
  z-index: 20;
  box-sizing: border-box;
  gap: 6px;
}
.moo-chat-migrate__halo {
  position: relative;
  width: 96px;
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 22px;
}
.moo-chat-migrate__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(0, 229, 160, 0.35);
  animation: moo-chat-migrate-pulse 1.8s cubic-bezier(0.25, 0.8, 0.4, 1) infinite;
}
.moo-chat-migrate__ring--delay {
  animation-delay: 0.6s;
}
.moo-chat-migrate__icon {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(0, 229, 160, 0.1);
  border: 1px solid rgba(0, 229, 160, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-accent);
  font-size: 28px;
  box-shadow: 0 0 40px rgba(0, 229, 160, 0.15);
}
@keyframes moo-chat-migrate-pulse {
  0%   { transform: scale(1);   opacity: 0.85; }
  100% { transform: scale(1.6); opacity: 0; }
}
.moo-chat-migrate__title {
  font-family: var(--font-ui);
  font-size: 17px;
  font-weight: 700;
  color: var(--color-text-primary);
  letter-spacing: -0.01em;
}
.moo-chat-migrate__subtitle {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-3);
  max-width: 280px;
  margin-top: 4px;
}
.moo-chat-migrate__status {
  margin-top: 14px;
  padding: 8px 14px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--hairline);
  font-size: 12px;
  color: var(--text-2);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.moo-chat-migrate__status i {
  color: var(--color-accent);
  font-size: 10px;
}

/* Chat info — encryption status */
.moo-enc-e2ee-desc {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-3);
}
.moo-enc-lock-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
}
.moo-enc-lock-row__title {
  font-size: 14px;
  color: var(--color-text-primary);
  font-weight: 600;
}
.moo-enc-lock-row__desc {
  font-size: 12px;
  color: var(--text-4);
  margin-top: 3px;
}

/* Enable encryption button */
.moo-enc-enable-btn {
  width: 100%;
  padding: 14px 20px;
  background: var(--grad-primary);
  border: none;
  border-radius: var(--radius);
  color: var(--color-bg);
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.moo-enc-enable-btn:active {
  transform: scale(0.97);
}



/* Invite code modal */
#ic_wrap {
  position: absolute;
  inset: 0;
  background: rgba(6, 13, 16, 0.6);
  z-index: 999;
  animation: mooOverlayIn 0.2s ease-out;
}
#ic_modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  flex-direction: column;
  background: var(--surface-sheet);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  width: min(380px, calc(100% - 48px));
  max-height: calc(100vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 48px);
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 48px);
  z-index: 9999;
  color: var(--color-text-primary);
  animation: mooModalIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

/* Settings account modals (username, password, recovery key) */
#cu_wrap, #cp_wrap, #rk_wrap, #tf_wrap, #tfd_wrap, #nm_wrap, #ph_wrap {
  position: absolute;
  inset: 0;
  background: rgba(6, 13, 16, 0.6);
  z-index: 999;
  animation: mooOverlayIn 0.2s ease-out;
}
#cu_modal, #cp_modal, #rk_modal, #tf_modal, #tfd_modal, #nm_modal, #ph_modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  flex-direction: column;
  background: var(--surface-sheet);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  width: min(380px, calc(100% - 48px));
  max-height: calc(100vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 48px);
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 48px);
  z-index: 9999;
  color: var(--color-text-primary);
  animation: mooModalIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}




.moo-note-share__btn {
  padding: 8px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--hairline-strong);
  color: var(--color-text-primary);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: opacity 0.2s, background-color 0.2s, color 0.2s, border-color 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 5px;
}
.moo-note-share__btn--active {
  background: rgba(0, 229, 160, 0.1);
  border-color: rgba(0, 229, 160, 0.25);
  color: var(--color-accent);
}
.moo-note-share__btn--cancel {
  background: rgba(244, 63, 94, 0.1);
  border-color: rgba(244, 63, 94, 0.25);
  color: var(--color-danger);
}
.moo-note-share__btn--pending {
  background: rgba(251, 191, 36, 0.08);
  border-color: rgba(251, 191, 36, 0.22);
  color: var(--color-warning);
}
.moo-note-share__btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}
/* ===== GLOBAL TOAST (window.mooToast, main_js.php) =====
   Floats above the tab bar, centred; slides up into view (.moo-toast--visible). */
.moo-toast {
  position: fixed;
  bottom: calc(var(--h-tabbar) + 16px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  box-sizing: border-box;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 13px 18px;
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  z-index: 100005;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: var(--blur-sheet);
  backdrop-filter: var(--blur-sheet);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.3s ease;
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) { .moo-toast { transition: opacity 0.2s ease; } }
.moo-toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.moo-toast i { font-size: 14px; flex-shrink: 0; }
.moo-toast--error {
  background: rgba(32, 12, 18, 0.92);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: var(--color-toast-error);
}
.moo-toast--error i { color: var(--color-danger); }
.moo-toast--warn {
  background: rgba(32, 26, 12, 0.92);
  border: 1px solid rgba(251, 191, 36, 0.3);
  color: var(--color-toast-warn);
}
.moo-toast--warn i { color: var(--color-warning); }
.moo-toast--info {
  background: rgba(12, 26, 22, 0.92);
  border: 1px solid rgba(0, 229, 160, 0.28);
  color: var(--color-toast-info);
}
.moo-toast--info i { color: var(--color-accent); }

/* ===== SHARED DOWNLOAD PROGRESS MODAL ===== */
/* Shown while a file is being fetched + decrypted. Mirrors the visual
   language of the upload queue modal so both flows feel consistent.
   Single vertical column around a big progress ring — no flex-row
   fragility on narrow viewports. Cancel button is absolutely positioned
   top-right so it never competes with content for horizontal space. */
#cd_dl_overlay {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 600px 300px at 50% 20%, rgba(0, 229, 160, 0.07), transparent 70%),
    rgba(6, 13, 16, 0.85);
  z-index: 100002;
  animation: mooOverlayIn 0.25s ease-out;
}
#cd_dl_modal {
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  width: calc(100% - 32px) !important;
  max-width: 380px !important;
  background:
    radial-gradient(ellipse 380px 180px at 50% 0%, rgba(0, 229, 160, 0.08), transparent 70%),
    var(--surface-1) !important;
  border: 1px solid var(--hairline) !important;
  border-radius: var(--radius) !important;
  box-shadow:
    0 40px 100px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(0, 229, 160, 0.04) inset !important;
  z-index: 100003 !important;
  animation: mooModalIn 0.25s ease-out;
  overflow: hidden !important;
  padding: 36px 28px 32px 28px !important;
  text-align: center !important;
  box-sizing: border-box !important;
  /* Force flex column so all children stack vertically and centre regardless
     of any generic #cd_dl_modal selectors elsewhere in the cascade. Note
     `display` is deliberately NOT set here — the inline HTML style starts it
     hidden and the JS `.css('display', 'flex')` toggles it on. Setting display
     with !important here would block the JS show/hide. */
  flex-direction: column !important;
  align-items: center !important;
  justify-content: flex-start !important;
}
/* All download-modal children use ID+class selectors so their specificity
   beats `#cd_dl_modal > *`-style and bare-class rules elsewhere — immune to
   cascade surprises from future generic rules. */

/* Close button — absolute-positioned in corner, doesn't participate in flow. */
#cd_dl_modal > .moo-cddl__close {
  position: absolute !important;
  top: 14px !important;
  right: 14px !important;
  left: auto !important;
  width: 34px !important;
  height: 34px !important;
  max-width: 34px !important;
  background: var(--surface-2) !important;
  border: 1px solid var(--hairline) !important;
  color: var(--text-2) !important;
  border-radius: var(--radius) !important;
  cursor: pointer !important;
  font-size: 13px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  padding: 0 !important;
  z-index: 2 !important;
  margin: 0 !important;
  box-sizing: border-box !important;
}
#cd_dl_modal > .moo-cddl__close:hover {
  background: rgba(244, 63, 94, 0.18) !important;
  color: var(--color-danger) !important;
  border-color: rgba(244, 63, 94, 0.35) !important;
}

/* Ring wrapper — fixed 120px square, auto-centred horizontally by margin. */
#cd_dl_modal > .moo-cddl__ring-wrap {
  position: relative !important;
  width: 120px !important;
  height: 120px !important;
  min-width: 0 !important;
  max-width: 120px !important;
  margin: 0 auto 22px auto !important;
  padding: 0 !important;
  display: block !important;
  flex-shrink: 0 !important;
  box-sizing: border-box !important;
}
#cd_dl_modal .moo-cddl__ring {
  width: 120px !important;
  height: 120px !important;
  display: block !important;
  overflow: visible;
}
#cd_dl_modal .moo-cddl__ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.06);
  stroke-width: 7;
}
#cd_dl_modal .moo-cddl__ring-fg {
  fill: none;
  stroke: var(--color-accent);
  stroke-width: 7;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.3s ease-out;
  filter: drop-shadow(0 0 10px rgba(0, 229, 160, 0.55));
}
#cd_dl_modal .moo-cddl__ring-pct {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: auto !important;
  height: auto !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 22px !important;
  font-weight: 800 !important;
  color: var(--color-accent) !important;
  font-variant-numeric: tabular-nums !important;
  letter-spacing: -0.02em;
  margin: 0 !important;
  padding: 0 !important;
}

/* Text rows — block-level, full width, centred by text-align + flexbox parent.
   min-width: 0 is CRITICAL so long filenames trigger text-overflow: ellipsis
   instead of forcing the flex item wider than the modal. */
#cd_dl_modal > .moo-cddl__title,
#cd_dl_modal > .moo-cddl__filename,
#cd_dl_modal > .moo-cddl__phase,
#cd_dl_modal > .moo-cddl__bytes {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  text-align: center !important;
  flex-shrink: 0 !important;
  box-sizing: border-box !important;
  padding: 0 !important;
}
#cd_dl_modal > .moo-cddl__title {
  font-size: 16px !important;
  font-weight: 700 !important;
  color: var(--color-text-primary) !important;
  letter-spacing: 0.01em;
  margin: 0 0 6px 0 !important;
}
#cd_dl_modal > .moo-cddl__filename {
  font-size: 12px !important;
  color: var(--text-3) !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  margin: 0 0 20px 0 !important;
  font-weight: 500 !important;
}
#cd_dl_modal > .moo-cddl__phase {
  font-size: 13px !important;
  font-weight: 600 !important;
  color: rgba(0, 229, 160, 0.9) !important;
  letter-spacing: 0.02em;
  text-transform: uppercase !important;
  margin: 0 0 6px 0 !important;
}
#cd_dl_modal > .moo-cddl__bytes {
  font-size: 12px !important;
  color: var(--text-3) !important;
  font-variant-numeric: tabular-nums !important;
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace !important;
  min-height: 1em !important;
  margin: 0 !important;
}

/* ---- Admin / Developer tables ---- */
.moo-tools .table_cont {
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
}
.moo-tools .table_header {
  background: var(--surface-1);
  padding: 16px 20px;
  color: var(--color-text-primary);
  font-weight: 700;
  font-size: 16px;
  border-bottom: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  gap: 10px;
}
.moo-tools .table_header i {
  color: var(--color-accent);
  font-size: 14px;
}
.moo-tools .table_content {
  background: transparent;
}
.moo-tools .table_headers {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  border-bottom: 1px solid var(--hairline);
}
.moo-tools .table_row {
  font-size: 13px;
  color: var(--text-2);
}
.moo-tools .table_row_content {
  border-bottom: 1px solid var(--hairline);
}
.moo-tools .table_row_content:last-child {
  border-bottom: 0;
}
.moo-tools .table_row_content:nth-child(odd) {
  background: rgba(14, 22, 28, 0.88);
}
.moo-tools .table_row_content b {
  color: var(--text-1);
}
.moo-tools .table_column {
  padding: 14px 16px;
  font-size: 13px;
}
.moo-tools .table_buttons button {
  background: rgba(244, 63, 94, 0.1) !important;
  border: 1px solid rgba(244, 63, 94, 0.2) !important;
  color: var(--color-danger) !important;
  border-radius: var(--radius) !important;
  width: 28px !important;
  height: 28px !important;
  padding: 0 !important;
  cursor: pointer;
  transition: opacity 0.2s, background-color 0.2s;
}
.moo-tools .table_buttons button:hover {
  background: rgba(244, 63, 94, 0.2) !important;
}
.moo-tools .fa_eye_slash_button {
  background: rgba(245, 158, 11, 0.1) !important;
  border: 1px solid rgba(245, 158, 11, 0.2) !important;
  color: var(--color-warning) !important;
}
.moo-tools .fa_eye_slash_button:hover {
  background: rgba(245, 158, 11, 0.2) !important;
}
.moo-tools .table_open_content_button {
  background: rgba(0, 229, 160, 0.1);
  border: 1px solid rgba(0, 229, 160, 0.15);
  color: var(--color-accent);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 700;
  padding: 0 12px;
  height: 28px;
}
.moo-tools .table_norows {
  padding: 20px;
  color: var(--text-4);
  font-size: 14px;
  text-align: left;
}
.moo-tools .tc_margintop {
  margin-top: 16px;
}

/* Content dialog modal (admin) */
body:has(.moo-tools) #content_dialog_wrap {
  background: rgba(6, 13, 16, 0.6);
  animation: mooOverlayIn 0.2s ease-out;
}
body:has(.moo-tools) #cd_popup {
  background: var(--surface-sheet);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 24px;
  width: 80%;
  max-height: 80%;
  color: var(--text-2);
  animation: mooModalIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
body:has(.moo-tools) .content_dialog_text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-2);
}

/* Tools responsive */
@media (max-width: 480px) {
  .moo-tools .table_column {
    padding: 10px 12px;
    font-size: 12px;
  }
}

/* ===== CHATS LIST PAGE OVERHAUL ===== */

/* Content area */
.moo-chats {
  background: transparent !important;
  color: var(--color-text-primary);
  padding-top: 20px !important;
  padding-bottom: 0px !important;
  height: calc(100% - 154px) !important;
}

/* Chat list rows — flat messenger rows on the aurora: a press plate, an
   inset hairline between rows (starting after the avatar), mint for unread. */
:is(.moo-chats, .contacts_page) .chat_cont {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 72px;
  margin: 0 -8px !important;
  padding: 10px 8px !important;
  border: 0 !important;
  border-radius: var(--radius);
  background: transparent;
  position: relative;
  transition: background-color var(--dur-2) var(--ease-out);
}
:is(.moo-chats, .contacts_page) .chat_cont::after {
  content: '';
  position: absolute;
  left: 74px;
  right: 8px;
  bottom: 0;
  height: 1px;
  background: var(--hairline);
}
.moo-chats a:last-of-type .chat_cont::after,
#getContacts_API > a:last-child .chat_cont::after,
.fr_list_cont > a:last-child .chat_cont::after { display: none; }
@media (hover: hover) {
  :is(.moo-chats, .contacts_page) .chat_cont:hover { background: var(--surface-1); }
}
:is(.moo-chats, .contacts_page) .chat_cont:active { background: var(--surface-2); }
:is(.moo-chats, .contacts_page) .chat_cont_first { padding-top: 10px !important; }
:is(.moo-chats, .contacts_page) .chat_cont_picture {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
}
:is(.moo-chats, .contacts_page) .chat_cont_picture img {
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px var(--hairline);
  /* Placeholder tint so an avatar that hasn't decoded yet reads as an intentional
     rounded tile (the list paints before avatars finish loading). */
  background: var(--surface-2);
}
:is(.moo-chats, .contacts_page) .chat_cont_name {
  margin-left: 0;
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  padding-right: 64px;
  color: var(--text-1);
}
:is(.moo-chats, .contacts_page) .chat_name_title {
  font-size: var(--fs-md);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
:is(.moo-chats, .contacts_page) .chat_name_sub {
  margin-top: 3px;
  font-size: var(--fs-sm);
  line-height: 1.4;
  color: var(--text-3);
  -webkit-line-clamp: 1;
  line-clamp: 1;
}
:is(.moo-chats, .contacts_page) .chat_cont--unread .chat_name_title { font-weight: 700; }
:is(.moo-chats, .contacts_page) .chat_cont--unread .chat_name_sub { color: var(--text-2); }

/* Right column: time, then muted bell / unread pill */
:is(.moo-chats, .contacts_page) .chat_right_info {
  right: 8px;
  top: 14px;
  transform: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  font-size: var(--fs-xs);
}
:is(.moo-chats, .contacts_page) .chat_right_dt {
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
:is(.moo-chats, .contacts_page) .chat_cont--unread .chat_right_dt { color: var(--accent); font-weight: 600; }
.chat_right_badges {
  display: flex;
  align-items: center;
  gap: 6px;
}
.chat_muted_icon {
  font-size: 12px;
  color: var(--text-4);
}
/* Unread pill — a square at one digit, grows into a pill for 2+ (server caps 99+). */
:is(.moo-chats, .contacts_page) .chat_unread_messages {
  float: none;
  margin: 0;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: var(--fs-2xs);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  width: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  box-sizing: border-box;
  border-radius: var(--radius);
}

/* Chat rows are block-level so the FLIP reorder transform applies (anchors
   are inline by default, and transforms don't render on inline boxes). The
   animation itself is Web Animations API in loadChats — no transition class
   here; reduced motion is gated in JS (_mooReducedMotion). */
.moo-chats .cli_finder {
  display: block;
}

/* No chats empty state — an invitation to act, not a dead end */
.moo-chats .chats_list_none {
  text-align: center;
  padding: 56px 24px;
}
.moo-chats .cln_icon {
  width: 56px;
  height: 56px;
  margin: 0 auto;
  border-radius: var(--radius);
  background: rgba(0, 229, 160, 0.08);
  border: 1px solid rgba(0, 229, 160, 0.14);
  color: var(--color-accent);
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.moo-chats .cln_title {
  margin-top: 16px;
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text-primary);
}
.moo-chats .cln_text {
  margin-top: 6px;
  margin-left: auto;
  margin-right: auto;
  max-width: 280px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-3);
}
.moo-chats .cln_button { margin-top: 20px; }

/* Connection-failure notice (mooChatsPollFailed shows it after 3 misses) */
.moo-chats .chats_list_error {
  display: none;
  text-align: center;
  padding: 56px 24px;
  font-size: 14px;
  color: var(--text-3);
}

/* Last chat item — bottom spacing via margin to work around WebKit ignoring padding-bottom on scroll containers */
.moo-chats::after {
  content: '';
  display: block;
  height: 20px;
}

/* ===== CHAT INFO PAGE OVERHAUL ===== */

/* Content area */
.moo-chatinfo {
  background: transparent !important;
  color: var(--color-text-primary);
  padding: 20px !important;
  height: calc(100% - 104px) !important;
  width: calc(100% - 40px) !important;
}

/* F14: /info slide-over panel — fetched .moo-chatinfo fragment slides in over
   the chat view (no full-page reload, DEK reused). Right-anchored; full-width on
   phones, a side sheet on desktop. */
.moo-info-panel {
  position: fixed;
  top: 0; /* JS sets this to the chat top-bar's bottom on open */
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.moo-info-panel.is-open { transform: translateX(0); }
.moo-info-panel__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: none;
  padding-bottom: env(safe-area-inset-bottom);
}
/* The injected fragment keeps its .chat_info_cont class (overflow:scroll +
   overscroll-behavior:none). With auto height it can't scroll yet TRAPS the
   desktop wheel — force it to a plain flow block so the panel body is the single
   scroller (touch already worked; this restores wheel scrolling). */
.moo-info-panel .moo-chatinfo { height: auto !important; overflow: visible !important; }
@media (prefers-reduced-motion: reduce) {
  .moo-info-panel {
    transition: opacity 0.2s ease;
    transform: none;
    opacity: 0;
    pointer-events: none;
  }
  .moo-info-panel.is-open { opacity: 1; pointer-events: auto; }
}

/* F5: muted notifications icon (warning tint), toggled by the inline mute JS. */
.moo-chatinfo .moo-settings-card__icon.is-muted {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.15);
  color: var(--color-warning);
}
/* Group picture */
.moo-chatinfo .moo-ap-buttons {
  display: flex;
  gap: 8px;
}

/* Chat participants list — flat rows inside the card */
.moo-chatinfo .chat_participants {
  margin: 4px -18px -18px;
}
.moo-chatinfo .chat_cont {
  background: transparent;
  border: 0 !important;
  border-top: 1px solid var(--hairline) !important;
  border-radius: 0;
  padding: 10px 18px !important;
  margin: 0 !important;
  gap: 12px;
  transition: background-color var(--dur-2) var(--ease-out);
}
.moo-chatinfo .chat_cont:active { background: var(--surface-2); }
.moo-chatinfo .chat_cont_first { padding-top: 10px !important; }
.moo-chatinfo .chat_cont_picture { width: 44px; height: 44px; flex-shrink: 0; }
.moo-chatinfo .chat_cont_picture img {
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px var(--hairline);
  background: var(--surface-2);
}
.moo-chatinfo .chat_cont_name {
  margin-left: 0;
  width: calc(100% - 60px);
}
.moo-chatinfo .chat_name_title {
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Leave chat button */
.moo-chatinfo__leave {
  margin-top: 16px;
}
.moo-chatinfo__leave button {
  width: 100%;
  box-sizing: border-box;
  height: var(--h-control);
  padding: 0 18px;
  background: var(--danger-soft);
  border: 1px solid var(--danger-line);
  border-radius: var(--radius);
  color: var(--danger);
  font-weight: 600;
  font-size: var(--fs-body);
  font-family: var(--font-ui);
  cursor: pointer;
  transition: opacity 0.2s, background-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.moo-chatinfo__leave button:hover {
  background: rgba(244, 63, 94, 0.15);
}

/* ===== GROUP ADMIN ROLES ===== */

/* Member badges row */
.moo-member-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}

/* Admin badge pill */
.moo-admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(0, 229, 160, 0.1);
  border: 1px solid rgba(0, 229, 160, 0.18);
  color: var(--color-accent);
  font-size: 9px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: var(--radius);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  line-height: 1.4;
}
.moo-admin-badge i {
  font-size: 7px;
}

/* You badge */
.moo-you-badge {
  color: var(--text-4);
  font-size: 11px;
  font-weight: 600;
}

/* Pending badge — E2EE chats, member waiting on DEK wrap completion */
.moo-pending-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.2);
  color: var(--color-warning);
  font-size: 9px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: var(--radius);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  line-height: 1.4;
}
.moo-pending-badge i {
  font-size: 7px;
}

/* Member row with action buttons (admin view) */
.moo-chatinfo .moo-member-row {
  display: flex;
  align-items: center;
}
.moo-chatinfo .moo-member-link {
  display: flex;
  align-items: center;
  gap: 12px; /* same avatar-to-name gap as a plain .chat_cont row */
  flex: 1;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}
.moo-chatinfo .moo-member-row .chat_cont_name {
  width: auto;
  flex: 1;
  min-width: 0;
}
.moo-chatinfo .moo-member-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  margin-left: 8px;
}
.moo-chatinfo .moo-member-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  border: 1px solid var(--hairline);
  background: var(--surface-1);
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 11px;
  transition: opacity 0.2s, background-color 0.2s, color 0.2s, border-color 0.2s;
  padding: 0;
}
.moo-chatinfo .moo-member-btn:hover {
  background: rgba(0, 229, 160, 0.1);
  border-color: rgba(0, 229, 160, 0.25);
  color: var(--color-accent);
}
.moo-chatinfo .moo-member-btn--active {
  background: rgba(0, 229, 160, 0.1);
  border-color: rgba(0, 229, 160, 0.2);
  color: var(--color-accent);
}
.moo-chatinfo .moo-member-btn--danger:hover {
  background: rgba(244, 63, 94, 0.1) !important;
  border-color: rgba(244, 63, 94, 0.25) !important;
  color: var(--color-danger) !important;
}

/* Remove member modal */
#grm_wrap {
  position: absolute;
  inset: 0;
  background: rgba(6, 13, 16, 0.7);
  z-index: 100000; /* above the F14 /info slide-over panel (10000) */
  animation: mooOverlayIn 0.2s ease-out;
}
#grm_modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100001;
  background: var(--surface-sheet);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 28px;
  box-sizing: border-box;
  width: min(340px, calc(100% - 32px));
  text-align: center;
  animation: mooModalIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.moo-grm__icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.15);
  color: var(--color-danger);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin: 0 auto 16px;
}
.moo-grm__title {
  font-size: 18px;
  font-weight: 800;
  color: var(--color-text-primary);
  margin-bottom: 8px;
}
.moo-grm__text {
  font-size: 14px;
  color: var(--text-3);
  line-height: 1.5;
  margin-bottom: 24px;
}
.moo-grm__text strong {
  color: var(--color-text-primary);
  font-weight: 700;
}
.moo-grm__buttons {
  display: flex;
  gap: 10px;
}
.moo-grm__btn {
  flex: 1;
  padding: 13px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: opacity 0.2s, background-color 0.2s, color 0.2s, border-color 0.2s;
  border: none;
}
.moo-grm__btn--cancel {
  background: var(--surface-2);
  border: 1px solid var(--hairline-strong);
  color: var(--color-text-primary);
}
.moo-grm__btn--cancel:hover {
  background: var(--surface-3);
}
.moo-grm__btn--remove {
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.25);
  color: var(--color-danger);
}
.moo-grm__btn--remove:hover {
  background: rgba(244, 63, 94, 0.25);
}

/* Upload picture sub-page (form card) */
.moo-chatinfo .moo-form-card input[type="file"] {
  background: var(--surface-1);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  color: var(--text-2);
  padding: 14px;
  font-size: 14px;
  font-family: var(--font-ui);
  width: calc(100% - 30px);
  margin-bottom: 24px;
  cursor: pointer;
}

/* Mute chat */
.moo-mute-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  font-weight: 600;
  margin-bottom: 12px;
  background: var(--warning-soft);
  border: 1px solid rgba(251, 191, 36, 0.24);
  color: var(--warning);
}
.moo-mute-status i { flex-shrink: 0; }
.moo-mute-form {
  display: flex;
  gap: 8px;
}
.moo-mute-select {
  flex: 1;
  min-width: 0;
  box-sizing: border-box;
  height: var(--h-control);
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  color: var(--text-1);
  padding: 0 40px 0 14px;
  font-size: var(--fs-input);
  font-weight: 500;
  font-family: var(--font-ui);
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23a9b8bf' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 15px center;
}
.moo-mute-select option { background: var(--surface-solid); color: var(--text-1); }
.moo-mute-form button,
.moo-unmute-btn {
  box-sizing: border-box;
  height: var(--h-control) !important;
  padding: 0 18px !important;
  background: var(--surface-2) !important;
  border: 1px solid var(--hairline-strong) !important;
  border-radius: var(--radius) !important;
  color: var(--text-1) !important;
  font-size: var(--fs-body) !important;
  font-weight: 600 !important;
  font-family: var(--font-ui);
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out);
}
.moo-mute-form button { width: auto !important; }
.moo-unmute-btn { width: 100%; }
@media (hover: hover) {
  .moo-mute-form button:hover,
  .moo-unmute-btn:hover {
    background: var(--accent-soft) !important;
    border-color: var(--accent-line) !important;
    color: var(--accent) !important;
  }
}

/* ===== GLOBAL IMAGE VIEWER ===== */
#moo_img_viewer {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-top: calc(20px + env(safe-area-inset-top, 0));
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0));
  animation: mooImgViewerIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
#moo_img_viewer_bg {
  position: absolute;
  inset: 0;
  background: rgba(6, 13, 16, 0.92);
  z-index: -1;
}
@keyframes mooImgViewerIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}
#moo_img_close {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top, 0));
  right: calc(16px + env(safe-area-inset-right, 0));
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--hairline-strong);
  color: var(--color-text-primary);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.2s, background-color 0.2s, color 0.2s, border-color 0.2s;
  z-index: 2;
  padding: 0;
  margin: 0;
}
#moo_img_close:hover {
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.3);
  color: var(--color-danger);
}
#moo_img_container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  width: 100%;
  margin-top: 60px;
  pointer-events: none;
}
#moo_img_preview {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  /* The gesture handler owns all directions (pan / double-tap zoom / swipe-down
     dismiss), so opt out of the global touch-action: pan-y. */
  touch-action: none;
  transform-origin: center center;
}

/* Video.js player wrapper */
#moo_vid_wrap {
  position: relative;
  width: 100%;
  height: 100%;
  pointer-events: auto;
  /* Square corners on the open video player — keep the box-shadow for depth
   * but no rounding on the visible video frame or the title bar above it. */
  border-radius: 0;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  /* Flex column so the title bar can sit ABOVE the player at full width
   * (instead of being a partial-width overlay), and the player flexes to
   * fill the remaining height. Without this layout the video would still
   * fill 100% height and push the title under it. */
  display: flex;
  flex-direction: column;
  background: #060d10;
}
#moo_vid_wrap > #moo_vid_preview,
#moo_vid_wrap > .video-js {
  flex: 1 1 auto;
  min-height: 0;
}

/* Video.js dark theme overrides */
#moo_vid_wrap .video-js {
  background-color: transparent;
  font-family: var(--font-ui);
}
#moo_vid_wrap .video-js .vjs-tech {
  border-radius: 0;
}
#moo_vid_wrap .vjs-big-play-button {
  background: rgba(0, 229, 160, 0.15);
  border: 2px solid rgba(0, 229, 160, 0.4);
  border-radius: var(--radius);
  width: 70px;
  height: 70px;
  line-height: 70px;
  font-size: 30px;
  top: 50%;
  left: 50%;
  margin-top: -35px;
  margin-left: -35px;
  transition: opacity 0.2s, background-color 0.2s, border-color 0.2s;
}
#moo_vid_wrap .vjs-big-play-button .vjs-icon-placeholder::before {
  display: flex;
  align-items: center;
  justify-content: center;
}
#moo_vid_wrap .vjs-big-play-button:hover,
#moo_vid_wrap .vjs-big-play-button:focus {
  background: rgba(0, 229, 160, 0.25);
  border-color: rgba(0, 229, 160, 0.6);
}
/* Hide the big play button while Video.js is buffering — otherwise both the
 * loading spinner AND the big play button render on top of each other during
 * the cold-start of CD video streaming (autoplay is firing in the background
 * but the first chunks aren't decrypted yet). The user only needs the spinner
 * during this window. After playback starts, vjs-has-started replaces vjs-
 * waiting and the button stays hidden naturally. If autoplay was blocked,
 * the player exits vjs-waiting without becoming vjs-has-started → big play
 * shows again so the user can manually start. */
#moo_vid_wrap .vjs-waiting:not(.vjs-has-started) .vjs-big-play-button,
#moo_vid_wrap .video-js.vjs-seeking .vjs-big-play-button,
/* During the explicit loading/recovery windows we manage via JS, NEVER show
 * the big play button or the static "paused" poster. The user clicked a file
 * (or we're auto-recovering after a stall) — they don't need a manual play
 * affordance, they need a spinner that shows we're working. The cd-loading
 * class is set in moo_open_video and cleared on `playing`; cd-recovering
 * is set in attemptRecovery and cleared on `playing`. Both layered with
 * !important to defeat Video.js's own state-class rules. */
#moo_vid_wrap.cd-loading .vjs-big-play-button,
#moo_vid_wrap.cd-loading .vjs-poster,
#moo_vid_wrap.cd-recovering .vjs-big-play-button,
#moo_vid_wrap.cd-recovering .vjs-poster {
  display: none !important;
}
/* cd-force-play: the inverse — FORCE the existing big center mint play button
 * visible when iOS blocked the unmuted autoplay of a downloaded blob (set in
 * moo_open_video on the play() rejection or the 4s backstop; removed on
 * `playing`). The 4-class second selector beats the 3-class vjs-waiting hide
 * above, so the obvious center CTA shows instead of only the small control-bar
 * play. Reuses the existing .vjs-big-play-button styling — no new button. */
#moo_vid_wrap.cd-force-play .vjs-big-play-button,
#moo_vid_wrap.cd-force-play .vjs-waiting:not(.vjs-has-started) .vjs-big-play-button {
  display: block !important;
}
/* ...and while that CTA button is up, HIDE Video.js's own loading spinner.
 * A blocked autoplay can leave the player in vjs-waiting, which renders the
 * native spinner — the user must see ONLY the button, never a spinner behind
 * it. (cd-loading is already removed when cd-force-play is set, so this only
 * suppresses Video.js's native vjs-waiting/seeking spinner.) */
#moo_vid_wrap.cd-force-play .vjs-loading-spinner {
  display: none !important;
}
/* Force the spinner visible during cd-loading + cd-recovering. Video.js may
 * exit vjs-waiting briefly during src() reset of recovery — that flash should
 * still be a spinner, not a play button. visibility: visible bypasses the
 * 300ms grace (vjs-spinner-show animation) so our managed states show the
 * spinner instantly — these states are entered explicitly and the user
 * deserves immediate feedback. */
#moo_vid_wrap.cd-loading .vjs-loading-spinner,
#moo_vid_wrap.cd-recovering .vjs-loading-spinner {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
}
/* During mid-stream recovery, attemptRecovery rebuilds the player by
 * calling player.src(...). Setting a new src forces HTMLVideoElement
 * currentTime back to 0 — there's no API to set currentTime before the
 * new media has reached HAVE_METADATA. We only restore resumeAt inside
 * the loadedmetadata callback, so for the ~50-300 ms between src reset
 * and metadata arriving the progress bar visibly bounces to 0:00 and
 * then snaps back to where the user actually was. Hide the time + scrub
 * UI during BOTH cd-loading and cd-recovering so the user sees only the
 * spinner during ANY load state, full stop. The bar reappears with the
 * correct currentTime as soon as `playing` clears the class. Includes
 * cd-loading so initial-open and post-seek loading states match
 * recovery's UI exactly — flickering between visible-then-hidden as
 * the video transitions through cd-loading → cd-recovering → playing
 * was the source of the "timeline jumps to start" complaint. Volume +
 * fullscreen + play/pause stay visible so the user can still interact
 * with the chrome they expect. */
#moo_vid_wrap.cd-loading .vjs-progress-control,
#moo_vid_wrap.cd-loading .vjs-current-time,
#moo_vid_wrap.cd-loading .vjs-time-divider,
#moo_vid_wrap.cd-loading .vjs-duration,
#moo_vid_wrap.cd-loading .vjs-remaining-time,
#moo_vid_wrap.cd-recovering .vjs-progress-control,
#moo_vid_wrap.cd-recovering .vjs-current-time,
#moo_vid_wrap.cd-recovering .vjs-time-divider,
#moo_vid_wrap.cd-recovering .vjs-duration,
#moo_vid_wrap.cd-recovering .vjs-remaining-time {
  visibility: hidden !important;
}
#moo_vid_wrap .vjs-control-bar {
  background: rgba(6, 13, 16, 0.85);
  border-radius: 0;
  font-family: var(--font-ui);
}

/* Video viewer title bar — refined caption that sits ABOVE the player at
 * full container width. Lives as a flex row at the top of #moo_vid_wrap
 * (which is now display:flex column), so it spans exactly the player's
 * width with no offset. Aurora glass-morphism dark, mint accent icon,
 * ellipsis truncation. We do NOT overlay the player — Video.js's own
 * controls (big play button, loading spinner) need an unobstructed
 * surface so the user sees the canonical engine UI, not our redundant
 * surfaces on top of it. */
.moo-vid-title {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  background: var(--surface-sheet);
  border-bottom: 1px solid var(--hairline);
  font-family: var(--font-ui);
  animation: mooVidTitleIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.moo-vid-title > i {
  font-size: 12px;
  color: var(--color-accent);
  opacity: 0.85;
  flex-shrink: 0;
}
.moo-vid-title__name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.1px;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Alarm evidence multi-camera switcher — pills in the video viewer title
   bar (only shown when an incident recorded >1 camera). Glass-morphism to
   match the alarm aesthetic; active pill takes the viewer's accent. Sits
   right of the (truncating) title name; stays inert + hidden for chat
   video + single-camera incidents. */
.moo-evid-switcher {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.moo-evid-switcher[hidden] { display: none; }
.moo-evid-switcher__pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--alarm-border, rgba(255, 255, 255, 0.07));
  background: var(--alarm-glass-1, rgba(255, 255, 255, 0.035));
  color: var(--alarm-text-secondary, rgba(255, 255, 255, 0.62));
  font: 600 11px/1 var(--font-ui);
  letter-spacing: 0.02em;
  cursor: pointer;
  white-space: nowrap;
  appearance: none;
  -webkit-appearance: none;
  font-family: inherit;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, transform 80ms ease;
}
.moo-evid-switcher__pill > i { font-size: 10px; opacity: 0.8; }
.moo-evid-switcher__pill:active { transform: translateY(1px); }
.moo-evid-switcher__pill:hover:not(.is-active):not(.is-disabled) {
  background: var(--alarm-glass-2, rgba(255, 255, 255, 0.062));
  color: var(--alarm-text-primary, rgba(255, 255, 255, 0.95));
}
.moo-evid-switcher__pill.is-active {
  background: color-mix(in srgb, var(--color-accent) 20%, transparent);
  border-color: color-mix(in srgb, var(--color-accent) 55%, transparent);
  color: var(--color-accent);
  cursor: default;
}
.moo-evid-switcher__pill.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.moo-evid-switcher__unavail {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.75;
  padding-left: 2px;
}
@media (max-width: 480px) {
  .moo-evid-switcher__pill > span:not(.moo-evid-switcher__unavail) {
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
@keyframes mooVidTitleIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

#moo_vid_wrap .vjs-play-progress,
#moo_vid_wrap .vjs-volume-level {
  background: var(--color-accent) !important;
}
#moo_vid_wrap .vjs-play-progress::before {
  color: var(--color-accent) !important;
}
#moo_vid_wrap .vjs-slider {
  background: var(--surface-3);
}
#moo_vid_wrap .vjs-load-progress,
#moo_vid_wrap .vjs-load-progress div {
  background: rgba(255, 255, 255, 0.15);
}
#moo_vid_wrap .vjs-time-control {
  font-size: 12px;
  font-weight: 500;
}
#moo_vid_wrap .vjs-menu-content {
  background: rgba(6, 13, 16, 0.92);
  border-radius: var(--radius);
  font-family: var(--font-ui);
}
#moo_vid_wrap .vjs-menu li.vjs-selected,
#moo_vid_wrap .vjs-menu li.vjs-selected:hover {
  background: var(--color-accent);
  color: var(--color-bg);
}
#moo_vid_wrap .vjs-menu li:hover,
#moo_vid_wrap .vjs-menu li:focus {
  background: var(--surface-3);
}
#moo_vid_wrap .video-js .vjs-poster {
  background-color: var(--color-bg);
}
/* Spinner — clean single-arc design.
 *
 * Video.js ships a dual-arc spinner: ::before and ::after each rotate, and a
 * `vjs-spinner-fade` keyframe animation cycles border-top-color through #fff
 * (35% keyframe) and back to gray. A static border-top-color override gets
 * defeated by the running animation, so the arcs flash white. The visual
 * effect: a green outer ring with two white arcs chasing each other —
 * reads as a "double spinner". Fix: hide the dual pseudo-elements entirely
 * and animate the spinner element itself with one solid green top arc.
 *
 * NOTE: a custom keyframe is required (not Video.js's `vjs-spinner-spin`)
 * because the spinner element relies on `transform: translate(-50%, -50%)`
 * for centering — Video.js's keyframe rotates with no translate, so applying
 * it to the outer element would clobber the translate and the spinner would
 * render in the top-left corner. This keyframe preserves the translate. */
@keyframes moo-spinner-spin-centered {
  0%   { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}
#moo_vid_wrap .vjs-loading-spinner {
  border: 0.42em solid rgba(0, 229, 160, 0.18);
  border-top-color: var(--color-accent);
  width: 4em;
  height: 4em;
  /* Two animations combined: our rotation (continuous) + Video.js's own
   * `vjs-spinner-show` (a 0s/0.3s/forwards animation that flips the
   * spinner's `visibility` from hidden→visible). Video.js's base rule sets
   * the spinner to `visibility: hidden` and relies on the spinner-show
   * keyframe to reveal it after a 300ms grace; if we replace the animation
   * shorthand entirely the spinner is permanently invisible. Combining
   * keeps the natural buffering grace (fast loads don't flash) while
   * giving us the rotation. The cd-loading + cd-recovering rules below
   * force visibility immediately for our managed states. */
  animation:
    moo-spinner-spin-centered 0.85s linear infinite,
    vjs-spinner-show 0s linear 0.3s forwards !important;
}
/* Kill the dual-arc system entirely — would otherwise still flash white via
 * Video.js's vjs-spinner-fade keyframe. The element-level rotation above
 * gives us a single, on-brand, jank-free spinner. */
#moo_vid_wrap .vjs-loading-spinner::before,
#moo_vid_wrap .vjs-loading-spinner::after {
  display: none !important;
}
#moo_vid_wrap .vjs-error-display {
  background: rgba(6, 13, 16, 0.85);
  font-family: var(--font-ui);
}
#moo_vid_wrap .vjs-error-display .vjs-modal-dialog-content {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--color-danger);
  padding: 20px;
}
#moo_vid_wrap .vjs-time-tooltip {
  background: rgba(6, 13, 16, 0.92);
  color: var(--color-text-primary);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius);
  padding: 4px 8px;
}
#moo_vid_wrap .vjs-remaining-time {
  color: var(--text-2);
  font-size: 12px;
}
#moo_vid_wrap .vjs-button > .vjs-icon-placeholder::before {
  font-size: 18px;
}
/* ===== GLOBAL FILE VIEWER (PDF / text / unsupported) ===== */
#moo_pdf_frame {
  width: 100%;
  height: 100%;
  max-width: 1000px;
  border: none;
  border-radius: var(--radius);
  background: #1a1a1a;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
}
/* Canvas-based PDF viewer for iOS (see index.php moo_render_pdf_canvases).
 * Scrollable column of canvases, one per page, each CSS-sized to wrap width
 * so the user just scrolls to read through the whole document. */
#moo_pdf_canvas_wrap {
  width: 100%;
  height: 100%;
  max-width: 1000px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: none;
  background: #1a1a1a;
  border-radius: var(--radius);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  padding: 12px;
  box-sizing: border-box;
  pointer-events: auto;
}
#moo_pdf_canvas_wrap canvas {
  display: block;
  margin: 0 auto 12px auto;
  background: white;
  border-radius: var(--radius);
  max-width: 100%;
}
#moo_pdf_canvas_wrap canvas:last-child { margin-bottom: 0; }
.moo-pdf__loading,
.moo-pdf__error {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 60px;
  padding: 20px;
  color: var(--text-3);
  font-size: 14px;
  gap: 10px;
}
.moo-pdf__loading i { font-size: 20px; color: var(--color-accent); }
#moo_text_wrap {
  width: 100%;
  max-width: 900px;
  max-height: 100%;
  flex-direction: column;
  pointer-events: auto;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  background: var(--surface-sheet);
  border: 1px solid var(--hairline);
}
#moo_text_content {
  margin: 0;
  padding: 20px 24px;
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.55;
  color: var(--color-text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  overscroll-behavior: none;
  max-height: 100%;
  tab-size: 2;
  -moz-tab-size: 2;
  flex: 1 1 auto;
  min-height: 0;
}

/* DOCX preview (mammoth.js HTML output) — reuses the text-wrap glass card
   but renders proper HTML instead of monospace pre. */
#moo_docx_wrap {
  width: 100%;
  max-width: 900px;
  max-height: 100%;
  flex-direction: column;
  pointer-events: auto;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  /* DOCX files are authored for a white page — mammoth's converted HTML
     assumes black-on-white with coloured runs/highlights/tables that become
     unreadable on the app's dark theme. Force a true white page background
     + dark text so the document looks like a real Word preview. */
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
}
#moo_docx_content {
  padding: 28px 32px;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.65;
  color: #1a1a1a;
  overflow-y: auto;
  overscroll-behavior: none;
  max-height: 100%;
  flex: 1 1 auto;
  min-height: 0;
  word-wrap: break-word;
}
#moo_docx_content h1 { font-size: 22px; font-weight: 700; margin: 18px 0 10px; color: #111; }
#moo_docx_content h2 { font-size: 19px; font-weight: 700; margin: 16px 0 8px; color: #111; }
#moo_docx_content h3 { font-size: 16px; font-weight: 700; margin: 14px 0 6px; color: #111; }
#moo_docx_content h4, #moo_docx_content h5, #moo_docx_content h6 { font-size: 14px; font-weight: 700; margin: 12px 0 4px; color: #111; }
#moo_docx_content p { margin: 0 0 12px 0; }
#moo_docx_content ul, #moo_docx_content ol { margin: 0 0 12px 0; padding-left: 24px; }
#moo_docx_content li { margin-bottom: 4px; }
#moo_docx_content a { color: #0a66c2; text-decoration: underline; }
#moo_docx_content strong, #moo_docx_content b { font-weight: 700; }
#moo_docx_content em, #moo_docx_content i { font-style: italic; }
#moo_docx_content img { max-width: 100%; height: auto; border-radius: var(--radius); margin: 8px 0; }
#moo_docx_content table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 13px; }
#moo_docx_content th, #moo_docx_content td {
  border: 1px solid rgba(0, 0, 0, 0.2);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}
#moo_docx_content th { background: rgba(0, 0, 0, 0.05); font-weight: 700; }
#moo_docx_content hr { border: none; border-top: 1px solid rgba(0, 0, 0, 0.15); margin: 16px 0; }
#moo_docx_content blockquote {
  margin: 12px 0;
  padding: 8px 16px;
  border-left: 3px solid #0a66c2;
  background: rgba(10, 102, 194, 0.06);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: #333;
}

/* ==============================================================
   XLSX PREVIEW — "ledger sheet" aesthetic
   ==============================================================
   Crisp white paper for the data, a dark-glass tab bar at the
   bottom for sheet switching. This sits INSIDE the global file
   viewer, so the dark overlay provides atmosphere and the white
   paper reads as a proper document — same treatment as DOCX for
   cohesion, but with data-density instead of flowing text.
   Typography: a monospaced stack inside the cells gives numeric
   data that refined "ledger" feel. The Montserrat display face
   stays on the tab labels and everywhere else the app uses it.
*/
#moo_xlsx_wrap {
  width: 100%;
  max-width: 1200px;
  max-height: 100%;
  flex-direction: column;
  pointer-events: auto;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
}
#moo_xlsx_scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: none;
  background:
    linear-gradient(#ffffff, #ffffff),
    /* Very faint drafting-paper grid so empty area isn't a dead white void */
    repeating-linear-gradient(0deg, transparent 0, transparent 23px, rgba(0,0,0,0.025) 23px, rgba(0,0,0,0.025) 24px);
  background-attachment: local, local;
}
#moo_xlsx_content {
  padding: 0;
  min-width: fit-content;
}
.moo-xlsx__sheet {
  /* SheetJS's sheet_to_html emits one <table id="sjs-..."> per sheet.
     We target it via descendant selectors so we don't need to rewrite
     the HTML — just style what SheetJS hands us. */
  padding: 20px 24px 24px 24px;
}
.moo-xlsx__sheet table {
  border-collapse: collapse;
  font-family: 'SF Mono', 'JetBrains Mono', 'Fira Code', ui-monospace, Menlo, Consolas, monospace;
  font-size: 12.5px;
  color: #1a1a1a;
  background: #ffffff;
  /* Each sheet sits on the paper with a whisper of shadow so the
     eye has an edge to grab — very subtle, not a drop-shadow card. */
  box-shadow: 0 0 0 1px rgba(0,0,0,0.04);
  border-radius: var(--radius);
  table-layout: auto;
  min-width: 100%;
}
.moo-xlsx__sheet table td,
.moo-xlsx__sheet table th {
  padding: 7px 12px;
  border-right: 1px solid rgba(0,0,0,0.06);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  /* Tabular figures so digit columns align perfectly even inside a
     monospaced font — matters for long numeric columns. */
  font-variant-numeric: tabular-nums;
}
.moo-xlsx__sheet table tr:first-child td,
.moo-xlsx__sheet table tr:first-child th {
  /* First row styled as a header — slightly bolder, faint mint wash
     so the app's accent colour shows up in this "documents" context
     without fighting the white paper. */
  background: linear-gradient(180deg, rgba(0, 229, 160, 0.08), rgba(0, 229, 160, 0.02));
  font-weight: 700;
  color: #0d2e22;
  border-bottom: 2px solid rgba(0, 229, 160, 0.3);
  position: sticky;
  top: 0;
  z-index: 1;
}
.moo-xlsx__sheet table tr:hover td {
  background: rgba(0, 229, 160, 0.05);
}
.moo-xlsx__sheet table tr:first-child:hover td {
  /* Don't clobber the header row's gradient on hover. */
  background: linear-gradient(180deg, rgba(0, 229, 160, 0.12), rgba(0, 229, 160, 0.04));
}

/* Sheet tab bar — dark glass contrasts against the white paper.
   Same visual language as the app's bottom nav. */
#moo_xlsx_tabs {
  flex-shrink: 0;
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(10, 16, 20, 0.92), rgba(6, 13, 16, 0.96));
  border-top: 1px solid var(--hairline);
  overflow-x: auto;
  overflow-y: hidden;
  /* Scope to X axis: these tabs scroll horizontally only, so vertical wheel
     events need to propagate to the outer XLSX viewer scroll container
     (was 'overscroll-behavior: none' which trapped vertical wheels). */
  overscroll-behavior-x: none;
  white-space: nowrap;
}
.moo-xlsx__tab {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  color: var(--text-2);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  flex-shrink: 0;
  letter-spacing: 0.01em;
}
.moo-xlsx__tab:hover {
  background: var(--surface-2);
  color: var(--text-1);
  border-color: var(--hairline-strong);
}
.moo-xlsx__tab--active {
  background: linear-gradient(180deg, rgba(0, 229, 160, 0.22), rgba(0, 184, 126, 0.18));
  color: var(--color-toast-info);
  border-color: rgba(0, 229, 160, 0.5);
  box-shadow: 0 0 0 1px rgba(0, 229, 160, 0.18), 0 6px 20px -8px rgba(0, 229, 160, 0.5);
}
.moo-xlsx__tab--active:hover {
  background: linear-gradient(180deg, rgba(0, 229, 160, 0.28), rgba(0, 184, 126, 0.24));
  color: #ffffff;
}

/* ==============================================================
   PPTX PREVIEW — "proof sheet" aesthetic
   ==============================================================
   Vertical stack of 16:9 slide cards. Each slide is a piece of
   printed paper with generous padding, a mint slide-number badge
   in the top-left corner, bold display title, body lines, and any
   embedded images at the bottom. Dashed hair-rules between slides
   evoke a photo-lab contact sheet. Deliberately NOT a carousel —
   scrolling through slides like reviewing a printed handout is
   faster and more legible than prev/next buttons.
*/
#moo_pptx_wrap {
  width: 100%;
  max-width: 960px;
  max-height: 100%;
  flex-direction: column;
  pointer-events: auto;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  /* Warm off-white paper background that the white slide cards sit on
     — gives the proof-sheet concept a second layer of paper depth. */
  background: #f7f6f2;
  border: 1px solid rgba(0, 0, 0, 0.08);
}
#moo_pptx_content {
  overflow-y: auto;
  overscroll-behavior: none;
  max-height: 100%;
  padding: 32px 28px 48px 28px;
  flex: 1 1 auto;
  min-height: 0;
}
.moo-pptx__slide {
  position: relative;
  background: #ffffff;
  border-radius: var(--radius);
  padding: 48px 56px 40px 56px;
  margin-bottom: 36px;
  /* Layered shadow: a crisp hairline + a soft cast — makes each slide
     feel like it's lifted slightly off the proof sheet, not flat. */
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.06),
    0 1px 3px rgba(0, 0, 0, 0.04),
    0 20px 40px -24px rgba(0, 0, 0, 0.18);
  /* 16:9 minimum height feels like a real slide even when the slide
     content is sparse; tall content pushes it past the minimum. */
  min-height: 0;
}
.moo-pptx__slide::before {
  /* The mint "staple" — a thin vertical accent mark running down the
     left edge that ties the slide back to the app's accent colour
     without fighting the white-paper readability. */
  content: '';
  position: absolute;
  left: 0;
  top: 48px;
  bottom: 40px;
  width: 3px;
  background: linear-gradient(180deg, #00e5a0 0%, #00b87e 100%);
  border-radius: 0 var(--radius) var(--radius) 0;
  box-shadow: 0 0 12px rgba(0, 229, 160, 0.3);
}
.moo-pptx__slide:last-child {
  margin-bottom: 0;
}
/* Dashed hair-rule separators between slides — "contact sheet" cue.
   Drawn as a pseudo element so it sits on the paper, not the card. */
.moo-pptx__slide:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: -23px;
  width: 40%;
  height: 1px;
  background-image: repeating-linear-gradient(90deg, rgba(0,0,0,0.22) 0 6px, transparent 6px 12px);
}
.moo-pptx__num {
  position: absolute;
  top: 20px;
  right: 24px;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: rgba(0, 184, 126, 0.85);
  text-transform: uppercase;
  /* Ties the number into the mint staple without being a badge — feels
     like a stamp from a copy shop rather than a UI chip. */
}
.moo-pptx__num::before {
  content: 'SLIDE ';
  color: rgba(0, 0, 0, 0.35);
  font-weight: 600;
}
.moo-pptx__body {
  font-family: var(--font-ui);
  color: #1a1a1a;
}
.moo-pptx__title {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: #0d0d0d;
  margin-bottom: 16px;
  /* Subtle mint underline on the title — echoes the staple accent. */
  padding-bottom: 10px;
  border-bottom: 2px solid rgba(0, 229, 160, 0.25);
}
.moo-pptx__line {
  font-size: 14px;
  line-height: 1.6;
  color: #2d2d2d;
  margin-bottom: 8px;
  position: relative;
  padding-left: 18px;
}
.moo-pptx__line::before {
  /* Bullet as a mint diamond — small, refined, contextual. */
  content: '';
  position: absolute;
  left: 2px;
  top: 9px;
  width: 6px;
  height: 6px;
  background: #00b87e;
  transform: rotate(45deg);
  border-radius: var(--radius);
}
.moo-pptx__images {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  padding-top: 18px;
  border-top: 1px dashed rgba(0, 0, 0, 0.12);
}
.moo-pptx__images img {
  width: 100%;
  height: auto;
  max-height: 280px;
  object-fit: contain;
  background: #f4f4f4;
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}

/* Tight layout for narrow viewports — reduce paper padding, shrink
   title slightly, keep everything legible at phone widths. */
@media (max-width: 600px) {
  .moo-xlsx__sheet { padding: 14px 16px 18px 16px; }
  .moo-xlsx__sheet table td,
  .moo-xlsx__sheet table th { padding: 6px 9px; font-size: 11.5px; }
  #moo_pptx_content { padding: 20px 14px 32px 14px; }
  .moo-pptx__slide { padding: 32px 24px 28px 32px; margin-bottom: 28px; }
  .moo-pptx__title { font-size: 20px; }
  .moo-pptx__num { top: 14px; right: 16px; }
  .moo-pptx__slide::before { top: 32px; bottom: 28px; }
}

#moo_fv_unsupported {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  pointer-events: auto;
  padding: 36px 32px;
  max-width: 420px;
  width: calc(100% - 40px);
  background: var(--surface-sheet);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}
#moo_fv_unsupported .moo-fv__icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius);
  background: rgba(16, 24, 30, 0.92);
  border: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: var(--text-3);
  margin-bottom: 4px;
}
#moo_fv_unsupported .moo-fv__name {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-primary);
  word-break: break-all;
  line-height: 1.4;
}
#moo_fv_unsupported .moo-fv__reason {
  font-size: 13px;
  color: var(--text-3);
  line-height: 1.45;
}
#moo_fv_unsupported .moo-fv__hint {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 4px;
}

#moo_img_actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-shrink: 0;
}
.moo_img_action_btn {
  background: var(--surface-2);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  color: var(--color-text-primary);
  padding: 14px 22px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: opacity 0.2s, background-color 0.2s, color 0.2s, border-color 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.moo_img_action_btn:hover {
  background: rgba(0, 229, 160, 0.1);
  border-color: rgba(0, 229, 160, 0.25);
  color: var(--color-accent);
}
@media (max-width: 480px) {
  #moo_img_actions {
    flex-direction: column;
    width: 100%;
  }
  .moo_img_action_btn {
    width: 100%;
    justify-content: center;
    box-sizing: border-box;
  }
}

/* ===== CHAT PAGE OVERHAUL ===== */

/* Chatbox — the app aurora shows through; no wallpaper doodles. */
.moo-chat {
  background: transparent !important;
}

/* Loading screen */
body:has(.moo-chat) .chatbox_loading {
  position: absolute !important;
  inset: 64px 0 0 0 !important;
  background:
    radial-gradient(ellipse at 60% 20%, rgba(14, 165, 233, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 40% 80%, rgba(99, 102, 241, 0.1) 0%, transparent 50%),
    var(--color-bg);
  color: var(--color-text-primary);
}
body:has(.moo-chat) .cli_spin {
  color: var(--color-accent);
  font-size: 36px;
}
body:has(.moo-chat) .cli_text {
  color: var(--text-3);
  font-size: 16px;
  font-weight: 600;
  margin-top: 16px;
}

/* Loading more chat banner */
/* Loading older messages: skeleton bubbles fading into the thread */
body:has(.moo-chat) .loading_more_chat {
  top: 0;
  left: 0;
  width: 100%;
  box-sizing: border-box;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 14px 20px 34px;
  border: 0;
  border-radius: 0;
  background: linear-gradient(180deg, var(--color-bg) 0%, var(--color-bg) 65%, transparent 100%);
  z-index: 3;
}

/* Encryption banner */
.moo-chat .messages_encrypted {
  width: fit-content;
  max-width: 88%;
  margin: 4px auto 18px;
  text-align: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  color: var(--text-3);
  font-size: var(--fs-xs);
  line-height: 1.45;
  padding: 7px 12px;
  cursor: pointer;
  transition: background 0.2s;
}
.moo-chat .messages_encrypted:active {
  background: var(--surface-2);
}
.moo-chat .messages_encrypted i {
  margin-right: 6px;
  color: var(--color-accent);
}
.moo-chat .messages_encrypted b {
  color: var(--color-accent);
}

/* Scroll-to-message loading toast */
#scroll_to_toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 24px;
  white-space: nowrap;
  background: rgba(6, 13, 16, 0.9);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  color: var(--color-text-primary);
  font-size: 14px;
  font-weight: 600;
  z-index: 100;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}
#scroll_to_toast i {
  color: var(--color-accent);
}

/* Date and system lines — small floating pills */
.moo-chat .date_line,
.moo-chat .system_line {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.4;
  padding: 5px 12px;
  margin-bottom: 14px;
  width: fit-content;
  max-width: 80%;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.moo-chat .system_line { font-weight: 500; color: var(--text-3); text-align: center; }

/* Message bubbles — outgoing mint glass, incoming quiet glass. The time sits
   at the end of the last line (an inline spacer after the text reserves its
   place), so text uses the bubble's full width. */
.moo-chat .indv_message {
  border-radius: var(--radius);
  color: var(--text-1);
  font-size: var(--fs-body);
  line-height: 1.42;
  padding: 8px 12px 8px 13px;
  margin-bottom: 10px;
  max-width: 80%;
  display: inline-flex;
}
.moo-chat .indv_message.message_right {
  background: linear-gradient(180deg, rgba(0, 229, 160, 0.21), rgba(0, 229, 160, 0.13));
  border: 1px solid rgba(0, 229, 160, 0.18);
}
.moo-chat .indv_message.message_left {
  background: rgba(255, 255, 255, 0.075);
  border: 1px solid var(--hairline);
}
.moo-chat .indv_message pre {
  font-family: var(--font-ui);
  font-size: inherit;
  line-height: inherit;
}
.moo-chat .indv_message pre::after {
  content: '';
  display: inline-block;
  width: 44px;
  height: 1px;
}
/* Pinned: a small pin glyph before the time */
.moo-chat .indv_message[data-pinned="true"] .indv_message_info::before {
  content: '\f08d';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  font-size: 9px;
  margin-right: 5px;
  color: var(--accent);
  opacity: 0.85;
}
/* Same-sender run: tighten this bubble's gap to the next one (base is a 20px
   margin-bottom) so a burst reads as one calm block. margin-bottom (not a
   negative margin-top) because the bubbles are floated + clear:both, where a
   negative top margin is swallowed by clearance. The repeated name is dropped
   server-side. */
.moo-chat .indv_message--run {
  margin-bottom: 2px;
}
/* In-flow typing bubble: an incoming-style glass pill with three bouncing dots,
   appended at the bottom of #chatbox while the peer is typing. Matches
   .indv_message.message_left (bg/border/radius); floated + clear:both like the
   real bubbles, no time-badge gutter. */
.moo-chat .moo-typing-bubble {
  float: left;
  clear: both;
  margin: 0 0 10px 0;
  padding: 13px 15px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.075);
  border: 1px solid var(--hairline);
  max-width: 80%;
}
.moo-typing-dots {
  display: flex;
  align-items: center;
  gap: 5px;
}
.moo-typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-text-primary);
  opacity: 0.45;
  animation: mooTypingDot 1.3s infinite ease-in-out;
}
.moo-typing-dots span:nth-child(2) { animation-delay: 0.18s; }
.moo-typing-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes mooTypingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 0.85; }
}
@media (prefers-reduced-motion: reduce) {
  .moo-typing-dots span { animation: none; opacity: 0.6; }
}
/* Swipe-to-reply: during the drag the bubble follows the finger (no transition);
   overflow goes visible so the reply arrow shows in the revealed space, and text
   selection is suppressed. On release .swipe-return adds the spring-back. */
.moo-chat .indv_message.swiping {
  overflow: visible;
  user-select: none;
  -webkit-user-select: none;
}
.moo-chat .indv_message.swipe-return {
  transition: transform 0.22s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.moo-swipe-arrow {
  position: absolute;
  left: -34px;
  top: 50%;
  transform: translateY(-50%) scale(0.7);
  color: var(--color-accent);
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  .moo-chat .indv_message.swipe-return { transition: transform 0.01s linear; }
}
/* Long-press feedback: a quiet dip while held (added after ~140ms so taps and
   scroll-starts never flash it), released on menu-open/cancel. */
.moo-chat .indv_message.pressing {
  transform: scale(0.97);
  filter: brightness(0.92);
  transition: transform 0.12s ease-out, filter 0.12s ease-out;
}
/* Touch devices: long-press opens the options menu, so suppress the native iOS
   callout + text selection (Copy lives in the menu). Desktop keeps selection. */
@media (pointer: coarse) {
  .moo-chat .indv_message {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .moo-chat .indv_message.pressing { transform: none; transition: filter 0.1s ease; }
}
/* Time (and the desktop-only "more" handle) pinned bottom-right */
.moo-chat .indv_message_info_cont {
  width: auto;
  height: auto;
  top: auto;
  right: 10px;
  bottom: 6px;
  cursor: pointer;
}
.moo-chat .indv_message_info {
  position: static;
  min-height: 0;
  width: auto;
  background: transparent;
  padding: 0;
  font-size: var(--fs-2xs);
  font-variant-numeric: tabular-nums;
  line-height: 16px;
  color: var(--text-3);
  white-space: nowrap;
}
.moo-chat .indv_message.message_right .indv_message_info { color: rgba(205, 255, 236, 0.62); }
/* No hover "⋯" handle: clicking the time (or a long-press on touch) opens the message options. */
.moo-chat .indv_message_moreinfo { display: none; }
/* Media-only bubbles: no padding gutter; the time floats on the photo as a chip */
.moo-chat .indv_message:has(> .moo-media-grid):not(:has(> pre)) {
  padding: 3px;
}
.moo-chat .indv_message:has(> .moo-media-grid):not(:has(> pre)) .indv_message_info_cont {
  right: 10px;
  bottom: 10px;
}
.moo-chat .indv_message:has(> .moo-media-grid):not(:has(> pre)) .indv_message_info {
  padding: 1px 7px;
  border-radius: var(--radius);
  background: rgba(3, 8, 10, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: rgba(255, 255, 255, 0.92);
}
.moo-chat .indv_message .moo-media-grid { border-radius: var(--radius); overflow: hidden; }
/* File-card bubbles: the time sits under the card */
.moo-chat .indv_message:has(> .moo-file-attachments) { padding: 6px 6px 22px; }
.moo-chat .indv_message:has(> .moo-file-attachments) .indv_message_info_cont { bottom: 4px; }
/* A freshly-sent (optimistic) bubble rises a few px as it appears — one quiet
   motion, no bounce. The class is removed once adopted so it never replays on
   reflow. */
@keyframes mooMsgRise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.moo-chat .indv_message--optimistic-enter,
.moo-chat .indv_message--enter { animation: mooMsgRise 0.18s ease-out; }
/* M6: failed send — the bubble stays, tappable to retry. A danger exclamation by
   the time + a faint danger ring; retrying dims it. Restrained, no heavy tint. */
.moo-chat .indv_message--failed {
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(244, 63, 94, 0.3);
}
.moo-chat .indv_message--failed .indv_message_info::before {
  content: '\f06a';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  color: var(--color-danger);
  margin-right: 5px;
  font-size: 11px;
}
.moo-chat .indv_message--retrying {
  opacity: 0.55;
  transition: opacity 0.2s ease;
}
/* The mirror of the entrance: a deleted bubble fades + settles, then its real
   (JS-measured) height collapses so the thread slides up smoothly at any size,
   before it's detached. The JS sets max-height to the measured height then to 0
   so the collapse is linear (a fixed CSS ceiling would clip tall messages and
   back-load the collapse). Reversible — the JS clears the inline styles + class
   on a failed delete. Specific properties only, never transition: all. */
.moo-chat .indv_message--leaving {
  overflow: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease-in,
              transform 0.15s ease-in,
              max-height 0.24s ease-in,
              margin-top 0.24s ease-in,
              margin-bottom 0.24s ease-in,
              padding-top 0.24s ease-in,
              padding-bottom 0.24s ease-in;
}
@media (prefers-reduced-motion: reduce) {
  @keyframes mooMsgRise { from, to { opacity: 1; transform: none; } }
  /* Still collapse the space (so there's no ghost gap), just fast and without
     the transform/settle. */
  .moo-chat .indv_message--leaving {
    transition: opacity 0.1s ease, max-height 0.1s ease,
                margin-top 0.1s ease, margin-bottom 0.1s ease,
                padding-top 0.1s ease, padding-bottom 0.1s ease;
  }
}
.moo-chat .indv_message_moreinfo {
  color: var(--text-3);
}
.moo-chat .indv_message pre a {
  color: var(--color-accent);
}

.moo-chat .indv_message_name {
  color: var(--accent);
  font-size: var(--fs-sm);
  font-weight: 650;
  margin-bottom: 2px;
}
/* Grouped (same sender as the bubble above, within the run window): the name node
   is still emitted so the client re-stitch can toggle it both ways, but hidden. */
.moo-chat .indv_message_name--grouped {
  display: none;
}

/* GIF images in messages */
.moo-chat .GIF_IMG {
  border-radius: var(--radius);
}

/* New messages scroll button */
body:has(.moo-chat) #new_messages_button {
  background: rgba(0, 229, 160, 0.15);
  border: 1px solid rgba(0, 229, 160, 0.2);
  color: var(--color-accent);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
}
body:has(.moo-chat) #new_messages_button i {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
/* Unread count above the jump-to-bottom pill. Dark glass with mint text +
   hairline mint border — mint stays the light source, not a painted fill. */
body:has(.moo-chat) #new_messages_button .moo-new-msg-count {
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  box-sizing: border-box;
  border-radius: var(--radius);
  background: rgba(6, 13, 16, 0.95);
  border: 1px solid rgba(0, 229, 160, 0.35);
  color: var(--color-accent);
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
}

/* ---- Message input bar ---- */
.moo-chat-bar {
  background: var(--surface-bar) !important;
  -webkit-backdrop-filter: var(--blur-bar);
  backdrop-filter: var(--blur-bar);
  border-top: 1px solid var(--hairline);
  padding: 20px !important;
  width: calc(100% - 40px) !important;
  min-height: 30px !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
}
/* chat.php hides the composer inline while the chat is locked or still being
   set up (chat.js clears it on unlock); the !important above must not win. */
.moo-chat-bar[style*="display:none"], .moo-chat-bar[style*="display: none"] { display: none !important; }
.moo-chat-bar #user_message {
  background: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid var(--hairline-strong) !important;
  border-radius: var(--radius) !important;
  color: var(--text-1) !important;
  padding: 7px 14px !important;
  font-size: var(--fs-input);
  font-family: var(--font-ui);
  margin-left: 0 !important;
  flex: 1 1 0 !important;
  width: auto !important;
  min-width: 0 !important;
  min-height: 20px;
  height: 20px;
  line-height: 20px;
  user-select: text;
  -webkit-user-select: text;
  touch-action: manipulation;
}
.moo-chat-bar button {
  position: relative !important;
  bottom: auto !important;
  left: auto !important;
  right: auto !important;
  background: var(--surface-2) !important;
  border: 1px solid var(--hairline-strong) !important;
  border-radius: var(--radius) !important;
  color: var(--text-2) !important;
  width: 36px !important;
  height: 36px !important;
  min-width: 36px;
  flex-shrink: 0;
  transition: opacity 0.2s, background-color 0.2s, color 0.2s, border-color 0.2s;
}
.moo-chat-bar #send_message {
  background: var(--grad-primary) !important;
  border: none !important;
  color: var(--accent-ink) !important;
  font-size: 15px !important;
  box-shadow: 0 6px 18px rgba(0, 229, 160, 0.22);
}
.moo-chat-bar .message_process {
  background: rgba(6, 13, 16, 0.95) !important;
  color: var(--text-2) !important;
  font-size: 15px;
}

/* ---- Message options popup ---- */
body:has(.moo-chat) #mop_wrap {
  background: rgba(6, 13, 16, 0.6);
  animation: mooOverlayIn 0.2s ease-out;
}
body:has(.moo-chat) #message_options_popup {
  background: rgba(20, 30, 38, 0.85);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 28px;
  width: min(320px, 80%);
  height: auto !important;
  color: var(--color-text-primary);
  animation: mooModalIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
body:has(.moo-chat) .mop_title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.3px;
  margin-bottom: 16px;
}
body:has(.moo-chat) #mop_message {
  position: absolute;
  left: -9999px;
  opacity: 0;
  height: 1px;
  width: 1px;
  padding: 0;
  margin: 0;
  border: 0;
}
body:has(.moo-chat) .mop_buttons_cont {
  display: flex;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
}
body:has(.moo-chat) .mop_button {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  color: var(--color-text-primary);
  padding: 14px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-ui);
  width: auto;
  cursor: pointer;
  transition: opacity 0.2s, background-color 0.2s, color 0.2s, border-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
/* hover: hover only — on touch, the synthetic hover from a long-press opening
   the options menu under the finger sticks and looks like the button is armed. */
@media (hover: hover) {
  body:has(.moo-chat) .mop_button:hover {
    background: rgba(0, 229, 160, 0.08);
    border-color: rgba(0, 229, 160, 0.2);
    color: var(--color-accent);
  }
}
body:has(.moo-chat) .mop_button_delete {
  background: rgba(244, 63, 94, 0.08);
  border-color: rgba(244, 63, 94, 0.15);
  color: var(--color-danger);
}
@media (hover: hover) {
  body:has(.moo-chat) .mop_button_delete:hover {
    background: rgba(244, 63, 94, 0.15);
    border-color: rgba(244, 63, 94, 0.25);
    color: var(--color-danger);
  }
}
body:has(.moo-chat) #delete_message {
  margin-left: 0;
}

/* ---- Attachments popover (anchored above the composer, bottom left) ---- */
body:has(.moo-chat) #attachments_wrap {
  background: transparent;
  animation: none;
}
body:has(.moo-chat) #attachments_popup.moo-attach-bubble {
  flex-direction: column;
  gap: 8px;
  width: min(304px, calc(100vw - 24px));
  padding: 10px;
  box-sizing: border-box;
  background: var(--surface-sheet);
  -webkit-backdrop-filter: var(--blur-sheet);
  backdrop-filter: var(--blur-sheet);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-3), var(--inset-hi);
  color: var(--text-1);
  opacity: 0;
  transform: translateY(10px) scale(0.96);
  transform-origin: bottom left;
  pointer-events: none;
  transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out);
  animation: none;
}
body:has(.moo-chat) #attachments_popup.moo-attach-bubble.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.moo-attach-bubble__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 4px 4px;
}
.moo-attach-bubble__title {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-3);
}
.moo-attach-bubble__hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-2xs);
  font-weight: 600;
  color: var(--text-4);
}
.moo-attach-bubble__hint i { font-size: 9px; }
.moo-attach-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.moo-attach-tile {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 10px;
  box-sizing: border-box;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--surface-1);
  color: var(--text-1);
  font: 600 var(--fs-xs)/1 var(--font-ui);
  cursor: pointer;
  text-align: left;
  transition: background var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out);
}
.moo-attach-tile i { color: var(--accent); font-size: 14px; width: 18px; text-align: center; flex: 0 0 auto; }
@media (hover: hover) {
  .moo-attach-tile:hover { background: var(--surface-2); border-color: var(--hairline-strong); }
}
.moo-attach-tile:active { transform: scale(0.97); background: var(--surface-3); }
.moo-attach-bubble button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-line);
}

/* ---- KLIPY/GIF popup ---- */
body:has(.moo-chat) #klipy_wrap {
  background: rgba(6, 13, 16, 0.6);
  animation: mooOverlayIn 0.2s ease-out;
}
body:has(.moo-chat) #klipy_popup {
  background: var(--surface-sheet);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  color: var(--color-text-primary);
}
body:has(.moo-chat) .klipy_title {
  color: var(--color-text-primary);
}
body:has(.moo-chat) .klipy_title_sub {
  color: var(--text-3);
}
body:has(.moo-chat) #klipy_search {
  background: var(--surface-2);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  color: var(--color-text-primary);
  padding-left: 36px;
}
body:has(.moo-chat) .klipy_search_icon {
  color: var(--text-4);
}
body:has(.moo-chat) .klipy_indv img {
  border-radius: var(--radius);
}
body:has(.moo-chat) .gifs_loading {
  background: var(--surface-solid);
  color: var(--text-1);
  font-size: 16px;
  align-items: flex-start;
  justify-content: stretch;
  box-sizing: border-box;
  padding: 4px 16px;
}
.gifs_loading .moo-skel-wrap--tiles { width: 100%; gap: 6px; }
.gifs_loading .moo-skel-tile { aspect-ratio: 4 / 3; border-radius: var(--radius); }
#gi_list .moo-skel-wrap { padding: 4px 18px 12px; }
body:has(.moo-chat) .gifs_loading .cli_spin {
  color: var(--color-accent);
  font-size: 28px;
}
body:has(.moo-chat) .gifs_loading .cli_text {
  color: var(--text-3);
  font-size: 14px;
}

/* ---- Encryption info popup ---- */
body:has(.moo-chat) #ms_popup_wrap {
  background: rgba(6, 13, 16, 0.6);
  animation: mooOverlayIn 0.2s ease-out;
}
body:has(.moo-chat) #ms_popup {
  background: rgba(20, 30, 38, 0.85);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 32px;
  width: min(360px, 80%);
  color: var(--color-text-primary);
  animation: mooModalIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
body:has(.moo-chat) .ms_popup_title {
  font-size: 18px;
  font-weight: 800;
  color: var(--color-text-primary);
  letter-spacing: -0.3px;
}
body:has(.moo-chat) .ms_popup_message {
  color: var(--text-3);
  font-size: 14px;
  line-height: 1.7;
}
body:has(.moo-chat) .ms_popup_message b {
  color: var(--text-2);
}

/* Reply reference card (inside message bubbles) */
.reply_reference {
  background: var(--surface-2);
  border-left: 3px solid var(--color-accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 8px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.2s;
  max-width: 100%;
  overflow: hidden;
}
.reply_reference:active {
  background: var(--surface-3);
}
.reply_ref_name {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-accent);
  margin-bottom: 2px;
}
.reply_ref_text {
  font-size: 13px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Forwarded label */
.forwarded_label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  margin-bottom: 4px;
  font-style: italic;
}
.forwarded_label i {
  margin-right: 4px;
}

/* Message highlight animation (scroll to reply target) */
.message_highlight {
  animation: mooMsgHighlight 2s ease-out;
}
@keyframes mooMsgHighlight {
  0%, 20% { outline: 2px solid var(--color-accent); outline-offset: 2px; }
  100% { outline: 2px solid transparent; outline-offset: 2px; }
}

/* Reply preview bar (above message input) */
#reply_preview {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--surface-1);
  border-left: 3px solid var(--color-accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 10px;
  width: calc(100% - 19px);
}
#reply_preview_inner {
  flex: 1;
  min-width: 0;
}
#reply_preview_name {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-accent);
}
#reply_preview_text {
  font-size: 13px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#reply_cancel {
  background: var(--surface-2) !important;
  border: 1px solid var(--hairline-strong) !important;
  border-radius: var(--radius) !important;
  color: var(--text-3) !important;
  width: 28px !important;
  height: 28px !important;
  min-width: 28px;
  font-size: 12px !important;
  cursor: pointer;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0;
  position: relative !important;
  bottom: auto !important;
  left: auto !important;
  right: auto !important;
}

/* Input row wrapper */
#moo_chat_input_row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  width: 100%;
}

/* Message options - accent button (reply) */
body:has(.moo-chat) .mop_button_accent {
  background: rgba(0, 229, 160, 0.08);
  border-color: rgba(0, 229, 160, 0.15);
  color: var(--color-accent);
}
@media (hover: hover) {
  body:has(.moo-chat) .mop_button_accent:hover {
    background: rgba(0, 229, 160, 0.15);
    border-color: rgba(0, 229, 160, 0.25);
  }
}

/* Message options button grid */
body:has(.moo-chat) .mop_buttons_grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}
body:has(.moo-chat) .mop_buttons_grid .mop_button {
  flex: 1 1 calc(50% - 4px);
  min-width: calc(50% - 4px);
  box-sizing: border-box;
}
body:has(.moo-chat) .mop_buttons_grid .mop_button:last-child:nth-child(odd) {
  flex: 1 1 100%;
  min-width: 100%;
}

/* Forward picker modal */
body:has(.moo-chat) #forward_wrap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(6, 13, 16, 0.6);
  display: none;
  z-index: 999;
  animation: mooOverlayIn 0.2s ease-out;
}
body:has(.moo-chat) #forward_popup {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface-sheet);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 28px;
  box-sizing: border-box;
  width: min(360px, calc(100% - 32px));
  max-height: 70%;
  color: var(--color-text-primary);
  display: none;
  flex-direction: column;
  z-index: 9999;
  animation: mooModalIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
#forward_list {
  overflow-y: auto;
  overscroll-behavior: none;
  flex: 1;
  min-height: 0;
  margin-bottom: 16px;
}
.forward_section_title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-3);
  margin-bottom: 8px;
  margin-top: 16px;
}
.forward_section_title:first-child {
  margin-top: 0;
}
.forward_item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 4px;
}
.forward_item:hover {
  background: var(--surface-1);
}
.forward_item:active {
  background: var(--surface-2);
}
.forward_item img {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.forward_item span {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.forward_check {
  width: 24px;
  height: 24px;
  border-radius: var(--radius);
  border: 2px solid var(--hairline-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s, background-color 0.15s, color 0.15s, border-color 0.15s;
  font-size: 11px;
  color: transparent;
}
.forward_selected .forward_check {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-bg);
}
.forward_selected {
  background: rgba(0, 229, 160, 0.06);
}
#forward_send {
  width: 100%;
  padding: 14px;
  background: var(--grad-primary);
  border: none;
  border-radius: var(--radius);
  color: var(--color-bg);
  font-weight: 700;
  font-size: 15px;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
}
#forward_send:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(0, 229, 160, 0.25);
}

/* ===== ATTACHMENTS ===== */

/* ---- Location Card ---- */
.moo-location-card {
  display: block;
  width: 260px;
  max-width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  color: var(--color-text-primary);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--hairline);
}
/* CSS-only abstract "map" — renders with NO external requests (no map tiles, no
   third-party imagery). A faint street grid + roads over a dark aurora wash,
   with the pin floating at centre. Coordinates stay private until the user
   explicitly taps "Open". */
.moo-location-card__map {
  width: 100%;
  height: 112px;
  overflow: hidden;
  position: relative;
  background:
    radial-gradient(130% 100% at 50% 125%, rgba(0, 229, 160, 0.12), transparent 60%),
    var(--surface-1);
}
.moo-location-card__grid {
  position: absolute;
  inset: -1px;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 26px 26px;
  background-position: center;
  -webkit-mask-image: radial-gradient(82% 82% at 50% 44%, #000 52%, transparent 100%);
  mask-image: radial-gradient(82% 82% at 50% 44%, #000 52%, transparent 100%);
}
.moo-location-card__map::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(116deg, transparent 46.5%, rgba(255, 255, 255, 0.07) 47%, rgba(255, 255, 255, 0.07) 48.6%, transparent 49.1%),
    linear-gradient(31deg, transparent 61.5%, rgba(0, 229, 160, 0.10) 62%, transparent 63%);
  pointer-events: none;
}
.moo-location-card__pin {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -60%);
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: rgba(0, 229, 160, 0.16);
  border: 1px solid rgba(0, 229, 160, 0.38);
  color: var(--color-accent);
  font-size: 15px;
  z-index: 1;
}
.moo-location-card__pin::after {
  content: '';
  position: absolute;
  bottom: -9px;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(0, 229, 160, 0.5);
}
.moo-location-card__info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
}
.moo-location-card__meta {
  min-width: 0;
  flex: 1;
}
.moo-location-card__label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-primary);
}
.moo-location-card__label i {
  color: var(--color-accent);
  font-size: 12px;
}
.moo-location-card__coords {
  margin-top: 2px;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.moo-location-card__open {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  color: var(--color-accent);
  background: rgba(0, 229, 160, 0.10);
  border: 1px solid rgba(0, 229, 160, 0.22);
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.moo-location-card__open:active {
  background: rgba(0, 229, 160, 0.18);
}

/* ---- Media Grid ---- */
.moo-media-grid {
  display: grid;
  gap: 3px;
  border-radius: var(--radius);
  overflow: hidden;
  max-width: 280px;
}
.moo-media-grid--single {
  grid-template-columns: auto;
}
.moo-media-grid--two {
  grid-template-columns: 1fr 1fr;
}
.moo-media-grid--three {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
}
.moo-media-grid--three .moo-media-grid__item:first-child {
  grid-column: 1 / -1;
}
.moo-media-grid--multi {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
}
/* Album cap (> 4): square 2x2; tiles 5+ are hidden and a "+N" overlay sits on
   the 4th cell. The grid is the offset parent; the square tiles guarantee equal
   rows so the 50%/50% overlay lines up. Tapping +N removes --capped to reveal
   the rest in place. */
.moo-media-grid--capped {
  position: relative;
}
.moo-media-grid--capped .moo-media-grid__item {
  aspect-ratio: 1;
}
.moo-media-grid--capped .moo-media-grid__item:nth-child(n+5) {
  display: none;
}
.moo-media-grid__more {
  display: none;
}
.moo-media-grid--capped .moo-media-grid__more {
  display: flex;
  position: absolute;
  right: 0;
  bottom: 0;
  width: calc(50% - 1.5px);
  height: calc(50% - 1.5px);
  align-items: center;
  justify-content: center;
  background: rgba(6, 13, 16, 0.62);
  color: var(--color-text-primary);
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  z-index: 3;
}
/* Album "Save all" chip (chat.js): top-right over the first row. The grid is
   its offset parent; a dark scrim chip, no blur (iOS blur ignores radius). */
.moo-media-grid--two, .moo-media-grid--three, .moo-media-grid--multi {
  position: relative;
}
.moo-media-grid__save {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  background: rgba(6, 13, 16, 0.72);
  color: var(--text-1);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s, opacity 0.2s;
}
.moo-media-grid__save i { font-size: 11px; color: var(--accent); }
.moo-media-grid__save:hover { background: rgba(6, 13, 16, 0.86); border-color: rgba(255, 255, 255, 0.24); }
.moo-media-grid__save:disabled { cursor: default; opacity: 0.9; }
.moo-media-grid__save--ready { border-color: rgba(0, 229, 160, 0.55); color: var(--accent); }
.moo-media-grid__item {
  position: relative;
  overflow: hidden;
  background: var(--surface-1);
  min-height: 80px;
}
.moo-media-grid--single .moo-media-grid__item {
  min-height: 0;
  max-height: 320px;
}
.moo-media-grid__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  min-height: 80px;
}
.moo-media-grid--single .moo-media-grid__item img {
  min-height: 0;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 320px;
  object-fit: contain;
}
/* ---- Reply preview inside media bubbles ----
   The media grid owns the bubble width: the reply chip contributes ZERO
   intrinsic width (width: 0) then stretches back to the grid's width
   (min-width: 100%). Without this a wide reply sets the bubble width and the
   narrower media sits left-aligned with its right corners un-rounded (the
   grid's radius clips at the grid box, which spanned the full bubble). */
.indv_message:has(.moo-media-grid) .reply_reference {
  width: 0;
  min-width: 100%;
  box-sizing: border-box;
}
.indv_message:has(.moo-media-grid) .reply_ref_name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Group sender names get the same treatment — a long name above a narrow GIF
   would re-widen the bubble and un-round the media's right corners. */
.indv_message:has(.moo-media-grid) .indv_message_name {
  width: 0;
  min-width: 100%;
  box-sizing: border-box;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Media bubbles drop to a 3px gutter so the image reads edge-to-edge; the bare
   header lines would then sit flush against the bubble. Inset them by the text
   bubble's gutter instead (1px border + 13px left / 8px top), keeping them
   aligned with where they would sit above a normal message. The name below a
   forwarded label skips the top inset: the label's own 4px margin already
   spaces them as in a text bubble. */
.moo-chat .indv_message:has(> .moo-media-grid):not(:has(> pre)) > .indv_message_name {
  padding: 5px 10px 3px;
}
.moo-chat .indv_message:has(> .moo-media-grid):not(:has(> pre)) > .forwarded_label {
  padding: 5px 10px 0;
}
.moo-chat .indv_message:has(> .moo-media-grid):not(:has(> pre)) > .forwarded_label + .indv_message_name {
  padding-top: 0;
}
/* Floor for tiny media: don't let a small GIF/photo crush the reply chip into
   an unreadable sliver — widen the single tile instead. Its image fills the
   box (GIFs cover-crop; photos letterbox on the dark card at worst). */
.indv_message:has(.reply_reference) .moo-media-grid--single .moo-media-grid__item {
  min-width: 200px;
}
.indv_message:has(.reply_reference) .moo-media-grid--single .moo-media-grid__item img {
  width: 100%;
}
.moo-media-grid__video-ph {
  width: 100%;
  height: 100%;
  min-height: 80px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(145deg, #0d2420 0%, #091a16 100%);
}
.moo-media-grid__video-ph i {
  display: none;
}
.moo-media-grid--single .moo-media-grid__video-ph {
  min-height: 120px;
  aspect-ratio: 16 / 9;
  max-height: 320px;
}
.moo-media-grid__play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 50px;
  height: 50px;
  border-radius: var(--radius);
  background: rgba(0, 229, 160, 0.13);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 2;
}
.moo-media-grid__play i {
  color: var(--color-accent);
  font-size: 18px;
  margin-left: 3px;
}

/* ---- File Card ---- */
.moo-file-attachments {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: min(280px, 100%);
}
.moo-file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--color-text-primary);
  transition: background 0.15s, border-color 0.15s;
  min-width: 0;
}
.moo-file-card:active {
  background: var(--surface-2);
  border-color: var(--hairline-strong);
}
.moo-file-card__icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(0, 229, 160, 0.15), rgba(0, 229, 160, 0.05));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.moo-file-card__icon i {
  color: var(--color-accent);
  font-size: 16px;
}
.moo-file-card__info {
  flex: 1;
  min-width: 0;
}
.moo-file-card__name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.moo-file-card__size {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}
.moo-file-card__download {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  background: var(--surface-1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.moo-file-card__download i {
  color: var(--text-3);
  font-size: 13px;
}

/* ---- Upload Overlay ---- */
/* ---- Non-blocking upload pill (above the composer input row) ---- */
.moo-upload-pill {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 9px 12px 11px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  margin-bottom: 10px;
  position: relative;
  overflow: hidden;
  animation: mooUploadPillIn 0.2s ease-out;
}
@keyframes mooUploadPillIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.moo-upload-pill .moo-upload__status {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.moo-upload-pill.is-error .moo-upload__status {
  color: var(--color-danger);
}
.moo-upload-pill__right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.moo-upload-pill .moo-upload__percent {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-accent);
  font-variant-numeric: tabular-nums;
}
.moo-upload-pill__retry {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-accent);
  background: rgba(0, 229, 160, 0.1);
  border: 0;
  border-radius: var(--radius);
  padding: 5px 10px;
  cursor: pointer;
  transition: transform 0.1s ease;
}
.moo-upload-pill__cancel {
  width: 26px;
  height: 26px;
  border-radius: var(--radius);
  border: 0;
  background: rgba(255, 255, 255, 0.06);
  color: var(--color-text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  flex-shrink: 0;
  transition: transform 0.1s ease;
}
.moo-upload-pill__retry:active,
.moo-upload-pill__cancel:active {
  transform: scale(0.92);
}
/* The generic `.moo-chat-bar button` rule forces a 34px square (!important) on
   every button in the composer — it clips the Retry label and oversizes Cancel.
   Restore the pill buttons' own sizing/look (higher specificity beats it). */
.moo-chat-bar .moo-upload-pill__retry {
  width: auto !important;
  height: auto !important;
  min-width: 0 !important;
  padding: 5px 10px !important;
  background: rgba(0, 229, 160, 0.1) !important;
  border: 0 !important;
  border-radius: var(--radius) !important;
  color: var(--color-accent) !important;
  transition: transform 0.12s ease !important; /* beat the generic .moo-chat-bar button transition so the :active press eases */
}
.moo-chat-bar .moo-upload-pill__cancel {
  width: 26px !important;
  height: 26px !important;
  min-width: 26px !important;
  background: rgba(255, 255, 255, 0.06) !important;
  border: 0 !important;
  border-radius: var(--radius) !important;
  transition: transform 0.12s ease !important;
}
/* F16: wax-seal progress disc (replaces the bottom-edge fill). A 2px mint ring
   traces the rim as it fills; a dark recessed "wax" centre reads as a pressed
   seal. One subtle press + a mint check on completion. Mint stays light-on-rim. */
.moo-seal {
  position: relative;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.moo-seal__svg { width: 24px; height: 24px; display: block; }
.moo-seal__track { fill: none; stroke: rgba(255, 255, 255, 0.07); stroke-width: 3; }
.moo-seal__ring {
  fill: none;
  stroke: var(--color-accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 106.8;
  stroke-dashoffset: 106.8;
  transition: stroke-dashoffset 0.3s ease, stroke 0.3s ease;
}
.moo-upload-pill.is-error .moo-seal__ring { stroke: rgba(255, 255, 255, 0.18); }
.moo-seal__check {
  position: absolute;
  font-size: 9px;
  line-height: 1;
  color: var(--color-accent);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.moo-upload-pill.is-done .moo-seal__check { opacity: 1; }
.moo-upload-pill.is-done .moo-seal { animation: mooSealPress 0.32s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes mooSealPress {
  0% { transform: scale(0.88); }
  55% { transform: scale(1.04); }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .moo-upload-pill { animation: none; }
  .moo-seal__ring { transition: none; }
  .moo-upload-pill.is-done .moo-seal { animation: none; }
  .moo-upload-pill__retry:active,
  .moo-upload-pill__cancel:active { transform: none; }
}

/* ---- Upload Preview Modal ---- */
#moo_upload_wrap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(6, 13, 16, 0.6);
  display: none;
  z-index: 999;
  animation: mooOverlayIn 0.2s ease-out;
}
#moo_upload_preview {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  flex-direction: column;
  gap: 14px;
  padding: 28px;
  background: var(--surface-sheet);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  width: min(360px, 85%);
  max-height: 70%;
  z-index: 9999;
  color: var(--color-text-primary);
  animation: mooModalIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  overscroll-behavior: none;
}
.moo-upload-preview__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.moo-upload-preview__count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
}
.moo-upload-preview__close {
  background: var(--surface-2) !important;
  border: 1px solid var(--hairline-strong) !important;
  border-radius: var(--radius) !important;
  color: var(--text-3) !important;
  width: 28px !important;
  height: 28px !important;
  min-width: 28px;
  font-size: 12px !important;
  cursor: pointer;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0;
  position: relative !important;
  bottom: auto !important;
  left: auto !important;
  right: auto !important;
}
.moo-upload-preview__items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  overflow-y: auto;
  overscroll-behavior: none;
  max-height: 40vh;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.moo-upload-preview__items::-webkit-scrollbar {
  display: none;
}
.moo-upload-preview__thumb {
  width: 64px;
  height: 64px;
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
}
.moo-upload-preview__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.moo-upload-preview__thumb-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  border-radius: var(--radius);
  background: rgba(6, 13, 16, 0.8);
  border: 1px solid var(--hairline-strong);
  color: var(--text-2);
  font-size: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
}
.moo-upload-preview__file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  width: 100%;
  box-sizing: border-box;
}
.moo-upload-preview__file-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: rgba(0, 229, 160, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.moo-upload-preview__file-icon i {
  color: var(--color-accent);
  font-size: 15px;
}
.moo-upload-preview__file-details {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.moo-upload-preview__file-remove {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  background: rgba(244, 63, 94, 0.06);
  border: 1px solid rgba(244, 63, 94, 0.1);
  color: rgba(244, 63, 94, 0.5);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s, background-color 0.15s, color 0.15s, border-color 0.15s;
}
.moo-upload-preview__file-remove:active {
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.3);
  color: var(--color-danger);
}
.moo-upload-preview__file-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.moo-upload-preview__file-size {
  font-size: 10px;
  color: var(--text-4);
}
.moo-upload-preview__send {
  background: var(--grad-primary) !important;
  border: none !important;
  border-radius: var(--radius) !important;
  color: var(--color-bg) !important;
  font-weight: 700 !important;
  font-size: 14px !important;
  font-family: var(--font-ui) !important;
  padding: 12px !important;
  cursor: pointer;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px;
  transition: transform 0.15s, box-shadow 0.15s;
  width: 100%;
  box-sizing: border-box;
  position: relative !important;
  bottom: auto !important;
  left: auto !important;
  right: auto !important;
}
.moo-upload-preview__send:active {
  transform: scale(0.98);
}

/* ---- Upload Encryption Toggle ---- */
.moo-upload-preview__encrypt {
  padding: 12px 0 0;
  border-top: 1px solid var(--hairline);
  margin-top: 4px;
}
.moo-upload-preview__encrypt-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
}
.moo-upload-preview__encrypt-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
}
.moo-upload-preview__encrypt-label i {
  color: var(--color-accent);
  margin-right: 4px;
  font-size: 11px;
}
.moo-upload-preview__encrypt-note {
  font-size: 10px;
  color: var(--text-4);
  margin-top: 6px;
}
.moo-toggle--sm {
  width: 36px;
  height: 20px;
}
.moo-toggle--sm .moo-toggle__track::after {
  width: 14px;
  height: 14px;
  left: 3px;
  top: 3px;
}
.moo-toggle--sm input:checked + .moo-toggle__track::after {
  transform: translateX(16px);
}

/* ---- Encrypted Media ----
   Post-E2EE-default, every chat message's media is encrypted. Rather than
   badge every thumbnail with a padlock, we render the same visual as an
   unencrypted image/video and let main_js's auto-decrypt loop populate the
   <img src> with a blob URL of the decrypted bytes. .moo-media-enc-img is
   the empty <img> the auto-decrypt loop fills. The subtle background tint
   is a loading placeholder — visible until the blob URL is set, then the
   image itself covers it. */
.moo-media-grid__item--encrypted {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.moo-media-enc-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.03);
  min-height: 80px;
}
/* F13: a mint skeleton sweep while the encrypted image is still src-less (i.e.
   fetching + decrypting). The decrypt loop sets [src] the moment it has bytes,
   which drops this selector and reveals the image. Reduced-motion => flat tint. */
.moo-media-enc-img:not([src]) {
  background-image: linear-gradient(100deg, transparent 20%, rgba(0, 229, 160, 0.10) 50%, transparent 80%);
  background-size: 200% 100%;
  background-repeat: no-repeat;
  animation: mooEncSkeleton 1.5s ease-in-out infinite;
}
@keyframes mooEncSkeleton {
  0% { background-position: 180% 0; }
  100% { background-position: -80% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .moo-media-enc-img:not([src]) { animation: none; background-image: none; }
}
/* When an LQIP blur is painted on the item (E2EE attachment-metadata), drop the
   skeleton sweep + the img's faint tint so the real preview shows through cleanly
   until the decrypted blob paints over it. */
.moo-media-grid__item--encrypted[data-lqip-set] .moo-media-enc-img:not([src]) {
  background: transparent;
  animation: none;
}
.moo-media-grid--single .moo-media-enc-img {
  min-height: 100px;
}
/* Reserve a default box for single encrypted images BEFORE decrypt so the row
   isn't 0-height and snapping to natural size on load. The auto-decrypt loop
   reads the real dimensions from the decrypted bytes and sets the exact px box
   on the item (E2EE → the server can't read pixels to render dims up front), so
   the only residual movement is a small default->exact adjustment, not 0->full.
   The image always fills the reserved box (contain), so a wrong default just
   letterboxes briefly rather than overflowing. */
.moo-media-grid--single .moo-media-grid__item--encrypted {
  width: 240px;
  max-width: 100%;
  /* aspect-ratio (not an explicit height) so that when max-width:100% clamps the
     width on a narrow screen, the height tracks it and the ratio is preserved.
     The decrypt loop overrides --enc-ar inline with the image's real ratio. */
  aspect-ratio: var(--enc-ar, 4 / 3);
}
.moo-media-grid--single .moo-media-grid__item--encrypted .moo-media-enc-img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}
/* GIFs crop-fill the box (cover) instead of contain, so the KLIPY watermark
   never floats over an empty letterbox bar if the exact box wasn't set (e.g. a
   createImageBitmap failure leaves the default ratio). With the exact box,
   cover == contain. Must follow the rule above (equal specificity). */
.moo-media-grid--single .moo-media-grid__item--gif .moo-media-enc-img {
  object-fit: cover;
}

/* ---- Encrypted File Card ----
   Visually identical to an unencrypted file card now that every E2EE chat's
   files are encrypted by default. The only difference is the click handler
   (routes to mooDecryptAndView for in-browser decrypt). */
.moo-file-card--encrypted {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ---- Encrypted Items in Chat Info Grid ----
   Same principle as the in-message encrypted media: images get auto-decrypted
   inline (cmAutoDecryptEncImages), videos/files keep their existing visual
   (video icon / file icon) minus the padlock badge. */
.moo-chat-media__item--encrypted {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.moo-chat-media-enc-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.03);
}


/* Hidden file inputs for upload */
#moo_file_input_media,
#moo_file_input_files {
  display: none !important;
}

/* Shared modal component — used by group invite list */
/* Title centred as on every other popup; the close button sits at the right. */
.moo-fm-modal__header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 60px;
  flex-shrink: 0;
  text-align: center;
}
.moo-fm-modal__title {
  font-size: 17px;
  font-weight: 700;
  text-wrap: balance;
}
.moo-fm-modal__header button {
  position: absolute;
  top: 50%;
  right: 16px;
  margin-top: -16px;
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  color: var(--text-3);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.moo-fm-modal__header button:active {
  background: var(--surface-3);
}
.moo-fm-modal__list {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding: 0 24px 24px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: none;
}
.moo-fm-modal__loading,
.moo-fm-modal__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 0;
  color: var(--text-4);
  font-size: 14px;
}
.moo-fm-modal__loading i,
.moo-fm-modal__empty i {
  font-size: 28px;
  color: var(--text-4);
}

/* Generic row component — used by group invite list */
.moo-fm-file {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--hairline);
  transition: opacity 0.2s;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.moo-fm-file:last-child {
  border-bottom: none;
}
.moo-fm-file__icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: rgba(0, 229, 160, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.moo-fm-file__icon i {
  color: var(--color-accent);
  font-size: 15px;
}
.moo-fm-file__info {
  flex: 1;
  min-width: 0;
}
.moo-fm-file__type {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-primary);
}

/* ---- Danger-confirm modal pattern (.moo-da-modal__*) ----
   Shared by medication delete, time-tracker, and the note conflict modal. */
.moo-da-modal__body p {
  margin: 0 0 8px;
}
.moo-da-modal__body ul {
  margin: 0 0 12px;
  padding-left: 20px;
}
.moo-da-modal__body li {
  margin-bottom: 4px;
}
.moo-da-modal__warn {
  color: var(--color-danger);
  font-weight: 600;
  font-size: 13px;
}
.moo-da-modal__actions form {
  flex: 1;
  margin: 0;
}
.moo-da-modal__confirm:disabled {
  cursor: not-allowed;
}
.moo-da-modal__countdown {
  text-align: center;
  padding: 0 24px 20px;
  font-size: 12px;
  color: var(--text-4);
  font-weight: 500;
}
.moo-da-modal__countdown span {
  color: var(--color-danger);
  font-weight: 700;
}

/* Note concurrent-edit conflict modal — reuses the .moo-da-modal structure but
   with neutral chrome (a version fork is a choice, not a destructive action).
   Mint icon + primary button match the brand's "light source" accent. */
#ncf_wrap {
  position: absolute;
  inset: 0;
  background: rgba(6, 13, 16, 0.6);
  z-index: 999;
  animation: mooOverlayIn 0.2s ease-out;
}
#ncf_modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  flex-direction: column;
  background: var(--surface-sheet);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  width: min(380px, calc(100% - 48px));
  z-index: 9999;
  color: var(--color-text-primary);
  animation: mooModalIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}
.moo-cf-modal__icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  background: rgba(0, 229, 160, 0.1);
  border: 1px solid rgba(0, 229, 160, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--color-accent);
}
.moo-cf-modal__primary {
  flex: 1;
  padding: 14px 20px;
  border-radius: var(--radius);
  white-space: nowrap;
  background: rgba(0, 229, 160, 0.14);
  border: 1px solid rgba(0, 229, 160, 0.3);
  color: var(--color-accent);
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}
.moo-cf-modal__primary:hover {
  background: rgba(0, 229, 160, 0.2);
  border-color: rgba(0, 229, 160, 0.5);
}

/* Pinned messages list (chat info page) */
.moo-pinned-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.moo-pinned-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
}
/* Pinned-message popup (tap a pin to read it in place). Above the /info panel. */
#pinned_view_wrap {
  position: absolute;
  inset: 0;
  background: rgba(6, 13, 16, 0.7);
  z-index: 100000;
  animation: mooOverlayIn 0.2s ease-out;
}
#pinned_view_modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100001;
  width: min(420px, 80%);
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 48px);
  display: flex;
  flex-direction: column;
  background: var(--surface-sheet);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 24px;
  color: var(--color-text-primary);
  animation: mooModalIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.moo-pinview__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.moo-pinview__sender {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-accent);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.moo-pinview__close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
  color: var(--color-text-primary);
  cursor: pointer;
}
.moo-pinview__body {
  font-size: 15px;
  line-height: 1.5;
  color: var(--color-text-primary);
  overflow-y: auto;
  overscroll-behavior: none;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.moo-pinview__gifwrap {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
}
.moo-pinview__gif {
  max-width: 100%;
  max-height: 50vh;
  border-radius: var(--radius);
  display: block;
}
.moo-pinview__coords {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-3);
}
.moo-pinview__maps {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  color: var(--color-accent);
  text-decoration: none;
  font-size: 14px;
}
.moo-pinview__time {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-3);
}
.moo-pinned-item__content {
  flex: 1;
  min-width: 0;
}
.moo-pinned-item__sender {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-accent);
  margin-bottom: 3px;
}
.moo-pinned-item__text {
  font-size: 14px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.moo-pinned-item__text i {
  margin-right: 4px;
}
.moo-pinned-item__time {
  font-size: 11px;
  color: var(--text-4);
  margin-top: 4px;
}
.moo-pinned-item__unpin {
  flex-shrink: 0;
}
.moo-pinned-item__unpin button {
  background: rgba(244, 63, 94, 0.1) !important;
  border: 1px solid rgba(244, 63, 94, 0.2) !important;
  border-radius: var(--radius) !important;
  color: var(--color-danger) !important;
  width: 32px !important;
  height: 32px !important;
  padding: 0 !important;
  font-size: 14px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer;
  transition: opacity 0.2s, background-color 0.2s;
  margin: 0;
}
.moo-pinned-item__unpin button:hover {
  background: rgba(244, 63, 94, 0.2) !important;
}

/* ===== CHAT INFO — FILES & MEDIA ===== */
.moo-chat-media__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  contain: layout style paint;
  /* Reserve one row so the auto-load (F18) doesn't collapse-then-jump the card. */
  min-height: 104px;
}
/* Failed/empty media states render as DIVs, never <button> (the settings-card
   button override at .moo-chatinfo ... button[type=button] would force odd sizing). */
.moo-chat-media__state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 104px;
  padding: 16px;
  text-align: center;
  color: var(--color-text-primary);
  opacity: 0.6;
  font-size: 14px;
}
.moo-chat-media__state i { font-size: 20px; }
.moo-chat-media__state--failed { cursor: pointer; opacity: 0.75; }
.moo-chat-media__item {
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 1;
  cursor: pointer;
  position: relative;
  background: var(--surface-1);
  -webkit-tap-highlight-color: transparent;
  content-visibility: auto;
  contain-intrinsic-size: auto 100px;
}
.moo-chat-media__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.moo-chat-media__item .moo-media-grid__video-ph {
  min-height: 0;
  aspect-ratio: 1;
}
/* Play badge: a small corner rounded-square glass tile (8px chip radius, brand
   scale) instead of a centred 50% circle that obscured the thumbnail. */
.moo-chat-media__item--video::after {
  content: '\f04b';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  position: absolute;
  bottom: 6px;
  left: 6px;
  width: 26px;
  height: 26px;
  background: rgba(6, 13, 16, 0.5);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-accent);
  font-size: 12px;
  padding-left: 2px;
  pointer-events: none;
  z-index: 2;
}
/* Recoverable decrypt states for /info media tiles. --failed shows a tappable
   refresh glyph (the grid click handler re-queues the decrypt); --missing is a
   quiet dimmed 'unavailable' tile. Pure ::after overlay, no <button>/<div> child
   so it dodges the settings-card button override. */
.moo-chat-media__item--failed::after {
  content: '\f021';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--color-accent);
  background: rgba(6, 13, 16, 0.5);
  z-index: 2;
}
.moo-chat-media__item--missing {
  opacity: 0.5;
}
.moo-chat-media__item--missing::after {
  content: '\f127';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--color-text-primary);
  background: rgba(6, 13, 16, 0.45);
  z-index: 2;
}
.moo-chat-media__item--file {
  aspect-ratio: 1;
}
.moo-chat-media__file-cover {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--surface-1);
}
.moo-chat-media__file-cover i {
  font-size: 28px;
  color: var(--color-accent);
  opacity: 0.5;
}
.moo-chat-media__file-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-4);
}
.moo-chat-media__grid:not(:empty) + .moo-chat-media__show-all {
  margin-top: 12px;
}
.moo-chat-media__show-all {
  width: 100%;
  padding: 12px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  color: var(--color-text-primary);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: opacity 0.2s, background-color 0.2s, color 0.2s, border-color 0.2s, transform 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.moo-chat-media__show-all:hover {
  background: rgba(0, 229, 160, 0.1);
  border-color: rgba(0, 229, 160, 0.25);
  color: var(--color-accent);
}
.moo-chat-media__show-all:active {
  transform: scale(0.98);
  background: rgba(0, 229, 160, 0.08);
}

/* ===== GROUP INVITE CARDS (chats page) ===== */
.moo-gi-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 229, 160, 0.06);
  border: 1px solid rgba(0, 229, 160, 0.12);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: opacity 0.2s;
}
.moo-gi-card:last-child {
  margin-bottom: 0;
}
.moo-gi-card__icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: rgba(0, 229, 160, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--color-accent);
  font-size: 16px;
}
.moo-gi-card__info {
  flex: 1;
  min-width: 0;
}
.moo-gi-card__title {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.moo-gi-card__sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}
.moo-gi-card__actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.moo-gi-card__accept {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  border: none;
  background: var(--grad-primary);
  color: var(--color-bg);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s, transform 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.moo-gi-card__accept:active {
  transform: scale(0.9);
}
.moo-gi-card__decline {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  border: 1px solid var(--hairline-strong);
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s, background-color 0.2s, color 0.2s, border-color 0.2s, transform 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.moo-gi-card__decline:active {
  transform: scale(0.9);
  background: rgba(244, 63, 94, 0.1);
  border-color: rgba(244, 63, 94, 0.2);
  color: var(--color-danger);
}

/* ===== RECOVERY-KEY BACKFILL NUDGE (chats page) =====
   One-time security prompt shown only to accounts whose recovery key can't yet
   unlock their encrypted data. Shares the glass-card language of the invite
   cards; the labeled primary action marks it as an account-security task rather
   than a routine notification. Mint is the light source — no glow/halo. */
.moo-rk-nudge {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 13px;
  background: rgba(0, 229, 160, 0.06);
  border: 1px solid rgba(0, 229, 160, 0.16);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.moo-rk-nudge__icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: rgba(0, 229, 160, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--color-accent);
  font-size: 18px;
}
.moo-rk-nudge__body {
  flex: 1;
  min-width: 0;
  padding-right: 22px; /* clear the dismiss control */
}
.moo-rk-nudge__title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--color-text-primary);
  letter-spacing: -0.01em;
}
.moo-rk-nudge__text {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-2);
  margin-top: 4px;
}
.moo-rk-nudge__cta {
  display: inline-flex;
  align-items: center;
  margin-top: 13px;
  padding: 10px 16px;
  border-radius: var(--radius);
  border: none;
  background: var(--grad-primary);
  color: var(--color-bg);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.18s ease, filter 0.18s ease;
}
.moo-rk-nudge__cta:hover {
  filter: brightness(1.06);
}
.moo-rk-nudge__cta:active {
  transform: scale(0.97);
}
.moo-rk-nudge__dismiss {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 26px;
  height: 26px;
  border-radius: var(--radius);
  border: none;
  background: transparent;
  color: var(--text-3);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.18s ease, color 0.18s ease;
}
.moo-rk-nudge__dismiss:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--color-text-primary);
}

/* Group invite modal */
#gi_wrap {
  position: absolute;
  inset: 0;
  background: rgba(6, 13, 16, 0.6);
  z-index: 100000; /* above the F14 /info slide-over panel (10000) */
  animation: mooOverlayIn 0.2s ease-out;
}
#gi_modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  flex-direction: column;
  background: var(--surface-sheet);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  width: min(400px, calc(100% - 48px));
  max-height: calc(100vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 48px);
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 48px);
  z-index: 100001;
  color: var(--color-text-primary);
  animation: mooModalIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

/* Clickable pinned items */
.moo-pinned-item__content {
  cursor: pointer;
  transition: opacity 0.2s;
}
.moo-pinned-item__content:active {
  opacity: 0.7;
}

#delete_chat_button {
  width:100%;
}
.chat_participants {
  margin-top:20px;
}

.klipy_indv {
    width: 100%;
    aspect-ratio: 16 / 9;
}
.klipy_indv img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: var(--radius);
}

/* KLIPY attribution watermark — subtle dark-glass chip on the sent GIF message
   card. Mint as atmosphere (the light source), not paint. Anchored to the
   position:relative .moo-media-grid__item card. Bottom-LEFT: the message
   time chip floats bottom-right on media bubbles, so they'd overlap. */
.klipy_wm {
    position: absolute;
    left: 8px;
    bottom: 8px;
    z-index: 2;
    pointer-events: none;
    padding: 4px;
    border-radius: var(--radius);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.06em;
    line-height: 1;
    color: var(--text-1);
    background: rgba(6, 13, 16, 0.55);
    border: 1px solid rgba(0, 229, 160, 0.22);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.gifs_loading {
  position:absolute;
  top:68px;
  left:0px;

  opacity: 0;
  transition: opacity 250ms ease;

  display:none;
  text-align: center;
  vertical-align:middle;
  justify-content: center;
  align-items: center;

  width:100%;
  height:calc(100% - 68px);
  background-color: var(--color-bg-elevated);
  z-index:9;

  font-size:24px;
  font-weight:bold;
  color:var(--color-white);
}

#klipy_results {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;

    width: 100%;
    height: calc(100% - 108px);

    overflow-y: scroll;
    overflow-x: hidden;
    overscroll-behavior: none;
    position: relative;

    margin-top: 20px;
    border-radius: var(--radius);
    padding: 0;
    box-sizing: border-box;
}

#klipy_search {
    width:calc(100% - 35px);
    min-height: 20px;
    line-height: 20px;
    background-color: var(--color-white);
    color: var(--color-black);
    margin: 0px;
    padding: 5px;
    padding-left:30px;
    font-size: 14px;
    height: 20px;
    border: 0px;
    border-radius: var(--radius);
}
#klipy_popup {
    overflow:hidden;
    position:absolute;
    top:50%;
    left:50%;
    transform:translate(-50%, -50%);
    padding:20px;
    width:80%;
    height:80%;
    background-color:var(--color-bg-elevated);
    color:var(--color-text-primary);
    border-radius:var(--radius);
    display:none;
    z-index:9999;
}
#klipy_wrap {
    position:absolute;
    top:0px;
    left:0px;
    width:100%;
    height:100%;

    display:none;
    z-index:999;
}
.klipy_title {
    margin-bottom:20px;
    font-weight:bold;
    height:38px;
    font-size:20px;
    text-align:center;
    line-height:1.2;
}
.klipy_title_sub {
  width:100%;
  font-weight: normal;
  font-size:12px;
  text-align: center;
}

.GIF_IMG {
    width:auto !important;
    height:auto !important;

    min-width: 200px;
    max-width: 50vw;

    border-radius: var(--radius);
    overflow:hidden;
    display:flex;
}
.klipy_search_cont {
    position:relative;
}
.klipy_search_icon {
    position:absolute;
    top:0px;
    left:0px;

    display:flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height:1;

    width:30px;
    height:30px;

    color:var(--color-black);
}

.push_button {
  display:flex;
  justify-content: center;
  align-items: center;
  gap:10px;
}

.unread_badge {
  position: absolute;
  top: -3px;
  right: 4px;
  box-sizing: border-box;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius);
  background: var(--danger);
  color: #fff;
  box-shadow: 0 0 0 2px var(--color-bg);
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  overflow: hidden;
  display: none;
  justify-content: center;
  text-align: center;
  align-items: center;
}

.input_time {
  background-color: var(--color-white);
  height:23px;
  text-align: left;
}

#pn_asked_wrap {
    position: absolute;
    top: 0px;
    left: 0px;
    width: 100%;
    height: 100%;
    background: rgba(6, 13, 16, 0.6);
    display: block;
    z-index: 999;
    animation: mooOverlayIn 0.2s ease-out;
}
#pn_asked_popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 32px;
    box-sizing: border-box;
    width: min(320px, 80%);
    height: auto;
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    color: var(--color-text-primary);
    display: block;
    text-align: center;
    z-index: 9999;
    animation: mooModalIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.moo-pn-asked-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius);
    background: rgba(0, 229, 160, 0.1);
    border: 1px solid rgba(0, 229, 160, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 22px;
    color: var(--color-accent);
}
#pn_asked_popup .pn_popup_title {
    font-size: 18px;
    font-weight: 800;
    color: var(--color-text-primary);
    letter-spacing: -0.3px;
    margin-bottom: 8px;
}
#pn_asked_popup .pn_popup_message {
    font-size: 14px;
    color: var(--text-3);
    line-height: 1.6;
    margin-bottom: 24px;
}
#pn_asked_popup .mop_buttons_cont {
    display: flex;
    gap: 10px;
}
#pn_asked_popup .pn_button_no {
    flex: 1;
    margin-left: 0;
    padding: 14px;
    background: var(--surface-2);
    border: 1px solid var(--hairline-strong);
    border-radius: var(--radius);
    color: var(--text-2);
    font-weight: 600;
    font-size: 14px;
    font-family: var(--font-ui);
    cursor: pointer;
    transition: opacity 0.2s, background-color 0.2s;
    width: auto;
}
#pn_asked_popup .pn_button_no:hover {
    background: var(--surface-3);
}
#pn_asked_popup .mop_button_yes {
    flex: 1;
    padding: 14px;
    background: var(--grad-primary);
    border: none;
    border-radius: var(--radius);
    color: var(--color-bg);
    font-weight: 700;
    font-size: 14px;
    font-family: var(--font-ui);
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s, box-shadow 0.2s;
    width: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
#pn_asked_popup .mop_button_yes:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 229, 160, 0.25);
}

/* ===== Push-notification recovery banner =====
 * Surfaces the localStorage 'vocyl_pn_recovery_needed' flag set by
 * pwa_pn.js when the subscription dies silently. NON-modal (a banner,
 * not an interrupt) since the recovery state is "you should fix this"
 * not "you must fix this immediately". Amber-warning aurora glass to
 * differentiate from the accent-green primary actions — same visual
 * vocabulary as #pn_asked_popup (icon chip + title + button) but a
 * banner geometry that doesn't block the viewport.
 *
 * Hidden by default; JS toggles display:flex when the flag is set or
 * the 'vocyl-pn-needs-attention' custom event fires. */
#pn_recovery_banner {
    position: fixed;
    top: var(--h-appbar); /* under the top bar, so the page title stays readable */
    left: 0;
    right: 0;
    z-index: 990;
    margin: env(safe-area-inset-top) auto 0;
    padding: 12px 14px;
    max-width: 540px;
    align-items: center;
    gap: 12px;
    background: linear-gradient(180deg, rgba(36, 28, 12, 0.96), var(--surface-sheet));
    border-bottom: 1px solid rgba(251, 191, 36, 0.28);
    box-shadow: 0 12px 28px -16px rgba(0, 0, 0, 0.85);
    animation: mooPnBannerIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--color-text-primary);
    font-family: var(--font-ui);
}
@media (min-width: 600px) {
    #pn_recovery_banner {
        margin-top: calc(env(safe-area-inset-top) + 12px);
        border: 1px solid rgba(251, 191, 36, 0.28);
        border-radius: var(--radius);
    }
}
@keyframes mooPnBannerIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0);    }
}
.moo-pn-banner__icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    background: rgba(251, 191, 36, 0.14);
    border: 1px solid rgba(251, 191, 36, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fbbf24;
    font-size: 14px;
    flex-shrink: 0;
}
.moo-pn-banner__body {
    flex: 1;
    min-width: 0;
}
.moo-pn-banner__title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-1);
    letter-spacing: -0.1px;
}
.moo-pn-banner__msg {
    font-size: 11.5px;
    color: var(--text-2);
    line-height: 1.4;
    margin-top: 1px;
}
.moo-pn-banner__action {
    flex-shrink: 0;
    padding: 8px 14px;
    background: rgba(251, 191, 36, 0.16);
    border: 1px solid rgba(251, 191, 36, 0.4);
    border-radius: var(--radius);
    color: #fbbf24;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font-ui);
    transition: background-color 0.15s, border-color 0.15s, opacity 0.15s;
}
.moo-pn-banner__action:hover {
    background: rgba(251, 191, 36, 0.24);
    border-color: rgba(251, 191, 36, 0.55);
}
.moo-pn-banner__action:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.moo-pn-banner__close {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    background: transparent;
    border: 0;
    border-radius: var(--radius);
    color: var(--text-3);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s, color 0.15s;
}
.moo-pn-banner__close:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-1);
}

/* The chats and contacts "+" popups (frosted glass, as every modal). */
#chats_popup_wrap {
    position:absolute;
    top:0px;
    left:0px;
    width:100%;
    height:100%;

    display:none;
    z-index:999;
    animation: mooOverlayIn 0.2s ease-out;
}
#chats_popup {
    position:absolute;
    top:50%;
    left:50%;
    transform:translate(-50%, -50%);
    box-sizing: border-box;
    padding:32px;
    width: min(384px, calc(100% - 32px));
    height:auto;
    border: 1px solid var(--hairline);
    color:var(--color-text-primary);
    border-radius:var(--radius);
    animation: mooModalIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display:none;

    align-items: center;
    justify-content: center;
    text-align: center;
    flex-direction: column;
    z-index:9999;
}

.co_contact_form {
  display:flex;
  justify-content: center;
  text-align: center;
  align-items: center;
  gap:40px;
}
.contact_mn_display {
  font-size:16px;
  font-weight:normal;
}

.contact_last_online {
  font-size:14px;
  font-weight:normal;

  margin-top:10px;
}
.contact_timezone {
  font-size:14px;
  font-weight:normal;
}


.loading_bar {
    position: fixed;
    top: 0px;
    left: 0px;

    width: calc(100% - 40px);
    height: 24px;

    color: var(--color-text-primary);
    background: var(--color-bg);
    border: none;
    border-bottom: 1px solid var(--hairline);

    border-radius: 0px;
    padding: 20px;
    padding-top: calc(20px + env(safe-area-inset-top, 0));
    overflow: hidden;

    display: none;
    justify-content: flex-start;
    align-items: center;
    text-align: left;

    z-index: 999999;
}
.lb_left {
  font-size: 20px;
  color: var(--color-accent);

  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}
.lb_right {
  display: flex;
  justify-content: center;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  margin-left: 14px;
}
.lbr_line1 {
  font-weight: 700;
  font-size: 15px;
  color: var(--color-text-primary);

  display: flex;
  justify-content: flex-start;
  align-items: center;
  text-align: left;
  line-height: 1;
}
.lbr_line2 {
  font-size: 12px;
  color: var(--text-3);

  display: flex;
  justify-content: flex-start;
  align-items: center;
  text-align: left;
  line-height: 1;
  margin-top: 2px;
}

#br_popup_wrap {
    position:absolute;
    top:0px;
    left:0px;
    width:100%;
    height:100%;

    display:none;
    z-index:999;
}
#br_popup {
    position:absolute;
    top:50%;
    left:50%;
    transform:translate(-50%, -50%);
    padding:20px;

    width:80%;
    max-width:300px;

    height:auto;
    max-height:80%;

    overflow-x:hidden;
    overflow-y:auto;
    overscroll-behavior: none;

    background-color:var(--color-white);
    border: 1px solid var(--hairline);
    color:var(--color-black);
    border-radius:var(--radius);

    display:none;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex-direction: column;

    z-index:9999;
}
.br_popup_title {
  font-size:18px;
  text-align:center;
  font-weight:bold;
  margin-bottom:20px;
}
.br_form {
  display:flex;
  flex-direction: column;
  gap:10px;
  width:100%;
}
.br_submit_button {
  font-size: 17px;
  font-weight: bold;
  padding: 15px;
  text-align: center;
  height: auto;
  margin: 0px;
  border: 0px;
  border-radius: var(--radius);
  background-color: var(--color-bg-elevated);
  border: 1px solid var(--hairline-strong);
  color: var(--color-text-primary);
  width: 100%;
}
.br_selectbox {
  -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;

  font-size: 17px;
  margin: 0px;
  padding: 15px;
  width:100%;
  margin-right: 10px;
  border-radius: var(--radius);
  border: 1px solid var(--hairline-strong);
  background-color: var(--color-white);
  color:var(--color-black);
}
.br_textarea {
  -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;

  font-size: 17px;
  margin: 0px;
  padding: 15px;
  width:calc(100% - 32px);
  height:140px;
  margin-right: 10px;
  border-radius: var(--radius);
  border: 1px solid var(--hairline-strong);
  color:var(--color-black);

  overflow-x:hidden;
  overflow-y:auto;
  overscroll-behavior: none;

  resize:none;
}
.br_textarea::placeholder {
  font-weight: normal;
  opacity: 1;
  color: var(--color-black);
}

#ms_popup_wrap {
    position:absolute;
    top:0px;
    left:0px;
    width:100%;
    height:100%;

    display:none;
    z-index:999;
}
#ms_popup {
    position:absolute;
    top:50%;
    left:50%;
    transform:translate(-50%, -50%);
    padding:20px;
    width:80%;
    height:auto;
    max-height:80%;

    overflow-x:hidden;
    overflow-y:auto;
    overscroll-behavior: none;

    background-color:var(--color-bg-elevated);
    border:0px;
    color:var(--color-text-primary);
    border-radius:var(--radius);
    display:none;

    align-items: center;
    justify-content: center;
    text-align: center;
    flex-direction: column;

    z-index:9999;
}
.ms_popup_title {
  font-size:18px;
  text-align:center;
  font-weight:bold;
  margin-bottom:20px;
}

.messages_encrypted {
  height:auto;
  width:fit-content;
  text-align:center;
  padding:10px;
  font-size:14px;
  font-weight:normal;
  clear:both;
  margin-bottom:20px;
  background-color:var(--color-bg-elevated);
  color:var(--color-text-primary);
  border-radius:var(--radius);
  margin-left:auto;
  margin-right:auto;
}

.input_select {
  font-size: 18px;
  margin: 0px;
  padding: 5px;
  width: calc(100% - 12px);
  border-radius: var(--radius);
  border: 1px solid var(--hairline-strong);
}

.loading_more_chat {
  position:absolute;
  top:20px;
  left:20px;
  width:calc(100% - 80px);
  height:auto;

  padding: 20px;
  font-size: 20px;
  font-weight: bold;

  background-color: var(--color-bg-elevated);
  color: var(--color-text-primary);
  border-radius: var(--radius);

  opacity: 0;
  transition: opacity 200ms ease;

  display:none;
  justify-content: center;
  align-items: center;
  text-align: center;
}
.lmc_text {
  margin-left:10px;
}

.table_cont {
  border:1px solid var(--hairline-strong);
  border-radius:var(--radius);

  display:flex;
  flex-direction: column;
  overflow:hidden;
}
.table_header {
  background-color: var(--color-bg-elevated);
  padding:20px;
  color:var(--color-white);
  font-weight:bold;
  font-size:20px;
}
.table_content {
  display:flex;
  flex-direction: column;
  overflow:hidden;
}
.table_headers {
  font-weight:bold;
  font-size:18px;
  border-bottom:1px solid var(--hairline-strong);
}
.table_row {
  font-size:16px;
  display:flex;
  justify-content: space-between;
  align-items: center;
  overflow:hidden;
}
.table_column {
  display:flex;
  padding:20px;

  overflow-x:scroll;
  overscroll-behavior-x: none;

  white-space: nowrap;

  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
}
.tc_splitbutton {
  justify-content: space-between;
  align-items: center;
  gap:20px;
}
.table_buttons {
  display:flex;
  align-items: center;
  gap:10px;
  justify-content: flex-start;

  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
}
.table_buttons button {
  color: var(--color-text-primary);
  font-size:16px;
  width:28px;
  height:28px;
  border-radius: var(--radius);
  background-color: var(--color-bg-elevated);
  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;

  margin: 0px;
  padding: 0px;
  border: 0px;

  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
}
.fa_eye_slash_button {
  font-size:13px !important;
}
.table_content_hidden {
  display:none;
}
.table_open_content_button {
  border-radius:var(--radius);
  cursor: pointer;

  font-size:14px;
  font-weight:bold;

  padding:0px 10px;
  height:28px;

  background-color: var(--color-accent);
  color:var(--color-bg);

  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;

  display:flex;
  text-align: center;
  align-items: center;
  justify-content: center;
}

.table_row_content:nth-child(odd) {
  background-color: var(--color-row-alt);
}
.sv_trc1 {
  width:50%;
}
.sv_trc2 {
  width:50%;
}
.tc_margintop {
  margin-top:20px;
}
.table_norows {
  padding:20px;
}
.report_trc1 {
  width:20%;
}
.report_trc2 {
  width:30%;
}
.report_trc3 {
  width:50%;
}

.content_dialog_text {
  display:flex;
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-all;
}
#content_dialog_wrap {
    position:absolute;
    top:0px;
    left:0px;
    width:100%;
    height:100%;

    display:none;
    z-index:999;
}
#cd_popup {
    position:absolute;
    top:50%;
    left:50%;
    transform:translate(-50%, -50%);
    padding:20px;

    width:80%;
    height:auto;
    max-height:80%;

    overflow-x:hidden;
    overflow-y:auto;
    overscroll-behavior: none;

    background-color:var(--color-white);
    border: 1px solid var(--hairline);
    color:var(--color-black);
    border-radius:var(--radius);

    display:none;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex-direction: column;

    z-index:9999;
}

.chats_list_none {
  display:none;
}

.settings_item_last {
  margin-bottom:0px;
}

/* =====================================================================
   Tools: shared form-label spacing and header button state. (These lived in
   the retired Alarm tool block; the alarm itself is now the Home tool, styled
   by assets/css/home-core.css + home.css.)
   ===================================================================== */
body:has(.moo-tools) .hb_button_multi.is-active {
  background: color-mix(in srgb, var(--color-accent) 18%, transparent);
  border-color: color-mix(in srgb, var(--color-accent) 45%, transparent);
  color: var(--color-accent);
}
body:has(.moo-tools) .cn_input_title {
  margin: 18px 0 8px 2px;
}
.moo-tools .cn_input_title:first-child,
.moo-tools form .cn_input_title:first-child {
  margin-top: 0;
}

/* ============================================================
   Time Tracker Tool (.moo-tt-*)
   Tone = pay status, used the same way everywhere (rows, tags, picker, modal):
   work = mint accent, paid (holiday, paid day off) = info sky,
   unpaid (off sick, unpaid day off) = warning amber, rest = neutral.
   ============================================================ */
.moo-tt-page {
  --tt-when: 38px;
  --tt-val: 48px;
  --tt-gap: 12px;
  padding-bottom: 40px;
}

/* Week navigation */
.moo-tt-weeknav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0 16px;
}
.moo-tt-weeknav__btn {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  color: var(--text-1);
  text-decoration: none;
  transition: background-color 0.2s, border-color 0.2s;
}
.moo-tt-weeknav__btn:hover { border-color: var(--hairline-strong); background: var(--surface-2); }
.moo-tt-weeknav__btn:active { background: var(--surface-3); }
.moo-tt-weeknav__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.moo-tt-weeknav__center { flex: 1 1 auto; text-align: center; min-width: 0; }
.moo-tt-weeknav__title {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--text-1);
}
.moo-tt-weeknav__range {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  margin-top: 3px;
}
.moo-tt-today {
  display: flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  margin: -6px auto 16px;
  padding: 7px 13px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.2s;
}
.moo-tt-today i { font-size: 11px; }
.moo-tt-today:hover { background: rgba(0, 229, 160, 0.18); }
.moo-tt-today:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* The week's pay sum, set like a payslip: figures right-aligned, a rule, then the result. */
.moo-tt-ledger {
  margin-bottom: 20px;
  padding: 16px 20px 18px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
}
.moo-tt-ledger--over {
  background: linear-gradient(180deg, rgba(0, 229, 160, 0.07), rgba(0, 229, 160, 0) 70%), var(--surface-1);
  border-color: rgba(0, 229, 160, 0.16);
}
.moo-tt-ledger__line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 5px 0;
}
.moo-tt-ledger__lbl {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
}
.moo-tt-ledger__note { font-size: var(--fs-xs); font-weight: 500; line-height: 1.35; color: var(--text-3); }
.moo-tt-ledger__num {
  flex: 0 0 auto;
  font-size: var(--fs-md);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--text-1);
}
.moo-tt-ledger__op { margin-right: 5px; color: var(--text-3); font-weight: 500; }
.moo-tt-ledger__result {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--hairline-strong);
}
.moo-tt-ledger__result .moo-tt-ledger__lbl { padding-bottom: 5px; font-size: 15px; font-weight: 700; color: var(--text-1); }
.moo-tt-ledger__total {
  font-size: var(--fs-hero);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--text-1);
}
.moo-tt-ledger--over .moo-tt-ledger__total { color: var(--accent); }
.moo-tt-ledger--short .moo-tt-ledger__total { color: var(--text-2); }
.moo-tt-ledger--empty { padding: 22px 20px; text-align: center; }
.moo-tt-ledger__empty-title { margin: 0; font-size: var(--fs-md); font-weight: 700; color: var(--text-1); }
.moo-tt-ledger__empty-sub { margin: 6px 0 0; font-size: 14px; color: var(--text-3); }

/* The week as a strip chart. Axis, rows and tracks share one column grid, so every
   shift bar sits on the same clock and the week reads top to bottom like a tacho trace. */
.moo-tt-days { display: flex; flex-direction: column; gap: 6px; }
.moo-tt-axis {
  display: grid;
  grid-template-columns: var(--tt-when) minmax(0, 1fr) var(--tt-val);
  column-gap: var(--tt-gap);
  padding: 0 15px;
  margin-bottom: 1px;
}
.moo-tt-axis__scale { grid-column: 2; position: relative; height: 15px; }
.moo-tt-axis__tick {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 15px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--text-4);
}
.moo-tt-axis__tick--mid { color: var(--text-3); }

.moo-tt-day {
  display: grid;
  grid-template-columns: var(--tt-when) minmax(0, 1fr) var(--tt-val);
  align-items: center;
  column-gap: var(--tt-gap);
  width: 100%;
  min-height: 60px;
  box-sizing: border-box;
  margin: 0;
  padding: 10px 14px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  color: var(--text-1);
  font-family: var(--font-ui);
  text-align: left;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.2s, border-color 0.2s, transform 0.15s;
}
.moo-tt-day:hover { background: var(--surface-2); border-color: var(--hairline-strong); }
.moo-tt-day:active { transform: scale(0.99); }
.moo-tt-day:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.moo-tt-day--rest { background: transparent; }
.moo-tt-day--empty { background: transparent; border-style: dashed; border-color: var(--hairline-strong); }
.moo-tt-day--today { border-color: var(--accent-line); border-style: solid; }

.moo-tt-day__when { display: flex; flex-direction: column; line-height: 1.2; }
.moo-tt-day__dow { font-size: 13.5px; font-weight: 700; color: var(--text-1); }
.moo-tt-day--today .moo-tt-day__dow { color: var(--accent); }
.moo-tt-day__num { margin-top: 1px; font-size: var(--fs-xs); font-weight: 500; font-variant-numeric: tabular-nums; color: var(--text-3); }
.moo-tt-day__body { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-width: 0; }
.moo-tt-day__times {
  font-size: 14.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.moo-tt-day__val {
  text-align: right;
  font-size: var(--fs-md);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--text-1);
}
.moo-tt-day--paid .moo-tt-day__val { color: var(--info); }
.moo-tt-day__none { color: var(--text-4); font-weight: 600; }
.moo-tt-day__add { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--text-3); }
.moo-tt-day__add i { font-size: 12px; color: var(--accent); }

/* Shift track: the bar is the shift (start to finish), the hairline marks midnight. */
.moo-tt-track {
  position: relative;
  display: block;
  width: 100%;
  height: 6px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
}
.moo-tt-track__bar {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--accent-strong), var(--accent));
  transform-origin: left center;
  animation: mooTtBarIn 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: calc(var(--i, 0) * 45ms);
}
.moo-tt-track__mid {
  position: absolute;
  top: -3px;
  bottom: -3px;
  z-index: 1;
  width: 1px;
  margin-left: -0.5px;
  background: rgba(226, 236, 240, 0.32);
}
@keyframes mooTtBarIn { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* Day-type tags (rows) */
.moo-tt-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  padding: 5px 10px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.moo-tt-tag i { font-size: 12px; }
.moo-tt-tag--paid { background: var(--info-soft); color: var(--info); }
.moo-tt-tag--unpaid { background: var(--warning-soft); color: var(--warning); }
.moo-tt-tag--rest { background: rgba(255, 255, 255, 0.05); color: var(--text-3); }

.moo-tt-rules {
  margin: 18px 4px 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-3);
}

/* Entry modal (overlay + centered; absolute because it holds inputs) */
#tt_entry_wrap {
  position: absolute;
  inset: 0;
  background: rgba(6, 13, 16, 0.6);
  z-index: 9998;
  animation: mooOverlayIn 0.25s ease;
}
#tt_entry_modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  flex-direction: column;
  width: min(400px, calc(100% - 32px));
  max-height: calc(100vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 32px);
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface-sheet);
  -webkit-backdrop-filter: var(--blur-sheet);
  backdrop-filter: var(--blur-sheet);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  z-index: 9999;
  color: var(--text-1);
  animation: mooModalIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
#tt_entry_modal form { margin: 0; }
#tt_entry_modal .moo-da-modal__icon { background: var(--accent-soft); color: var(--accent); transition: background-color 0.2s, color 0.2s; }
#tt_entry_modal .moo-da-modal__icon[data-tone="paid"] { background: var(--info-soft); color: var(--info); }
#tt_entry_modal .moo-da-modal__icon[data-tone="unpaid"] { background: var(--warning-soft); color: var(--warning); }
#tt_entry_modal .moo-da-modal__icon[data-tone="rest"] { background: var(--surface-2); color: var(--text-2); }

/* Entry modal fields */
.moo-tt-times { display: flex; gap: 12px; }
.moo-tt-field { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.moo-tt-field__lbl { font-size: 13px; font-weight: 600; color: var(--text-2); }
.moo-tt-field input[type="time"] {
  width: 100%;
  min-height: 48px;
  box-sizing: border-box;
  background: var(--surface-1);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  color: var(--text-1);
  color-scheme: dark;
  padding: 12px 14px;
  font-size: var(--fs-input);
  font-weight: 600;
  font-family: var(--font-ui);
  font-variant-numeric: tabular-nums;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.25s;
}
.moo-tt-field input[type="time"]:focus { border-color: rgba(0, 229, 160, 0.45); outline: none; }
.moo-tt-field input[type="time"]:focus-visible { box-shadow: 0 0 0 3px var(--accent-soft); }

/* Live preview */
.moo-tt-preview {
  margin-top: 14px;
  padding: 12px 16px;
  background: rgba(0, 229, 160, 0.05);
  border: 1px solid rgba(0, 229, 160, 0.12);
  border-radius: var(--radius);
}
.moo-tt-preview__empty { font-size: 13px; line-height: 1.4; color: var(--text-3); }
.moo-tt-preview__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  font-size: 14px;
  color: var(--text-2);
}
.moo-tt-preview__row strong { color: var(--text-1); font-weight: 700; font-variant-numeric: tabular-nums; }
.moo-tt-preview__row--net { margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--hairline); }
.moo-tt-preview__row--net span { color: var(--text-1); font-weight: 600; }
.moo-tt-preview__row--net strong { color: var(--accent); font-size: 16px; }
.moo-tt-preview__note { margin-top: 8px; display: flex; align-items: center; gap: 6px; font-size: 12px; color: rgba(0, 229, 160, 0.85); }

/* Modal action buttons */
.moo-tt-save {
  flex: 1;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 20px;
  border-radius: var(--radius);
  background: var(--grad-primary);
  border: none;
  color: var(--accent-ink);
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: box-shadow 0.2s, opacity 0.2s;
}
.moo-tt-save:hover { box-shadow: 0 8px 24px rgba(0, 229, 160, 0.25); }
.moo-tt-save:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.moo-tt-save:disabled { opacity: 0.6; cursor: not-allowed; box-shadow: none; }
#tt_entry_delform { margin-top: -8px; padding: 0 22px 16px; }
.moo-tt-del {
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 20px;
  border-radius: var(--radius);
  background: transparent;
  border: 0;
  color: var(--danger);
  font-size: 13.5px;
  font-weight: 600;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: background-color 0.2s;
}
.moo-tt-del:hover { background: var(--danger-soft); }
.moo-tt-del:focus-visible { outline: 2px solid var(--danger); outline-offset: 2px; }

/* Day-type picker (entry modal). Worked spans the top; the 2x2 grid pairs the paid days (Holiday,
   Paid day off) above the unpaid ones (Off sick, Unpaid day off); Rest day spans the bottom.
   A selected tile takes its tone, the same one its tag wears in the week list. */
.moo-tt-typesel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  background: rgba(8, 14, 18, 0.6);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
}
.moo-tt-typesel__opt {
  --tt-tone: var(--text-1);
  --tt-tone-soft: rgba(255, 255, 255, 0.08);
  --tt-tone-line: rgba(255, 255, 255, 0.16);
  position: relative;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text-3);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.2s, color 0.2s, box-shadow 0.2s;
}
.moo-tt-typesel__opt--wide { grid-column: 1 / -1; }
.moo-tt-typesel__opt span { text-wrap: balance; }
.moo-tt-typesel__opt i { flex: 0 0 14px; font-size: 12px; text-align: center; opacity: 0.75; transition: opacity 0.2s; }
.moo-tt-typesel__opt--work { --tt-tone: var(--accent); --tt-tone-soft: rgba(0, 229, 160, 0.14); --tt-tone-line: var(--accent-line); }
.moo-tt-typesel__opt--paid { --tt-tone: var(--info); --tt-tone-soft: var(--info-soft); --tt-tone-line: rgba(56, 189, 248, 0.3); }
.moo-tt-typesel__opt--unpaid { --tt-tone: var(--warning); --tt-tone-soft: var(--warning-soft); --tt-tone-line: rgba(251, 191, 36, 0.32); }
.moo-tt-typesel__opt input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
@media (hover: hover) {
  .moo-tt-typesel__opt:hover:not(:has(input:checked)) { background: rgba(255, 255, 255, 0.04); color: var(--text-2); }
}
.moo-tt-typesel__opt:has(input:checked) {
  background: var(--tt-tone-soft);
  box-shadow: inset 0 0 0 1px var(--tt-tone-line);
  color: var(--tt-tone);
}
.moo-tt-typesel__opt:has(input:checked) i { opacity: 1; }
.moo-tt-typesel__opt:has(input:focus-visible) { outline: 2px solid var(--tt-tone); outline-offset: 1px; }

/* No-times info panel (entry modal); the icon takes the type's tone */
.moo-tt-typeinfo {
  padding: 14px 16px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--hairline);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-2);
  align-items: flex-start;
  gap: 10px;
}
.moo-tt-typeinfo i { margin-top: 3px; color: var(--text-3); font-size: 14px; flex: 0 0 16px; text-align: center; }
.moo-tt-typeinfo[data-tone="paid"] i { color: var(--info); }
.moo-tt-typeinfo[data-tone="unpaid"] i { color: var(--warning); }
.moo-tt-typeinfo strong { color: var(--text-1); font-weight: 700; }
.moo-tt-hint { margin: 12px 2px 0; font-size: 12.5px; line-height: 1.4; color: var(--text-3); }

@media (prefers-reduced-motion: reduce) {
  .moo-tt-track__bar { animation: none; }
  .moo-tt-day, .moo-tt-typesel__opt, .moo-tt-typesel__opt i, #tt_entry_modal .moo-da-modal__icon { transition: none; }
}

/* ==========================================================================
   VELLO UI — wide screens: a centred reading column
   Phones are untouched. On desktop the header, content, chat box and composer
   share one gutter so their edges line up. Content-box widths are preserved
   (vertical padding / heights unchanged), only the horizontal gutter grows.
   ========================================================================== */
@media (min-width: 900px) {
  :root { --col: 760px; --gutter: max(20px, calc((100vw - var(--col)) / 2)); }
  body:has(.moo-chat) { --col: 900px; }
  .chat_top_info,
  .chats_cont,
  .chat_info_cont,
  #chatbox {
    padding-left: var(--gutter) !important;
    padding-right: var(--gutter) !important;
    width: calc(100% - 2 * var(--gutter)) !important;
  }
  .moo-chat-media__grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

/* ---- Skeleton loading (first paint of lists) ---- */
.moo-skel-list {
  display: block;
  background: transparent;
  text-align: left;
  position: absolute;
  top: var(--h-appbar);
  left: 0;
  right: 0;
  bottom: var(--h-tabbar);
  z-index: 9;
  padding: 20px 20px 0;
  overflow: hidden;
  pointer-events: none;
}
body:has(.moo-skel-list) #chats_list_cont { visibility: hidden; }
.moo-skel-row { display: flex; align-items: center; gap: 14px; height: 72px; }
.moo-skel-row__lines { flex: 1; display: flex; flex-direction: column; gap: 9px; }
.moo-skel {
  display: block;
  border-radius: var(--radius);
  background: linear-gradient(90deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.10) 40%, rgba(255,255,255,0.05) 80%) 0 0 / 300% 100%;
  animation: mooSkelShimmer 1.3s ease-in-out infinite;
}
.moo-skel--avatar { width: 52px; height: 52px; border-radius: var(--radius); flex-shrink: 0; }
.moo-skel--line { height: 12px; }
.moo-skel--sub { height: 10px; opacity: 0.7; }
.moo-skel-chat {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: stretch;
  gap: 8px;
  background: var(--color-bg);
  position: absolute;
  top: var(--h-appbar);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9;
  padding: 20px 20px 96px;
  overflow: hidden;
  pointer-events: none;
}
.moo-skel-bubble { height: 38px; border-radius: var(--radius); }
.moo-skel-bubble--l { align-self: flex-start; }
.moo-skel-bubble--r { align-self: flex-end; background-color: rgba(0, 229, 160, 0.06); }
.moo-skel--icon { width: 40px; height: 40px; border-radius: var(--radius); flex-shrink: 0; }
.moo-skel-wrap { display: flex; flex-direction: column; gap: 0; }
.moo-skel-wrap--rows .moo-skel-row { height: 62px; }
.moo-skel-wrap--rows .moo-skel-row + .moo-skel-row { border-top: 1px solid var(--hairline); }
.moo-skel-wrap--tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.moo-skel-tile { aspect-ratio: 1 / 1; border-radius: var(--radius); }
.moo-skel-wrap--bubbles { gap: 8px; justify-content: flex-end; }
.moo-skel-block { height: 220px; border-radius: var(--radius); }
/* Slow-navigation overlay: covers the content region with the target's shape */
.moo-nav-skel {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 50;
  box-sizing: border-box;
  padding: 20px;
  overflow: hidden;
  pointer-events: none;
  background: var(--color-bg);
  background-image:
    radial-gradient(120% 70% at 85% -10%, rgba(0, 229, 160, 0.08) 0%, transparent 55%),
    radial-gradient(90% 60% at -10% 30%, rgba(14, 165, 233, 0.08) 0%, transparent 60%);
  animation: velloFadeIn 160ms ease-out both;
}
.moo-nav-skel--bubbles .moo-skel-wrap { height: 100%; padding-bottom: 76px; box-sizing: border-box; }
@media (min-width: 900px) {
  .moo-nav-skel { padding-left: var(--gutter); padding-right: var(--gutter); }
}
.moo-info-skel { display: flex; flex-direction: column; gap: 14px; padding: 20px; }
.moo-info-skel .moo-skel-wrap--rows { padding: 0 14px; background: var(--surface-1); border: 1px solid var(--hairline); border-radius: var(--radius); }
.moo-info-skel .moo-skel-block { height: 120px; border-radius: var(--radius); }
.moo-tf-skel { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 6px 0 4px; }
.moo-tf-skel .moo-skel--line { align-self: stretch; }
.moo-tf-skel__qr { width: 200px; height: 200px; border-radius: var(--radius); margin-top: 6px; }
.moo-tf-skel__key { width: 100%; height: 64px; border-radius: var(--radius); }
.moo-pdf__skel { padding: 16px; }
.moo-pdf__skel .moo-skel-wrap--block { gap: 16px; }
.moo-pdf__skel .moo-skel-block { height: auto; aspect-ratio: 1 / 1.414; border-radius: var(--radius); }
/* AJAX refresh in flight: content dims softly, the pressed button spins */
.moo-refreshing { opacity: 0.55; transition: opacity var(--dur-2) var(--ease-out); pointer-events: none; }
button.is-busy { position: relative; color: transparent !important; }
button.is-busy::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-color: var(--text-2) var(--text-2) var(--text-2) transparent;
  animation: mooBusySpin 0.7s linear infinite;
}
@keyframes mooBusySpin { to { transform: rotate(360deg); } }
@keyframes mooSkelShimmer { from { background-position: 100% 0; } to { background-position: 0% 0; } }
@media (prefers-reduced-motion: reduce) { .moo-skel { animation: none; } }
@media (min-width: 900px) {
  .moo-skel-list { padding-left: var(--gutter); padding-right: var(--gutter); }
}

/* ==========================================================================
   VELLO UI — app layout + sizing scale
   <body> is a flex column: app bar (fixed height) / content (flex:1, scrolls)
   / tab bar or composer. No page hard-codes the bars' heights any more.
   Sizes: app bar = tab bar = composer 56, icon buttons 32, controls 44, base text 15.
   ========================================================================== */
body { display: flex; flex-direction: column; }
.chat_top_info {
  flex: 0 0 auto;
  box-sizing: border-box;
  width: 100% !important;
  height: var(--h-appbar) !important;
  padding: 0 16px !important;
  gap: 10px;
  font-size: var(--fs-lg);
}
.chats_cont,
#chatbox,
.chat_info_cont {
  flex: 1 1 auto;
  min-height: 0 !important;
  height: auto !important;
  max-height: none !important;
  font-size: var(--fs-body);
}
.bottom_nav,
.moo-chat-bar { flex: 0 0 auto; }
.chatbox_long { height: auto !important; min-height: 0 !important; max-height: none !important; }
body:has(.moo-chat) .chatbox_loading { inset: var(--h-appbar) 0 0 0 !important; }

/* App bar titles: large on tab roots, compact on sub-pages */
.header_top .header_text {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.header_top--sub .header_text,
.chat_top_info .chat_other_name {
  font-size: var(--fs-md);
  font-weight: 650;
  letter-spacing: -0.01em;
}
#chat_online_status { font-size: var(--fs-2xs); line-height: 14px; }
.cti_avatar, .cti_avatar img { width: 34px; height: 34px; border-radius: var(--radius); }
.cti_identity { gap: 10px; }

/* App bar icon buttons */
.hb_button,
.hb_button_multi,
.cti_right,
.chat_back_button {
  width: var(--h-iconbtn);
  height: var(--h-iconbtn);
  border-radius: var(--radius);
}
.hb_button i, .hb_button_multi i, .cti_right i { font-size: 13px; }
.chat_back_button i { font-size: 16px; }
.hbbm_cont { gap: 6px; }

/* Tab bar: icons only (a touch larger now there are no labels; the bar keeps
   its height), the active tab is simply mint (no plate) */
.bottom_nav { box-sizing: border-box; height: var(--h-tabbar) !important; }
.bnm_icon {
  width: auto;
  height: 26px;
  border-radius: 0;
  background: none !important;
  font-size: 22px;
}
.unread_badge { top: -4px; right: -10px; }

/* Composer */
.moo-chat-bar {
  box-sizing: border-box;
  width: 100% !important;
  /* single-line composer = app bar height (36px controls + 1px top border) */
  padding: calc((var(--h-appbar) - 37px) / 2) 14px !important;
}
.moo-chat-bar #user_message::placeholder { color: var(--text-4); }
/* A chat with no messages says so, under the encryption note. */
#chatbox.is-empty::after { content: 'No messages yet. Say hello.'; display: block; margin: 28px auto 0; text-align: center; font-size: var(--fs-sm); color: var(--text-3); }
/* On wide screens the composer's controls sit in the messages' column. */
@media (min-width: 900px) { .moo-chat-bar { padding-left: var(--gutter) !important; padding-right: var(--gutter) !important; } }

/* Titles: one scale (card 16, page/form 20, profile 24) */
.moo-settings-card .settings_item_title { font-size: var(--fs-md); }
.moo-form-card .settings_item_title { font-size: var(--fs-lg); }
.moo-form-card .cn_subtext { font-size: var(--fs-sm); margin-bottom: 20px; }
.moo-form-icon { width: 42px; height: 42px; font-size: 17px; margin-bottom: 14px; border-radius: var(--radius); }
.moo-form-card { padding: 22px 18px 20px; }
.moo-med-hero__name { font-size: var(--fs-lg); }
.contacts_page .contact_name { font-size: var(--fs-xl); }
.contacts_page .contact_pic { width: 96px; height: 96px; margin-bottom: 14px; }
.contacts_page .contact_pic img { border-radius: var(--radius); }
.moo-profile-hero__avatar, .moo-profile-hero__avatar img { width: 60px; height: 60px; border-radius: var(--radius); }
.moo-profile-hero__name { font-size: var(--fs-md); }
.moo-settings-card__icon { width: 32px; height: 32px; font-size: 13px; }
.moo-settings-card__header { margin-bottom: 12px; }
.moo-settings-card { padding: 16px; }

/* ==========================================================================
   iOS status bar (iOS 26)
   iOS 26 frosts the status bar unless a position:fixed element with an OPAQUE
   background sits at the very top; it then extends that colour up into the
   status bar. #moo_statusbar is that element: it covers the top safe-area
   inset plus the app bar's height, BEHIND the in-flow app bar (z 9 < 10), so
   the layout is unchanged. At phone widths every piece of chrome is opaque
   --bar-solid with no backdrop-filter, matching the safe-area fills exactly.
   ========================================================================== */
#moo_statusbar { display: none; }
@media (max-width: 899px) {
  #moo_statusbar {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: env(safe-area-inset-top, 0px);
    min-height: 1px;
    background: var(--bar-solid);
    pointer-events: none;
    z-index: 9;
  }
  body:has(.chat_top_info) #moo_statusbar { height: calc(env(safe-area-inset-top, 0px) + var(--h-appbar)); }
  .chat_top_info,
  .bottom_nav,
  .moo-chat-bar {
    background: var(--bar-solid) !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }
  body::before,
  body::after { background: var(--bar-solid); }
}

/* Shared inner parts: header (icon + title), body, actions */
.moo-nc-modal__header,
.moo-da-modal__header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 26px 22px 0;
  flex-shrink: 0;
}
.moo-nc-modal__icon,
.moo-da-modal__icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  color: var(--accent);
}
.moo-da-modal__icon { background: var(--danger-soft); color: var(--danger); }
.moo-nc-modal__title,
.moo-da-modal__title {
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  color: var(--text-1);
}
.moo-nc-modal__body,
.moo-da-modal__body {
  padding: 18px 22px;
  overflow-y: auto;
  overscroll-behavior: none;
  font-size: var(--fs-body);
  line-height: 1.5;
  color: var(--text-2);
}
.moo-nc-modal__hint {
  font-size: var(--fs-sm);
  line-height: 1.5;
  color: var(--text-3);
  margin-bottom: 12px;
}
.moo-nc-modal__form { display: contents; }
.moo-nc-modal__body.moo-modal__options { width: auto; }
.moo-nc-modal__input {
  box-sizing: border-box;
  width: 100%;
  height: 52px;
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  color: var(--text-1);
  font-size: var(--fs-input);
  font-weight: 500;
  font-family: var(--font-ui);
  outline: none;
  -webkit-appearance: none;
  user-select: text;
  -webkit-user-select: text;
  transition: border-color var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out);
}
.moo-nc-modal__input:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.moo-nc-modal__input::placeholder { color: var(--text-4); font-weight: 400; }
.moo-nc-modal__actions,
.moo-da-modal__actions {
  display: flex;
  gap: 10px;
  padding: 4px 22px 22px;
}
.moo-nc-modal__create,
.moo-da-modal__cancel,
.moo-da-modal__confirm,
.moo-da-modal__delete {
  flex: 1;
  box-sizing: border-box;
  height: var(--h-control);
  padding: 0 18px;
  border-radius: var(--radius);
  font-size: var(--fs-body);
  font-weight: 650;
  font-family: var(--font-ui);
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  transition: background-color var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out), transform var(--dur-1) var(--ease-out), opacity var(--dur-2) var(--ease-out);
}
.moo-nc-modal__create {
  background: linear-gradient(180deg, #1df2b4 0%, var(--accent) 45%, var(--accent-strong) 100%);
  border: 0;
  color: var(--accent-ink);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset, 0 8px 22px rgba(0, 229, 160, 0.16);
}
.moo-da-modal__cancel {
  background: var(--surface-2);
  border: 1px solid var(--hairline-strong);
  color: var(--text-1);
}
.moo-da-modal__confirm,
.moo-da-modal__delete {
  width: 100%;
  background: var(--danger);
  border: 0;
  color: #fff;
  box-shadow: 0 8px 22px rgba(255, 90, 115, 0.18);
}
.moo-da-modal__confirm:disabled,
.moo-da-modal__delete:disabled { opacity: 0.45; cursor: not-allowed; }
.moo-nc-modal__create:active,
.moo-da-modal__cancel:active,
.moo-da-modal__confirm:active,
.moo-da-modal__delete:active { transform: scale(0.98); }
.moo-nc-modal__create:disabled { opacity: 0.45; cursor: not-allowed; }
.moo-modal__option--danger,
.moo-modal__option--danger i { color: var(--danger) !important; }
button.moo-modal__option { width: 100%; font-family: var(--font-ui); cursor: pointer; }

@keyframes mooOverlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes mooModalIn {
  from { opacity: 0; transform: translate(-50%, -46%) scale(0.96); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  @keyframes mooOverlayIn { from, to { opacity: 1; } }
  @keyframes mooModalIn { from, to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
}

/* ==========================================================================
   VELLO UI — page transitions (cross-document View Transitions)
   The tab bar is pinned (never animates); tab switches crossfade; drilling
   into a sub-page slides the content in from the right, going back slides it
   the other way. Direction types are set in app.js (pagereveal). Browsers
   without support simply navigate as before.
   ========================================================================== */
@view-transition { navigation: auto; }
.bottom_nav { view-transition-name: vello-tabbar; }
.chat_top_info:not(.moo-info-panel *) { view-transition-name: vello-appbar; }
.chats_cont,
#chatbox,
.chat_info_cont:not(.moo-info-panel *) { view-transition-name: vello-page; }
::view-transition-group(vello-tabbar) { animation: none; }
::view-transition-old(vello-tabbar),
::view-transition-new(vello-tabbar) { animation: none; }
::view-transition-old(root),
::view-transition-new(root) { animation-duration: 180ms; }
::view-transition-group(vello-page),
::view-transition-group(vello-appbar) { animation-duration: 260ms; animation-timing-function: var(--ease-out); }
::view-transition-old(vello-appbar),
::view-transition-new(vello-appbar) { animation-duration: 200ms; }
@keyframes velloSlideInFromRight { from { transform: translateX(28%); opacity: 0; } }
@keyframes velloSlideOutToLeft   { to   { transform: translateX(-12%); opacity: 0; } }
@keyframes velloSlideInFromLeft  { from { transform: translateX(-12%); opacity: 0; } }
@keyframes velloSlideOutToRight  { to   { transform: translateX(28%); opacity: 0; } }
@keyframes velloFadeIn  { from { opacity: 0; } }
@keyframes velloFadeOut { to   { opacity: 0; } }
html:active-view-transition-type(forward)::view-transition-old(vello-page) { animation: velloSlideOutToLeft 240ms var(--ease-out) both; }
html:active-view-transition-type(forward)::view-transition-new(vello-page) { animation: velloSlideInFromRight 280ms var(--ease-out) both; }
html:active-view-transition-type(back)::view-transition-old(vello-page) { animation: velloSlideOutToRight 240ms var(--ease-out) both; }
html:active-view-transition-type(back)::view-transition-new(vello-page) { animation: velloSlideInFromLeft 280ms var(--ease-out) both; }
html:active-view-transition-type(tab)::view-transition-old(vello-page) { animation: velloFadeOut 140ms ease-out both; }
html:active-view-transition-type(tab)::view-transition-new(vello-page) { animation: velloFadeIn 200ms ease-out both; }
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}
/* ===== Composer attachment toggle ===== */
.moo-attach-toggle {
  position: relative;
  display: block;
  width: 20px;
  height: 20px;
}
.moo-attach-toggle i {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-spring);
}
.moo-attach-toggle i:last-child {
  opacity: 0;
  transform: rotate(-90deg) scale(0.55);
}
#attach_message.is-open {
  background: var(--accent-soft);
  color: var(--accent);
}
#attach_message.is-open .moo-attach-toggle i:first-child {
  opacity: 0;
  transform: rotate(90deg) scale(0.55);
}
#attach_message.is-open .moo-attach-toggle i:last-child {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}
#attach_message:focus-visible,
#send_message:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-line);
}

/* ---- Final attachment-bubble polish ---- */
body:has(.moo-chat) .moo-chat-bar #attach_message {
  position: relative;
}
/* Keep the visual 36px control but give it a 44px touch target. */
body:has(.moo-chat) .moo-chat-bar #attach_message::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: inherit;
}
body:has(.moo-chat) .moo-chat-bar #attach_message.is-open {
  background: var(--accent-soft) !important;
  color: var(--accent) !important;
}
.moo-attach-bubble__title { color: var(--text-2); }
.moo-attach-bubble__hint { color: var(--text-3); }


/* Device list */

/* Pair flow */

/* Modals: solid enough, and blurred behind, that the page never reads through
   them (the Time Tracker sheet already looked like this). */
#med_del_modal, #ic_modal, #cu_modal, #cp_modal, #rk_modal, #tf_modal, #tfd_modal, #nm_modal, #ph_modal, #grm_modal, #gi_modal, #chats_popup, #pn_asked_popup,
body:has(.moo-chat) :is(#forward_popup, #message_options_popup, #klipy_popup, #ms_popup) {
  background: rgba(15, 23, 29, 0.97);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  backdrop-filter: blur(24px) saturate(1.3);
}

/* The close button on modals that had only a tap outside (Forward to, GIF search). */
.moo-modal__x {
  position: absolute; top: 12px; right: 12px; z-index: 1; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; border: 1px solid var(--hairline); background: var(--surface-2);
  color: var(--text-2); font-size: 15px; cursor: pointer;
}
.moo-modal__x:hover { color: var(--text-1); }
.moo-modal__x:focus-visible { outline: 2px solid var(--color-accent, #6fe3c0); outline-offset: 2px; }

.chat_name_sub--empty { font-style: italic; opacity: .7; }

/* Every popup's backdrop dims the page (the chats list had it; contacts did not). */
#chats_popup_wrap { background: rgba(6, 13, 16, 0.6); }
