/* Prayer Letters — X-inspired, minimal, bg #ffffff + secondary #22467d */
:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --border: #e6e8ec;
  --border-soft: #f0f1f3;
  --text: #0f1419;
  --text-secondary: #536471;
  --hover: rgba(15, 20, 25, 0.04);
  --hover-strong: rgba(15, 20, 25, 0.08);
  --accent: #1a1a1a;
  --secondary: #22467d;
  --secondary-soft: rgba(34, 70, 125, 0.1);
  --pray: #c45c26;
  --pray-soft: rgba(196, 92, 38, 0.12);
  --new: #dc2626;
  --radius: 16px;
  --radius-sm: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --col-width: 780px;
  --sidebar-w: 380px;
  --stamp-slot-w: 76px;
  --sidebar-collapsed-w: 72px;
  --topbar-h: 53px;
  --bottom-nav-h: 56px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

body.drawer-open { overflow: hidden; }
body.photo-open { overflow: hidden; }

button, input, textarea, select {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }

/* Layout */
#app {
  display: flex;
  justify-content: center;
  min-height: 100dvh;
  max-width: 1400px;
  margin: 0 auto;
}

/* Sidebar — desktop sticky; mobile drawer */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 80;
  height: 100dvh;
  width: min(var(--sidebar-w), 92vw);
  padding: 8px 12px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
  background: var(--bg);
  border-right: 1px solid var(--border);
  transform: translateX(-105%);
  transition: transform 0.28s ease, width 0.22s ease, padding 0.22s ease;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  will-change: transform;
}

.sidebar.open { transform: translateX(0); }

/* Finger-tracking drawer (X-style) — no CSS transition while dragging */
.sidebar.is-dragging {
  transition: none !important;
}

.sidebar-top {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  flex-shrink: 0;
}

.sidebar-top .brand { flex: 1; min-width: 0; }

.sidebar-collapse-btn {
  margin-top: 8px;
  flex-shrink: 0;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 25, 0.4);
  z-index: 75;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: opacity 0.28s ease, background-color 0.28s ease;
}

.drawer-backdrop[hidden] { display: none; }

.drawer-backdrop.is-dragging {
  transition: none !important;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  padding: 8px 12px 12px 8px;
  border-radius: 12px;
  margin-bottom: 2px;
  flex-shrink: 0;
  background: transparent;
}

.brand:hover { background: var(--hover); }

.brand-logo {
  object-fit: contain;
  background: transparent !important;
  flex-shrink: 0;
  display: block;
}

/* Expanded: transparent wordmark, slightly larger than nav labels */
.brand-logo-full {
  height: 40px;
  width: auto;
  max-width: calc(100% - 4px);
  border-radius: 0;
}

.sidebar-top .brand {
  width: 100%;
}

/* Collapsed panel / mark: 29 — match nav icon size (24px) with a bit of presence */
.brand-logo-mark {
  display: none;
  width: 32px;
  height: 32px;
  border-radius: 0;
  object-fit: contain;
}

.side-nav { display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-radius: 999px;
  font-size: 1.1rem;
  font-weight: 500;
  text-align: left;
  transition: background 0.15s;
}

.nav-item:hover { background: var(--hover); }
.nav-item.active {
  font-weight: 700;
  color: var(--secondary);
}
.nav-item svg { flex-shrink: 0; }
.nav-label { white-space: nowrap; }

/* Horizontal flip while Letters / Missionaries / Compose page loads (~30% slower) */
.nav-item.is-loading > svg,
.bottom-item.is-loading > svg,
.topbar-logo-btn.is-loading .topbar-logo {
  animation: nav-icon-flip-x 1.1s linear infinite;
  transform-origin: center center;
  transform-style: preserve-3d;
  backface-visibility: visible;
}

@keyframes nav-icon-flip-x {
  from { transform: rotateY(0deg); }
  to { transform: rotateY(360deg); }
}

.sidebar-schedule {
  margin-top: 12px;
  padding-bottom: 24px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.main {
  width: 100%;
  max-width: var(--col-width);
  min-height: 100dvh;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 16px);
  position: relative;
  flex: 1 1 auto;
}

.rail-card {
  background: var(--border-soft);
  border-radius: var(--radius);
  padding: 16px;
}

.rail-card h2,
.schedule-card h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.schedule-sub {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-bottom: 12px;
}

.schedule-list {
  --schedule-gap: 8px;
  --schedule-rail-dash: repeating-linear-gradient(
    to bottom,
    rgba(34, 70, 125, 0.42) 0 3.5px,
    transparent 3.5px 8px
  );
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--schedule-gap);
  padding-left: 2px;
}

.schedule-item {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 32px 22px 1fr;
  gap: 6px;
  align-items: stretch;
  padding: 7px 8px 7px 2px;
  background: var(--border-soft);
  border-radius: 10px;
}

.schedule-item .flag,
.schedule-body {
  align-self: center;
}

.schedule-rail {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  min-height: 36px;
  align-self: stretch;
}

.schedule-rail::before {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 2.5px;
  top: calc(var(--schedule-gap) / -2);
  bottom: calc(var(--schedule-gap) / -2);
  z-index: 0;
  pointer-events: none;
  background: var(--secondary);
}

.schedule-item.is-upcoming .schedule-rail::before,
.schedule-item.is-cancelled .schedule-rail::before {
  background: var(--schedule-rail-dash);
}

.schedule-item:first-child .schedule-rail::before {
  top: 50%;
}

.schedule-item:last-child .schedule-rail::before {
  bottom: 50%;
}

.schedule-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid var(--secondary);
  box-shadow: 0 0 0 2px var(--border-soft);
  z-index: 2;
  flex-shrink: 0;
  position: relative;
  box-sizing: border-box;
}

.schedule-item.is-complete .schedule-dot,
.schedule-item.is-ongoing .schedule-dot {
  background: var(--secondary);
  border-color: var(--secondary);
}

.schedule-item.is-cancelled .schedule-dot {
  background: var(--border-soft);
  border-color: #b0b8c4;
}

.schedule-item.is-current .schedule-dot {
  opacity: 0;
  width: 0;
  height: 0;
  border: 0;
  box-shadow: none;
}

.schedule-plane {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--secondary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 0;
  box-shadow:
    0 0 0 2px var(--border-soft),
    0 2px 6px rgba(34, 70, 125, 0.45);
  pointer-events: none;
}

.schedule-plane-icon {
  display: block;
  width: 18px;
  height: 18px;
  transform: rotate(180deg);
}

/* Sit on the existing gap above this trip — do not insert extra space */
.schedule-item.has-plane-before {
  z-index: 2;
}

.schedule-item.has-plane-before .schedule-plane {
  top: calc(var(--schedule-gap) / -2);
  transform: translate(-50%, -50%);
}

.schedule-item.has-plane-before:first-child .schedule-plane {
  top: 0;
}

.schedule-item .flag {
  width: 28px;
  height: 20px;
  object-fit: cover;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
}

.schedule-body {
  min-width: 0;
}

.schedule-item .area {
  font-weight: 700;
  font-size: 0.78rem;
  line-height: 1.3;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  max-width: 100%;
  width: 100%;
  cursor: default;
}

/* Stamp on the dates line — no reserved column next to area/team */
.schedule-item .dates-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 2px;
  min-width: 0;
}

.schedule-item .dates-row .dates {
  margin-top: 0;
  flex: 1;
  min-width: 0;
}

.schedule-item .stamp-slot {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-shrink: 0;
  min-height: 0;
  width: auto;
  min-width: 0;
  box-sizing: border-box;
  padding-top: 0;
}

.schedule-item .stamp-slot:empty {
  display: none;
}

.schedule-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.schedule-card-head h2 {
  margin: 0;
  flex: 1;
  min-width: 0;
}

.schedule-gear {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: var(--text-secondary);
  margin: -4px -6px 0 0;
}

.schedule-gear:hover {
  background: var(--hover);
  color: var(--text);
}

.schedule-item .team {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 1px;
}

.schedule-item .dates {
  font-size: 0.68rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.schedule-item .area {
  font-size: 0.78rem;
}

.schedule-card h2 {
  font-size: 0.95rem;
}

.schedule-sub {
  font-size: 0.72rem;
}

.schedule-item {
  padding: 7px 8px 7px 2px;
  gap: 6px;
}

.schedule-item .flag {
  width: 22px;
  height: 16px;
}

.cancelled-stamp {
  color: #6b7280;
  border: 1.5px solid #9ca3af;
  background: rgba(243, 244, 246, 0.95);
}

.schedule-item.is-cancelled .area,
.schedule-item.is-cancelled .team,
.schedule-item.is-cancelled .dates {
  color: var(--text-secondary);
  opacity: 0.7;
}

.schedule-item.is-cancelled .flag {
  filter: grayscale(0.6);
  opacity: 0.75;
}

/* Mission area admin */
.area-admin-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.area-admin-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: var(--border-soft);
  border-radius: 10px;
}

.area-flag {
  width: 28px;
  height: 20px;
  object-fit: cover;
  border-radius: 3px;
  flex-shrink: 0;
}

.area-admin-fields {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.area-admin-fields input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  background: #fff;
}

.area-admin-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-add-area h4 {
  font-size: 0.9rem;
  margin: 8px 0 10px;
}

/* Completed trips */
.schedule-item.is-complete .area {
  color: var(--text-secondary);
  font-weight: 600;
  opacity: 0.8;
}

.schedule-item.is-complete .dates {
  opacity: 0.75;
}

.schedule-item.is-complete .flag {
  filter: grayscale(0.35);
  opacity: 0.85;
}

.complete-stamp,
.cancelled-stamp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 1px 4px;
  border-radius: 3px;
  transform: rotate(-8deg);
  line-height: 1.15;
  flex-shrink: 0;
  white-space: nowrap;
}

.complete-stamp {
  color: #dc2626;
  border: 1.5px solid #dc2626;
  background: rgba(254, 242, 242, 0.9);
}

/* Outreach D-x countdown (Eastern time; trip start = D-Day) */
.dday-stamp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.15;
  padding: 1px 5px;
  border-radius: 3px;
}

/* D-4 and beyond — plain black */
.dday-stamp--far {
  color: #1a1a1a;
  font-weight: 600;
  font-size: 0.6rem;
  padding: 0;
  border: none;
  background: transparent;
  transform: none;
}

/* D-3 — subtle emphasis */
.dday-stamp--d3 {
  color: #1a1a1a;
  font-weight: 800;
  border: 1px solid #1a1a1a;
  background: #fff;
  transform: rotate(-4deg);
}

/* D-2 — warmer accent */
.dday-stamp--d2 {
  color: #b45309;
  font-weight: 800;
  font-size: 0.64rem;
  border: 1.5px solid #d97706;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  transform: rotate(-7deg);
  box-shadow: 0 1px 3px rgba(217, 119, 6, 0.25);
}

/* D-1 — urgent */
.dday-stamp--d1 {
  color: #dc2626;
  font-weight: 900;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 2px solid #dc2626;
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  transform: rotate(-10deg) scale(1.05);
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.3);
}

/* D-Day — maximum emphasis + flash */
.dday-stamp--today {
  color: #fff;
  font-weight: 900;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 2px solid #dc2626;
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 50%, #ef4444 100%);
  background-size: 200% 200%;
  transform: rotate(-12deg) scale(1.1);
  box-shadow: 0 0 8px rgba(220, 38, 38, 0.55), 0 2px 8px rgba(0, 0, 0, 0.15);
  animation: dday-flash 1.1s ease-in-out infinite;
}

@keyframes dday-flash {
  0%, 100% {
    opacity: 1;
    box-shadow: 0 0 10px rgba(220, 38, 38, 0.7), 0 2px 8px rgba(0, 0, 0, 0.15);
    background-position: 0% 50%;
    transform: rotate(-12deg) scale(1.1);
  }
  50% {
    opacity: 0.82;
    box-shadow: 0 0 18px rgba(250, 204, 21, 0.85), 0 0 12px rgba(220, 38, 38, 0.9);
    background-position: 100% 50%;
    transform: rotate(-8deg) scale(1.14);
  }
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px 0 4px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.topbar-logo-btn {
  padding: 4px;
  border-radius: 10px;
  line-height: 0;
  flex-shrink: 0;
}

.topbar-logo-btn:hover { background: var(--hover); }

.topbar-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: contain;
  background: transparent;
}

.topbar-title,
.topbar-title-btn {
  font-size: 1.15rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  max-width: 100%;
}

.topbar-title-btn {
  padding: 6px 8px;
  margin: -6px -8px;
  border-radius: 8px;
  cursor: pointer;
  color: inherit;
}

.topbar-title-btn.is-home:hover {
  background: var(--hover);
}

.topbar-title-btn:not(.is-home) {
  cursor: default;
}

.icon-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, opacity 0.15s;
  padding: 0;
}

.icon-btn svg {
  display: block;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.icon-btn:hover:not(:disabled) { background: var(--hover-strong); }

.icon-btn:disabled,
.icon-btn[aria-disabled="true"] {
  opacity: 0.28;
  cursor: default;
  pointer-events: none;
}

/* Nav chevron is always interactive on home (panel toggle) */
.back-btn.is-panel-toggle:disabled,
.back-btn.is-panel-toggle[aria-disabled="true"] {
  opacity: 1;
  cursor: pointer;
  pointer-events: auto;
}

.settings-btn {
  margin-left: auto;
}

/* Infinite-scroll sentinel: invisible hit area unless loading */
.scroll-sentinel {
  display: flex;
  justify-content: center;
  min-height: 1px;
  padding: 0;
  pointer-events: none;
}

.scroll-sentinel .spinner {
  display: none;
}

.scroll-sentinel.is-loading {
  padding: 24px;
  min-height: 48px;
}

.scroll-sentinel.is-loading .spinner {
  display: block;
}

/* Bottom nav mobile */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 60;
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: transform;
}

/* X-style: hide bottom bar when scrolling down the feed */
body.bottom-nav-hidden .bottom-nav {
  transform: translateY(110%);
  pointer-events: none;
}

body.photo-open .bottom-nav { display: none; }

.bottom-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.65rem;
  color: var(--text-secondary);
  padding: 6px;
}

.bottom-item:hover { color: var(--text); }
.bottom-item.active { color: var(--secondary); }

.view-root { min-height: 40vh; }

/* Post card — avatar top-left next to name */
.post {
  display: block;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
  position: relative;
}

.post:hover { background: var(--hover); }

.post-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding-right: 52px;
  margin-bottom: 6px;
}

.post-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--border);
  flex-shrink: 0;
}

.post-avatar-btn {
  padding: 0;
  border-radius: 50%;
  line-height: 0;
  cursor: pointer;
  flex-shrink: 0;
}

.post-avatar-btn:hover { opacity: 0.9; }

.post-header-text {
  min-width: 0;
  flex: 1;
  padding-top: 2px;
}

.post-name-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
}

.post-name {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.25;
}

.post-name:hover { text-decoration: underline; }

.post-meta {
  color: var(--text-secondary);
  font-size: 0.88rem;
}

.badge-new {
  display: inline-flex;
  align-items: center;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  background: var(--new);
  padding: 2px 7px;
  border-radius: 4px;
  line-height: 1.2;
  vertical-align: middle;
}

.post-stamp {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 40px;
  height: 48px;
  pointer-events: none;
  opacity: 0.92;
  transform: rotate(8deg);
}

.post-stamp .stamp-frame {
  width: 100%;
  height: 100%;
  border: 2px dashed #8a8680;
  border-radius: 3px;
  padding: 3px;
  background: rgba(255, 255, 255, 0.75);
  box-shadow: 1px 1px 0 rgba(0,0,0,0.06);
}

.post-stamp img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 1px;
  filter: contrast(1.05) saturate(0.9);
}

.post-body { min-width: 0; }

.post-content-wrap {
  margin: 4px 0 10px;
}

.post-content {
  font-size: 0.95rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0;
}

/* Main feed: ~10 lines then "Show more" (X-style) */
.post-content.is-clamped {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 10;
  line-clamp: 10;
  overflow: hidden;
  /* fallback max-height for engines without line-clamp + pre-wrap quirks */
  max-height: calc(1.55em * 10);
}

.show-more-btn {
  display: inline;
  margin-top: 4px;
  padding: 0;
  border: none;
  background: none;
  color: #1d9bf0;
  font-size: 0.95rem;
  font-weight: 400;
  cursor: pointer;
  text-align: left;
}

.show-more-btn:hover {
  text-decoration: underline;
}

.show-more-btn[hidden] {
  display: none !important;
}

.post.detail .post-content-wrap {
  margin: 4px 0 10px;
}

.post.detail .post-content {
  margin: 4px 0 10px;
}

.post-dates {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.post-dates strong {
  font-weight: 600;
  color: var(--text-secondary);
}

/* Photo grid — fixed height so all cells (incl. 3-up) paint fully */
.photo-grid {
  display: grid;
  gap: 2px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 10px;
  width: 100%;
  background: var(--border);
}

.photo-grid.count-1 {
  grid-template-columns: 1fr;
  height: min(56vw, 360px);
  min-height: 200px;
}
.photo-grid.count-2 {
  grid-template-columns: 1fr 1fr;
  height: min(48vw, 280px);
  min-height: 180px;
}
.photo-grid.count-3 {
  grid-template-columns: 1.15fr 0.85fr;
  grid-template-rows: 1fr 1fr;
  height: min(56vw, 320px);
  min-height: 220px;
}
.photo-grid.count-3 .photo-cell:nth-child(1) {
  grid-column: 1;
  grid-row: 1 / span 2;
}
.photo-grid.count-3 .photo-cell:nth-child(2) {
  grid-column: 2;
  grid-row: 1;
}
.photo-grid.count-3 .photo-cell:nth-child(3) {
  grid-column: 2;
  grid-row: 2;
}
.photo-grid.count-4 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  height: min(52vw, 300px);
  min-height: 220px;
}

.photo-cell {
  position: relative;
  background: #d8d6cf;
  overflow: hidden;
  min-height: 0;
  min-width: 0;
  height: 100%;
  width: 100%;
  cursor: pointer;
}

.photo-cell img {
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: center;
  position: absolute;
  inset: 0;
  display: block;
}

/* Actions */
.post-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: 320px;
  margin-top: 2px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  transition: background 0.15s, color 0.15s;
}

.action-btn:hover { background: var(--hover-strong); }

.action-btn.pray:hover,
.action-btn.pray.prayed {
  color: var(--pray);
  background: var(--pray-soft);
}

.action-btn.edit .edited-mark,
.edited-mark {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-left: 2px;
}

.post-edited-standalone {
  display: inline-flex;
  align-items: center;
  padding: 0 6px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.edit-photo-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.edit-photo-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 88px;
  font-size: 0.75rem;
}

.edit-photo-item img {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.edit-photo-keep {
  display: flex;
  align-items: center;
  gap: 4px;
}

.modal-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 36px 16px 28px;
  min-height: 160px;
}

.modal-loading .spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--border);
  border-top-color: var(--text-secondary);
  border-radius: 50%;
  animation: spin 0.91s linear infinite;
}

.modal-loading .hint {
  margin: 0;
  text-align: center;
}

.action-btn.share:hover { color: var(--text); }

.action-btn.pray {
  position: relative;
  overflow: visible;
}

.pray-icon {
  width: 22px;
  height: 22px;
  font-size: 17px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Slight warm tint when prayed / hovered via parent color filter */
.action-btn.pray.prayed .pray-icon,
.action-btn.pray:hover .pray-icon {
  filter: none;
}

.action-btn.pray.animating .pray-icon {
  animation: pray-pulse 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes pray-pulse {
  0% { transform: scale(1); }
  20% { transform: scale(1.55); }
  40% { transform: scale(0.9); }
  60% { transform: scale(1.28); }
  80% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* X-like confetti burst + multicolor ring around pray icon */
.pray-burst {
  position: absolute;
  left: 50%;
  top: 42%;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 2;
}

.pray-confetti {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 1px;
  transform: translate(-50%, -50%);
  animation: pray-confetti-fly 0.75s cubic-bezier(0.15, 0.75, 0.35, 1) forwards;
  opacity: 0;
}

@keyframes pray-confetti-fly {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.4) rotate(0deg);
  }
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(
        calc(-50% + var(--dx)),
        calc(-50% + var(--dy))
      )
      scale(1)
      rotate(var(--rot));
  }
}

.pray-ring {
  position: absolute;
  left: 0;
  top: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow:
    0 0 0 0 rgba(196, 92, 38, 0.55),
    0 0 12px 2px rgba(232, 165, 75, 0.45),
    0 0 18px 4px rgba(69, 123, 157, 0.25);
  animation: pray-ring-pop 0.7s ease-out forwards;
}

@keyframes pray-ring-pop {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.3);
    box-shadow:
      0 0 0 0 rgba(196, 92, 38, 0.7),
      0 0 4px 0 rgba(232, 165, 75, 0.6);
  }
  50% {
    opacity: 1;
    box-shadow:
      0 0 0 10px rgba(196, 92, 38, 0),
      0 0 20px 6px rgba(232, 165, 75, 0.35),
      0 0 28px 10px rgba(45, 106, 79, 0.2);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(2.4);
    box-shadow:
      0 0 0 16px rgba(196, 92, 38, 0),
      0 0 0 0 transparent;
  }
}

.pray-spark {
  position: absolute;
  left: 0;
  top: 0;
  width: 28px;
  height: 28px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    #c45c26,
    #e8a54b,
    #2d6a4f,
    #457b9d,
    #d64045,
    #e9c46a,
    #c45c26
  );
  opacity: 0;
  animation: pray-spark-spin 0.75s ease-out forwards;
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
}

@keyframes pray-spark-spin {
  0% {
    opacity: 0.95;
    transform: translate(-50%, -50%) scale(0.4) rotate(0deg);
  }
  60% {
    opacity: 0.85;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.8) rotate(200deg);
  }
}

/* Detail view */
.post.detail {
  cursor: default;
  padding: 16px;
}

.post.detail:hover { background: transparent; }

.post.detail .post-content {
  font-size: 1.05rem;
  line-height: 1.6;
}

.post.detail .post-actions {
  max-width: none;
  justify-content: flex-start;
  gap: 24px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 12px;
}

/* Photo media view */
.photo-view {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #0a0a0a;
  display: flex;
  flex-direction: column;
  color: #fff;
}

.photo-view[hidden] { display: none; }

.photo-view-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 52px;
  padding: 0 8px;
  background: rgba(0,0,0,0.85);
  flex-shrink: 0;
}

.photo-view-bar .icon-btn {
  color: #fff;
}

.photo-view-bar .icon-btn:hover { background: rgba(255,255,255,0.1); }

.photo-view-title {
  font-weight: 700;
  font-size: 0.95rem;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.photo-view-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.photo-view-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 8px;
  position: relative;
  background: #000;
  touch-action: pan-y;
  user-select: none;
}

.photo-view-stage img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.photo-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  line-height: 1;
}

.photo-nav:hover { background: rgba(255,255,255,0.22); }
.photo-nav.prev { left: 10px; }
.photo-nav.next { right: 10px; }
.photo-nav[hidden] { display: none; }

.photo-view-side {
  display: none;
  width: 380px;
  max-width: 40vw;
  background: var(--bg);
  color: var(--text);
  flex-direction: column;
  border-left: 1px solid var(--border);
  min-height: 0;
}

.photo-view-side-inner {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

.photo-view-side .post-top { padding-right: 0; }
.photo-view-side .post-content {
  font-size: 0.95rem;
  margin-top: 12px;
}

.photo-view-mobile-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: rgba(0,0,0,0.9);
  border-top: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}

.photo-view-mobile-actions .action-btn {
  color: rgba(255,255,255,0.75);
}

.photo-view-mobile-actions .action-btn.pray:hover,
.photo-view-mobile-actions .action-btn.pray.prayed {
  color: #f0a06a;
  background: rgba(196, 92, 38, 0.25);
}

.photo-view-mobile-actions .action-btn.share:hover {
  color: #fff;
  background: rgba(255,255,255,0.1);
}

.photo-counter {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.8rem;
  color: rgba(255,255,255,0.7);
  background: rgba(0,0,0,0.45);
  padding: 4px 10px;
  border-radius: 999px;
}

/* Profile */
.profile-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.profile-banner {
  height: 100px;
  background: linear-gradient(135deg, #e6e8ec, #d8dce3);
  border-radius: var(--radius-sm);
  margin-bottom: -32px;
}

.profile-pic-lg {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--bg);
  margin-left: 8px;
  background: var(--border);
}

.profile-info { margin-top: 40px; padding-left: 4px; }
.profile-info h2 { font-size: 1.25rem; font-weight: 800; }
.profile-info .area { color: var(--text-secondary); font-size: 0.95rem; margin-top: 2px; }

/* Forms */
.panel {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  min-height: calc(100dvh - var(--topbar-h) - var(--bottom-nav-h));
}

.panel h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 12px; }
.panel h3 { font-size: 0.95rem; font-weight: 700; margin: 20px 0 10px; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.field input[type="text"],
.field input[type="password"],
.field input[type="date"],
.field input[type="file"],
.field select,
.field textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  outline: none;
}

.field textarea { min-height: 180px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #999; }

/* Google Sign-In (admin) button mount point */
.google-signin-btn {
  margin: 4px 0 12px;
  min-height: 40px;
}
.google-signin-btn .hint {
  margin: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { opacity: 0.88; }
.btn-ghost { border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--hover); }
.btn-danger { color: #b91c1c; border: 1px solid #f0c4c4; }
.btn-danger:hover:not(:disabled) { background: #fef2f2; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn.is-saving {
  opacity: 0.72;
  pointer-events: none;
  cursor: wait;
}
.btn.is-saving::before {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
  flex-shrink: 0;
}
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

.auth-panel { padding: 20px 16px; }
.auth-panel .hint { color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 14px; }

.m-list { display: flex; flex-direction: column; }
.m-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-soft);
}
.m-item img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--border); }
.m-item .m-info { flex: 1; min-width: 0; }
.m-item .m-name { font-weight: 700; font-size: 0.95rem; }
.m-item .m-area { color: var(--text-secondary); font-size: 0.85rem; }
.m-item .m-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Missionaries directory (public browse) */
.missionaries-dir .dir-intro {
  margin: -4px 0 14px;
}

.m-dir-list {
  display: flex;
  flex-direction: column;
}

.m-dir-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 8px;
  border-bottom: 1px solid var(--border-soft);
  transition: background 0.12s;
  border-radius: 8px;
  margin: 0 -4px;
}

.m-dir-item:hover {
  background: var(--hover);
}

.m-dir-item .m-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--border);
  flex-shrink: 0;
}

.m-dir-item .m-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.m-dir-item .m-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  min-width: 0;
}

.m-dir-item .m-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.m-dir-item .m-flag {
  width: 18px;
  height: 12px;
  object-fit: cover;
  border-radius: 2px;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(15, 20, 25, 0.08);
  background: var(--border);
}

.m-dir-item .m-area {
  color: var(--text-secondary);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.m-darakbang {
  color: var(--pray);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.m-dir-stats {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.m-dir-chevron {
  flex-shrink: 0;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
}

.profile-darakbang {
  margin-top: 4px;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.field-label-row label {
  margin-bottom: 0;
}

.field-settings-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  color: var(--text-secondary);
}

.field-settings-btn:hover:not(:disabled) {
  background: var(--hover);
  color: var(--text);
}

.field-settings-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.db-preview {
  font-size: 0.75rem;
  margin-top: 2px;
}

.darakbang-multi {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 180px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.darakbang-multi label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  margin: 0;
}

.darakbang-multi input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--secondary);
}

.darakbang-multi-group {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin: 6px 0 2px;
}

.darakbang-multi-group:first-child {
  margin-top: 0;
}

.field-pair-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 520px) {
  .field-pair-row {
    grid-template-columns: 1fr;
  }
}

.m-dir-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.m-post-count {
  font-size: 0.75rem;
  font-weight: 600;
  text-align: right;
  line-height: 1.3;
  white-space: nowrap;
}

.empty-m-hint {
  padding: 12px 0 8px;
}

.field input:disabled,
.field select:disabled,
.field textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: var(--border-soft);
}

button.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.inline-edit {
  background: var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin: 8px 0 12px;
}

.photo-preview { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.photo-preview img {
  width: 72px; height: 72px; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--border);
}

.spinner {
  width: 28px; height: 28px;
  border: 2.5px solid var(--border);
  border-top-color: var(--text-secondary);
  border-radius: 50%;
  animation: spin 0.91s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton-post {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.skel {
  background: linear-gradient(90deg, #eceef1 25%, #f5f6f8 50%, #eceef1 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 8px;
}
.skel-avatar { width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0; }
.skel-line { height: 12px; margin-bottom: 8px; }
.skel-line.w60 { width: 60%; }
.skel-line.w90 { width: 90%; }
.skel-line.w40 { width: 40%; }
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-secondary);
}
.empty-state h3 { color: var(--text); font-size: 1.2rem; margin-bottom: 8px; }

.toast {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + 20px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 300;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  max-width: 90vw;
  text-align: center;
}
.toast[hidden] { display: none; }

.mobile-only { display: block; }

.admin-badge {
  display: inline-flex;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--border-soft);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  margin-left: auto;
}

.lang-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  width: auto;
  min-width: 0;
  height: 40px;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.35);
}

.lang-toggle-btn:hover {
  background: var(--hover);
}

.lang-toggle-btn .lang-sep {
  opacity: 0.45;
  font-weight: 500;
}

.lang-toggle-btn .lang-opt {
  opacity: 0.45;
  font-weight: 700;
  transition: opacity 0.12s, color 0.12s;
}

.lang-toggle-btn .lang-opt.is-active {
  opacity: 1;
  color: var(--text);
  font-weight: 800;
}

.settings-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.settings-lock-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
}

.settings-lock-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.settings-compose-btn {
  margin-bottom: 4px;
}

a.settings-section-btn {
  text-decoration: none;
  display: flex;
  align-items: center;
}

.profile-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.m-dir-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.m-dir-edit-inline {
  flex-shrink: 0;
}

.compose-photos-note { font-size: 0.8rem; color: var(--text-secondary); margin-top: 4px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* Modal (schedule editor, etc.) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(15, 20, 25, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 12px;
  overflow-y: auto;
}

.modal-panel {
  width: min(560px, 100%);
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
  padding: 16px 16px 20px;
  margin: auto 0;
}

.modal-panel h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.modal-close {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.modal-close:hover { background: var(--hover); color: var(--text); }

.trip-edit-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: min(58vh, 520px);
  overflow-y: auto;
  margin: 12px 0;
  padding-right: 2px;
}

.trip-edit-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  background: rgba(255, 255, 255, 0.35);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.trip-edit-card .field { margin: 0; }
.trip-edit-card .field label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 3px;
}
.trip-edit-card .field input,
.trip-edit-card .field select,
.trip-edit-year input {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 0.85rem;
}
.trip-edit-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.trip-edit-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.trip-order-btns {
  display: flex;
  gap: 4px;
}

.trip-order-btns .btn {
  min-width: 36px;
  font-weight: 700;
}

.settings-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.settings-section-btn {
  justify-content: flex-start;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.35);
}

.settings-section-btn:hover {
  background: var(--hover);
}

.settings-section-btn.is-open {
  border-color: var(--text-secondary);
  background: var(--hover-strong);
  font-weight: 600;
}

.settings-collapsible {
  margin-top: 12px;
  padding-top: 4px;
  border-top: 1px solid var(--border-soft);
}

.settings-panel-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 8px 0 6px;
}
.deleted-m-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}
.deleted-m-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  text-align: left;
  width: 100%;
}
.deleted-m-item:hover { background: var(--hover); }
.deleted-m-item img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--border);
  flex-shrink: 0;
}
.deleted-m-item .m-info { flex: 1; min-width: 0; }
.deleted-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  color: #9a3412;
  background: #ffedd5;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 8px;
  vertical-align: middle;
}
.profile-info .deleted-badge { margin-left: 0; margin-top: 6px; }
.m-dir-item-wrap {
  display: flex;
  align-items: stretch;
  gap: 4px;
}
.m-dir-item-wrap .m-dir-item { flex: 1; min-width: 0; }
.m-dir-actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  gap: 4px;
  flex-shrink: 0;
  padding: 4px 0;
  min-width: 52px;
}

.m-dir-actions:empty {
  display: none;
}
.m-dir-item-wrap .m-dir-remove {
  flex-shrink: 0;
  align-self: center;
}

.profile-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.profile-name-row h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
}
.profile-edit-btn {
  flex-shrink: 0;
}

/* Desktop sidebar permanently visible */
@media (min-width: 860px) {
  .sidebar {
    position: sticky;
    transform: none !important;
    width: var(--sidebar-w);
    border-right: none;
    height: 100dvh;
  }

  /* Collapsed rail: icons only */
  body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-w);
    padding: 8px 6px 24px;
    align-items: center;
  }

  body.sidebar-collapsed .brand {
    justify-content: center;
    padding: 10px;
    margin-bottom: 4px;
  }

  body.sidebar-collapsed .brand-logo-full {
    display: none !important;
  }

  body.sidebar-collapsed .brand-logo-mark {
    display: block !important;
  }

  body.sidebar-collapsed .nav-label,
  body.sidebar-collapsed .sidebar-schedule {
    display: none !important;
  }

  body.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 12px;
    width: 48px;
    gap: 0;
  }

  body.sidebar-collapsed .sidebar-top {
    justify-content: center;
    width: 100%;
  }

  body.sidebar-collapsed .sidebar-top .brand {
    flex: none;
  }

  .drawer-backdrop { display: none !important; }
  .bottom-nav { display: none; }
  .main { padding-bottom: 32px; }
  .mobile-only { display: none !important; }
  .toast { bottom: 32px; }
  .panel { min-height: calc(100dvh - var(--topbar-h)); }
}

@media (min-width: 1100px) {
  .photo-view-body {
    flex-direction: row;
  }
  .photo-view-side {
    display: flex;
  }
  .photo-view-mobile-actions {
    display: none;
  }
  .photo-view-stage {
    flex: 1;
  }
}
