:root {
  --bg: linear-gradient(180deg, #08131f 0%, #111827 100%);
  --surface: rgba(20, 28, 42, 0.92);
  --surface-strong: rgba(9, 13, 24, 0.98);
  --surface-soft: rgba(67, 104, 179, 0.26);
  --surface-elevated: rgba(255, 255, 255, 0.06);
  --primary: #5f97ff;
  --primary-dark: #b8d4ff;
  --accent: #7dd4ff;
  --accent-dark: #4db4d9;
  --accent-soft: rgba(125, 212, 255, 0.16);
  --text: #f7f9ff;
  --text-muted: #9fb4d0;
  --border: rgba(255, 255, 255, 0.14);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.17);
  --radius: 20px;
  --radius-sm: 14px;
  --space: 1rem;
}

body[data-theme="dark"] {
  --bg: linear-gradient(180deg, #08131f 0%, #111827 100%);
  --surface: rgba(20, 28, 42, 0.92);
  --surface-strong: rgba(9, 13, 24, 0.98);
  --surface-soft: rgba(67, 104, 179, 0.26);
  --surface-elevated: rgba(255, 255, 255, 0.06);
  --primary: #5f97ff;
  --primary-dark: #b8d4ff;
  --accent: #7dd4ff;
  --accent-dark: #4db4d9;
  --accent-soft: rgba(125, 212, 255, 0.16);
  --text: #f7f9ff;
  --text-muted: #9fb4d0;
  --border: rgba(255, 255, 255, 0.14);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.17);
}

body[data-theme="light"] {
  --bg: linear-gradient(180deg, #f7f9fd 0%, #eff4fb 100%);
  --surface: rgba(255, 255, 255, 0.96);
  --surface-strong: rgba(255, 255, 255, 1);
  --surface-soft: rgba(223, 229, 242, 0.84);
  --surface-elevated: rgba(255, 255, 255, 0.92);
  --primary: #2d53ff;
  --primary-dark: #192e8a;
  --accent: #4b88ff;
  --accent-dark: #2f63b8;
  --accent-soft: rgba(75, 136, 255, 0.16);
  --text: #0f172a;
  --text-muted: #5f6f87;
  --border: rgba(15, 23, 42, 0.08);
  --shadow: 0 18px 42px rgba(15, 23, 42, 0.08);
}

body[data-theme="olive"] {
  --bg: linear-gradient(180deg, #f4f2ec 0%, #ece7da 100%);
  --surface: #ffffff;
  --surface-strong: #f7f3eb;
  --surface-soft: #f0eee7;
  --surface-elevated: #ffffff;
  --primary: #40513b;
  --primary-dark: #2f3a2b;
  --accent: #c3a05d;
  --accent-dark: #a57f3c;
  --accent-soft: rgba(195, 160, 93, 0.18);
  --text: #20251f;
  --text-muted: #70756d;
  --border: #e5e2da;
  --shadow: 0 18px 42px rgba(75, 60, 29, 0.1);
}

body[data-theme="blue"] {
  --bg: linear-gradient(180deg, #eef3f8 0%, #e1ebf5 100%);
  --surface: #ffffff;
  --surface-strong: #f3f7fb;
  --surface-soft: #edf2f7;
  --surface-elevated: #ffffff;
  --primary: #24527a;
  --primary-dark: #173a56;
  --accent: #7396b8;
  --accent-dark: #55779a;
  --accent-soft: rgba(115, 150, 184, 0.16);
  --text: #182331;
  --text-muted: #66788a;
  --border: #dce4ec;
  --shadow: 0 18px 42px rgba(28, 52, 73, 0.1);
}

body[data-theme="indigo"] {
  --bg: linear-gradient(180deg, #f5f5fa 0%, #ececf6 100%);
  --surface: #ffffff;
  --surface-strong: #f3f2f9;
  --surface-soft: #f1f1f7;
  --surface-elevated: #ffffff;
  --primary: #343b70;
  --primary-dark: #20264b;
  --accent: #c7a96b;
  --accent-dark: #a9874f;
  --accent-soft: rgba(199, 169, 107, 0.18);
  --text: #20233a;
  --text-muted: #777b95;
  --border: #e1e1ea;
  --shadow: 0 18px 42px rgba(41, 48, 92, 0.12);
}

body[data-theme="night"] {
  --bg: linear-gradient(180deg, #111713 0%, #18211a 100%);
  --surface: #192019;
  --surface-strong: #0f150f;
  --surface-soft: #202a20;
  --surface-elevated: rgba(255, 255, 255, 0.04);
  --primary: #5d7d52;
  --primary-dark: #91b07b;
  --accent: #c5a35a;
  --accent-dark: #a88431;
  --accent-soft: rgba(197, 163, 90, 0.16);
  --text: #f1f3ed;
  --text-muted: #9da69b;
  --border: #303a30;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.2);
}

body[data-theme="midnight"] {
  --bg: linear-gradient(180deg, #101820 0%, #17232e 100%);
  --surface: #17232e;
  --surface-strong: #11202a;
  --surface-soft: #1d2c38;
  --surface-elevated: rgba(255, 255, 255, 0.04);
  --primary: #3d7ea6;
  --primary-dark: #8aa9c4;
  --accent: #8aa9c4;
  --accent-dark: #5f89a9;
  --accent-soft: rgba(138, 169, 196, 0.16);
  --text: #edf2f7;
  --text-muted: #94a3b8;
  --border: #2b3b49;
  --shadow: 0 18px 42px rgba(3, 9, 20, 0.24);
}

body[data-theme="royalNight"] {
  --bg: #111222;
  --surface: #191b32;
  --surface-strong: #202341;
  --surface-soft: #202341;
  --surface-elevated: #202341;
  --primary: #5b62ad;
  --primary-dark: #d2b477;
  --accent: #d2b477;
  --accent-dark: #b58e4a;
  --accent-soft: rgba(210, 180, 119, 0.16);
  --text: #f3f3fa;
  --text-muted: #9da0bd;
  --border: #303351;
  --shadow: 0 18px 42px rgba(8, 10, 26, 0.24);
}

body[data-theme="pureDark"] {
  --bg: #0b0b0c;
  --surface: #141416;
  --surface-strong: #1c1c1f;
  --surface-soft: #1c1c1f;
  --surface-elevated: #1c1c1f;
  --primary: #6b7f68;
  --primary-dark: #b89b72;
  --accent: #b89b72;
  --accent-dark: #9c7a4f;
  --accent-soft: rgba(184, 155, 114, 0.16);
  --text: #f5f5f7;
  --text-muted: #98989f;
  --border: #2c2c2e;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  margin-bottom: 100px !important;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

img,
svg {
  max-width: 100%;
  display: block;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: none;
}

button,
a {
  transition: transform 0.18s ease, background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

/* Accessibility: clear focus indicator for keyboard users */
:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(75, 209, 190, 0.16);
  border-radius: 8px;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--primary-dark);
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-weight: 600;
  color: var(--accent);
}

.text-link::after {
  content: '↗';
  font-size: 0.9em;
  color: inherit;
}

.text-link:hover {
  color: var(--primary-dark);
}

body ::selection {
  background: rgba(194, 154, 70, 0.22);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface-strong);
  backdrop-filter: blur(18px);
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1rem;
}

/* Header layout helpers */
.container-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  justify-content: space-between;
  flex-wrap: wrap;
}

.header-controls {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  justify-content: flex-end;
  margin-left: auto;
}

.header-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text);
  text-decoration: none;
  min-height: 44px;
  box-shadow: none;
}

.header-link-btn:hover,
.header-link-btn:focus-visible {
  background: rgba(255, 255, 255, 0.16);
  outline: none;
}

.header-link-btn svg {
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
}

.header-link-label {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
}

.nav-list {
  list-style: none;
  display: flex;
  gap: 0.5rem;
  padding: 0;
  margin: 0;
  align-items: center;
  flex-wrap: wrap;
}

.nav-list a {
  padding: 0.52rem 0.9rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-weight: 600;
}

.nav-list a:hover,
.nav-list a:focus-visible {
  background: rgba(255, 255, 255, 0.16);
  outline: none;
}

/* Mobile-first: hide full nav and show toggle */
.nav-links {
  display: none;
}

.nav-links.nav-open {
  display: block;
}

.user-btn {
  display: inline-flex;
  gap: 0.65rem;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  cursor: pointer;
  color: var(--text);
  min-height: 44px;
  box-shadow: none;
}

.user-info.hidden {
  display: none;
}

.hidden {
  display: none;
}

.user-display {
  font-weight: 700;
  white-space: nowrap;
}

.user-avatar,
.avatar-fallback {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(255,255,255,0.18), rgba(255,255,255,0.08));
  overflow: hidden;
  display: grid;
  place-items: center;
  color: var(--text);
  font-weight: 700;
  font-size: 0.95rem;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.church-card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.church-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.6rem;
}

.church-card-header h3 {
  margin: 0;
}

.church-favorite-btn {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text-muted);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem 0.45rem;
  border-radius: 999px;
  transition: transform 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.church-favorite-btn:hover,
.church-favorite-btn:focus-visible {
  color: var(--accent);
  background: var(--surface-elevated);
  outline: none;
  transform: translateY(-1px);
}

.church-favorite-btn.active {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  background: color-mix(in srgb, var(--accent) 12%, var(--surface-soft));
}

.page-header-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.page-header-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.page-header-title h2 {
  margin: 0;
}

.church-profile-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.62rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  line-height: 1;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.church-profile-link:hover,
.church-profile-link:focus-visible {
  color: var(--accent);
  background: var(--surface-elevated);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  outline: none;
}

.church-profile-link svg {
  width: 0.95rem;
  height: 0.95rem;
  flex-shrink: 0;
}

.avatar-fallback {
  color: var(--text);
}

.avatar-fallback svg {
  width: 100%;
  height: 100%;
  display: block;
}

.avatar-initials-text {
  font-size: 0.95rem;
  font-weight: 700;
  fill: currentColor;
}

@media (min-width: 860px) {
  .nav-links { display: block !important; }
  .nav-toggle { display: none; }
}

@media (max-width: 860px) {
  .site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 0.25rem 0.65rem;
    z-index: 1100;
    border-bottom-width: 1px;
  }

  .container {
    margin: 5rem auto 2rem !important;
    width: 100%;
    padding: 0 0.75rem;
  }

  .container-row {
    align-items: center;
  }
  .header-controls {
    justify-content: flex-end;
    width: auto;
    margin-top: 0;
    gap: 0.35rem;
    align-items: center;
    margin-left: auto;
  }
  .nav-toggle {
    display: none !important;
  }
  .nav-links {
    display: flex !important;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0;
    padding: 0;
    border-radius: 0;
    background: transparent;
    border: none;
  }
  .nav-list {
    flex-direction: row;
    gap: 0.35rem;
    flex-wrap: wrap;
  }
  .nav-list a,
  .header-link-btn,
  .theme-toggle-btn,
  .user-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 0.35rem 0.55rem;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.16);
    background: rgba(255,255,255,0.08);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
  }
  .nav-list a {
    padding: 0.35rem 0.55rem;
  }
  .nav-list a:hover,
  .header-link-btn:hover,
  .theme-toggle-btn:hover,
  .user-btn:hover {
    background: rgba(255,255,255,0.14);
  }
  .user-info {
    padding: 0;
    gap: 0.35rem;
    background: transparent;
    border: none;
  }
  .user-btn {
    padding: 0.35rem;
    gap: 0;
    min-width: 44px;
    min-height: 44px;
    border-radius: 999px;
  }
  .user-avatar,
  .avatar-fallback {
    width: 34px;
    height: 34px;
    min-width: 34px;
  }
  .user-display,
  .header-link-label {
    display: none;
  }
  .header-link-btn {
    padding: 0.45rem;
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
  }
  .brand-note {
    display: none;
  }
  .modal-actions,
  .note-toolbar {
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
  }
  .modal-actions .btn,
  .modal-actions .btn-accent,
  .modal-actions .btn-secondary,
  .modal-actions .btn-sm,
  .note-toolbar button,
  .mode-toggle button {
    min-width: auto;
    padding: 0.5rem 0.75rem;
    font-size: 0.88rem;
  }
  .note-toolbar button,
  .modal-actions .btn,
  .modal-actions .btn-accent,
  .modal-actions .btn-secondary {
    white-space: nowrap;
  }
}

.header-brand {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.brand {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--accent);
}

.brand-note {
  font-size: 0.92rem;
  color: var(--text-muted);
}

.nav-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: rgba(35, 61, 98, 0.08);
  border: 1px solid rgba(35, 61, 98, 0.12);
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--primary-dark);
  border-radius: 999px;
}

.theme-toggle-btn {
  min-width: 44px;
  min-height: 44px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.08);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.theme-toggle-btn:hover {
  background: rgba(255,255,255,0.14);
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.nav-links a,
.user-info a {
  color: var(--text);
  text-decoration: none;
  padding: 0.7rem 1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.95rem;
}

.nav-links a:hover {
  background: rgba(255, 255, 255, 0.12);
}

.user-info,
.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.9rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--text);
}

.user-info {
  justify-content: center;
  background: transparent;
  border: none;
  padding: 0;
  gap: 0;
}

.user-avatar {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 50%;
  background: rgba(35, 61, 98, 0.14);
  overflow: hidden;
  display: grid;
  place-items: center;
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 0.95rem;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.container {
  width: min(1160px, 100% - 2rem);
  margin: 1.8rem auto 2rem;
  padding: 0 1rem;
}

.hero {
  background: var(--surface);
  border: 1px solid rgba(35, 61, 98, 0.08);
  border-radius: 24px;
  padding: clamp(2rem, 4vw, 3rem) 2rem;
}

.hero h2 {
  font-size: clamp(2rem, 4vw, 2.8rem);
  margin-bottom: 1rem;
  color: var(--primary-dark);
  letter-spacing: -0.02em;
}

.hero p {
  max-width: 720px;
  margin: 0 auto 1.5rem;
  color: var(--text-muted);
  font-size: 1.05rem;
}

.hero .btn + .btn {
  margin-left: 0.75rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
/* add consistent vertical spacing between cards */
.card { margin-bottom: 1rem; }

.theme-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-top: 0.85rem;
}

.theme-option {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  align-items: flex-start;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  border-radius: 16px;
  padding: 0.8rem;
  cursor: pointer;
  text-align: left;
}

.theme-option.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--accent-soft);
  background: var(--surface-elevated);
}

.theme-swatch {
  width: 100%;
  height: 0.55rem;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
}

.theme-option__label {
  font-weight: 700;
  font-size: 0.95rem;
}

.theme-option__hint {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.settings-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.settings-sidebar {
  display: grid;
  gap: 0.75rem;
}

.settings-sidebar__card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.settings-nav {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.settings-nav__item {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  text-align: left;
  cursor: pointer;
}

.settings-nav__item.active {
  background: var(--accent-soft);
  color: var(--text);
  border-color: transparent;
}

.sticky-save {
  position: fixed;
  bottom: 1rem;
  z-index: 95;
}

.settings-save-btn {
  width: 100%;
  justify-content: center;
  margin-top: 0.7rem;
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.settings-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.settings-header-actions .meta {
  margin: 0;
}

.settings-save-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  min-width: 150px;
  padding: 0 1rem;
  height: 48px;
  border-radius: 28px;
  box-shadow: 0 10px 24px rgba(35, 61, 98, 0.22);
  z-index: 1100;
  display: none;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.settings-save-fab.visible {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

.settings-save-fab.hidden {
  display: none;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
}

@media (max-width: 860px) {
  .settings-save-fab {
    right: 16px;
    bottom: 16px;
    min-width: 140px;
  }
}

.settings-card {
  padding: 1.25rem;
}

.settings-section__head {
  margin-bottom: 0.85rem;
}

.settings-section__head h4 {
  margin: 0 0 0.25rem;
  color: var(--primary-dark);
}

.settings-section__head p {
  margin: 0;
  color: var(--text-muted);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  align-items: start;
}

.settings-grid .form-group {
  margin-bottom: 0;
}

.settings-grid .full-width {
  grid-column: 1 / -1;
}

.upload-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.checkbox-label input {
  width: auto;
}

.public-link {
  margin-top: 0.6rem;
  font-weight: 600;
}

.bot-posts-preview {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
}

.bot-posts-preview__head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.bot-post-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.page-header,
.section-header,
.card-header-row,
.settings-sidebar__card,
.settings-section,
.stream-card,
.note-card,
.event-card,
.calendar-event-card {
  margin-bottom: 1rem;
}

.card h3 {
  margin-bottom: 0.75rem;
  color: var(--text);
}

.card .meta,
.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.9rem;
}

.form-box {
  max-width: 460px;
  margin: 1.8rem auto;
  background: var(--surface);
  border: 1px solid rgba(35, 61, 98, 0.08);
  border-radius: 22px;
  padding: 1.8rem;
  box-shadow: var(--shadow);
}

.form-box h2 {
  text-align: center;
  margin-bottom: 1.2rem;
  color: var(--primary-dark);
}

.form-group {
  margin-bottom: 0.9rem;
}

label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--text-muted);
  font-size: 0.94rem;
}

input,
textarea,
select {
  width: 100%;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  background: rgba(255,255,255,0.06);
  color: var(--text);
}

select option,
select optgroup {
  background: var(--surface);
  color: var(--text);
  border: none;
}

select {
  appearance: none;
}

textarea {
  resize: vertical;
  min-height: 120px;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(75, 209, 190, 0.45);
  box-shadow: 0 0 0 4px rgba(75, 209, 190, 0.14);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  padding: 0.75rem 1.35rem;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 700;
  min-width: auto;
  box-shadow: 0 14px 28px rgba(35, 61, 98, 0.12);
}

.btn:hover {
  background: var(--primary-dark);
}

.btn-accent {
  background: var(--accent);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.btn-accent:hover {
  background: var(--accent-dark);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.10);
  color: var(--text);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.16);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 0.55rem 0.95rem;
  font-size: 0.92rem;
  min-width: auto;
}

.hidden {
  display: none;
}

.form-inline-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

.stacked-grid {
  display: grid;
  gap: 0.75rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-top: 1.5rem;
}

.hero-actions .btn {
  min-width: 140px;
}

.landing-grid {
  margin-top: 3rem;
}

.form-footer {
  text-align: center;
  margin-top: 1rem;
  color: var(--text-muted);
}

.page-heading {
  margin-bottom: 0.5rem;
  color: var(--primary-dark);
}

.form-hint {
  margin-top: 0.25rem;
}

.checkbox-grid {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.full-width {
  grid-column: 1 / -1;
}

.card-row,
.action-row,
.group-header-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.group-members {
  margin-top: 0.8rem;
}

.member-badge {
  display: inline-flex;
  align-items: center;
  color: var(--success);
  font-weight: 700;
}

.member-status {
  margin-top: 0.5rem;
}

.compact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: -0.45rem;
  margin-bottom: 0.45rem;
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.stretch-select {
  flex: 1;
  min-width: 150px;
}

.pre-wrap {
  white-space: pre-wrap;
}

.section-title {
  margin-bottom: 1.5rem;
  color: var(--primary-dark);
}

.section-actions {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.profile-card {
  margin-bottom: 1.5rem;
  padding: 1.4rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.profile-panel {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  align-items: center;
}

.dashboard-actions-card {
  padding: 1.35rem;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.08);
  background: var(--surface);
}

.dashboard-actions-head h3 {
  margin: 0;
  font-size: 1.05rem;
}

.dashboard-actions-head .meta {
  margin: 0.55rem 0 0;
  color: var(--text-muted);
}

.dashboard-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@media (min-width: 860px) {
  .dashboard-grid {
    grid-template-columns: minmax(260px, 320px) 1fr;
    align-items: start;
  }
}

.profile-avatar-wrapper {
  display: grid;
  gap: 0.75rem;
  align-items: center;
}

.profile-avatar {
  width: 94px;
  height: 94px;
  min-width: 94px;
  border-radius: 22px;
  background: rgba(255,255,255,0.08);
  display: grid;
  place-items: center;
  overflow: hidden;
  font-size: 2rem;
  color: var(--text);
}

.avatar-upload {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.14);
}

.profile-details h3 {
  margin: 0;
  font-size: 1.15rem;
}

.profile-note {
  margin: 0.75rem 0 0;
  color: var(--text-muted);
  font-size: 0.93rem;
}

.profile-progress {
  margin-top: 0.85rem;
}

.progress-track {
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.3s ease;
}

.card-hidden {
  display: none;
}

.card-hidden[aria-hidden="false"] {
  display: block;
}

.profile-avatar-wrapper {
  flex-shrink: 0;
  position: relative;
}

.profile-details {
  flex: 1;
}

.profile-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: #e0e0e0;
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
  font-size: 2.5rem;
  color: #666;
  font-weight: 700;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar-upload {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  border: 2px solid #fff;
}

.profile-note {
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

.profile-progress {
  margin-top: 1rem;
}

.progress-track {
  height: 4px;
  background: #e0e0e0;
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.3s;
}

.card-hidden {
  display: none;
}

.public-card {
  max-width: 760px;
  margin: auto;
  padding: 1.5rem;
}

.public-hero {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
}

.public-info {
  flex: 1 1 320px;
  min-width: 260px;
}

.public-photo {
  width: 180px;
  flex: 0 0 180px;
  border-radius: 22px;
  overflow: hidden;
  background: rgba(255,255,255,0.08);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.04);
}

.public-meta {
  margin-top: 1.5rem;
}

.public-meta-item {
  margin-bottom: 1rem;
}

.public-meta-item .meta {
  margin: 0.25rem 0 0;
}

.public-markdown {
  margin-top: 0.5rem;
}

.note-composer-header {
  padding: 0 0 12px 0;
  border-bottom: 1px solid rgba(35, 61, 98, 0.12);
  margin-bottom: 12px;
  background: transparent;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.draft-status {
  /* margin-bottom: 12px; */
  min-height: 1.2em;
}

.note-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px,1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.mode-toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.mode-toggle button {
  min-height: 42px;
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 0.75rem 0.95rem;
  background: #fff;
  color: var(--primary-dark);
}

.mode-toggle button.active {
  background: var(--accent-soft);
}

.toolbar.note-toolbar {
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.editor-area.note-editor-area {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 12px;
  min-height: 420px;
}

.note-actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.preview {
  padding: 1rem;
  line-height: 1.5;
}

/* Fix: when `preview` class is used on toolbar buttons (EasyMDE),
   don't apply the large preview padding — keep toolbar compact */
.EasyMDEContainer .editor-toolbar .preview,
.EasyMDEContainer .editor-toolbar button.preview {
  padding: 0 !important;
  height: 34px !important;
  width: 34px !important;
  min-width: 34px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.compact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.7rem;
}

#bibleFinder {
  display: grid;
  gap: 0.6rem;
  padding: 0.9rem;
  margin-top: 0.7rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
}

.bible-block {
  margin: 0.8rem 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.bible-summary {
  width: 100%;
  border: none;
  background: transparent;
  padding: 0.8rem 0.95rem;
  text-align: left;
  font-weight: 700;
  color: var(--primary-dark);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.bible-summary::after {
  content: '▾';
  color: var(--text-muted);
}

.bible-block:not(.open) .bible-body {
  display: none;
}

.bible-block.open .bible-summary::after {
  content: '▴';
}

.bible-body {
  padding: 0 0.95rem 0.95rem;
  display: grid;
  gap: 0.45rem;
}

.btn-danger {
  background: #c64f50;
  color: #fff;
}

.btn-danger:hover {
  background: #a83f40;
}

.toast-alert {
  position: relative;
  margin-bottom: 0.75rem;
  opacity: 0;
  transform: translateY(-20px);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  border-radius: 16px;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.toast-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

.toast-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0 8px;
  color: inherit;
  opacity: 0.7;
}

.toast-close:hover {
  opacity: 1;
}

.alert {
  border-radius: 16px;
  padding: 1rem 1.25rem;
  box-shadow: 0 16px 34px rgba(35, 61, 98, 0.08);
}

.error-page {
  min-height: calc(100vh - 7rem);
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.error-card {
  width: min(560px, 100%);
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 1.75rem;
  box-shadow: var(--shadow);
  text-align: center;
}

.error-code {
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.04em;
}

.error-title {
  margin: 0.5rem 0 1rem;
  font-size: clamp(1.5rem, 2.2vw, 2rem);
  color: var(--primary-dark);
}

.error-text {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.7;
  margin-bottom: 1.2rem;
}

.error-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.section-header h3 {
  margin: 0;
  color: var(--primary-dark);
}

.section-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.tabs {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  align-items: center;
  justify-content: space-between;
}

.tab {
  flex: 1 1 0;
  min-width: 0;
  padding: 0.72rem 0.95rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-weight: 600;
  transition: transform 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}

.tab:hover,
.tab:focus-visible {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.14);
}

.tab.active {
  background: var(--accent-soft);
  color: var(--text);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
}

.section-actions {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.tab-content {
  display: none;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.24s ease, transform 0.24s ease;
}

.tab-content.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

.tab-content .card,
.tab-content .settings-section,
.tab-content .details,
.tab-content .search-box,
.tab-content .chat-box,
.tab-content .iframe-container {
  background: var(--surface);
}

.chat-log {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.92);
  min-height: 300px;
  max-height: 420px;
  overflow-y: auto;
}

.chat-input-row {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.85rem;
  align-items: center;
}

.chat-input-row input,
.chat-input-row textarea {
  flex: 1;
  min-width: 0;
}

.chat-input {
  width: 100%;
}

pre,
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  background: rgba(35, 61, 98, 0.05);
  border-radius: 12px;
}

pre {
  padding: 1rem;
  overflow: auto;
}

code {
  padding: 0.2rem 0.35rem;
}

details {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  padding: 0.9rem 1rem;
}

summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--primary-dark);
}

.details-body {
  margin-top: 0.75rem;
}

.invite-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 0.9rem;
  border-radius: 999px;
  border: 1px dashed rgba(194, 154, 70, 0.5);
  background: rgba(194, 154, 70, 0.12);
  color: var(--primary-dark);
  font-family: monospace;
  font-size: 0.95rem;
}

.note-editor {
  display: grid;
  gap: 1rem;
}

.note-toolbar button,
.mode-toggle button {
  min-height: 44px;
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 0.75rem 0.9rem;
  background: #fff;
  color: var(--primary-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.note-toolbar button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.note-toolbar button span {
  font-size: 0.92rem;
}

.note-editor-area {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  min-height: 360px;
}

.note-pane {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.pane-header {
  padding: 0.95rem 1rem;
  background: rgba(238, 244, 251, 0.9);
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  color: var(--primary-dark);
}

#noteContentRich,
.preview,
.modal-preview {
  padding: 1rem;
  /* min-height: 320px; */
  background: var(--surface);
  font-size: 1rem;
  line-height: 1.65;
}

.note-card {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  padding: 1rem;
  margin-bottom: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.note-meta {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.note-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.6rem;
  background: rgba(194, 154, 70, 0.18);
  color: var(--primary-dark);
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.modal {
  display: none;
  animation: fadeIn 0.2s ease;
  z-index: 99999;
  position: fixed;
  inset: 0;
  background: rgba(23, 42, 68, 0.68);
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal.show {
  display: flex;
}

body.modal-open {
  overflow: hidden;
  touch-action: none;
}

.modal .modal-dialog {
  width: min(820px, 100%);
  max-height: calc(100vh - 3rem);
  overflow: hidden;
  background: var(--surface-strong);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
}

.modal .modal-body {
  padding: 1.35rem 1.5rem 1.1rem;
  overflow-y: auto;
  max-height: calc(100vh - 13rem);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: -20px;
  padding: 1rem;
}

.modal-header > * {
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #5f6e8b;
}

.modal-close:hover {
  color: var(--primary-dark);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: flex-end;
  align-items: center;
  padding: 0.8rem 1rem calc(0.8rem + env(safe-area-inset-bottom, 0px));
  margin-top: auto;
  position: sticky;
  bottom: 0;
  background: var(--surface-strong);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 10;
  backdrop-filter: blur(8px);
}

.modal .modal-dialog {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 2rem);
  overflow: hidden;
}

.modal .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-elevated);
  color: var(--text);
}

/* hide elements marked hidden explicitly */
.tab.hidden { display: none !important; }

/* Tabs: fixed bottom navigation visible from any scroll position */
.tabs {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  backdrop-filter: blur(6px);
}
.tabs.bottom-nav {
  position: fixed;
  bottom: 0.8rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  width: min(920px, calc(100% - 1.5rem));
  max-width: 920px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 24px;
  justify-content: center;
  padding: 0.65rem 0.8rem;
  box-shadow: var(--shadow);
}
.tabs.bottom-nav,
.tabs.bottom-nav .tab {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none; /* iOS */
}

.tabs.bottom-nav .tab {
  flex: 0 1 auto;
  min-width: auto;
  font-size: 0.96rem;
  padding: 0.72rem 0.95rem;
  background: var(--surface-soft);
  color: var(--text);
}

.tabs.bottom-nav .tab:hover,
.tabs.bottom-nav .tab:focus-visible {
  background: var(--surface-elevated);
}

.tabs.bottom-nav .tab.active {
  background: var(--accent-soft);
  color: var(--text);
}

.tabs.bottom-nav .tab span {
  display: inline;
}

@media (max-width: 900px) {
  body { padding-bottom: 92px; }
}

.notes-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: rgba(255,255,255,0.10);
  color: var(--text);
  text-decoration: none;
  font-size: 1.1rem;
}

.notes-icon-btn:hover {
  background: rgba(255,255,255,0.18);
}

/* reduce modal padding for a tighter modal look */
.modal .modal-body {
  padding: 10px;
  overflow-y: auto;
  max-height: calc(100vh - 8rem);
}

/* make note cards visually separated on small screens */
.note-card { margin-bottom: 0.9rem; }

/* ensure no horizontal scroll caused by large elements */
html, body { overflow-x: hidden; }

.note-preview-snippet ul,
.note-preview-snippet ol,
#noteContentRich ul,
#noteContentRich ol,
.preview ul,
.preview ol,
.modal-preview ul,
.modal-preview ol {
  margin: 0 0 0.75rem 1.25rem;
  padding-left: 1.25rem;
}

.note-table,
.note-preview-snippet table,
#noteContentRich table,
.preview table,
.modal-preview table {
  border-collapse: collapse;
  width: 100%;
  margin: 1rem 0;
}

.note-table th,
.note-table td,
.note-preview-snippet th,
.note-preview-snippet td,
#noteContentRich th,
#noteContentRich td,
.preview th,
.preview td,
.modal-preview th,
.modal-preview td {
  border: 1px solid rgba(194, 154, 70, 0.24);
  padding: 0.6rem 0.75rem;
  min-width: 120px;
  vertical-align: top;
}

.note-preview-snippet table,
#noteContentRich table,
.preview table,
.modal-preview table {
  background: #fff;
}

#noteContentRich td[contenteditable="true"]:focus,
.preview td[contenteditable="true"]:focus,
.modal-preview td[contenteditable="true"]:focus {
  outline: 2px solid var(--accent);
  background: #fff7e6;
}

.search-box {
  position: relative;
  margin-bottom: 1rem;
}

.search-box input {
  width: 100%;
  padding-left: 2.5rem;
  border-radius: 16px;
}

.search-box::before {
  content: "🔍";
  position: absolute;
  left: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

.fab {
  position: fixed;
  right: 22px;
  bottom: 90px;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(35, 61, 98, 0.22);
  z-index: 900;
}

.fab:hover {
  transform: scale(1.06);
  box-shadow: 0 14px 30px rgba(35, 61, 98, 0.28);
}

.fab:active {
  transform: scale(0.96);
}

.stream-card {
  display: grid;
  gap: 1rem;
  padding: 1rem;
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
}

.stream-meta {
  display: grid;
  gap: 1rem;
  align-items: start;
  grid-template-columns: minmax(220px, 260px) 1fr;
}

.stream-thumb,
.iframe-container iframe,
.stream-player iframe {
  width: 100%;
  border-radius: 18px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.stream-thumb {
  max-height: 190px;
  object-fit: cover;
}

.stream-info {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.stream-info-title {
  font-size: 1.03rem;
  font-weight: 700;
  color: var(--text);
}

.stream-info-title {
  font-size: 1.05rem;
  font-weight: 600;
}

.stream-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.stream-player {
  margin-top: 0.75rem;
  border-top: 1px solid rgba(35, 61, 98, 0.1);
  padding-top: 1rem;
}

.event-section {
  margin-bottom: 1.25rem;
}

event-section h4 {
  color: var(--primary-dark);
  border-bottom: 2px solid var(--accent-soft);
  padding-bottom: 0.3rem;
  margin-bottom: 0.75rem;
  font-size: 1.05rem;
}

.event-card,
.calendar-event-card,
.card.event-card {
  margin-bottom: 1rem;
}

.tag {
  display: inline-block;
  background: rgba(194, 154, 70, 0.16);
  color: var(--primary-dark);
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  font-size: 0.85rem;
  margin-right: 0.25rem;
  margin-top: 0.2rem;
}

.calendar-header {
  margin-bottom: 1rem;
}

.calendar-grid {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-day-name {
  font-weight: 700;
  color: var(--primary-dark);
  text-align: center;
}

.calendar-cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  min-height: 110px;
  padding: 0.8rem;
}

.calendar-cell.empty {
  background: transparent;
  border: none;
}

.calendar-cell-header {
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.calendar-event-card {
  background: rgba(255,255,255,0.05);
  border-radius: 16px;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.4rem;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.calendar-event-card:hover {
  background: rgba(255,255,255,0.10);
}

#alert {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100000;
  width: 100%;
  max-width: 520px;
  padding: 0 15px;
  pointer-events: none;
}

#alert > .alert {
  pointer-events: auto;
  margin-bottom: 12px;
  box-shadow: 0 15px 35px rgba(35, 61, 98, 0.18);
}

.alert-success {
  background: #eaf4eb;
  color: #1f4a34;
  border: 1px solid #b9dbbf;
}

.alert-error {
  background: #fbeaea;
  color: #9e2e2c;
  border: 1px solid #f3c7c5;
}

.alert-warning {
  background: #fff6e5;
  color: #8d5f22;
  border: 1px solid #ffe4b4;
}

.alert-info {
  background: #e8f1ff;
  color: #1c4a86;
  border: 1px solid #c8d9f4;
}

@media (max-width: 980px) {
  .note-editor-area {
    grid-template-columns: 1fr;
  }

  .preview,
  #noteContentRich {
    min-height: 300px;
  }

  .settings-shell {
    grid-template-columns: 1fr;
  }

  .settings-sidebar {
    order: 2;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .modal {
    padding: 0;
  }

  .modal .modal-dialog {
    width: 100%;
    max-height: 100vh;
    border-radius: 0;
    margin: 0;
  }

  .modal .modal-body {
    max-height: calc(100vh - 8rem);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

@media (max-width: 760px) {
  .site-header {
    flex-wrap: wrap;
    align-items: stretch;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .nav-links {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
  }

  .nav-links.nav-open {
    max-height: 420px;
  }

  .nav-links a,
  .user-info {
    width: 100%;
  }

  .container {
    margin: 6rem auto 2rem !important;
    width: 100%;
  }

  .hero {
    padding: 1.75rem 1rem;
  }

  .hero h2 {
    font-size: 2rem;
  }

  .hero p,
  .card .meta,
  .error-text {
    font-size: 0.98rem;
  }

  .grid {
    gap: 0.9rem;
  }

  .form-box {
    padding: 1.4rem;
  }

  .section-header {
    flex-direction: column;
    align-items: stretch;
  }

  .section-actions {
    justify-content: stretch;
  }

  .stream-card {
    padding: 0.85rem;
  }

  .stream-meta {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .stream-thumb {
    max-height: 160px;
  }

  .stream-info {
    gap: 0.65rem;
  }

  .stream-info-title {
    font-size: 1rem;
  }

  .stream-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .form-box,
  .card,
  .error-card {
    border-radius: 20px;
  }

  .modal-actions {
    flex-wrap: nowrap;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.7rem 0.8rem calc(0.7rem + env(safe-area-inset-bottom, 0px));
    margin: 0 -0.25rem 0;
  }

  .modal-actions .btn,
  .modal-actions .btn-accent,
  .modal-actions .btn-secondary,
  .modal-actions .btn-sm {
    flex: 1 1 0;
    min-width: 0;
  }

  .header-brand {
    min-width: 0;
  }

  .header-link-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 0.8rem;
    border-radius: 999px;
    background: rgba(255,255,255,0.1);
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
  }

  /* mobile: simplify header to save vertical space */
  .brand-note { display: none; }

  .stream-card {
    padding: 0.85rem;
  }

  .stream-card h3 {
    font-size: 1rem;
    /* margin-bottom: 0.45rem; */
  }

  .stream-meta {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .stream-thumb {
    max-height: 140px;
  }

  .stream-info {
    gap: 0.5rem;
  }

  .stream-actions {
    flex-wrap: wrap;
    gap: 0.45rem;
  }

  .stream-actions .btn {
    flex: 1 1 48%;
    min-width: 0;
  }

  .stream-player .iframe-container {
    max-height: 220px;
  }

  .btn,
  .btn-accent,
  .btn-secondary {
    justify-content: center;
  }

  .modal-actions .btn,
  .modal-actions .btn-accent,
  .modal-actions .btn-secondary,
  .modal-actions .btn-sm,
  .toolbar-shell .btn,
  .toolbar-shell .btn-sm,
  .note-toolbar button,
  .mode-toggle button {
    width: auto;
    min-width: auto;
    padding: 0.5rem 0.75rem;
    font-size: 0.88rem;
  }

  .toolbar-shell .compact-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
  }

  .note-toolbar button,
  .mode-toggle button {
    width: auto;
  }

  .note-actions {
    flex-direction: column;
  }

  .stream-card {
    padding: 0.85rem;
  }

  .stream-card h3 {
    font-size: 1rem;
    /* margin-bottom: 0.5rem; */
  }

  .stream-meta {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .stream-thumb {
    max-height: 150px;
  }

  .stream-info {
    gap: 0.5rem;
  }

  .stream-info-title {
    font-size: 1rem;
  }

  .stream-actions {
    justify-content: flex-start;
  }

  .stream-player .iframe-container {
    max-height: 220px;
  }
}

@media (max-width: 480px) {
  .tabs.bottom-nav {
    margin: 0;
    padding: 0.85rem 0.9rem;
    gap: 0.4rem;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.18);
  }

  .tabs.bottom-nav .tab {
    min-width: 0;
    padding: 0.85rem 0.9rem;
    font-size: 0.88rem;
    justify-content: center;
  }

  .tabs.bottom-nav .tab span {
    display: none;
  }
}

@media (min-width: 900px) {
  .tabs.bottom-nav {
    position: fixed;
    top: auto;
    margin: 0 auto 1rem;
    max-width: min(920px, calc(100% - 3rem));
    justify-content: center;
    border: 1px solid var(--border);
    padding: 10px 16px;
    box-shadow: var(--shadow);
    border-radius: 24px;
    background: var(--surface-strong);
  }

  .tabs.bottom-nav .tab {
    flex: 0 1 auto;
    font-size: 0.96rem;
    padding: 0.75rem 0.95rem;
    min-width: auto;
  }

  .tabs.bottom-nav .tab span {
    display: inline;
  }
}

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

@media (max-width: 480px) {
  .site-header { padding: 0.6rem 0.8rem; }
  .brand { font-size: 1.05rem; }
  .brand-note { display: none; }
  .user-avatar { width: 34px; height: 34px; min-width:34px; }
}