:root {
  color-scheme: light;
  --bg: #eef2f5;
  --surface: #ffffff;
  --surface-muted: #f1f5f8;
  --line: #d9e1e8;
  --line-strong: #b9c7d2;
  --text: #14202b;
  --muted: #5d6d7a;
  --accent: #1a5fb4;
  --accent-strong: #154a8c;
  --accent-soft: #e3eefb;
  --danger: #b42318;
  --ok: #166534;
  --alloff-bg: #e7f6ec;
  --alloff-line: #8fd3a6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 32, 43, 0.06), 0 8px 24px rgba(20, 32, 43, 0.06);
  --sidebar-w: 232px;
  --header-h: calc(54px + env(safe-area-inset-top, 0px));
  /* sidebar nav-group glass cards */
  --nav-group-bg: rgba(255, 255, 255, 0.46);
  --nav-group-border: rgba(185, 199, 210, 0.6);
  --nav-group-shadow: 0 1px 2px rgba(20, 32, 43, 0.04), 0 6px 16px rgba(20, 32, 43, 0.05);
  /* premium zone — calm, professional deep-teal accent */
  --premium: #0f8676;
  --premium-strong: #0c6e60;
  --premium-zone-bg: linear-gradient(180deg, rgba(15, 134, 118, 0.06) 0%, rgba(15, 134, 118, 0.02) 100%), rgba(255, 255, 255, 0.46);
  --premium-zone-border: rgba(15, 134, 118, 0.26);
  --premium-pill-bg: rgba(15, 134, 118, 0.10);
  --premium-box-bg: rgba(15, 134, 118, 0.11);
  --premium-box-border: rgba(15, 134, 118, 0.30);
  /* event type colors */
  --t-flight: #1a5fb4;
  --t-checkin: #2e7d32;
  --t-checkout: #00838f;
  --t-hotel: #6a3fb5;
  --t-standby: #c77700;
  --t-off: #6b7785;
  --t-ground: #5b6488;
  --t-activity: #5d6d7a;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #f6f9fb 0%, var(--bg) 100%);
  color: var(--text);
}

/* Dark mode — light stays the default; only the theme variables are overridden. */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1722;
  --surface: #18222e;
  --surface-muted: #212d3a;
  --line: #2a3744;
  --line-strong: #3a4a59;
  --text: #e7eef4;
  --muted: #93a3b1;
  --accent: #58a6ff;
  --accent-strong: #84beff;
  --accent-soft: #16304a;
  --danger: #f06c6c;
  --ok: #5dbf73;
  --alloff-bg: #16301f;
  --alloff-line: #2f6b41;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px rgba(0, 0, 0, 0.4);
  --nav-group-bg: rgba(33, 45, 58, 0.5);
  --nav-group-border: rgba(58, 74, 89, 0.65);
  --nav-group-shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 6px 16px rgba(0, 0, 0, 0.32);
  --premium: #4cc4b2;
  --premium-strong: #6fd2c3;
  --premium-zone-bg: linear-gradient(180deg, rgba(42, 168, 151, 0.11) 0%, rgba(42, 168, 151, 0.035) 100%), rgba(33, 45, 58, 0.5);
  --premium-zone-border: rgba(42, 168, 151, 0.30);
  --premium-pill-bg: rgba(42, 168, 151, 0.16);
  --premium-box-bg: rgba(42, 168, 151, 0.16);
  --premium-box-border: rgba(42, 168, 151, 0.34);
  --t-flight: #3b82d6;
  --t-checkin: #3f9e48;
  --t-checkout: #2196a3;
  --t-hotel: #8b5fd1;
  --t-standby: #d98b2b;
  --t-off: #7a8896;
  --t-ground: #8b95c2;
  --t-activity: #93a3b1;
}
[data-theme="dark"] body {
  background: var(--bg);
}

.theme-toggle {
  margin-left: auto;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.theme-toggle svg {
  width: 17px;
  height: 17px;
  display: block;
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  border: 1px solid transparent;
}

a {
  color: var(--accent);
}

h1, h2 {
  letter-spacing: -0.01em;
}

/* Layout */
.app-layout {
  display: grid;
  /* minmax(0, …) caps the content track at the viewport — a plain 1fr has min-width:auto and
     EXPANDS to fit fixed content (e.g. the topbar's icons), pushing the whole page into
     horizontal scroll. The 0-min forces children (brand title, calendar) to shrink instead. */
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: var(--header-h) 1fr;
  grid-template-areas:
    "header header"
    "sidebar content";
  min-height: 100vh;
  /* Final guard: clip any residual horizontal spill (borders, sub-pixel rounding) so the page
     never scrolls sideways. `clip` keeps vertical scroll + the sticky topbar working. */
  overflow-x: clip;
}
/* Collapse the sidebar column on booting / signed-out screens */
.app-layout.no-sidebar {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "header"
    "content";
}
.app-layout.no-sidebar .sidebar { display: none; }

/* ── Global header bar (spans full width, sticky) ── */
.topbar {
  grid-area: header;
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: env(safe-area-inset-top, 0px) calc(0.9rem + env(safe-area-inset-right, 0px)) 0 calc(1.1rem + env(safe-area-inset-left, 0px));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  /* Must stay visible so the account dropdown (Logout) can drop below the bar. Horizontal
     overflow is already prevented by .brand-title truncation + flex-shrink:0 on the actions. */
  overflow: visible;
}
.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0; /* actions keep their size; the title truncates instead of overflowing */
}
.topbar-actions .theme-toggle { margin-left: 0; }

.topbar-icon {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.topbar-icon:hover { border-color: var(--accent); color: var(--accent); }
.topbar-icon.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.topbar-icon svg { width: 18px; height: 18px; display: block; }
/* Study mode: tint the parenthesised furigana readings, e.g. 良(よ)い */
.dm-furi { color: var(--accent); }
.topbar-badge {
  position: absolute;
  top: -5px;
  right: -4px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 17px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.account { position: relative; }
.account-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  padding: 0;
  cursor: pointer;
  background: transparent;
}
.account-ava {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}
.account-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 190px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 50;
}
.account-menu .ghost-button { width: 100%; }
.account-version {
  font-size: 0.7rem;
  color: var(--muted);
  text-align: center;
  padding-top: 2px;
  letter-spacing: 0.02em;
}
.account-version:empty { display: none; }

.sidebar {
  grid-area: sidebar;
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  height: calc(100svh - var(--header-h));
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.85rem 0.85rem;
  background: linear-gradient(168deg, var(--surface) 0%, var(--surface-muted) 100%);
  border-right: 1px solid var(--line);
  overflow: hidden;
}

.brand-title {
  font-weight: 800;
  font-size: 1.18rem;
  white-space: nowrap;
  color: var(--text);
  text-decoration: none;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.beta-badge {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--accent-strong);
  background: var(--accent-soft);
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.nav-version {
  margin-top: auto;
  padding: 0.6rem 0.5rem 0.2rem;
  font-size: 0.68rem;
  color: var(--muted);
  text-align: center;
  letter-spacing: 0.03em;
  opacity: 0.7;
  flex-shrink: 0;
}
.nav-version:empty { display: none; }

/* "More" tab + bottom sheet exist only on the mobile tab bar (shown in the media query) */
.nav-more-btn { display: none; }
.more-sheet,
.more-backdrop { display: none; }
@keyframes moreSheetUp {
  from { transform: translateY(14px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .more-sheet:not([hidden]) { animation: none; }
  #premiumMobileBar.pmb-pulse { animation: none; }
}

/* Each category becomes a frosted glass card so sections read as distinct groups. */
.nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.25rem 0.3rem 0.3rem;
  background: var(--nav-group-bg);
  border: 1px solid var(--nav-group-border);
  border-radius: 14px;
  box-shadow: var(--nav-group-shadow);
  -webkit-backdrop-filter: blur(10px) saturate(1.15);
  backdrop-filter: blur(10px) saturate(1.15);
}
/* per-section accent colour (used by the label dot) */
.nav-group:nth-of-type(1) { --nav-accent: var(--t-flight); }
.nav-group:nth-of-type(2) { --nav-accent: var(--t-checkout); }
.nav-group:nth-of-type(3) { --nav-accent: var(--t-standby); }
.nav-group:nth-of-type(4) { --nav-accent: var(--accent); }

/* Direct (Messages) — standalone category with an unread badge */
.nav-item-messages { position: relative; }
.nav-item-label { flex: 1; }
.nav-badge {
  min-width: 18px; height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 0.66rem; font-weight: 800;
  line-height: 18px; text-align: center;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.nav-section {
  margin: 0;
  padding: 0.35rem 0.6rem 0.3rem;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.nav-section::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--nav-accent, var(--accent));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--nav-accent, var(--accent)) 18%, transparent);
  flex-shrink: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-align: left;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text);
  font-weight: 600;
  padding: 0.45rem 0.75rem;
}

.nav-item:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--accent);
}
.nav-icon svg {
  width: 18px;
  height: 18px;
}
.nav-item.active .nav-icon { color: var(--accent-strong); }
/* premium-zone items use the teal accent for their icons */
.nav-premium-zone .nav-icon { color: var(--premium); }

/* ── Premium zone — calm, professional ── */
.nav-premium-zone {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.15rem;
  padding: 0.5rem 0.4rem 0.45rem;
  border-radius: 14px;
  background: var(--premium-zone-bg);
  border: 1px solid var(--premium-zone-border);
  box-shadow: var(--nav-group-shadow);
  -webkit-backdrop-filter: blur(10px) saturate(1.15);
  backdrop-filter: blur(10px) saturate(1.15);
}
/* legacy glow element no longer used — keep hidden if present */
.nav-premium-glow { display: none; }

.nav-premium-header {
  position: relative;
  display: flex;
  align-items: center;
  padding: 0.25rem 0.6rem 0.1rem;
  min-width: 0;
}
.nav-premium-title {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--premium);
}

/* inner sections flatten so the zone reads as one glass surface */
.nav-premium-zone .nav-group {
  background: transparent;
  border: none;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  padding: 0 0.05rem;
}
/* sub-section headers (Explore / Crew / Direct) — label + trailing divider line */
.nav-subsection {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem 0.3rem;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--premium-strong);
}
.nav-subsection::before { content: none; }   /* drop the dot */
.nav-subsection::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--premium-zone-border);
}

/* bottom status box — crown + label + duration */
.nav-premium-status-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 0.4rem;
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
  background: var(--premium-box-bg);
  border: 1px solid var(--premium-box-border);
}
.nav-premium-status-box .status-line {
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-premium-status-box .status-icon { flex-shrink: 0; color: var(--premium); }
.nav-premium-status-box .status-name { font-size: 0.8rem; font-weight: 700; color: var(--premium); }
.nav-premium-status-box .status-dur  { font-size: 0.7rem; font-weight: 600; color: var(--muted); padding-left: 1px; }
.nav-premium-status-box.is-warn   { background: color-mix(in srgb, var(--t-standby) 14%, transparent); border-color: color-mix(in srgb, var(--t-standby) 34%, transparent); }
.nav-premium-status-box.is-warn   .status-icon,
.nav-premium-status-box.is-warn   .status-name { color: var(--t-standby); }
.nav-premium-status-box.is-locked { background: color-mix(in srgb, var(--danger) 12%, transparent); border-color: color-mix(in srgb, var(--danger) 32%, transparent); }
.nav-premium-status-box.is-locked .status-icon,
.nav-premium-status-box.is-locked .status-name { color: var(--danger); }

/* locked state — dim + disable the bundle's sections (not the status box) */
.nav-premium-zone--locked .nav-group {
  opacity: 0.4;
  pointer-events: none;
  filter: saturate(0.4);
}

.nav-premium-upgrade {
  position: relative;
  margin-top: 0.15rem;
  padding: 0.6rem 0.7rem;
  border-radius: 12px;
  background: var(--premium-pill-bg);
  border: 1px solid var(--premium-zone-border);
}
.nav-upgrade-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--premium-strong);
  margin-bottom: 2px;
}
.nav-upgrade-sub {
  font-size: 0.68rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.nav-upgrade-btn {
  width: 100%;
  padding: 0.42rem;
  font-size: 0.74rem;
  font-weight: 700;
  background: var(--premium);
  color: #fff;
  border: none;
  border-radius: 9px;
  cursor: pointer;
}
.nav-upgrade-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* welcome / member: "Included" tag on the status line */
.nav-premium-status-box .status-tag {
  margin-left: auto;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--premium-strong);
  background: color-mix(in srgb, var(--premium) 16%, transparent);
  padding: 1px 7px;
  border-radius: 20px;
}

/* welcome spotlight — the calm one-tap "start your 6 months" card */
.nav-welcome { position: relative; }
.nav-welcome-fine {
  margin-top: 0.4rem;
  font-size: 0.6rem;
  line-height: 1.35;
  color: var(--muted);
}
.nav-welcome-dismiss {
  position: absolute;
  top: 0.25rem;
  right: 0.35rem;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
.nav-welcome-dismiss:hover { color: var(--premium-strong); }
.nav-welcome-pulse { animation: welcomePulse 0.6s ease; }
@keyframes welcomePulse {
  0%, 100% { box-shadow: 0 0 0 0 transparent; }
  50% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--premium) 35%, transparent); }
}

.sidebar-footer {
  flex-shrink: 0;   /* never compressed — nav (flex:1) absorbs all slack */
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.user-chip {
  padding: 0 0.5rem;
  text-align: center;
  overflow: hidden;
}
.user-name {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-email {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ghost-button {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--text);
  padding: 0.45rem 0.9rem;
  min-height: 36px;
}

.ghost-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.content {
  grid-area: content;
  padding: 1.5rem;
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* Hard guard: no view may ever scroll the page sideways. `clip` (not hidden) clips the
     x-axis without turning the y-axis into a scroll container, so vertical scroll/sticky stay. */
  overflow-x: clip;
}
/* Messages needs an edge-to-edge full-height canvas so the left/right divider
   runs all the way down. Drop the content padding only while it's the live view. */
.content:has(#messagesView:not([hidden])) {
  padding: 0;
}

/* ROOT FIX for "input not pinned": the base .app-layout uses min-height:100vh, so
   its grid 1fr 'content' track is free to grow with .dm-messages content and pushes
   the input row off-screen. While the chat is open, lock the shell to a DEFINITE
   viewport height so the 1fr track caps at (100vh - header) — then the already-correct
   flex chain (#appBody → #messagesView → .dm-layout → .dm-right) bounds .dm-messages,
   which becomes the internal scroller while .dm-input-row (flex-shrink:0) stays pinned.
   Scoped to the chat view via :has() so the tall scroll-the-page views (sync, calendar,
   signed-out) keep their normal page-scroll behavior and are never clipped. */
.app-layout:has(#messagesView:not([hidden])) {
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}

/* Signed-in shell fills the content area so percentage/flex heights resolve. */
#appBody:not([hidden]) {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#messagesView {
  gap: 0;
  flex: 1;
  min-height: 0;
  padding: 0;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.center-card {
  text-align: center;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  max-width: 560px;
  margin: 2rem auto;
}

.card-title {
  margin: 0 0 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* Hero / signed-out */
.hero {
  text-align: center;
  max-width: 560px;
  margin: 2rem auto;
}

.hero h1 {
  margin: 0.5rem 0 0.75rem;
  font-size: 1.8rem;
}

.hero-sub {
  margin: 0 auto 1.5rem;
  max-width: 30rem;
  color: var(--muted);
  line-height: 1.6;
}

/* Scannable 3-step "how it works" list on the sign-in screen — replaces a dense
   paragraph so the whole flow is graspable at a glance. */
.hero-steps {
  list-style: none;
  margin: 0.25rem auto 1.6rem;
  padding: 0;
  max-width: 23rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  text-align: left;
}

.hero-steps li {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-size: 1rem;
  line-height: 1.4;
  color: var(--text);
}

.hero-step-num {
  flex-shrink: 0;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.google-button {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-weight: 600;
  padding: 0.7rem 1.4rem;
  min-height: 46px;
  box-shadow: var(--shadow);
}

.google-button:hover {
  border-color: var(--accent);
}

.fine-print {
  margin-top: 1.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Consent gate — flip the Calendar switch ON to unlock "Continue to Google" */
.consent-badge {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin: 0 auto 0.5rem;
}
.consent-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-align: left;
  max-width: 30rem;
  margin: 0.5rem auto 0.75rem;
  padding: 0.8rem 0.95rem;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  transition: border-color 0.15s, background 0.15s;
}
.consent-row.on {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.consent-row-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}
.consent-row-label {
  flex: 1;
  min-width: 0;
}
.consent-row-label strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
}
.consent-row-label span {
  font-size: 0.78rem;
  color: var(--muted);
}
.consent-switch {
  flex-shrink: 0;
  width: 48px;
  height: 28px;
  border-radius: 999px;
  border: none;
  background: var(--line-strong);
  position: relative;
  cursor: pointer;
  padding: 0;
  transition: background 0.18s;
}
.consent-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(20, 32, 43, 0.2);
  transition: left 0.18s;
}
.consent-switch.on {
  background: var(--accent);
}
.consent-switch.on .consent-knob {
  left: 23px;
}
.consent-gate-hint {
  max-width: 30rem;
  margin: 0 auto 1rem;
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 1.2rem;
}
.consent-gate-hint.go {
  color: var(--accent-strong);
  font-weight: 600;
}
.google-button.is-locked {
  opacity: 0.45;
  cursor: not-allowed;
}
.consent-row.shake {
  animation: consentShake 0.3s;
}
@keyframes consentShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
@media (prefers-reduced-motion: reduce) {
  .consent-row.shake { animation: none; }
}

/* Dropzone */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  text-align: center;
  padding: 2rem 1rem;
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-muted);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover,
.dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone-icon {
  font-size: 1.8rem;
}

.dropzone-text {
  font-weight: 600;
}

.dropzone-hint {
  font-size: 0.8rem;
  color: var(--muted);
}

/* Summary */
.summary-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.summary-period {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.summary-meta {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.summary-total {
  text-align: right;
  line-height: 1.1;
}

.summary-total strong {
  font-size: 1.6rem;
  color: var(--accent);
}

.summary-total span {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
}

.count-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.count-chip {
  font-size: 0.82rem;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  color: var(--muted);
}

.count-chip strong {
  color: var(--text);
}

/* AI-extracted roster badge (Phase 3 standalone extraction). Theme-driven colors only. */
.ai-extracted-badge {
  display: inline-block;
  margin-left: 0.45rem;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.22rem 0.5rem;
  border-radius: 999px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  vertical-align: middle;
}

/* Parse warning (e.g. flights not recognised) */
.parse-warning {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--standby, var(--t-standby));
  border-radius: 10px;
  background: var(--surface-muted);
}
.parse-warning-title {
  margin: 0 0 0.25rem;
  font-weight: 700;
  color: var(--t-standby);
  font-size: 0.92rem;
}
.parse-warning-sub {
  margin: 0 0 0.5rem;
  font-size: 0.84rem;
  color: var(--muted);
}
.parse-warning-lines {
  margin: 0;
  padding: 0.6rem 0.7rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  -webkit-user-select: all;
  user-select: all;
}

.parse-help {
  border-left: 3px solid var(--t-standby);
}
.parse-help-lead {
  margin: 0 0 0.6rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--muted);
}
.parse-help-details {
  margin-top: 0.85rem;
}
.parse-help-details > summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}
.parse-help-details[open] > summary {
  margin-bottom: 0.5rem;
}

.primary-button {
  width: 100%;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  min-height: 48px;
  padding: 0 1.2rem;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.primary-button:disabled {
  background: var(--line-strong);
  border-color: var(--line-strong);
  cursor: default;
}

/* Sync progress */
.sync-progress {
  margin-top: 0.75rem;
}

.sync-progress-track {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  overflow: hidden;
}

.sync-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  transition: width 0.3s ease;
}

.sync-progress-text {
  margin: 0.5rem 0 0;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.link-button {
  display: block;
  margin: 0.85rem auto 0;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.8rem;
  text-decoration: underline;
}

.link-button:hover {
  color: var(--danger);
}

.status {
  margin: 0;
  padding: 0 0.25rem;
  font-size: 0.9rem;
  color: var(--muted);
  min-height: 1.2rem;
}

/* A finished sync (or a failure) is important — render it as a clear, readable banner
   with an icon instead of tiny coloured text that's easy to miss. Plain/loading status
   (no tone) keeps the subtle inline style above. */
/* But an EMPTY status (e.g. the PIN prompt's error slot before any error) must not show
   as a blank coloured box with a lone icon — collapse it until it has text. */
.status.success:empty,
.status.error:empty { display: none; }
.status.success,
.status.error {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.5rem;
  padding: 0.9rem 1.05rem;
  border-radius: 14px;
  border: 1px solid;
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.45;
}

.status.success::before,
.status.error::before {
  flex-shrink: 0;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
}

.status.success {
  color: var(--ok);
  background: color-mix(in srgb, var(--ok) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--ok) 38%, transparent);
}

.status.success::before {
  content: "✓";
  background: var(--ok);
}

.status.error {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--danger) 38%, transparent);
}

.status.error::before {
  content: "!";
  background: var(--danger);
}

/* Two-line success: a bold headline + a smaller, lower-emphasis detail line. */
.status-text {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  min-width: 0;
}

.status-title {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.status-detail {
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0.82;
}

/* Spinner */
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Calendar */
.calendar-card {
  padding: 1.25rem;
}

.calendar-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.cal-jump-wrap {
  position: relative;
}

/* calendar-month pill button — Option A */
.calendar-month {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.1rem 0 0.2rem;
  padding: 4px 10px 4px 4px;
  background: var(--surface-muted);
  border: 1.5px solid var(--line-strong);
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.2;
  transition: border-color 0.15s, background 0.15s;
}
.calendar-month:hover {
  border-color: var(--accent);
  background: var(--surface);
}
.calendar-month[aria-expanded="true"] {
  border-color: var(--accent);
}
.cal-month-icon {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
}
.cal-month-text {
  flex: 1;
}
.cal-month-caret {
  display: flex;
  align-items: center;
  color: var(--accent);
  margin-left: 1px;
}

/* Month/year jump picker */
.cal-jump-picker {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0.75rem;
  box-shadow: 0 6px 20px rgba(0,0,0,0.18);
  min-width: 200px;
}
.cal-jump-year-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}
.cal-jump-year-row button {
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--text);
  cursor: pointer;
  border-radius: 4px;
  font-size: 1rem;
}
.cal-jump-year-row button:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.cal-jump-year-label {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  letter-spacing: 0.02em;
}
.cal-jump-months {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.cal-jump-mo-btn {
  padding: 0.4rem 0;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--text);
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.82rem;
  text-align: center;
}
.cal-jump-mo-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.cal-jump-mo-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.calendar-sub {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}
/* Flight time stands out and stays whole (its own unbroken chunk when the line wraps). */
.cal-flight {
  color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
}

.calendar-nav {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.calendar-nav button {
  min-height: 34px;
  min-width: 34px;
  padding: 0 0.7rem;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
}

.calendar-nav button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.calendar-grid {
  display: grid;
  /* minmax(0, 1fr) caps each column at 1/7 of the row — without the 0 min, a nowrap chip's
     min-content widens the column and pushes the whole page into horizontal scroll (Team view). */
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.calendar-weekday {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 0.35rem 0;
}

.calendar-day {
  min-height: 96px;
  min-width: 0; /* allow the cell to shrink within its track so chips truncate (no page overflow) */
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 0.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  overflow: hidden;
}
/* Long-press magnifies — never let the OS hijack the hold with text selection
   or the iOS callout menu (Copy / Look Up / Translate). */
.calendar-day,
.calendar-day * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.calendar-day.outside {
  background: var(--surface-muted);
  color: var(--muted);
}

.calendar-day.today {
  background: var(--accent-soft);
  border-color: var(--accent);
  border-width: 1.5px;
}
.calendar-day.today .calendar-date {
  color: var(--accent-strong);
}
.calendar-day.today .calendar-date::after {
  content: "Today";
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--accent);
  margin-left: 4px;
}

.calendar-date {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.calendar-date small {
  font-weight: 500;
  color: var(--accent-strong);
}

.calendar-events {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.calendar-event {
  font-size: 0.68rem;
  line-height: 1.25;
  padding: 1px 5px;
  border-radius: 5px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--t-activity);
}

/* Check-in/out chip: the compact "C/I 17:00" / "C/O 22:20" form is used on every screen
   size so the label never truncates to "Check In a…". The full label is kept in the DOM
   for the title tooltip / accessibility but hidden visually. */
.calendar-event .chip-full { display: none; }
.calendar-event .chip-short { display: inline; }

.calendar-event.flight { background: var(--t-flight); }
.calendar-event.check-in { background: var(--t-checkin); }
.calendar-event.check-out { background: var(--t-checkout); }
.calendar-event.hotel { background: var(--t-hotel); }
.calendar-event.standby { background: var(--t-standby); }
.calendar-event.off-leave { background: var(--t-off); }
.calendar-event.ground { background: var(--t-ground); }
.calendar-event.duty { background: var(--accent-strong); }

.calendar-more {
  font-size: 0.66rem;
  color: var(--muted);
  padding-left: 4px;
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.1rem;
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
  font-size: 0.78rem;
  color: var(--muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
  background: var(--t-activity);
}

.dot.flight { background: var(--t-flight); }
.dot.check-in { background: var(--t-checkin); }
.dot.check-out { background: var(--t-checkout); }
.dot.hotel { background: var(--t-hotel); }
.dot.standby { background: var(--t-standby); }
.dot.off-leave { background: var(--t-off); }
.dot.ground { background: var(--t-ground); }

/* Friends */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
  border-top: 0.5px solid var(--line);
}

.setting-row:first-of-type {
  border-top: none;
}

.setting-label {
  font-size: 0.95rem;
  font-weight: 500;
}

.setting-sub {
  font-size: 0.8rem;
  color: var(--muted);
}

/* Compact profile card */
.profile-card {
  padding: 0.75rem 1rem;
}
.profile-card .card-title {
  margin-bottom: 0.4rem;
}
.profile-card .setting-row {
  padding: 0.35rem 0;
}
.profile-card .setting-sub {
  display: none;
}
.profile-card .setting-label {
  font-size: 0.875rem;
}

.scope-group {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 2px;
  gap: 2px;
}

.scope-seg {
  font-size: 0.8rem;
  padding: 5px 11px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
}

.scope-seg.on {
  background: var(--accent);
  color: #fff;
}

select,
input[type="text"],
input[type="email"] {
  font: inherit;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.friend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-top: 0.5px solid var(--line);
}

.friend-row:first-of-type {
  border-top: none;
}

.av-sm {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 500;
  flex-shrink: 0;
}

.friend-name {
  font-size: 0.95rem;
  font-weight: 500;
}

.air {
  font-size: 0.66rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-muted);
  color: var(--muted);
  vertical-align: 1px;
}

/* Team overlay */
.team-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.team-toggle {
  font-size: 0.8rem;
  padding: 5px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.team-toggle.on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}

/* Named Teams */
.team-tabs-wrap {
  margin-bottom: 0.75rem;
}
.team-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 4px;
}
.team-tab {
  font-size: 0.8rem;
  padding: 5px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}
.team-tab.on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
  font-weight: 600;
}
.team-tab-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.team-tab-new {
  border-style: dashed;
}
.team-mgmt-btns {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 4px;
}
.team-tab-edit {
  font-size: 0.75rem;
  padding: 3px 10px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
}
.team-tab-del {
  font-size: 0.75rem;
  padding: 3px 10px;
  border: 1px solid var(--danger);
  border-radius: 999px;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
}
.team-create-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.5rem;
}
.tcp-top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.tcp-input {
  flex: 1;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 0.75rem;
  font: inherit;
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--text);
}
.tcp-colors {
  display: flex;
  gap: 5px;
}
.tcp-color-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}
.tcp-color-btn.on {
  border-color: var(--text);
}
.tcp-members {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tcp-member-row {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.82rem;
  color: var(--text);
  cursor: pointer;
  background: var(--surface-muted);
  padding: 4px 10px 4px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
}
.tcp-member-row input[type="checkbox"] {
  width: 13px;
  height: 13px;
  cursor: pointer;
}
.tcp-hint {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0;
}
/* Leader's member-management panel + role badges */
.team-leader { font-size: 0.85em; }
.tcp-manage { display: flex; flex-direction: column; gap: 6px; }
.tcp-section { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); margin: 8px 0 2px; }
.tcp-mlist { display: flex; flex-direction: column; gap: 5px; }
.tcp-mrow {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-muted); border: 1px solid var(--line);
  border-radius: 10px; padding: 5px 8px;
}
.tcp-mname { flex: 1; min-width: 0; font-size: 0.86rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tcp-leadtag { font-size: 0.72rem; font-weight: 700; color: var(--accent); }
.tcp-invtoggle {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  font-size: 0.74rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; cursor: pointer;
}
.tcp-invtoggle.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
.tcp-mremove {
  border: none; background: transparent; color: var(--muted);
  font-size: 0.95rem; line-height: 1; width: 24px; height: 24px; border-radius: 6px; cursor: pointer; flex: 0 0 auto;
}
.tcp-mremove:hover { color: var(--error, #e0655a); background: var(--surface); }
.tcp-addlist { display: flex; flex-wrap: wrap; gap: 6px; }
.tcp-addbtn {
  border: 1px dashed var(--line); background: transparent; color: var(--text);
  font-size: 0.8rem; padding: 5px 11px; border-radius: 999px; cursor: pointer;
}
.tcp-addbtn:hover { border-style: solid; border-color: var(--accent); color: var(--accent-strong); }
.tcp-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.team-find-btn {
  font-size: 0.78rem;
  padding: 5px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  white-space: nowrap;
}
.team-find-btn.on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}
.find-day-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  /* Sits at the top of the Team view (above the calendar) so it's visible without scrolling. */
  margin: 0 0 1rem;
}
.find-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.find-day-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.find-day-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 2px 6px;
}
.find-day-summary {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0 0 0.75rem;
}
.avail-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.avail-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.avail-date {
  font-size: 0.78rem;
  color: var(--text);
  min-width: 100px;
}
.avail-bar-wrap {
  flex: 1;
  height: 8px;
  background: var(--surface-muted);
  border-radius: 999px;
  overflow: hidden;
}
.avail-bar {
  height: 100%;
  border-radius: 999px;
  transition: width 0.2s;
}
.avail-label {
  font-size: 0.75rem;
  color: var(--muted);
  min-width: 30px;
  text-align: right;
}
.avail-label.all {
  color: var(--ok);
  font-weight: 600;
}
.avail-copy {
  font-size: 0.72rem;
  padding: 2px 9px;
  border: 1px solid var(--ok);
  border-radius: 999px;
  background: transparent;
  color: var(--ok);
  cursor: pointer;
}

/* ============================================================
   Responsive — mobile gets an app-like shell:
   slim top bar (brand + account) + fixed bottom tab nav.
   ============================================================ */
@media (max-width: 720px) {
  .app-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--header-h) 1fr;
    grid-template-areas:
      "header"
      "content";
  }

  /* Slim the top bar so all action icons + brand fit a phone without overflow. */
  .beta-badge { display: none; }
  .topbar { gap: 0.4rem; }
  .topbar-actions { gap: 0.3rem; }
  .topbar-icon, .theme-toggle, .account-btn, .account-ava { width: 31px; height: 31px; }
  .brand-title { font-size: 1.05rem; }

  /* The global header IS the mobile top bar; the sidebar only hosts the bottom nav. */
  .sidebar {
    display: contents;
  }
  .brand-title {
    white-space: nowrap;
    font-size: 1.1rem;
  }

  /* Nav detaches into a fixed bottom tab bar */
  .nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    flex-direction: row;
    gap: 0;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding: 0.25rem 0.25rem calc(0.25rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -2px 14px rgba(20, 32, 43, 0.07);
  }
  /* Dissolve the desktop glass cards so the 6 tabs sit flat in the bottom bar */
  .nav-group {
    display: contents;
  }
  /* Premium zone also dissolves — its items join the flat tab row, chrome hides */
  .nav-premium-zone {
    display: contents;
    background: none;
    border: none;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .nav-premium-header,
  .nav-premium-status-box,
  .nav-premium-upgrade {
    display: none;
  }
  /* No section headers in the bottom tab bar — keep the tabs flat */
  .nav-section,
  .nav-subsection {
    display: none;
  }

  /* Option A: bottom bar shows only 4 core tabs + "More". Everything else
     moves into the More sheet, so the bar never overflows. */
  .nav-item.m-overflow,
  .nav-footer,
  .nav-version {
    display: none;
  }
  .nav-item[data-view="calendar"] { order: 1; }
  .nav-item[data-view="search"]   { order: 2; }
  .nav-item[data-view="sync"]     { order: 3; }
  .nav-item[data-view="compare"]  { order: 4; }
  .nav-more-btn {
    order: 5;
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 52px;
    padding: 0.3rem 0.15rem;
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 0.64rem;
    font-weight: 600;
    line-height: 1.1;
    border-radius: 12px;
    cursor: pointer;
  }
  .nav-more-btn.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
  .nav-more-btn.active .nav-icon { color: var(--accent); }
  /* Premium hub entry — crown reads teal so the premium suite is obvious in the bar */
  .nav-more-btn--prem { position: relative; }
  .nav-more-btn--prem .nav-icon { color: var(--premium); }
  .nav-more-btn--prem:not(.active) { color: var(--premium-strong); }
  .nav-more-btn .nav-more-dot {
    position: absolute; top: 6px; right: 50%; transform: translateX(14px);
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--danger); border: 2px solid var(--surface);
  }

  /* More bottom sheet — sits just above the tab bar, over a dimming backdrop */
  .more-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 38;
    background: rgba(8, 12, 18, 0.5);
  }
  .more-sheet:not([hidden]) {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    z-index: 39;
    background: var(--surface);
    border-top: 1px solid var(--line);
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.28);
    padding: 6px 8px 12px;
    animation: moreSheetUp 0.18s ease;
  }
  .more-grab {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--line-strong);
    margin: 4px auto 10px;
  }
  .more-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2px;
  }
  /* Slim, low-pressure status line at the top of the hub — no box, no pill, no crown. */
  .more-status { margin: 0 6px 13px; }
  .more-status-line { font-size: 0.78rem; color: var(--muted); }
  .more-status-line b { color: var(--premium); font-weight: 700; }
  .more-status-sub { font-size: 0.66rem; color: var(--muted); margin-top: 3px; }
  .more-status.is-warn .more-status-line b { color: var(--t-standby); }
  .more-status.is-locked .more-status-line b { color: var(--danger); }
  .more-div { height: 1px; background: var(--line); margin: 13px 6px 11px; }
  .more-row--sec { display: flex; gap: 1.4rem; padding: 0 8px; }
  .more-row--sec .more-item { flex: 0 0 auto; flex-direction: row; gap: 8px; padding: 4px 2px; }
  .more-row--sec .more-item .more-ic { width: auto; height: auto; }
  .more-row--sec .more-item .more-ic svg { width: 18px; height: 18px; }
  .more-sec {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 6px 5px;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--premium-strong);
  }
  .more-sec::after { content: ""; flex: 1; height: 1px; background: var(--line); }
  .more-sec-crown { display: inline-flex; color: var(--premium); }
  .more-sec-crown svg { width: 13px; height: 13px; }
  .more-sec--plain { color: var(--muted); }
  .more-item {
    position: relative;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 8px 2px;
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 0.64rem;
    font-weight: 600;
    line-height: 1.1;
    border-radius: 10px;
    cursor: pointer;
  }
  .more-item:active { background: var(--surface-muted); }
  .more-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
  .more-ic {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 23px;
    height: 23px;
    color: var(--muted);
  }
  .more-ic svg { width: 23px; height: 23px; }
  .more-item.active .more-ic { color: var(--accent); }
  .more-item.prem .more-ic { color: var(--premium); }
  .more-item.prem.active .more-ic { color: var(--accent); }
  .more-badge {
    position: absolute;
    top: 4px;
    right: 22%;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--danger);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
  }

  .nav-item {
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 52px;
    padding: 0.3rem 0.15rem;
    border-radius: 12px;
    font-size: 0.64rem;
    font-weight: 600;
    line-height: 1.1;
    color: var(--muted);
  }
  .nav-item:hover {
    background: transparent;
    color: var(--muted);
  }
  /* Active tab: pill background + heavier weight so it's distinguishable
     without relying on color alone (WCAG 1.4.1). */
  .nav-item.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 700;
  }
  .nav-icon {
    width: 23px;
    height: 23px;
    color: var(--muted);
  }
  .nav-icon svg { width: 23px; height: 23px; }
  .nav-item.active .nav-icon { color: var(--accent); }
  /* in the bottom bar, premium icons match the others (no teal) for consistency */
  .nav-premium-zone .nav-icon { color: var(--muted); }
  /* Bottom-tab unread badge floats over the Messages tab's icon */
  .nav-item-messages { position: relative; }
  .nav-item-label { flex: none; }
  .nav-item-messages .nav-badge {
    position: absolute;
    top: 3px;
    left: 50%;
    margin-left: 4px;
    height: 16px; min-width: 16px;
    line-height: 16px; border-radius: 8px;
    font-size: 0.6rem;
  }

  .ghost-button {
    min-height: 40px;
  }

  /* Leave room for the fixed tab bar */
  .content {
    padding: 1rem 0.9rem calc(76px + env(safe-area-inset-bottom, 0px));
  }
  /* Messages: edge-to-edge horizontally, but keep clearance for the fixed tab bar */
  .content:has(#messagesView:not([hidden])) {
    padding: 0 0 calc(76px + env(safe-area-inset-bottom, 0px));
  }

  .card {
    padding: 1.15rem;
  }
  .center-card,
  .hero {
    margin: 1.25rem auto;
  }
  .hero h1 {
    font-size: 1.5rem;
  }

  /* Calendar tightens */
  .calendar-card {
    padding: 1rem;
  }
  /* One-row toolbar: title takes remaining space, nav stays right */
  .calendar-toolbar {
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.5rem;
  }
  .cal-jump-wrap {
    flex: 1 1 0;
    min-width: 0;
  }
  .calendar-sub {
    /* Don't clip — flight time must stay visible. Wrap to a 2nd line if needed. */
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
  .cal-saved { display: none; } /* drop the minor "N months saved" on phones to keep flight time prominent */
  .calendar-nav {
    flex-shrink: 0;
    gap: 0.3rem;
  }
  .calendar-month {
    font-size: 1.1rem;
  }
  .cal-month-icon {
    width: 24px;
    height: 24px;
  }
  .calendar-nav button {
    min-height: 40px;
    min-width: 40px;
    padding: 0 0.55rem;
  }
  .cal-settings-wrap > button[data-kind="cal-settings"] {
    min-width: 40px;
  }
  .calendar-day {
    min-height: 84px;
  }
}

/* Narrow phone: stack label/control rows so they never collide */
@media (max-width: 560px) {
  .setting-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
  }
  .scope-group {
    align-self: flex-start;
  }
  .scope-seg {
    padding: 7px 13px;
  }
  select,
  input[type="text"],
  input[type="email"] {
    height: 42px;
  }
  #airlineInput {
    align-self: flex-start;
  }
  .friend-row .ghost-button,
  .friend-row .link-button {
    min-height: 38px;
  }
}

/* Phone: a 7-column month grid can't render legible event text,
   so chips collapse to colour dots and the legend becomes the key. */
@media (max-width: 480px) {
  /* Nav buttons shrink further so all 5 fit on a 375px screen */
  .calendar-nav {
    gap: 0.2rem;
  }
  .calendar-nav button {
    min-height: 36px;
    min-width: 36px;
    padding: 0 0.4rem;
    font-size: 0.85rem;
  }
  .cal-settings-wrap > button[data-kind="cal-settings"] {
    min-width: 36px;
  }
  .calendar-grid {
    gap: 2px;
  }
  /* Let the toolbar buttons wrap on tight phones instead of clipping the settings gear. */
  .calendar-toolbar {
    flex-wrap: wrap;
    row-gap: 0.4rem;
  }
  .calendar-day {
    min-height: 62px;
    padding: 0.2rem 0.1rem;
    gap: 0.25rem;
  }
  /* The today cell already has an accent border + fill; the extra "Today" label only clips
     the narrow phone cell ("28 To…"), so drop it on phones. */
  .calendar-day.today .calendar-date::after {
    display: none;
  }
  .calendar-date {
    font-size: 0.72rem;
  }
  .calendar-weekday {
    font-size: 0.6rem;
    padding: 0.2rem 0;
  }

  /* Slim calendar header on phones — the nav already labels this "Calendar". */
  .calendar-card {
    padding: 0.85rem;
  }
  .calendar-card .card-title {
    display: none;
  }
  .calendar-toolbar {
    margin-bottom: 0.5rem;
    gap: 0.5rem;
  }
  .calendar-month {
    font-size: 1rem;
    margin: 0;
    padding: 3px 8px 3px 3px;
  }
  .cal-month-icon {
    width: 24px;
    height: 24px;
    border-radius: 5px;
  }
  .calendar-sub {
    font-size: 0.7rem;
    line-height: 1.3;
  }

  /* Compact text chips (not dots) so flight numbers + routes are readable on a phone. */
  .calendar-events {
    flex-direction: column;
    gap: 2px;
  }
  .calendar-event {
    padding: 0 1px;
    border-radius: 3px;
    font-size: 0.44rem;
    line-height: 1.45;
    letter-spacing: -0.2px;
  }
  .calendar-event span {
    display: inline;
  }
  /* Hide the departure time on phones — the cell only has room for the route. */
  .calendar-event .chip-time {
    display: none;
  }
  /* Check-in/out: swap the truncating full label for the compact "C/I 13:45" / "C/O 22:30". */
  .calendar-event .chip-full { display: none; }
  .calendar-event .chip-short { display: inline; }
  .calendar-more {
    padding-left: 2px;
    font-size: 0.56rem;
    line-height: 1.2;
  }
  .calendar-legend {
    gap: 0.4rem 0.8rem;
    font-size: 0.7rem;
  }

  .hero h1 {
    font-size: 1.35rem;
  }
  .summary-total strong {
    font-size: 1.35rem;
  }
}

/* ============================================================
   Day-detail section — tap a day to reveal an inline section below
   the calendar grid with that day's schedule (+ flights & crew on
   Calendar).
   ============================================================ */
.calendar-day.has-events {
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.calendar-day.has-events:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.calendar-day.has-events:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.calendar-day.has-events.selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1.5px var(--accent);
  background: var(--accent-soft);
}

.day-panel {
  scroll-margin-top: 1rem;
}

.day-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}
.day-panel-date {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}
.day-panel-iso {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-left: 0.15rem;
}
.day-panel-count {
  margin: 0.15rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}
.day-sheet-close {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1;
}
.day-sheet-close:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.day-panel-events {
  display: flex;
  flex-direction: column;
}

/* Flights & crew */
.day-panel-flights {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.flight-block {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-muted);
  padding: 0.7rem 0.85rem;
}
.flight-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.4rem 0.7rem;
  margin-bottom: 0.5rem;
}
.flight-no {
  font-weight: 700;
  color: var(--accent-strong);
}
.flight-route {
  font-weight: 600;
}
.flight-time {
  font-size: 0.82rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.flight-pos {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent-strong);
  background: var(--accent-soft);
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
}
.crew-group {
  margin-top: 0.5rem;
}
.crew-group-title {
  margin: 0 0 0.2rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.crew-row {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.22rem 0;
  font-size: 0.86rem;
}
.crew-pos {
  flex-shrink: 0;
  width: 2.6rem;
  font-weight: 600;
  color: var(--accent-strong);
}
.crew-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crew-id {
  flex-shrink: 0;
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.day-panel-note {
  margin: 0.85rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.day-row {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  padding: 0.6rem 0;
  border-top: 1px solid var(--line);
}
.day-row:first-child {
  border-top: none;
}
.day-row-time {
  flex-shrink: 0;
  width: 5.1rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
}
.day-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.day-row-title {
  font-size: 0.92rem;
  color: var(--text);
}
.day-row-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  align-self: center;
}
.day-row-who {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}
.day-row-pill {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 600;
  color: #fff;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--t-activity);
  white-space: nowrap;
}
.day-row-pill.flight { background: var(--t-flight); }
.day-row-pill.check-in { background: var(--t-checkin); }
.day-row-pill.check-out { background: var(--t-checkout); }
.day-row-pill.hotel { background: var(--t-hotel); }
.day-row-pill.standby { background: var(--t-standby); }
.day-row-pill.off-leave { background: var(--t-off); }
.day-row-pill.ground { background: var(--t-ground); }
.day-row-pill.duty { background: var(--accent-strong); }
.day-row-type-muted {
  flex-shrink: 0;
  font-size: 0.74rem;
  color: var(--muted);
}

/* Quote-to-message button on each schedule row */
.day-row-quote {
  flex-shrink: 0;
  align-self: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: transparent;
  font-size: 0.82rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 0.15s, border-color 0.15s, background 0.15s;
}
.day-row-quote:hover {
  opacity: 1;
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ============================================================
   Search — find flights / crew / airports in your own roster
   ============================================================ */
.search-card {
  padding: 1.25rem;
}
.search-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0.55rem 0.8rem;
  background: var(--surface);
}
.search-bar:focus-within {
  border-color: var(--accent);
}
.search-bar-icon {
  font-size: 1rem;
  flex-shrink: 0;
  opacity: 0.7;
}
.search-bar input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  height: auto;
  padding: 0;
  font-size: 1rem;
  color: var(--text);
}
.search-bar input::-webkit-search-cancel-button {
  display: none;
}
.search-clear {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: none;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1;
}
.search-clear:hover {
  color: var(--danger);
}
.search-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 0.7rem;
}
.search-chips:empty {
  margin-top: 0;
}
.search-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 4px 6px 4px 11px;
}
.search-chip-lv {
  font-size: 0.66rem;
  font-weight: 700;
  opacity: 0.65;
}
.search-chip button {
  border: none;
  background: transparent;
  color: var(--accent-strong);
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
  padding: 0 3px;
  opacity: 0.7;
}
.search-chip button:hover {
  opacity: 1;
  color: var(--danger);
}
.search-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.85rem;
  min-height: 1px;
}
.search-actions.busy {
  opacity: 0.5;
  pointer-events: none;
}
.search-actions .ghost-button {
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  min-height: 36px;
}
.search-doc-header {
  margin-top: 1rem;
}
.search-doc-header:empty {
  margin-top: 0;
}
.search-doc-title {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.search-count {
  margin: 0.15rem 0 0;
  font-size: 1.05rem;
  font-weight: 700;
}
.search-hint {
  margin: 1rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}
.search-date {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin: 1.1rem 0 0.6rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--line);
}
.search-date b {
  font-size: 0.95rem;
  font-weight: 700;
}
.search-date span {
  font-size: 0.82rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.search-event {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  padding: 0.55rem 0;
  border-top: 1px solid var(--line);
}
.search-date + .search-event {
  border-top: none;
}
.search-event .day-row-time {
  width: 5.1rem;
}
.search-event .day-row-title {
  flex: 1;
  min-width: 0;
  font-size: 0.92rem;
}
.search-event .day-row-pill {
  flex-shrink: 0;
}
mark {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-radius: 3px;
  padding: 0 2px;
}

/* ============================================================
   Private memos — clickable names/flights, badges, editor, Notes
   ============================================================ */
.memo-target {
  background: transparent;
  border: none;
  padding: 2px 5px;
  margin: -2px -5px;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.memo-target:hover {
  background: var(--accent-soft);
}
.flight-no.memo-target {
  font-weight: 700;
  color: var(--accent-strong);
}
/* Quiet variant: looks like plain text (locked = no memo hint) but stays tappable. */
.memo-target-quiet {
  padding: 0;
  margin: 0;
  border-radius: 4px;
}
.memo-target-quiet:hover {
  background: var(--surface-muted);
}
.flight-no.memo-target-quiet:hover {
  background: var(--accent-soft);
}
.memo-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
/* Privacy mode: a neutral "has a note" dot with no colour (tag colours hidden). */
.memo-dot-muted { background: var(--muted); opacity: 0.45; }
.memo-mark {
  font-size: 0.78rem;
  opacity: 0.85;
}
.memo-add {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  opacity: 0.55;
}
.memo-target:hover .memo-add {
  opacity: 1;
  color: var(--accent);
}
.memo-prev {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--surface-muted);
  border-radius: 8px;
  padding: 0.3rem 0.55rem;
  margin: 0.15rem 0 0.4rem;
}

/* Memo editor modal */
body.memo-lock {
  overflow: hidden;
}
.memo-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(20, 32, 43, 0.45);
}
.memo-backdrop.open {
  display: flex;
}
.memo-sheet {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(20, 32, 43, 0.22);
  padding: 1.1rem 1.25rem 1.25rem;
}
.memo-sheet:focus {
  outline: none;
}
.memo-eh {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.85rem;
}
.memo-eh-av {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  flex-shrink: 0;
}
.memo-eh-av.flight {
  background: var(--surface-muted);
  color: var(--muted);
}
.memo-eh-nm {
  font-size: 1rem;
  font-weight: 700;
}
.memo-eh-sub {
  font-size: 0.78rem;
  color: var(--muted);
}
.memo-eh .day-sheet-close {
  margin-left: auto;
}
.memo-scope {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 2px;
  gap: 2px;
  margin-bottom: 0.7rem;
}
.memo-scope button {
  font-size: 0.8rem;
  padding: 5px 12px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
}
.memo-scope button.on {
  background: var(--accent);
  color: #fff;
}
.memo-ta {
  width: 100%;
  min-height: 64px;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  resize: vertical;
}
.memo-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin: 0.75rem 0;
}
.memo-tagl {
  font-size: 0.78rem;
  color: var(--muted);
}
.memo-dot-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  position: relative;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.memo-dot-btn::after {
  content: "";
  position: absolute;
  inset: -10px;
}
.memo-dot-btn.on {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text);
}
/* The tag currently being recoloured (edit mode) gets an accent ring. */
.memo-dot-btn.editing {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
}
/* Pencil button that toggles "recolour your tags" mode. */
.memo-dot-edit {
  width: 28px; height: 28px; border-radius: 50%; padding: 0; flex-shrink: 0;
  border: 1.5px dashed var(--line-strong); background: transparent; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.memo-dot-edit.on { border-style: solid; border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
/* The "pick from a grid of colours" editor (replaces the old HSL sliders). */
.memo-pal-edit { margin: 0.7rem 0 0.3rem; }
.memo-pal-hint { font-size: 0.8rem; color: var(--muted); margin: 0 0 0.6rem; }
/* Drag color picker — saturation/value square + hue bar */
.cp-sv {
  position: relative; width: 100%; height: 150px; border-radius: 12px;
  touch-action: none; cursor: crosshair; overflow: hidden;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.cp-sv-white { position: absolute; inset: 0; background: linear-gradient(to right, #fff, rgba(255,255,255,0)); border-radius: 12px; }
.cp-sv-black { position: absolute; inset: 0; background: linear-gradient(to top, #000, rgba(0,0,0,0)); border-radius: 12px; }
.cp-sv-knob, .cp-hue-knob {
  position: absolute; width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,0.35), 0 1px 4px rgba(0,0,0,0.4);
  transform: translate(-50%, -50%); pointer-events: none; background: transparent;
}
.cp-hue {
  position: relative; width: 100%; height: 18px; margin-top: 12px; border-radius: 9px;
  touch-action: none; cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
  background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
}
.cp-hue-knob { top: 50%; }
.cp-readout { display: flex; align-items: center; gap: 0.55rem; margin-top: 0.7rem; }
.cp-swatch { width: 26px; height: 26px; border-radius: 7px; border: 1.5px solid var(--line); }
.cp-hex { font-size: 0.85rem; font-weight: 700; letter-spacing: 0.04em; color: var(--text); font-variant-numeric: tabular-nums; }
/* Picker mode tabs (Spectrum / Grid) */
.cp-mode-tabs { display: inline-flex; margin: 0 0 0.7rem; }
/* Grid picker — a fine iOS-style colour matrix */
.cp-grid {
  display: grid;
  gap: 3px;
}
.cp-grid-cell {
  aspect-ratio: 1;
  border: none;
  padding: 0;
  border-radius: 4px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.cp-grid-cell.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.memo-dot-custom {
  background: conic-gradient(
    hsl(0, 80%, 55%),
    hsl(60, 80%, 50%),
    hsl(120, 75%, 40%),
    hsl(180, 75%, 38%),
    hsl(240, 75%, 58%),
    hsl(300, 75%, 52%),
    hsl(360, 80%, 55%)
  ) !important;
}
.memo-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.memo-icon-btn.on {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.memo-icon-none {
  font-size: 1.25rem;
  color: var(--muted);
}
.memo-hint-tag {
  margin: 0.7rem 0 0;
  font-size: 0.76rem;
  color: var(--muted);
  text-align: center;
}
.memo-icon {
  font-size: 0.82rem;
  line-height: 1;
  flex-shrink: 0;
}
.memo-icon-trail {
  font-size: 0.82rem;
  line-height: 1;
  margin-left: 0.2rem;
}
.memo-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.memo-actions .primary-button {
  width: auto;
  flex: 1;
}
.memo-priv {
  margin: 0.85rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
}

/* ── Inline custom colour picker ── */
.ccp-wrap {
  margin: -0.25rem 0 0.5rem;
  padding: 0.75rem 0.85rem;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.ccp-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.ccp-preview {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  flex-shrink: 0;
}
.ccp-hex-input {
  flex: 1;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 0.88rem;
  padding: 0 0.7rem;
  text-transform: uppercase;
  outline: none;
}
.ccp-hex-input:focus {
  border-color: var(--accent);
}
.ccp-sliders {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.ccp-slider-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.ccp-lbl {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  width: 14px;
  text-align: center;
  flex-shrink: 0;
}
.ccp-slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 20px;
  border-radius: 10px;
  outline: none;
  cursor: pointer;
  touch-action: manipulation;
}
.ccp-slider::-webkit-slider-runnable-track {
  height: 20px;
  border-radius: 10px;
}
.ccp-slider::-moz-range-track {
  height: 20px;
  border-radius: 10px;
}
.ccp-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid rgba(0,0,0,0.22);
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  margin-top: -4px;
  cursor: pointer;
}
.ccp-slider::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid rgba(0,0,0,0.22);
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  cursor: pointer;
}
.ccp-slider-hue::-webkit-slider-runnable-track {
  background: linear-gradient(to right,
    hsl(0,85%,55%), hsl(40,85%,52%), hsl(80,80%,45%),
    hsl(120,75%,42%), hsl(160,75%,45%), hsl(200,80%,52%),
    hsl(240,80%,58%), hsl(280,78%,55%), hsl(320,80%,52%), hsl(360,85%,55%));
}
.ccp-slider-hue::-moz-range-track {
  background: linear-gradient(to right,
    hsl(0,85%,55%), hsl(40,85%,52%), hsl(80,80%,45%),
    hsl(120,75%,42%), hsl(160,75%,45%), hsl(200,80%,52%),
    hsl(240,80%,58%), hsl(280,78%,55%), hsl(320,80%,52%), hsl(360,85%,55%));
}
.ccp-slider-sat::-webkit-slider-runnable-track {
  background: linear-gradient(to right,
    hsl(var(--ccp-h,200), 0%, 55%),
    hsl(var(--ccp-h,200), 100%, 50%));
}
.ccp-slider-sat::-moz-range-track {
  background: linear-gradient(to right,
    hsl(var(--ccp-h,200), 0%, 55%),
    hsl(var(--ccp-h,200), 100%, 50%));
}
.ccp-slider-lit::-webkit-slider-runnable-track {
  background: linear-gradient(to right,
    hsl(var(--ccp-h,200), var(--ccp-s,75%), 8%),
    hsl(var(--ccp-h,200), var(--ccp-s,75%), 50%),
    hsl(var(--ccp-h,200), var(--ccp-s,75%), 92%));
}
.ccp-slider-lit::-moz-range-track {
  background: linear-gradient(to right,
    hsl(var(--ccp-h,200), var(--ccp-s,75%), 8%),
    hsl(var(--ccp-h,200), var(--ccp-s,75%), 50%),
    hsl(var(--ccp-h,200), var(--ccp-s,75%), 92%));
}

/* Notes tab */
.notes-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}
.notes-count {
  margin: 0.15rem 0 0;
  font-size: 1.05rem;
  font-weight: 700;
}
.notes-grp {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 1rem 0 0.4rem;
}
.notes-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.2rem;
  border: none;
  background: transparent;
  border-top: 1px solid var(--line);
  text-align: left;
  cursor: pointer;
}
.notes-row:hover {
  background: var(--surface-muted);
}
.notes-rt {
  flex: 1;
  min-width: 0;
}
.notes-rn {
  font-size: 0.92rem;
  font-weight: 500;
  display: block;
}
.notes-rn small {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 400;
}
.notes-rp {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.notes-chev {
  color: var(--line-strong);
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* Always-visible Notes lock toggle (sidebar / top bar) */
.lock-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.4rem 0.7rem;
  min-height: 36px;
  font-size: 0.82rem;
}
.lock-toggle.unlocked {
  border-color: var(--ok);
  color: var(--ok);
}
.lt-icon {
  font-size: 0.95rem;
  line-height: 1;
}
@media (max-width: 720px) {
  .lock-toggle .lt-label {
    display: none;
  }
  .lock-toggle {
    padding: 0.4rem 0.65rem;
    min-height: 40px;
  }
}

/* PIN lock screen */
.memo-lockcard {
  gap: 0.6rem;
}
.secret-reset-warn {
  display: block;
  margin-top: 0.5rem;
  color: var(--t-standby);
  font-size: 0.82rem;
  line-height: 1.45;
}
.memo-bigicon {
  font-size: 2.2rem;
}
.memo-pin-input {
  width: 100%;
  text-align: center;
  letter-spacing: 0.55em;
  text-indent: 0.55em; /* keep the dots optically centered despite letter-spacing */
  font-size: 1.45rem;
  font-weight: 600;
  height: 56px;
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: 12px;
  color: var(--text);
  caret-color: var(--accent);
}
.memo-pin-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
/* PIN screen actions: full-width Unlock, then a quiet centered alternative below. */
.memo-pin-go { margin-top: 0.9rem; }
.memo-pin-alt { display: block; width: 100%; text-align: center; margin-top: 0.7rem; }

@media (max-width: 480px) {
  .memo-backdrop {
    align-items: flex-end;
    padding: 0;
  }
  .memo-sheet {
    max-width: none;
    border-radius: 16px 16px 0 0;
    border-bottom: none;
    padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  }
}

/* Calendar reminders (Sync view) */
.reminder-card .reminder-sub {
  margin: 0 0 12px;
  font-size: 0.85rem;
  color: var(--muted);
}
.rmd-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.rmd-chip {
  font-size: 0.8rem;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.rmd-chip.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.rmd-methods {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}
.rmd-method-label {
  margin-right: 4px;
  font-size: 0.8rem;
  color: var(--muted);
}
.reminder-hint {
  margin: 14px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}
.rmd-chip:not(.on):hover {
  border-color: var(--accent);
  color: var(--accent);
}
.rmd-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Pre-sync confirmation modal — a final, modern review (esp. of check-in reminders). */
.sync-confirm-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  z-index: 200;
}
.sync-confirm-backdrop.is-open {
  display: flex;
  animation: syncConfirmFade 0.15s ease;
}
.sync-confirm {
  width: 100%;
  max-width: 30rem;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 1.4rem 1.4rem 1.2rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.sync-confirm-backdrop.is-open .sync-confirm {
  animation: syncConfirmPop 0.18s cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes syncConfirmFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes syncConfirmPop {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
.sync-confirm-title {
  margin: 0 0 0.35rem;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.sync-confirm-sub {
  margin: 0 0 1.1rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}
.sync-confirm-label {
  margin: 0 0 0.6rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
  color: var(--muted);
}
.sync-confirm-warn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.9rem 0 0;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--t-standby);
  background: color-mix(in srgb, var(--t-standby) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--t-standby) 35%, transparent);
}
.sync-confirm-warn::before {
  content: "!";
  flex-shrink: 0;
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 50%;
  background: var(--t-standby);
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sync-confirm-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.3rem;
}
.sync-confirm-actions button {
  flex: 1;
  margin: 0;
}
.sync-confirm-cancel {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
.sync-confirm-cancel:hover { border-color: var(--accent); color: var(--accent); }

/* Sync view — calendar setup guide (replaces old .sync-note) */
.cal-setup-guide {
  margin: 14px 0 0;
  border: 1px solid var(--accent-soft, rgba(96,165,250,0.25));
  border-radius: 10px;
  background: var(--accent-tint, rgba(96,165,250,0.06));
  overflow: hidden;
}
.cal-setup-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--accent-strong, var(--accent));
  list-style: none;
  user-select: none;
}
.cal-setup-summary::-webkit-details-marker { display: none; }
.cal-setup-summary::after {
  content: "▾";
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--muted);
  transition: transform 0.2s;
}
details[open] .cal-setup-summary::after { transform: rotate(180deg); }
.cal-setup-icon { font-size: 1rem; line-height: 1; }
.cal-setup-body {
  padding: 0 14px 14px;
  border-top: 1px solid var(--accent-soft, rgba(96,165,250,0.15));
}
.cal-setup-intro {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 10px 0 8px;
  line-height: 1.5;
}
.cal-setup-steps {
  margin: 0 0 10px 1.2rem;
  font-size: 0.8rem;
  color: var(--text);
  line-height: 1.8;
}
.cal-setup-steps a {
  color: var(--accent);
  text-decoration: underline;
}
.cal-setup-ios {
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--bg-card, var(--surface, #1a1f2e));
  border-radius: 7px;
  padding: 8px 11px;
  line-height: 1.6;
}
.cal-setup-ios strong { color: var(--text); }
.cal-setup-ios a { color: var(--accent); text-decoration: underline; }

/* Team calendar — days when every selected member (with visible days off) is off */
.calendar-day.all-off {
  background: var(--alloff-bg);
  border-color: var(--alloff-line);
}
.all-off-badge {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--ok);
  white-space: nowrap;
}
/* Team availability heatmap — shade days by how many members are free. */
.calendar-day.avail-1 { background: color-mix(in srgb, var(--ok) 10%, transparent); }
.calendar-day.avail-2 { background: color-mix(in srgb, var(--ok) 22%, transparent); }
.calendar-day.avail-3 { background: color-mix(in srgb, var(--ok) 38%, transparent); }
.avail-badge {
  font-size: 0.58rem;
  font-weight: 700;
  color: var(--ok);
  background: color-mix(in srgb, var(--ok) 16%, transparent);
  padding: 1px 6px;
  border-radius: 20px;
  white-space: nowrap;
  margin-left: 4px;
}

/* Personal-event chips on the calendar */
.calendar-event.personal { background: color-mix(in srgb, var(--premium) 22%, var(--surface)); color: var(--premium-strong); }
.calendar-event.busy { background: color-mix(in srgb, var(--muted) 28%, var(--surface)); color: var(--text); }

/* Day-panel: personal plans section */
.day-panel-plans { margin-top: 0.6rem; padding-top: 0.6rem; border-top: 1px solid var(--line); }
.dpp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.45rem; font-size: 0.78rem; font-weight: 700; color: var(--muted); }
.dpp-add { font-size: 0.74rem; font-weight: 700; color: var(--accent); background: var(--accent-soft); border: none; border-radius: 16px; padding: 4px 11px; cursor: pointer; }
.dpp-row { display: flex; align-items: center; gap: 8px; padding: 6px 2px; font-size: 0.82rem; }
.dpp-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dpp-dot.busy { background: var(--muted); }
.dpp-dot.free { background: var(--ok); }
.dpp-title { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dpp-when { color: var(--muted); font-size: 0.72rem; margin-left: auto; white-space: nowrap; }
.dpp-share { font-size: 0.58rem; font-weight: 700; color: var(--muted); border: 1px solid var(--line-strong); padding: 1px 6px; border-radius: 12px; white-space: nowrap; }
.dpp-share.team { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.dpp-edit, .dpp-del { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 0.85rem; padding: 2px 4px; line-height: 1; }
.dpp-edit:hover, .dpp-del:hover { color: var(--accent); }
.dpp-empty { font-size: 0.74rem; color: var(--muted); padding: 4px 2px; }

/* Personal-event editor modal */
.pe-modal { background: var(--surface); border-radius: 16px; padding: 1rem 1.1rem 1.1rem; width: min(92vw, 380px); box-shadow: 0 14px 44px rgba(0,0,0,.32); display: flex; flex-direction: column; gap: 0.6rem; }
.pe-head { display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 0.9rem; color: var(--text); }
.pe-x { background: none; border: none; font-size: 1rem; color: var(--muted); cursor: pointer; }
.pe-input { width: 100%; padding: 0.55rem 0.7rem; border: 1px solid var(--line-strong); border-radius: 10px; background: transparent; color: var(--text); font-size: 0.9rem; box-sizing: border-box; }
.pe-check { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; color: var(--text); }
.pe-times { display: flex; gap: 14px; }
.pe-times label { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--muted); }
.pe-times input { padding: 0.35rem 0.5rem; border: 1px solid var(--line-strong); border-radius: 8px; background: transparent; color: var(--text); }
.pe-hint { color: var(--muted); font-size: 0.72rem; }
.pe-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 0.4rem; }
.pe-save { background: var(--accent); color: #fff; border: none; border-radius: 10px; padding: 0.5rem 1.3rem; font-weight: 700; font-size: 0.86rem; cursor: pointer; }
.pe-del { background: none; border: none; color: var(--danger); font-weight: 700; font-size: 0.82rem; cursor: pointer; }

/* Calendar settings gear button */
.cal-settings-wrap {
  position: relative;
}
.cal-settings-wrap > button[data-kind="cal-settings"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  min-width: 34px;
  padding: 0;
}
.cal-settings-wrap > button[data-kind="cal-settings"].on {
  border-color: var(--accent);
  color: var(--accent);
}

/* Settings dropdown */
.cal-settings-picker {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  z-index: 110;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.18);
  min-width: 190px;
  padding: 4px;
  white-space: nowrap;
}
.cal-settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  padding: 0.55rem 0.85rem;
  background: none;
  border: none;
  border-radius: 7px;
  color: var(--text);
  font-size: 0.875rem;
  text-align: left;
  cursor: pointer;
  line-height: 1;
}
.cal-settings-row:hover {
  background: var(--surface-muted);
}
.cal-settings-row.active {
  color: var(--accent);
}
.cal-settings-row svg {
  flex-shrink: 0;
  color: var(--accent);
}
/* Destructive row in the calendar settings menu (delete this month). */
.cal-settings-row.cal-settings-danger {
  color: var(--error, #e0655a);
  border-top: 1px solid var(--line);
  margin-top: 2px;
  padding-top: 8px;
}
.cal-settings-row.cal-settings-danger:hover { background: color-mix(in srgb, var(--error, #e0655a) 12%, transparent); }
/* Delete-this-day button in the day-detail panel. */
.day-panel-actions { margin-top: 0.6rem; display: flex; justify-content: flex-end; }
.day-panel-delete {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--error, #e0655a);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.day-panel-delete:hover { border-color: var(--error, #e0655a); background: color-mix(in srgb, var(--error, #e0655a) 10%, transparent); }
/* Day-detail row — per-flight flight time */
.day-row-ftime {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

/* Offline banner (inserted as the first body child, spans full width) */
.offline-banner {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 8px 14px;
  background: var(--t-standby);
  color: #fff;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.35;
}
.offline-banner[hidden] {
  display: none;
}

/* Compare — roster version history (diff of two synced versions) */
.compare-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.compare-field {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.6rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.compare-summary {
  margin: 0.85rem 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.compare-stat {
  font-weight: 600;
}
.compare-stat.added {
  color: var(--ok);
}
.compare-stat.removed {
  color: var(--danger);
}
.compare-stat.retimed {
  color: var(--t-standby);
}
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.compare-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.compare-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.8rem;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--line);
}
.compare-panel-title {
  font-weight: 600;
  font-size: 0.85rem;
}
.compare-panel-stamp {
  font-size: 0.74rem;
  color: var(--muted);
}
.compare-panel-rows {
  padding: 0.4rem 0.5rem;
}
.compare-row {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.32rem 0.4rem;
  border-radius: 6px;
  font-size: 0.8rem;
}
.compare-row-time {
  flex-shrink: 0;
  min-width: 78px;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.compare-row-title {
  flex: 1;
}
.compare-row.added {
  background: var(--alloff-bg);
}
.compare-row.added .compare-row-title {
  color: var(--ok);
}
.compare-row.removed {
  background: rgba(244, 63, 63, 0.1);
}
.compare-row.removed .compare-row-title {
  text-decoration: line-through;
  color: var(--danger);
}
.compare-row.retimed {
  background: rgba(217, 139, 43, 0.13);
}
.compare-row.retimed .compare-row-title {
  color: var(--t-standby);
}
.dot.compare-added {
  background: var(--ok);
}
.dot.compare-removed {
  background: var(--danger);
}
.dot.compare-retimed {
  background: var(--t-standby);
}
@media (max-width: 720px) {
  .compare-grid {
    grid-template-columns: 1fr;
  }
}

/* ─── Per-friend sharing ─────────────────────────────────────────────────── */

.friend-row-sharing {
  cursor: pointer;
  transition: background 0.15s;
}
.friend-row-sharing:hover {
  background: var(--surface-muted);
}

/* Status chips */
.share-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.share-chip {
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 10px;
  border: 1px solid;
  white-space: nowrap;
}
.chip-active   { color: var(--t-flight); background: color-mix(in srgb, var(--t-flight) 12%, transparent); border-color: color-mix(in srgb, var(--t-flight) 35%, transparent); }
.chip-paused   { color: var(--muted); background: var(--surface-muted); border-color: var(--line); }
.chip-expiring { color: var(--t-standby); background: color-mix(in srgb, var(--t-standby) 12%, transparent); border-color: color-mix(in srgb, var(--t-standby) 35%, transparent); }
.chip-level    { color: var(--t-checkout); background: color-mix(in srgb, var(--t-checkout) 10%, transparent); border-color: color-mix(in srgb, var(--t-checkout) 30%, transparent); }
.chip-perm     { color: var(--muted); background: transparent; border-color: var(--line); }
.chip-timed    { color: var(--t-standby); background: transparent; border-color: color-mix(in srgb, var(--t-standby) 40%, transparent); }

/* Quick toggle */
.share-toggle {
  width: 36px; height: 20px; border-radius: 10px;
  background: var(--line-strong); border: none; cursor: pointer;
  position: relative; flex-shrink: 0; transition: background 0.2s;
}
.share-toggle::after {
  content: '';
  position: absolute; top: 3px; left: 3px;
  width: 14px; height: 14px;
  background: #fff; border-radius: 50%;
  transition: transform 0.2s;
}
.share-toggle-on { background: var(--t-flight); }
.share-toggle-on::after { transform: translateX(16px); }

/* Friends card header */
.friends-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.friends-card-header .card-title { margin-bottom: 0; }
.pause-all-btn {
  font-size: 11px; padding: 4px 10px;
  border: 1px solid var(--line-strong); border-radius: 6px;
  background: transparent; color: var(--muted);
  cursor: pointer;
}
.pause-all-btn:hover { background: var(--surface-muted); }

/* Expiry notification cards */
.expiry-notif {
  display: flex; gap: 10px;
  padding: 12px 14px; border-radius: 8px;
  margin-bottom: 8px; border: 1px solid;
  border-left-width: 3px;
}
.expiry-soon { border-color: var(--t-standby); background: color-mix(in srgb, var(--t-standby) 6%, transparent); }
.expiry-ended { border-color: var(--line-strong); background: var(--surface-muted); }
.expiry-icon { font-size: 16px; flex-shrink: 0; padding-top: 1px; }
.expiry-body { flex: 1; min-width: 0; }
.expiry-title { font-size: 13px; font-weight: 600; }
.expiry-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.expiry-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.expiry-btn-renew, .expiry-btn-end {
  font-size: 11px; padding: 4px 10px;
  border-radius: 6px; cursor: pointer; border: 1px solid;
}
.expiry-btn-renew { background: var(--t-flight); color: #fff; border-color: var(--t-flight); }
.expiry-btn-end   { background: transparent; color: var(--muted); border-color: var(--line-strong); }

/* Bottom sheet overlay */
body.sheet-active { overflow: hidden; }
#sharingSheetMount { position: fixed; inset: 0; z-index: 200; pointer-events: none; }
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  pointer-events: all;
}
.sharing-sheet {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-width: 600px; margin: 0 auto;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  border: 1px solid var(--line-strong);
  padding: 0 16px 32px;
  pointer-events: all;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32,0.72,0,1);
  max-height: 85vh;
  overflow-y: auto;
}
.sharing-sheet.sheet-open { transform: translateY(0); }

.sheet-handle {
  width: 40px; height: 4px;
  background: var(--line-strong); border-radius: 2px;
  margin: 10px auto 14px;
}
.sheet-hdr { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; }
.sheet-hdr-info { display: flex; align-items: center; gap: 10px; }
.sheet-name { font-size: 15px; font-weight: 700; }
.sheet-reciprocal { font-size: 11px; color: var(--muted); margin-top: 2px; }
.sheet-close { background: none; border: none; cursor: pointer; font-size: 18px; color: var(--muted); padding: 4px 8px; }

.sheet-section-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--muted); margin: 14px 0 6px;
}
.sheet-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; background: var(--surface-muted); border-radius: 8px;
}
.sheet-toggle-title { font-size: 13px; font-weight: 600; }
.sheet-toggle-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Segment buttons */
.seg-group { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 4px; }
.seg-btn {
  font-size: 12px; padding: 6px 12px; border-radius: 6px;
  border: 1px solid var(--line-strong); background: transparent;
  color: var(--muted); cursor: pointer; transition: all 0.15s;
}
.seg-btn.seg-on {
  background: color-mix(in srgb, var(--t-flight) 15%, transparent);
  color: var(--t-flight);
  border-color: var(--t-flight);
}

/* Duration detail */
.dur-detail { margin-top: 10px; }
.dur-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.dur-label { font-size: 11px; color: var(--muted); width: 36px; flex-shrink: 0; }
.dur-date {
  flex: 1; background: var(--surface-muted);
  border: 1px solid var(--line-strong); border-radius: 6px;
  padding: 6px 8px; font-size: 12px; color: var(--text);
}

/* Month picker */
.month-picker { margin-top: 10px; }
.month-picker-year { font-size: 11px; color: var(--muted); text-align: center; margin-bottom: 8px; }
.month-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.month-cell {
  padding: 7px 4px; text-align: center; border-radius: 6px; font-size: 12px;
  border: 1px solid var(--line); cursor: pointer; background: transparent;
  color: var(--text); transition: all 0.15s;
}
.month-cell:hover:not(:disabled) { background: var(--surface-muted); }
.month-cell.month-sel {
  background: color-mix(in srgb, var(--t-flight) 15%, transparent);
  color: var(--t-flight); border-color: var(--t-flight);
}
.month-cell.month-past { opacity: 0.35; cursor: default; }

/* Templates */
.sheet-templates {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  margin-top: 8px; font-size: 11px;
}
.sheet-tmpl-label { color: var(--muted); margin-right: 2px; }
.sheet-templates button {
  font-size: 11px; padding: 3px 8px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: transparent;
  color: var(--text); cursor: pointer;
}
.sheet-templates button:hover { background: var(--surface-muted); }

/* Danger zone */
.sheet-danger { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.sheet-remove-btn {
  width: 100%; padding: 8px; font-size: 13px;
  border-radius: 8px; border: 1px solid #ef4444;
  color: #ef4444; background: transparent; cursor: pointer;
}
.sheet-remove-btn:hover { background: color-mix(in srgb, #ef4444 8%, transparent); }

/* Save button */
.sheet-save-btn {
  width: 100%; padding: 12px; margin-top: 12px;
  font-size: 14px; font-weight: 600; border-radius: 10px;
  border: none; background: var(--t-flight); color: #fff; cursor: pointer;
}
.sheet-save-btn:hover { opacity: 0.9; }
.sheet-save-btn:disabled { opacity: 0.5; cursor: default; }

/* ─── Compact friend list ─────────────────────────────────────────────────── */

/* Compact row — 2 lines but tighter than chip rows */
.friend-row-compact { padding: 7px 0 7px 4px; }
.friend-row-compact:first-of-type { border-top: none; }

.friend-info { flex: 1; min-width: 0; }
.friend-name-line {
  display: flex; align-items: center; gap: 5px;
  overflow: hidden;
}
.friend-name-line .friend-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 200px;
}
.friend-status-line {
  display: flex; align-items: center; gap: 4px;
  margin-top: 2px;
}

/* Status dot */
.fstatus-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
.fstatus-active   { background: var(--t-flight); }
.fstatus-paused   { background: var(--muted); }
.fstatus-expiring { background: var(--t-standby); }
.fstatus-ended    { background: var(--danger); }

/* Status text */
.fstatus-text { font-size: 11px; white-space: nowrap; }
.fstatus-ok   { color: var(--t-flight); }
.fstatus-muted { color: var(--muted); }
.fstatus-warn  { color: var(--t-standby); }
.fstatus-sep   { font-size: 10px; color: var(--line-strong); }

/* Friends search bar */
.friends-search-wrap {
  position: relative; display: flex; align-items: center;
  margin-bottom: 4px;
}
.friends-search-icon {
  position: absolute; left: 9px; width: 14px; height: 14px;
  color: var(--muted); pointer-events: none; flex-shrink: 0;
}
.friends-search {
  width: 100%; padding: 7px 30px 7px 30px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface-muted); color: var(--text);
  font-size: 13px; font-family: inherit;
}
.friends-search:focus { outline: none; border-color: var(--accent); }
.friends-search-clear {
  position: absolute; right: 8px;
  background: none; border: none; padding: 3px 5px;
  color: var(--muted); font-size: 11px; cursor: pointer; border-radius: 4px;
}
.friends-search-clear:hover { color: var(--text); background: var(--surface-muted); }
.friends-count-label {
  font-size: 11px; color: var(--muted);
  text-align: right; padding: 0 2px 6px;
}

/* ─── Name detect banner ──────────────────────────────────────────────────── */

.name-detect-card { padding: 14px 16px; }
.name-detect-body {
  display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px;
}
.name-detect-icon { font-size: 20px; flex-shrink: 0; padding-top: 1px; }
.name-detect-title { font-size: 13px; font-weight: 600; }
.name-detect-sub { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.name-detect-actions { display: flex; gap: 8px; }
.name-detect-apply {
  font-size: 12px; font-weight: 600; padding: 5px 14px;
  background: var(--t-flight); color: #fff;
  border: none; border-radius: 6px; cursor: pointer;
}
.name-detect-apply:hover { opacity: 0.88; }
.name-detect-skip {
  font-size: 12px; padding: 5px 12px;
  background: transparent; color: var(--muted);
  border: 1px solid var(--line-strong); border-radius: 6px; cursor: pointer;
}
.name-detect-skip:hover { background: var(--surface-muted); }

/* Inline detected name button in Friends > Your Profile */
.setting-row-highlight { background: color-mix(in srgb, var(--t-flight) 5%, transparent); border-radius: 8px; padding: 8px 6px; margin: -4px -6px 4px; }
.displayname-input-group { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.displayname-input-group input { width: 160px; }
.detected-name-btn {
  font-size: 11px; padding: 4px 10px; white-space: nowrap;
  background: var(--accent-soft); color: var(--accent-strong);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 6px; cursor: pointer;
}
.detected-name-btn:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); }

/* ── DM Episode System ─────────────────────────────────────────────────────── */

/* ── Split pane layout ── */
.dm-layout {
  display: flex;
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.dm-left {
  width: 26%;
  min-width: 190px;
  max-width: 270px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg);
}
.dm-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  background: var(--bg);
}

/* ── Left pane header ── */
.dm-left-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 12px 10px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.dm-left-title {
  font-size: 14px; font-weight: 700; color: var(--text);
  flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dm-back-sm {
  background: none; border: none;
  color: var(--accent); cursor: pointer;
  font-size: 16px; font-family: inherit; padding: 0; line-height: 1;
  flex-shrink: 0;
}
.dm-left-list { flex: 1; overflow-y: auto; }

/* ── Sidebar empty ── */
.dm-sidebar-empty {
  padding: 20px 12px; text-align: center;
  color: var(--muted); font-size: 12px; line-height: 1.8;
}

/* ── Right pane: empty state ── */
.dm-empty-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; color: var(--muted); padding: 2rem;
}
.dm-empty-icon { font-size: 36px; opacity: 0.5; }
.dm-empty-msg { font-size: 13px; text-align: center; line-height: 1.7; }

/* ── Avatar ── */
.dm-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* Online presence dot (Option 1) — a corner status dot on a friend's avatar. */
.av-presence { position: relative; }
.presence-dot {
  position: absolute; right: -1px; bottom: -1px;
  width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid var(--surface); box-sizing: border-box;
}
.presence-dot.online { background: #2ea043; }
.presence-dot.recent { background: var(--t-standby); }
[data-theme="dark"] .presence-dot.online { background: #3fb950; }
.dm-preview.dm-preview-online { color: #2ea043; font-weight: 600; }
[data-theme="dark"] .dm-preview.dm-preview-online { color: #3fb950; }

/* Inline presence dot for text rows without an avatar (crew names in the day-detail). */
.presence-inline {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-left: 5px; vertical-align: middle; flex-shrink: 0;
}
.presence-inline.online { background: #2ea043; }
.presence-inline.recent { background: var(--t-standby); }
/* Simple presence legend in the Friends list */
.presence-legend { display: flex; align-items: center; font-size: 0.74rem; color: var(--muted); margin: 0 0 8px; padding: 0 2px; }
.presence-legend .presence-inline { margin: 0 5px 0 0; }
.presence-legend .pl-gap { margin-left: 16px; }
[data-theme="dark"] .presence-inline.online { background: #3fb950; }

/* What's new (changelog) page + the "unseen updates" nav dot. */
.nav-item-whatsnew { position: relative; }
.nav-whatsnew-dot {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
}
.whatsnew-sub { margin: 0 0 1.1rem; color: var(--muted); font-size: 0.9rem; }
.cl-group { margin: 0 0 1.4rem; }
.cl-group:last-child { margin-bottom: 0; }
.cl-date {
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.03em; color: var(--muted);
  padding-bottom: 0.5rem; margin-bottom: 0.7rem; border-bottom: 1px solid var(--line);
}
.cl-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.7rem; }
.cl-item { display: flex; align-items: flex-start; gap: 0.7rem; }
.cl-tag {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 4px; justify-content: center;
  min-width: 74px; font-size: 0.7rem; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  margin-top: 1px;
}
.cl-tag.cl-new { background: var(--accent-soft); color: var(--accent); }
.cl-tag.cl-improved { background: rgba(15, 134, 118, 0.13); color: var(--premium); }
.cl-tag.cl-fixed { background: rgba(199, 119, 0, 0.14); color: var(--t-standby); }
.cl-text { font-size: 0.92rem; line-height: 1.45; color: var(--text); }
/* Segmented filter bar — same pill control as .memo-tabs, tinted per update type. */
.cl-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  margin: 0 0 1.2rem;
}
.cl-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.82rem;
  padding: 0.35rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
}
.cl-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
.cl-tab.active[data-cl-filter="new"] { color: var(--accent); }
.cl-tab.active[data-cl-filter="improved"] { color: var(--premium); }
.cl-tab.active[data-cl-filter="fixed"] { color: var(--t-standby); }
.dm-avatar-sm { width: 28px; height: 28px; font-size: 11px; }

/* ── Friend rows ── */
.dm-friend-row {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 12px; cursor: pointer;
  border-bottom: 1px solid var(--line);
  transition: background 0.15s;
}
.dm-friend-row:hover { background: var(--surface-muted); }

/* Loading skeleton while the friends list warms up */
.dm-friend-skeleton {
  height: 36px; margin: 10px 12px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--surface-muted) 25%, var(--surface) 50%, var(--surface-muted) 75%);
  background-size: 200% 100%;
  animation: dm-skel 1.2s ease-in-out infinite;
}
@keyframes dm-skel { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.dm-friend-info { flex: 1; min-width: 0; }
.dm-friend-name { font-weight: 600; font-size: 13px; color: var(--text); }
.dm-airline {
  font-size: 10px; font-weight: 600; color: var(--muted);
  background: var(--surface-muted); border-radius: 4px; padding: 1px 4px;
  margin-left: 4px;
}
.dm-preview {
  font-size: 11px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 2px;
}
.dm-friend-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.dm-ep-count { font-size: 10px; color: var(--muted); }
.dm-unread-badge {
  background: var(--accent); color: #fff;
  border-radius: 10px; padding: 1px 6px;
  font-size: 10px; font-weight: 700;
}

/* ── New episode button ── */
.dm-new-ep-btn {
  display: block; width: calc(100% - 16px); margin: 8px;
  padding: 7px 0;
  background: transparent;
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit; text-align: center;
  transition: background 0.15s; flex-shrink: 0;
}
.dm-new-ep-btn:hover { background: var(--accent-soft); }

/* ── Episode cards in sidebar ── */
.dm-ep-card {
  margin: 0; padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid transparent;
  transition: background 0.15s, border-left-color 0.15s;
}
.dm-ep-card:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.dm-ep-card-active {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-left-color: var(--accent);
}
.dm-ep-unread { border-left-color: var(--accent) !important; }
.dm-ep-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 3px; }
.dm-ep-name { font-size: 12px; font-weight: 700; color: var(--text); }
.dm-timer-badge { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 5px; }
.dm-timer-green { background: rgba(22, 101, 52, 0.10); color: var(--ok); }
.dm-timer-amber { background: rgba(199, 119, 0, 0.12); color: var(--t-standby); }
.dm-timer-red   { background: rgba(180, 35, 24, 0.10); color: var(--danger); }
[data-theme="dark"] .dm-timer-green { background: rgba(93, 191, 115, 0.12); color: var(--ok); }
[data-theme="dark"] .dm-timer-amber { background: rgba(245, 158, 11, 0.12); color: #fbbf24; }
[data-theme="dark"] .dm-timer-red   { background: rgba(240, 108, 108, 0.12); color: var(--danger); }

@keyframes dm-badge-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}
.dm-timer-badge.dm-badge-urgent { animation: dm-badge-pulse 1.6s ease-in-out infinite; }
.dm-ep-preview {
  font-size: 11px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 3px;
}
.dm-ep-foot { display: flex; align-items: center; justify-content: space-between; }
.dm-ep-ext { font-size: 10px; color: var(--muted); }

/* ── Chat: header ── */
.dm-chat-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.dm-mobile-back { display: none; }
.dm-back {
  background: none; border: none;
  color: var(--accent); cursor: pointer;
  font-size: 13px; font-family: inherit; padding: 0;
}
.dm-chat-title-block { flex: 1; min-width: 0; }
.dm-chat-ep-name { font-size: 14px; font-weight: 700; color: var(--text); }
.dm-chat-ep-meta { font-size: 11px; color: var(--muted); margin-top: 1px; }
.dm-chat-actions { display: flex; gap: 6px; flex-shrink: 0; }
.dm-action-btn {
  font-size: 11px; padding: 4px 10px;
  border-radius: 6px; border: 1px solid;
  cursor: pointer; font-weight: 600; font-family: inherit;
  background: transparent;
}
.dm-action-extend { border-color: var(--accent); color: var(--accent); }
.dm-action-delete { border-color: var(--danger); color: var(--danger); }

/* ── Chat: progress bar (episode time remaining) ── */
.dm-progress-bar {
  height: 3px;
  background: var(--line);
  flex-shrink: 0;
  overflow: hidden;
  width: 100%;
}
.dm-progress-fill {
  height: 100%;
  border-radius: 0 1px 1px 0;
  transition: width 0.8s ease;
}
.dm-progress-green { background: var(--ok); }
.dm-progress-amber { background: var(--t-standby); }
.dm-progress-red   {
  background: var(--danger);
  animation: dm-progress-pulse 2s ease-in-out infinite;
}
@keyframes dm-progress-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.55; }
}

/* ── Chat: live digital countdown strip ── */
.dm-countdown-strip {
  display: flex; align-items: center; justify-content: center;
  flex-wrap: wrap; gap: 4px 10px;
  padding: 7px 16px;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.dm-cd-icon { font-size: 12px; line-height: 1; }
.dm-cd-time {
  font-family: ui-monospace, "SF Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 14px; font-weight: 700;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--ok);
}
.dm-cd-time.dm-cd-amber { color: var(--t-standby); }
.dm-cd-time.dm-cd-red   { color: var(--danger); }
[data-theme="dark"] .dm-cd-time.dm-cd-amber { color: #fbbf24; }
.dm-cd-note { font-size: 11px; color: var(--muted); }

/* ── Chat: messages ── */
.dm-messages {
  flex: 1; overflow-y: auto; min-height: 0;
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 10px;
}
.dm-chat-start {
  text-align: center; color: var(--muted);
  font-size: 13px; padding: 3rem 1rem; margin: 0;
}
.dm-msg { display: flex; flex-direction: column; max-width: 68%; }
.dm-msg-mine  { align-self: flex-end;   align-items: flex-end; }
.dm-msg-theirs { align-self: flex-start; align-items: flex-start; }
.dm-msg-sender { font-size: 10px; color: var(--muted); margin-bottom: 2px; }
.dm-bubble {
  padding: 8px 13px; border-radius: 16px;
  font-size: 13px; line-height: 1.5; word-break: break-word;
}
.dm-bubble-mine {
  background: var(--accent); color: #fff;
  border-bottom-right-radius: 4px;
}
.dm-bubble-theirs {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}
.dm-msg-meta { font-size: 10px; color: var(--muted); margin-top: 3px; }
.dm-queued { color: var(--t-standby); }

/* ── Chat: flight card ── */
.dm-flight-card {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 4px;
  max-width: 220px;
}
.dm-flight-card-header {
  font-size: 10px; font-weight: 700; color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px;
}
.dm-flight-route { font-size: 18px; font-weight: 800; color: var(--text); margin-bottom: 2px; }
.dm-flight-meta { font-size: 11px; color: var(--muted); line-height: 1.5; }

/* ── Chat: quoted schedule card ── */
.dm-quote-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 4px;
  max-width: 240px;
}
.dm-quote-head {
  font-size: 10px; font-weight: 700; color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 3px;
}
.dm-quote-title { font-size: 14px; font-weight: 700; color: var(--text); line-height: 1.3; }
.dm-quote-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
.dm-quote-open { cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.dm-quote-open:hover { background: var(--surface-muted); border-color: var(--accent); }
.dm-quote-flight    { border-left-color: var(--t-flight); }
.dm-quote-flight .dm-quote-head { color: var(--t-flight); }
.dm-quote-check-in  { border-left-color: var(--t-checkin); }
.dm-quote-check-out { border-left-color: var(--t-checkout); }
.dm-quote-standby   { border-left-color: var(--t-standby); }
.dm-quote-hotel     { border-left-color: var(--t-hotel); }

/* Friend picker: quoted-schedule preview strip */
.dm-quote-preview {
  margin: 0 14px 8px;
  padding: 8px 11px;
  background: var(--surface-muted);
  border-radius: 8px;
  font-size: 12px; font-weight: 600; color: var(--text);
}
.dm-quote-preview span { font-weight: 400; color: var(--muted); }

/* ── Chat: input row ── */
.dm-input-row {
  display: flex; gap: 8px; align-items: center;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.dm-flight-btn, .dm-img-btn {
  width: 32px; height: 32px; border-radius: 50%;
  background: transparent; border: 1px solid var(--line);
  color: var(--accent); font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: background 0.15s;
}
.dm-flight-btn:hover, .dm-img-btn:hover { background: var(--accent-soft); }
.dm-file-input { display: none; }

/* ── Image preview bar (above input row) ── */
.dm-img-preview-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px;
  background: var(--surface-muted); border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.dm-img-preview-thumb {
  width: 44px; height: 44px; border-radius: 6px;
  object-fit: cover; flex-shrink: 0;
  border: 1px solid var(--line);
}
.dm-img-preview-name {
  flex: 1; font-size: 12px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dm-img-preview-cancel {
  width: 22px; height: 22px; border-radius: 50%;
  background: transparent; border: 1px solid var(--line);
  color: var(--muted); cursor: pointer; font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; padding: 0;
}
.dm-img-preview-cancel:hover { color: var(--danger); border-color: var(--danger); }

/* ── Image message bubble ── */
.dm-image-msg {
  max-width: 260px;
}
.dm-image {
  display: block; max-width: 100%; border-radius: 10px;
  cursor: pointer; border: 1px solid var(--line);
  transition: opacity 0.15s;
}
.dm-image:hover { opacity: 0.88; }
.dm-image-name {
  font-size: 11px; color: var(--muted); margin-top: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dm-img-bubble-wrap {
  display: flex; align-items: flex-end; gap: 5px;
  flex-direction: row-reverse;
}
.dm-input {
  flex: 1; background: var(--surface-muted);
  border: 1px solid var(--line); border-radius: 20px;
  padding: 8px 14px; font-size: 13px; color: var(--text);
  outline: none; font-family: inherit;
}
.dm-input:focus { border-color: var(--accent); }
.dm-send-btn {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent); border: none;
  color: #fff; cursor: pointer; font-size: 15px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* ── Flight picker modal ── */
.dm-modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0, 0, 0, 0.45);
  display: flex; align-items: center; justify-content: center;
}
.dm-modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  width: min(460px, 90vw); max-height: 60vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
.dm-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  font-weight: 700; font-size: 14px; color: var(--text);
}
.dm-modal-header button {
  background: none; border: none; cursor: pointer;
  font-size: 16px; color: var(--muted); padding: 0;
}
.dm-picker-list { flex: 1; overflow-y: auto; padding: 4px 0; }
.dm-picker-row {
  padding: 10px 16px; cursor: pointer;
  border-bottom: 1px solid var(--line);
  transition: background 0.15s;
}
.dm-picker-row:hover { background: var(--surface-muted); }
.dm-picker-route { font-weight: 700; font-size: 14px; color: var(--text); }
.dm-picker-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── Message: hover actions (edit / delete) ── */
.dm-bubble-wrap {
  display: flex; align-items: flex-end; gap: 5px;
  flex-direction: row-reverse;
}
.dm-msg-actions { display: none; gap: 3px; align-items: center; margin-bottom: 2px; }
.dm-bubble-wrap:hover .dm-msg-actions,
.dm-bubble-wrap:focus-within .dm-msg-actions { display: flex; }
.dm-act-btn {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--line);
  cursor: pointer; font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); padding: 0; font-family: inherit;
  transition: border-color 0.15s, color 0.15s;
}
.dm-act-edit:hover { color: var(--accent); border-color: var(--accent); }
.dm-act-del:hover  { color: var(--danger); border-color: var(--danger); }

/* ── Message: inline edit form ── */
.dm-bubble-edit-wrap { display: flex; flex-direction: column; gap: 6px; max-width: 360px; min-width: 180px; }
.dm-edit-textarea {
  background: var(--surface); border: 1px solid var(--accent);
  border-radius: 12px; padding: 8px 12px;
  font-size: 13px; font-family: inherit; color: var(--text);
  resize: none; outline: none; min-height: 56px; line-height: 1.5;
}
.dm-edit-btns { display: flex; gap: 6px; justify-content: flex-end; }
.dm-edit-save, .dm-edit-cancel {
  font-size: 12px; padding: 4px 14px; border-radius: 6px;
  cursor: pointer; font-family: inherit; font-weight: 600; border: 1px solid;
}
.dm-edit-save   { background: var(--accent); border-color: var(--accent); color: #fff; }
.dm-edit-cancel { background: transparent; border-color: var(--line); color: var(--muted); }

/* ── Read receipts + edited label ── */
.dm-receipt      { color: var(--muted); }
.dm-receipt-read { color: var(--accent); font-weight: 700; }
.dm-edited       { font-style: italic; color: var(--muted); }

/* ── Inline error banner (DM layout) ── */
#dmLayout { position: relative; }
.dm-inline-error {
  position: absolute; top: 0; left: 0; right: 0; z-index: 20;
  background: var(--danger); color: #fff;
  font-size: 12px; font-weight: 600; text-align: center;
  padding: 6px 16px;
  animation: dm-err-in 0.2s ease;
}
@keyframes dm-err-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Mobile: stack panels, show only active one ── */
@media (max-width: 600px) {
  /* The panes are position:absolute, so the layout needs an explicit height or it
     collapses to 0 (blank screen). Pin the whole view between the top bar and the bottom
     tab bar so the chat fills the screen. */
  #messagesView:not([hidden]) {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    z-index: 5;
  }
  .dm-layout { position: relative; height: 100%; }
  .dm-left {
    width: 100%; max-width: none; border-right: none;
    position: absolute; inset: 0; z-index: 1;
  }
  .dm-right {
    position: absolute; inset: 0; z-index: 2;
    display: none; background: var(--bg);
  }
  .dm-layout.dm-has-episode .dm-right { display: flex; }
  .dm-layout.dm-has-episode .dm-left  { display: none; }
  .dm-mobile-back { display: flex !important; }
}

/* ── Toast notifications (new-message nudges) ── */
.dm-toast-host {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top, 0px));
  right: 14px;
  z-index: 1000;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
  max-width: min(340px, calc(100vw - 28px));
}
.dm-toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 11px;
  padding: 11px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(15, 24, 36, 0.22);
  cursor: pointer;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.28s ease, transform 0.28s ease;
}
.dm-toast.dm-toast-in { opacity: 1; transform: translateY(0); }
.dm-toast:hover { border-color: var(--accent); }
.dm-toast-icon {
  font-size: 18px; line-height: 1; flex-shrink: 0;
}
.dm-toast-body { min-width: 0; }
.dm-toast-title {
  font-size: 13px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dm-toast-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }

@media (max-width: 600px) {
  /* On phones, drop toasts in from the top, clear of the slim top bar */
  .dm-toast-host {
    top: calc(58px + env(safe-area-inset-top, 0px));
    left: 14px; right: 14px;
    max-width: none;
  }
}

/* --- Secret Memo (tier 2) — vault UI ---------------------------------------- */
.memo-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  margin-bottom: 1rem;
}
.memo-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.memo-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
.memo-tab.active[data-memo-tab="secret"] { color: #6a4ed8; }
.secret-card { border-top: 3px solid #6a4ed8; }
[data-theme="dark"] .secret-card { border-top-color: #9a82f0; }

/* Quick / Secret chooser (Option A) — first step when tapping a target with no memo yet. */
.memo-choose-prompt { font-size: 0.85rem; color: var(--muted); margin: 0.1rem 0 0.85rem; }
.memo-choice {
  display: flex; align-items: center; gap: 0.85rem; width: 100%; text-align: left;
  padding: 0.9rem 1rem; margin: 0 0 0.7rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  cursor: pointer; transition: border-color 0.12s, background 0.12s, transform 0.06s;
}
.memo-choice:last-child { margin-bottom: 0; }
.memo-choice:hover { border-color: var(--accent); background: var(--accent-soft); }
.memo-choice:active { transform: scale(0.99); }
.memo-choice.is-secret:hover { border-color: #6a4ed8; background: rgba(106, 78, 216, 0.08); }
[data-theme="dark"] .memo-choice.is-secret:hover { border-color: #9a82f0; }
.memo-choice-ic {
  flex-shrink: 0; width: 40px; height: 40px; border-radius: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.2rem; background: var(--accent-soft);
}
.memo-choice.is-secret .memo-choice-ic { background: rgba(106, 78, 216, 0.13); }
.memo-choice-tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.memo-choice-t { font-size: 0.98rem; font-weight: 700; color: var(--text); }
.memo-choice-s { font-size: 0.8rem; color: var(--muted); line-height: 1.35; }
.memo-choice-arr { flex-shrink: 0; color: var(--muted); font-size: 1.3rem; line-height: 1; }
.secret-warn { font-size: 0.78rem; color: var(--muted); margin: 0.2rem 0 0; }
.secret-recovery-key {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  font-weight: 700;
  background: var(--surface-muted);
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin: 0.4rem 0;
  word-break: break-all;
  user-select: all;
}
.secret-recovery-actions { display: flex; gap: 0.5rem; }
.secret-ack { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; color: var(--text); margin: 0.3rem 0; }
.secret-ack input { width: 16px; height: 16px; }
.secret-new { width: 100%; margin-bottom: 0.85rem; }
.memo-title-input,
.memo-body-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--text);
  padding: 0.6rem 0.75rem;
  font: inherit;
  margin-bottom: 0.7rem;
}
.memo-title-input { font-weight: 600; }
.memo-body-input { resize: vertical; line-height: 1.5; }
.memo-colors { display: flex; gap: 0.5rem; margin-bottom: 0.9rem; }
.memo-color { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.memo-color.sel { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface); }
.mc-neutral { background: var(--muted); }
.mc-good { background: var(--t-checkin); }
.mc-caution { background: var(--t-standby); }
.mc-flight { background: var(--t-flight); }
.av-sm.mc-neutral, .av-sm.mc-good, .av-sm.mc-caution, .av-sm.mc-flight { color: #fff; }
.secret-editor-actions { display: flex; align-items: center; gap: 1rem; }
.link-button.danger { color: var(--danger); }

/* PIN inputs use big letter-spacing for the digits; the placeholder text is long, so
   shrink just the placeholder (normal spacing) to fit the box. */
.memo-pin-input::placeholder {
  font-size: 0.8rem;
  letter-spacing: normal;
}

/* iOS Safari auto-zooms when a focused input's font is < 16px (it then can't be tapped
   back out easily, hiding the Send button). Keep the DM composer + edit fields at 16px. */
.dm-input,
.dm-edit-textarea {
  font-size: 16px;
}

/* ── Update-available banner (service-worker new-version prompt) ───────────── */
.update-banner {
  position: fixed;
  left: 50%;
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 20px);
  z-index: 1200;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 28px);
  padding: 9px 10px 9px 16px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: var(--shadow, 0 8px 28px rgba(0, 0, 0, 0.3));
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.update-banner.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}
/* Two-line layout so the version/date is always fully readable (no truncation). */
.update-banner-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ub-title { font-weight: 600; font-size: 14px; line-height: 1.25; color: var(--text); }
.ub-ver {
  color: var(--accent); font-weight: 700; font-size: 12.5px; line-height: 1.25;
  white-space: nowrap; letter-spacing: 0.01em; font-variant-numeric: tabular-nums;
}
.update-banner-reload {
  flex: 0 0 auto;
  padding: 6px 14px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.update-banner-reload:hover { filter: brightness(1.08); }
.update-banner-dismiss {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.update-banner-dismiss:hover { color: var(--text); }
@media (max-width: 600px) {
  .update-banner { bottom: calc(68px + env(safe-area-inset-bottom, 0px)); font-size: 13px; }
}

/* ── One-time iOS "new icon" notice (installed PWA only) ── */
.icon-refresh-sheet {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 1200;
  display: flex; justify-content: center;
  padding: 0 12px;
  pointer-events: none;
}
.icon-refresh-card {
  pointer-events: auto;
  display: flex; align-items: center; gap: 12px;
  width: min(440px, 100%);
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(15, 24, 36, 0.28);
}
.icon-refresh-img {
  width: 44px; height: 44px; border-radius: 11px; flex-shrink: 0;
}
.icon-refresh-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.icon-refresh-text strong { font-size: 13px; color: var(--text); }
.icon-refresh-text span { font-size: 12px; color: var(--muted); line-height: 1.45; }
.icon-refresh-ok {
  flex-shrink: 0; align-self: center;
  font-size: 12px; font-weight: 600;
  padding: 7px 14px; border-radius: 8px;
  background: var(--accent); border: 1px solid var(--accent); color: #fff;
  cursor: pointer; font-family: inherit;
}

/* ── Mobile premium upgrade bar ──────────────────────────────────────────────
   The sidebar (with its upgrade CTA + status) is hidden on phones, so locked/expiring
   users would have no way to see their status or subscribe. This fixed bar sits just
   above the bottom tab nav and is created lazily in app.js (renderPremiumMobileBar). */
#premiumMobileBar { display: none; }

@media (max-width: 720px) {
  #premiumMobileBar:not([hidden]) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    position: fixed;
    left: 0; right: 0;
    bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    z-index: 29;
    padding: 0.5rem 0.85rem;
    background: var(--surface);
    border-top: 1px solid var(--line);
    box-shadow: 0 -3px 14px rgba(20, 32, 43, 0.10);
  }
  #premiumMobileBar .pmb-label {
    display: inline-flex; align-items: center; gap: 0.4rem;
    font-size: 0.8rem; font-weight: 700; min-width: 0;
  }
  #premiumMobileBar .pmb-label > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #premiumMobileBar.is-locked .pmb-label { color: var(--danger); }
  #premiumMobileBar.is-locked .status-icon { color: var(--danger); }
  #premiumMobileBar.is-warn   .pmb-label { color: var(--t-standby); }
  #premiumMobileBar.is-warn   .status-icon { color: var(--t-standby); }
  #premiumMobileBar.is-welcome .pmb-label { color: var(--premium); }
  #premiumMobileBar.is-welcome .status-icon { color: var(--premium); }
  #premiumMobileBar .nav-upgrade-btn { width: auto; flex: none; white-space: nowrap; padding: 0.42rem 0.8rem; }
  #premiumMobileBar.pmb-pulse { animation: pmbPulse 0.5s ease; }
}

@keyframes pmbPulse {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-3px); }
}

/* ── Long-press magnifier: enlarged day schedule (touch accessibility) ── */
.cal-magnify-overlay {
  position: fixed; inset: 0; z-index: 1300;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(8, 14, 22, 0.55);
  opacity: 0; transition: opacity 0.16s ease;
}
.cal-magnify-overlay.open { opacity: 1; }
.cal-magnify {
  width: min(560px, 100%);
  max-height: 82vh; overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(8, 14, 22, 0.45);
  transform: scale(0.9); transition: transform 0.18s ease;
}
.cal-magnify-overlay.open .cal-magnify { transform: scale(1); }
.cal-mag-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--surface); border-radius: 18px 18px 0 0;
}
.cal-mag-date { font-size: 1.4rem; font-weight: 800; color: var(--text); }
.cal-mag-close {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line-strong); background: transparent;
  color: var(--muted); font-size: 1.1rem; cursor: pointer; flex-shrink: 0;
}
.cal-mag-body { padding: 8px 20px 20px; }
.cal-mag-row {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 0; border-top: 1px solid var(--line);
}
.cal-mag-row:first-child { border-top: none; }
.cal-mag-time {
  flex-shrink: 0; width: 6.2rem;
  font-size: 1.25rem; font-weight: 700; color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
}
.cal-mag-title { flex: 1; min-width: 0; font-size: 1.35rem; font-weight: 600; color: var(--text); line-height: 1.3; }
.cal-mag-pill {
  flex-shrink: 0; font-size: 0.9rem; font-weight: 700; color: #fff;
  padding: 4px 12px; border-radius: 999px; background: var(--t-activity);
}
.cal-mag-pill.flight { background: var(--t-flight); }
.cal-mag-pill.check-in { background: var(--t-checkin); }
.cal-mag-pill.check-out { background: var(--t-checkout); }
.cal-mag-pill.hotel { background: var(--t-hotel); }
.cal-mag-pill.standby { background: var(--t-standby); }
.cal-mag-pill.off-leave { background: var(--t-off); }
.cal-mag-pill.ground { background: var(--t-ground); }
.cal-mag-pill.duty { background: var(--accent-strong); }

/* ── Messages: "email me about new messages" setting toggle ────────────────── */
.dm-setting-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.dm-setting-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text); min-width: 0;
}
.dm-setting-label svg { width: 16px; height: 16px; color: var(--muted); flex: 0 0 auto; }
.dm-switch {
  position: relative; flex: 0 0 auto;
  width: 40px; height: 23px; padding: 0;
  border: none; border-radius: 999px;
  background: var(--line-strong); cursor: pointer;
  transition: background .18s ease;
}
.dm-switch.on { background: var(--accent); }
.dm-switch-knob {
  position: absolute; top: 2px; left: 2px;
  width: 19px; height: 19px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
  transition: transform .18s ease;
}
.dm-switch.on .dm-switch-knob { transform: translateX(17px); }

/* Magnifier popup: also no selection/callout (the finger lands on it after the hold) */
.cal-magnify-overlay,
.cal-magnify-overlay * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* ── DM image lightbox (in-page enlarged view; works offline via cached <img>) ── */
.dm-lightbox-overlay {
  position: fixed; inset: 0; z-index: 1400;
  display: flex; align-items: center; justify-content: center;
  padding: 14px;
  background: rgba(0, 0, 0, 0.9);
  opacity: 0; transition: opacity 0.16s ease;
}
.dm-lightbox-overlay.open { opacity: 1; }
.dm-lightbox-img {
  max-width: 96vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 12px 44px rgba(0, 0, 0, 0.5);
}
.dm-lightbox-close {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: 14px;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  border: none; color: #fff;
  font-size: 1.15rem; line-height: 1; cursor: pointer;
}

/* ── Feedback nav footer + view ──────────────────────────────────────────────── */
.nav-footer {
  margin-top: auto;
  padding-top: 0.4rem;
  flex-shrink: 0;
}
.nav-item-feedback {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-muted);
  color: var(--muted);
}
.nav-item-feedback:hover { color: var(--text); border-color: var(--line-strong); }
.nav-item-feedback.active {
  color: var(--accent-strong);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.nav-item-feedback .nav-icon { color: inherit; }
/* When the version line follows the footer, drop its auto-margin (footer owns it). */
.nav-footer + .nav-version { margin-top: 0; }

.fb-wrap { max-width: 640px; }
.fb-head { margin-bottom: 1rem; }
.fb-title { font-size: 1.3rem; font-weight: 800; color: var(--text); margin: 0 0 0.2rem; }
.fb-sub { font-size: 0.9rem; color: var(--muted); margin: 0; }

.fb-form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.4rem;
}
.fb-form.fb-drag { border-color: var(--accent); background: var(--accent-soft); }

.fb-chips { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.fb-chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.36rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem; font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
}
.fb-chip:hover { border-color: var(--line-strong); color: var(--text); }
.fb-chip.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.fb-text {
  width: 100%;
  resize: vertical;
  min-height: 88px;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  line-height: 1.5;
}
.fb-text:focus { outline: none; border-color: var(--accent); }

.fb-thumbs { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.7rem; }
.fb-thumb { position: relative; width: 64px; height: 64px; }
.fb-thumb img {
  width: 100%; height: 100%; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--line);
}
.fb-thumb-x {
  position: absolute; top: -7px; right: -7px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--line-strong);
  color: var(--muted); font-size: 0.7rem; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.fb-thumb-x:hover { color: var(--danger); border-color: var(--danger); }
.fb-thumb-add {
  width: 64px; height: 64px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.15rem;
  border: 1px dashed var(--line-strong); border-radius: 10px;
  background: transparent; color: var(--muted);
  font-size: 1.1rem; cursor: pointer;
}
.fb-thumb-add:hover { border-color: var(--accent); color: var(--accent); }
.fb-thumb-add-label { font-size: 0.62rem; }

.fb-form-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 0.8rem; }
.fb-count { font-size: 0.74rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.fb-send {
  padding: 0.5rem 1.4rem;
  border: none; border-radius: 10px;
  background: var(--accent); color: #fff;
  font-size: 0.88rem; font-weight: 700; cursor: pointer;
  transition: opacity 0.12s;
}
.fb-send:hover:not(:disabled) { opacity: 0.9; }
.fb-send:disabled { opacity: 0.45; cursor: default; }

.fb-status { font-size: 0.8rem; margin: 0.6rem 0 0; min-height: 1em; color: var(--muted); }
.fb-status.ok { color: var(--premium-strong); }
.fb-status.error { color: var(--danger); }
.fb-status.warn { color: var(--t-standby); }

.fb-list-title { font-size: 0.86rem; font-weight: 700; color: var(--muted); margin: 0 0 0.6rem; }
.fb-list { display: flex; flex-direction: column; gap: 0.6rem; }
.fb-empty {
  padding: 1.6rem; text-align: center;
  color: var(--muted); font-size: 0.85rem;
  border: 1px dashed var(--line); border-radius: var(--radius);
}

.fb-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
}
.fb-row-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.4rem; gap: 0.5rem; }
.fb-cat-tag {
  display: inline-flex; align-items: center; gap: 0.25rem;
  font-size: 0.72rem; font-weight: 600;
  padding: 0.12rem 0.55rem; border-radius: 999px;
  background: var(--surface-muted); color: var(--muted);
}
.fb-badge {
  font-size: 0.7rem; font-weight: 700;
  padding: 0.12rem 0.55rem; border-radius: 999px;
}
.fb-st-new { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent-strong); }
.fb-st-review { background: color-mix(in srgb, var(--t-standby) 18%, transparent); color: var(--t-standby); }
.fb-st-done { background: color-mix(in srgb, var(--premium) 18%, transparent); color: var(--premium-strong); }
.fb-st-closed { background: var(--surface-muted); color: var(--muted); }

.fb-row-text { font-size: 0.9rem; color: var(--text); line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.fb-row-thumbs { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.5rem; }
.fb-row-thumb {
  width: 56px; height: 56px; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--line); cursor: pointer;
}
.fb-note {
  margin-top: 0.5rem; padding: 0.45rem 0.6rem;
  background: var(--surface-muted); border-radius: 8px;
  font-size: 0.82rem; color: var(--muted);
}
.fb-row-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 0.55rem; }
.fb-row-time { font-size: 0.72rem; color: var(--muted); }
.fb-withdraw {
  background: none; border: none; cursor: pointer;
  font-size: 0.74rem; color: var(--muted); text-decoration: underline;
}
.fb-withdraw:hover { color: var(--danger); }

/* ── DM aviation reaction stickers (Concept A — solid tinted chip, pronounced selected state) ── */
.dm-reactions { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 5px; }
.dm-msg-mine .dm-reactions { justify-content: flex-end; }
.dm-react-chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px 3px 7px; border-radius: 20px; background: var(--surface-muted); border: 1px solid var(--line-strong); color: var(--text); cursor: pointer; transition: border-color .12s, background .12s, transform .08s; }
.dm-react-chip svg { width: 16px; height: 16px; color: var(--premium); }
.dm-react-chip span { font-size: 0.78rem; font-weight: 800; color: var(--text); }
.dm-react-chip:hover { border-color: var(--premium-strong); transform: translateY(-1px); }
.dm-react-chip.mine { background: var(--premium-box-bg); border-color: var(--premium-strong); }
.dm-react-chip.mine svg, .dm-react-chip.mine span { color: var(--premium-strong); }
.dm-react-add { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; background: none; border: 1px solid var(--line-strong); color: var(--muted); cursor: pointer; opacity: 0.75; transition: opacity .12s, color .12s, border-color .12s; }
.dm-react-add svg { width: 16px; height: 16px; }
.dm-react-add:hover { opacity: 1; color: var(--premium); border-color: var(--premium-strong); }

.dm-react-backdrop { position: fixed; inset: 0; z-index: 70; display: none; align-items: center; justify-content: center; padding: 1rem; background: rgba(20, 32, 43, 0.5); }
.dm-react-backdrop.open { display: flex; }
.dm-react-panel { width: min(94vw, 460px); max-height: 80vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 14px 18px; box-shadow: 0 14px 44px rgba(0, 0, 0, 0.4); }
.dm-react-title { font-size: 0.92rem; font-weight: 700; color: var(--text); margin: 0 2px 10px; }
.dm-react-sec { display: flex; align-items: center; gap: 8px; font-size: 0.6rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--premium-strong); margin: 12px 2px 8px; }
.dm-react-sec span { flex: 1; height: 1px; background: var(--line); }
.dm-react-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px 4px; }
.dm-react-opt { display: flex; flex-direction: column; align-items: center; gap: 5px; background: none; border: none; cursor: pointer; padding: 2px; }
.dm-react-ic { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--premium) 10%, transparent); border: 1px solid color-mix(in srgb, var(--premium) 22%, transparent); color: var(--premium); }
.dm-react-ic svg { width: 23px; height: 23px; }
.dm-react-opt:hover .dm-react-ic { background: color-mix(in srgb, var(--premium) 20%, transparent); }
.dm-react-lab { font-size: 0.62rem; color: var(--muted); text-align: center; line-height: 1.1; }
@media (max-width: 480px) { .dm-react-grid { grid-template-columns: repeat(4, 1fr); } }

/* ── Language switcher (top-bar globe) ── */
.lang-wrap { position: relative; display: inline-flex; }
.lang-menu { position: absolute; top: calc(100% + 8px); right: 0; z-index: 50; min-width: 196px; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 12px 34px rgba(0, 0, 0, 0.28); overflow: hidden; padding: 5px; }
.lang-menu[hidden] { display: none; }
.lang-menu-title { font-size: 0.6rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); padding: 9px 12px 6px; }
.lang-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: none; background: none; border-radius: 9px; cursor: pointer; text-align: left; }
.lang-item:hover { background: color-mix(in srgb, var(--muted) 12%, transparent); }
.lang-native { font-size: 0.92rem; color: var(--text); }
.lang-item.on .lang-native { color: var(--accent); font-weight: 700; }
.lang-sub { margin-left: auto; font-size: 0.72rem; color: var(--muted); }
.lang-check { margin-left: auto; color: var(--accent); display: flex; }

/* ── DM auto-translate (quiet inline) ── */
.dm-tr { margin: 4px 2px 0 2px; display: flex; flex-direction: column; gap: 3px; max-width: 90%; }
.dm-tr-line { display: flex; gap: 7px; align-items: baseline; }
.dm-tr-tag { flex: none; font-size: 9px; font-weight: 700; letter-spacing: .05em; color: var(--premium, #2f9e8f); border: 1px solid color-mix(in srgb, var(--premium, #2f9e8f) 45%, transparent); border-radius: 5px; padding: 0 4px; line-height: 15px; }
.dm-tr-txt { font-size: 12.5px; line-height: 1.4; color: var(--muted, #8a98a6); }
.dm-tr-pending { opacity: .9; }
.dm-tr-dot { flex: none; width: 5px; height: 5px; border-radius: 50%; background: var(--premium, #2f9e8f); animation: dmTrPulse 1s ease-in-out infinite; }
@keyframes dmTrPulse { 0%, 100% { opacity: .25; } 50% { opacity: .7; } }
.dm-tr-toggle.on { color: var(--premium, #2f9e8f); }
/* translate popover */
.dm-tr-backdrop { position: fixed; inset: 0; z-index: 1200; background: rgba(0, 0, 0, .3); display: flex; align-items: center; justify-content: center; padding: 16px; }
.dm-tr-panel { width: min(310px, 90vw); background: var(--surface, #fff); border: 1px solid var(--line, #e2e6ea); border-radius: 14px; box-shadow: 0 16px 40px rgba(0, 0, 0, .3); padding: 6px; }
.dm-tr-prow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 12px; font-size: 14px; color: var(--text, #1a2530); }
.dm-tr-prow + .dm-tr-prow { border-top: 1px solid var(--line, #eee); }
.dm-tr-prow select { font-size: 13px; padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line, #ccc); background: var(--surface, #fff); color: var(--text, #1a2530); }
.dm-tr-pnote { margin: 4px 12px 10px; font-size: 11px; color: var(--muted, #8a98a6); line-height: 1.45; }

/* DM translate — language multi-select (max 3) */
.dm-tr-lhead { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 4px; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted, #8a98a6); }
.dm-tr-count { font-weight: 600; color: var(--premium, #2f9e8f); }
.dm-tr-langs { display: flex; flex-direction: column; padding: 0 6px 2px; }
.dm-tr-lopt { display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-radius: 9px; cursor: pointer; font-size: 14px; color: var(--text, #1a2530); }
.dm-tr-lopt:hover { background: color-mix(in srgb, var(--muted, #8a98a6) 12%, transparent); }
.dm-tr-lopt input { width: 16px; height: 16px; accent-color: var(--premium, #2f9e8f); }
.dm-tr-lopt.is-disabled { opacity: .4; cursor: not-allowed; }

/* DM sender-courtesy translation */
.dm-ctr-mark { display: flex; justify-content: flex-end; align-items: baseline; gap: 5px; flex-wrap: wrap; margin: 4px 2px 0 0; max-width: 90%; align-self: flex-end; }
.dm-ctr-mark .dm-tr-tag { font-size: 8.5px; flex: none; }
.dm-ctr-arrow { color: var(--muted); font-size: 11px; }
.dm-ctr-sent-txt { font-size: calc(var(--dm-fs, 13px) - 1px); color: var(--muted); line-height: 1.35; }
.dm-ctr-deliv { font-size: 10px; color: var(--premium, #2f9e8f); }
.dm-ctr-suggest { display: flex; align-items: center; gap: 9px; margin: 0 10px 8px; padding: 9px 12px; background: color-mix(in srgb, var(--premium, #2f9e8f) 12%, transparent); border: 1px solid color-mix(in srgb, var(--premium, #2f9e8f) 38%, transparent); border-radius: 12px; }
.dm-ctr-s-ic { font-size: 15px; flex: none; }
.dm-ctr-s-tx { flex: 1; font-size: 12px; line-height: 1.4; color: var(--text, #1a2530); }
.dm-ctr-s-on { flex: none; font-size: 12px; font-weight: 600; color: #fff; background: var(--premium, #2f9e8f); border: none; border-radius: 18px; padding: 5px 13px; cursor: pointer; }
.dm-ctr-s-x { flex: none; font-size: 12px; color: var(--muted, #8a98a6); background: none; border: none; cursor: pointer; padding: 4px 6px; }
.dm-tr-ctr-sel { width: 100%; font-size: 13px; padding: 7px 9px; border-radius: 9px; border: 1px solid var(--line, #ccc); background: var(--surface, #fff); color: var(--text, #1a2530); }

/* DM friend-header presence (online status when you enter a person) */
.dm-left-title-wrap { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.dm-left-status { font-size: 11px; line-height: 1.2; font-weight: 500; }
.dm-left-status.online { color: #34b36b; }
.dm-left-status.recent { color: #d98b2b; }

/* ── DM chat readability: deep slate (dark) / cool light (light) + adjustable text size ── */
/* (messages keep the original full-width left/right layout — base .dm-messages padding stays) */
.dm-messages { background: #f3f5f8; --dm-fs: 13px; }   /* light: cool-grey; --dm-fs set inline by JS (zoom) */
[data-theme="dark"] .dm-messages { background: #0a0e14; }   /* dark: deep slate (easier than pure black) */
[data-theme="dark"] .dm-bubble-theirs { background: #1c2632; border-color: rgba(120, 160, 190, 0.16); color: #eef4f6; }
/* text size — ONLY message text + its translations (zoom up to 300%) */
.dm-messages .dm-bubble { font-size: var(--dm-fs); }
.dm-messages .dm-tr-txt { font-size: calc(var(--dm-fs) - 0.5px); }
/* font-size stepper in the chat header */
.dm-fs-ctl { display: inline-flex; align-items: center; gap: 1px; }
.dm-fs-ctl .dm-action-btn { min-width: 24px; padding: 4px 6px; font-weight: 700; }
.dm-fs-val { font-size: 11px; color: var(--muted); min-width: 40px; text-align: center; }
/* multi-select delete */
.dm-select-bar { display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border-bottom: 1px solid var(--line); font-size: 13px; }
.dm-select-bar .count { font-weight: 600; color: var(--text); }
.dm-select-bar .spacer { flex: 1; }
.dm-select-bar button { font-size: 13px; padding: 5px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
.dm-select-bar button.danger { background: var(--t-standby, #e0655a); color: #fff; border-color: transparent; }
.dm-select-bar button.danger:disabled { opacity: .45; cursor: default; }
/* select mode: clear check circle beside the bubble + strong selected state */
.dm-msg.dm-selectable { cursor: pointer; flex-direction: row; align-items: center; gap: 10px; padding: 4px 6px; }
.dm-msg-col { display: flex; flex-direction: column; min-width: 0; }
.dm-msg-mine .dm-msg-col { align-items: flex-end; }
.dm-msg-theirs .dm-msg-col { align-items: flex-start; }
.dm-sel-box {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800; line-height: 1; color: #fff; background: transparent;
}
.dm-msg.dm-selected .dm-sel-box { background: var(--accent); border-color: var(--accent); }
.dm-msg.dm-selectable .dm-bubble { outline: 2px solid transparent; outline-offset: 2px; transition: outline-color .12s; }
.dm-msg.dm-selected .dm-bubble { outline-color: var(--accent); }
.dm-msg.dm-selected { background: color-mix(in srgb, var(--accent) 14%, transparent); border-radius: 14px; }
.dm-messages.dm-selecting .dm-msg-actions { display: none !important; }

/* DM confirm toast (delete confirmation) — buttons, no auto-click on body */
.dm-toast-confirm { cursor: default; align-items: flex-start; }
.dm-toast-actions { display: flex; gap: 8px; margin-top: 9px; }
.dm-toast-btn { font-size: 13px; font-weight: 600; padding: 6px 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
.dm-toast-btn.dm-toast-danger { background: var(--t-standby, #e0655a); color: #fff; border-color: transparent; }
.dm-toast-btn.dm-toast-cancel:hover { background: color-mix(in srgb, var(--muted) 14%, transparent); }

/* DM translate bar (above composer) — Receive / Send chips */
.dm-tr-bar { display: flex; gap: 8px; flex-wrap: wrap; padding: 7px 14px 2px; }
.dm-tr-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; border: 1px solid var(--line); border-radius: 18px; padding: 5px 11px; background: var(--surface); color: var(--text); cursor: pointer; }
.dm-tr-chip:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.dm-tr-chip .lab { font-size: 10.5px; font-weight: 700; color: var(--muted); }
.dm-tr-chip .v, .dm-tr-chip .cv { font-weight: 600; color: var(--accent); }
.dm-tr-chip .cv-caret { color: var(--muted); font-size: 10px; }
.dm-tr-chip.on { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
/* send (courtesy) menu options */
.dm-tr-sopts { display: flex; flex-direction: column; padding: 2px; }
.dm-tr-sopt { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: none; background: none; border-radius: 9px; cursor: pointer; font-size: 14px; color: var(--text); text-align: left; }
.dm-tr-sopt:hover { background: color-mix(in srgb, var(--muted) 12%, transparent); }
.dm-tr-sopt.on { color: var(--accent); font-weight: 600; }
.dm-tr-sck { color: var(--accent); }

/* DM contacts-list sort toggle */
.dm-sort-row { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-top: 1px solid var(--line); }
.dm-sort-lab { font-size: 11px; font-weight: 700; letter-spacing: .03em; color: var(--muted); }
.dm-sort-seg { margin-left: auto; display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.dm-sort-seg button { font-size: 12px; padding: 4px 12px; border: none; background: var(--surface); color: var(--muted); cursor: pointer; }
.dm-sort-seg button + button { border-left: 1px solid var(--line); }
.dm-sort-seg button.on { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); font-weight: 600; }

/* DM episode card — conversation start date */
.dm-ep-date { font-size: 10.5px; color: var(--muted); }
.dm-ep-foot .dm-ep-date + .dm-ep-ext::before { content: "· "; color: var(--muted); }
.dm-sort-seg button .dm-sort-dir { margin-left: 3px; font-size: 10px; }

/* Mobile: keep the Receive/Send translate chips on ONE compact row */
@media (max-width: 720px) {
  .dm-tr-bar { flex-wrap: nowrap; gap: 6px; padding: 6px 12px 2px; }
  .dm-tr-chip { flex: 1 1 0; min-width: 0; gap: 5px; padding: 5px 9px; font-size: 11.5px; }
  .dm-tr-chip .lab { flex: none; }
  .dm-tr-chip .v, .dm-tr-chip .cv { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .dm-tr-chip .cv-caret { flex: none; margin-left: auto; }
}
