/* ===============================================
   StuddyBuddy — Full CSS Overhaul
   Strategy: browser-first (wide → narrow via media queries).
   Typography: latin-ext subset, word-break, overflow-wrap
               for correct Latvian text rendering.
   =============================================== */

/* ─── Design tokens ─────────────────────────────── */
:root {
  /* colours */
  --surface:         #ffffff;
  --bg:              #f2f5fb;
  --text:            #0b1220;
  --muted:           #546172;
  --border:          rgba(15, 23, 42, 0.11);
  --surface-soft:    #fbfcff;
  --surface-strong:  #f4f7fd;

  --brand-500:       #2563eb;
  --brand-600:       #1f4fcf;

  --accent-100:      rgba(37, 99, 235, 0.06);
  --accent-200:      rgba(37, 99, 235, 0.12);

  --danger:          #dc2626;
  --danger-light:    rgba(220, 38, 38, 0.08);

  --success:         #16a34a;
  --success-light:   rgba(22, 163, 74, 0.08);

  /* radii */
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;
  --radius-xl:  22px;

  /* shadows */
  --shadow-sm:  0 2px 10px rgba(15, 23, 42, 0.05);
  --shadow-md:  0 10px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg:  0 16px 36px rgba(15, 23, 42, 0.11);
  --shadow-nav: 0 8px 40px rgba(11, 18, 32, 0.14);

  /* layout */
  --container:  1200px;
  --header-h:   72px;
  --transition: 180ms ease-in-out;
}

/* ─── Reset & box-sizing ────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    'Inter',
    'Roboto',
    'Helvetica Neue',
    Arial,
    sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ─── Latvian-typography safety ─────────────────── */
/* Latvian has geminate letters (ā,ē,ī,ū,ģ,ķ,ļ,ņ,š,ž) that can
   behave differently than single Latin characters in some browsers.
   The rules below prevent overflow / visual glitches. */
/* latin-ext is in Google Fonts URL; these rules enforce it at render time */
*,
*::before,
*::after {
  word-break: break-word;
  overflow-wrap: anywhere;
  hyphens: auto;
  -webkit-hyphens: auto;
  -ms-hyphens: auto;
}

h1, h2, h3, h4, h5, h6 {
  word-break: break-word;
  overflow-wrap: break-word;
}

/* ─── Shared reset on form controls ─────────────── */
button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}

button { cursor: pointer; }

textarea { resize: vertical; }

a { color: inherit; text-decoration: none; }

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

ul, ol { list-style: none; padding: 0; margin: 0; }
figure { margin: 0; }

/* ─── Screen-reader only ─────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ─── Hidden ─────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Layout helpers ─────────────────────────────── */
.muted    { color: var(--muted); }
.mt-sm    { margin-top: 12px; }
.mt-md    { margin-top: 20px; }
.mt-lg    { margin-top: 32px; }
.mb-sm    { margin-bottom: 12px; }
.mb-md    { margin-bottom: 20px; }
.mb-lg    { margin-bottom: 32px; }

/* ─── Container ─────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: 36px;
}

/* ─── Header ────────────────────────────────────── */
.site-header {
  background: linear-gradient(180deg, #ffffff 0%, #eef4ff 100%);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(8px);
}

.header-grid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: var(--header-h);
}

/* ── Brand ── */
.site-header .brand {
  font-weight: 800;
  font-size: 1.35rem;
  color: var(--brand-600);
  text-decoration: none;
  letter-spacing: -0.01em;
  line-height: 1;
  white-space: nowrap;
  transition: color var(--transition);
}
.site-header .brand:hover { color: var(--brand-500); }

.brand-tag {
  margin: 4px 0 0;
  font-size: 0.80rem;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Header actions (nav + controls shared wrapper) ── */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
}

.header-right {
  /* theme + language buttons cluster */
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
}

/* ── Primary nav ── */
.primary-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.primary-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  transition:
    color   var(--transition),
    background var(--transition);
  position: relative;
}

.primary-nav a:hover,
.primary-nav a:focus-visible {
  color: var(--brand-600);
  background: var(--accent-100);
}

.primary-nav a:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-200);
}

/* Active nav state */
.primary-nav a.active {
  color: var(--brand-600);
  font-weight: 700;
  background: var(--accent-100);
}

.primary-nav a#logoutBtn {
  color: #b45353;
  background: rgba(180, 83, 83, 0.08);
}

.primary-nav a#logoutBtn:hover,
.primary-nav a#logoutBtn:focus-visible {
  color: #991b1b;
  background: rgba(220, 38, 38, 0.14);
}

.primary-nav a#logoutBtn:focus-visible {
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.24);
}

/* ── navGroups fix: explicit ID rule, always styled via anchor classes ── */
#navGroups {
  display: inline-flex !important;
  align-items: center;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
}
#navGroups.active {
  color:  var(--brand-600);
  background: var(--accent-100);
  font-weight: 700;
}

/* ── Theme toggle ── */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font-size: 1.1rem;
  transition:
    box-shadow var(--transition),
    transform   120ms ease;
}
.theme-toggle:hover   { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.theme-toggle:active  { transform: translateY(0);   box-shadow: var(--shadow-sm); }

/* ── Language switcher ── */
.language-switcher {
  display: flex;
  gap: 4px;
}
.lang-btn {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition:
    background var(--transition),
    color      var(--transition),
    border-color var(--transition);
  cursor: pointer;
  line-height: 1;
  letter-spacing: 0.02em;
}
.lang-btn:hover   { border-color: var(--brand-500); }
.lang-btn.active  { background: var(--brand-500); color: #fff; border-color: var(--brand-500); }
.lang-btn:focus-visible { box-shadow: 0 0 0 3px var(--accent-200); }

/* ── Hamburger / Mobile nav toggle ── */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font-size: 1.2rem;
  transition: background var(--transition);
}
.nav-toggle:hover { background: var(--accent-100); }

/* Backdrop shown when nav panel is open (mobile) */
.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11, 18, 32, 0.35);
  z-index: 39;
  backdrop-filter: blur(2px);
}

/* ─────────────────────────────────────────────────────────
   COMPONENTS
   ───────────────────────────────────────────────────────── */

/* ── Button ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: var(--radius-md);
  background: var(--brand-500);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.92rem;
  line-height: 1.2;
  border: 2px solid transparent;
  cursor: pointer;
  transition:
    background  var(--transition),
    transform   120ms ease,
    box-shadow  var(--transition);
  white-space: nowrap;
  text-decoration: none;
  min-height: 44px;
}
.btn:hover   { background: var(--brand-600); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn:active  { background: var(--brand-600); transform: translateY(0);   box-shadow: var(--shadow-sm); }
.btn:focus-visible { box-shadow: 0 0 0 3px var(--accent-200); }

.btn.ghost {
  background: transparent;
  color: var(--brand-500);
  border: 2px solid var(--brand-500);
}
.btn.ghost:hover { background: var(--accent-100); box-shadow: none; }

.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b91c1c; }
.btn.sm { padding: 8px 14px; font-size: 0.84rem; }

/* ── Card ── */
.card,
.group-card,
.form-card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-soft) 100%);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  transition: box-shadow var(--transition);
}
.card:hover,
.group-card:hover,
.form-card:hover {
  box-shadow: var(--shadow-lg);
}

/* ── Group card ── */
.group-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.group-card h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}
.group-card > p:first-of-type {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
}
.group-card .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: auto;
  padding-top: 12px;
}
.group-card .meta .btn { min-height: 40px; }

/* ── Stat card ── */
.stat-card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-soft) 100%);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: box-shadow var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-lg); }
.stat-card strong {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--brand-500);
  line-height: 1;
}
.stat-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ── Form helpers ── */
.form-group { margin-bottom: 20px; }
.form-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88rem;
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.5;
  transition:
    border-color var(--transition),
    box-shadow  var(--transition);
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.12);
}
.form-group input::placeholder,
.form-group textarea::placeholder {
  color: #9ca8b8;
}

.keyword-field {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.keyword-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 18px;
}

.keyword-list.readonly {
  align-items: flex-start;
}

.keyword-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1;
}

.keyword-chip.removable {
  padding-right: 8px;
}

.keyword-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.12);
  color: var(--brand-600);
  font-size: 0.84rem;
  font-weight: 800;
}

.keyword-chip-remove:hover,
.keyword-chip-remove:focus-visible {
  background: rgba(37, 99, 235, 0.2);
}

.keyword-empty {
  color: var(--muted);
}

.helper {
  display: block;
  margin-top: 6px;
  font-size: 0.80rem;
  color: var(--muted);
}
.message { margin-top: 10px; font-size: 0.88rem; }
.message.success { color: var(--success); }
.message.error   { color: var(--danger); }

.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.danger-card {
  border-color: rgba(220, 38, 38, 0.25);
  background: linear-gradient(135deg, #fff8f8 0%, rgba(220, 38, 38, 0.08) 100%);
}
.danger-card h2 { color: var(--danger); }

/* ── Search panel ── */
.search-panel {
  display: flex;
  gap: 10px;
  align-items: stretch;
  flex-wrap: wrap;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-soft) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px;
  box-shadow: var(--shadow-sm);
}
.search-panel input {
  flex: 1;
  min-width: 200px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  font-size: 0.95rem;
  background: var(--surface-strong);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-panel input:focus {
  border-color: var(--brand-500);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.10);
}

/* ── Section panels / headings ── */
.section { padding: 44px 0; }
.section-heading {
  margin-bottom: 10px;
}
.section-heading h2 {
  margin: 0 0 6px;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.section-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

/* Features heading/body section wrapper */
.features h2 {
  margin: 0 0 20px;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.section-panel {
  margin-bottom: 0;
  padding: 22px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-soft) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.section-panel h2 {
  margin: 0 0 18px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* ── Features list ── */
.feature-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.feature-list li {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-soft) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: box-shadow var(--transition);
}
.feature-list li:hover { box-shadow: var(--shadow-md); }
.feature-list strong {
  display: block;
  margin-bottom: 6px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--brand-600);
}
.feature-list span {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
}

/* ── Research panel ── */
.research-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.research-card {
  position: relative;
  padding: 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff 0%, #f4f8ff 100%);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.research-card-alt {
  background:
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.08), transparent 34%),
    linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
}
.research-label {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--brand-600);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.research-stat {
  font-size: clamp(2.25rem, 4vw, 3.25rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--text);
}
.research-card p {
  margin: 0;
  color: var(--muted);
}
.research-source {
  margin-top: auto;
  font-size: 0.88rem;
}
.research-source a {
  color: var(--brand-600);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── Admin panel ── */
.admin-page {
  padding-bottom: 40px;
}
.admin-intro h1 {
  margin: 0 0 8px;
  font-size: 2rem;
  font-weight: 800;
}
.admin-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
  gap: 24px;
  align-items: start;
}
.admin-main {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.admin-sidebar {
  position: sticky;
  top: calc(var(--header-h) + 24px);
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.admin-card {
  padding: 24px;
}
.admin-members-card {
  overflow: hidden;
}
.admin-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}
.admin-group-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.admin-feed {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.admin-feed-item {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-soft);
}
.admin-feed-item strong {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.95rem;
}
.admin-feed-item p {
  margin: 6px 0 0;
  color: var(--text);
}
.admin-member-grid {
  margin-top: 10px;
}
.admin-member-grid-inner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}
.admin-member-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}
.admin-member-copy strong {
  display: block;
  margin-bottom: 6px;
  font-size: 1rem;
}
.admin-member-copy p {
  margin: 2px 0 0;
  color: var(--muted);
  word-break: break-word;
}
.admin-member-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.admin-member-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.admin-filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.admin-filter-grid .form-group {
  margin-bottom: 0;
}
.admin-filter-grid input,
.admin-filter-grid select {
  min-height: 48px;
}
.admin-search-results {
  margin-bottom: 14px;
}
.admin-search-window {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  overflow: hidden;
}
.admin-search-window-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.admin-search-window-list {
  display: grid;
  gap: 8px;
  padding: 12px;
}
.admin-search-result {
  display: grid;
  gap: 2px;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: inherit;
}
.admin-search-result strong,
.admin-search-result span,
.admin-search-result small {
  display: block;
}
.admin-search-result span,
.admin-search-result small {
  color: var(--muted);
}
.admin-search-result:hover {
  border-color: rgba(37, 99, 235, 0.35);
  transform: translateY(-1px);
}
.admin-status {
  margin-bottom: 12px;
  font-size: 0.95rem;
}
.admin-meter {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(37, 99, 235, 0.12);
}
.admin-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand-500), #60a5fa);
}
.admin-assignment-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}
.admin-assignment-copy strong,
.admin-site-admin-item strong {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}
.admin-assignment-copy p {
  margin: 6px 0 0;
  color: var(--muted);
}
.admin-assignment-actions,
.admin-site-admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.admin-site-admin-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.admin-site-admin-item p {
  margin: 0;
  color: var(--muted);
}
.admin-chat-form textarea {
  width: 100%;
  min-height: 120px;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--surface);
  resize: vertical;
}

/* ── Grids ── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 20px;
}
.groups-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Hero section ── */
.hero {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 44px;
  align-items: center;
  padding: 56px 0;
  position: relative;
}
.hero-copy h1 {
  margin: 0;
  font-size: 48px;
  font-weight: 800;
  line-height: 1.03;
  letter-spacing: -0.03em;
  color: var(--text);
  word-break: break-word;
  overflow-wrap: break-word;
}
.hero-copy p {
  margin-top: 18px;
  color: var(--muted);
  font-size: 1.1rem;
  max-width: 620px;
  line-height: 1.65;
}
.hero-actions {
  margin-top: 28px;
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.hero-media {
  position: relative;
  display: flex;
  justify-content: center;
}

.hero-image-shell {
  position: relative;
  width: min(100%, 560px);
  padding: 8px;
  border-radius: 28px;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.18), transparent 42%),
    linear-gradient(160deg, #eaf2ff 0%, #f8fbff 55%, #eef4ff 100%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.hero-image-shell::after {
  content: "";
  position: absolute;
  inset: auto 10% 0;
  height: 20px;
  background: rgba(11, 18, 32, 0.12);
  filter: blur(22px);
  z-index: 0;
}

.hero-image {
  position: relative;
  z-index: 1;
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  border-radius: 22px;
}

/* ── Forgot password / helper link ── */
a.helper-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--brand-500);
  text-decoration: underline;
  text-underline-offset: 2px;
}
a.helper-link:hover { color: var(--brand-600); }

/* ─────────────────────────────────────────────────────────
   PAGE LAYOUTS
   ───────────────────────────────────────────────────────── */

/* ── Dashboard ── */
.dashboard-intro { padding-bottom: 28px; }
.dashboard-intro h1 { margin: 0 0 8px; font-size: 1.9rem; font-weight: 800; }
.dashboard-intro p  { margin: 0; color: var(--muted); font-size: 1rem; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  align-items: start;
}
.dashboard-main   { display: flex; flex-direction: column; gap: 24px; }
.dashboard-sidebar { position: sticky; top: calc(var(--header-h) + 28px); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.dashboard-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.dashboard-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.dashboard-group-grid .group-card,
.groups-page-grid .group-card {
  height: 100%;
}

.dashboard-group-grid .group-card {
  padding: 20px;
}

.dashboard-group-grid .group-card h3,
.groups-page-grid .group-card h3 {
  font-size: 1rem;
}

.dashboard-group-grid .group-card p,
.groups-page-grid .group-card p {
  margin: 0;
}

.groups-page-shell,
.create-group-shell {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.groups-page-heading,
.create-group-intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.groups-page-heading h1,
.create-group-intro h1 {
  margin: 0 0 8px;
  font-size: 2rem;
  line-height: 1.05;
}

.groups-page-heading p,
.create-group-intro p {
  margin: 0;
  color: var(--muted);
}

.groups-page-grid {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 18px;
  align-items: stretch;
}

.create-group-card {
  max-width: 780px;
}

/* ── Profile ── */
.profile-intro { padding-bottom: 28px; }
.profile-intro h1 { margin: 0 0 8px; font-size: 1.9rem; font-weight: 800; }
.profile-intro p  { margin: 0; color: var(--muted); font-size: 1rem; }

.profile-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 32px;
  align-items: start;
}
.profile-main     { display: flex; flex-direction: column; gap: 24px; }
.profile-sidebar  { position: sticky; top: calc(var(--header-h) + 28px); }

.profile-display {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 8px;
}
.profile-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.profile-field label {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.profile-field p {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
}

.profile-field > .keyword-list {
  margin: 0;
}

.profile-card { margin-bottom: 20px; }
.profile-card h2 { margin: 0 0 20px; font-size: 1.15rem; font-weight: 700; }

/* ── Group page ── */
.group-page { padding-top: 32px; }

.group-hero {
  margin-bottom: 36px;
}
.group-hero h1 {
  margin: 0 0 8px;
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.group-hero .muted {
  font-size: 0.98rem;
}
.group-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin: 14px 0 0;
  font-size: 0.84rem;
  color: var(--muted);
}
.group-meta span { padding: 3px 10px; background: var(--accent-100); border-radius: 99px; }
.group-hero .btn {
  margin-top: 16px;
}

.group-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  align-items: start;
}

/* Members list */
.member-list { list-style: none; padding: 0; margin: 0; }
.member-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}
.member-list li:last-child { border-bottom: none; }
.member-list li strong {
  font-weight: 600;
  font-size: 0.95rem;
}
.member-list li span {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--accent-100);
  color: var(--brand-600);
  text-transform: capitalize;
}

.member-entry {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.member-actions {
  position: relative;
}

.member-actions summary {
  list-style: none;
  cursor: pointer;
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--accent-100);
  color: var(--brand-600);
  font-weight: 700;
}

.member-actions summary::-webkit-details-marker {
  display: none;
}

.member-actions-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 5;
  min-width: 170px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
}

.member-actions-menu button {
  width: 100%;
  border: none;
  border-radius: 10px;
  padding: 9px 10px;
  text-align: left;
  background: var(--accent-100);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}

.member-actions-menu button.danger {
  color: #991b1b;
  background: rgba(220, 38, 38, 0.1);
}

.pending-requests {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.pending-requests h3 {
  margin: 0 0 10px;
  font-size: 0.98rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 18px;
  color: var(--muted);
  font-weight: 500;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 700;
  background: var(--accent-100);
}

.status-pill.pending {
  color: #9a6700;
  background: rgba(250, 204, 21, 0.18);
}

.status-pill.banned {
  color: #991b1b;
  background: rgba(220, 38, 38, 0.12);
}

/* Sessions list */
.schedule-list { list-style: none; padding: 0; margin: 0 0 20px; }
.schedule-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.schedule-list li:last-child { border-bottom: none; padding-bottom: 0; }
.schedule-list li strong { display: block; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.schedule-list li small {
  color: var(--muted);
  font-size: 0.80rem;
}

.schedule-event {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: transparent;
  cursor: pointer;
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 14px;
  align-items: center;
  text-align: left;
  padding: 10px;
  transition:
    border-color var(--transition),
    background var(--transition),
    transform var(--transition);
}

.schedule-event:hover,
.schedule-event:focus-visible,
.schedule-event.active {
  background: var(--accent-100);
  border-color: rgba(34, 197, 94, 0.35);
  transform: translateY(-1px);
}

.schedule-date-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70px;
  padding: 10px 8px;
  border-radius: 16px;
  background: linear-gradient(180deg, #bbf7d0 0%, #86efac 100%);
  color: #14532d;
  box-shadow: var(--shadow-sm);
}

.schedule-date-badge span {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.schedule-date-badge strong {
  margin-top: 4px;
  font-size: 1rem;
}

.schedule-event-copy strong {
  display: block;
}

.schedule-event-copy small {
  display: block;
  margin-top: 4px;
}

.schedule-detail {
  margin-top: 16px;
}

.schedule-detail-bubble {
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid rgba(34, 197, 94, 0.22);
  background: linear-gradient(180deg, rgba(187, 247, 208, 0.38) 0%, rgba(255, 255, 255, 0.98) 100%);
  box-shadow: var(--shadow-sm);
}

.schedule-detail-bubble h4 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.schedule-detail-bubble p {
  margin: 6px 0;
  color: var(--text);
  line-height: 1.5;
}

.schedule-form h3 { margin: 0 0 18px; font-size: 1.05rem; font-weight: 700; }

/* Chat */
.chat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 520px;
}
.chat-card > h2 {
  margin: 0;
  padding: 20px 28px;
  font-size: 1.05rem;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.chat-feed {
  flex: 1;
  padding: 20px 28px;
  overflow-y: auto;
  min-height: 360px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #fafcff;
}

.chat-message {
  border-radius: var(--radius-md);
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.chat-message strong {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--brand-600);
  margin-bottom: 4px;
}
.chat-message strong span {
  font-weight: 400;
  font-size: 0.78rem;
  color: var(--muted);
}
.chat-message p  { margin: 0; color: var(--text); font-size: 0.94rem; line-height: 1.6; }

.chat-form {
  padding: 18px 28px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.chat-form .form-group { margin-bottom: 0; }
.chat-form .btn { width: 100%; }

.pagination-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 22px;
  flex-wrap: wrap;
}

.pagination-status {
  font-size: 0.92rem;
  color: var(--muted);
  font-weight: 600;
}

.access-notice {
  margin: 0;
  color: #dc2626;
  font-weight: 700;
}

.feature-grid-compact {
  align-items: stretch;
}

/* ── Form panel / Card ── */
.form-card.form-panel { max-width: 480px; margin: 0 auto; }
.form-panel h2   { margin: 0 0 6px; font-size: 1.4rem; font-weight: 800; letter-spacing: -0.02em; }
.form-panel p    { margin: 0 0 28px; color: var(--muted); font-size: 0.95rem; line-height: 1.6; }
.form-panel .btn { width: 100%; }

/* ─────────────────────────────────────────────────────────
   FOOTER
   ───────────────────────────────────────────────────────── */
.site-footer {
  padding: 32px 0;
  margin-top: 60px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--muted);
  font-size: 0.87rem;
}

/* ────────────────────────────────────────────────────────
   RESPONSIVE — scales down from browser viewport widths
   ──────────────────────────────────────────────────────── */

/* ── Tablet / small laptop ──────────────────────────── */
@media (max-width: 1000px) {
  /* 1 float more toward mobile-like visuals */
  :root {
    --header-h: 64px;
  }

  .container  { padding-inline: 24px; }
  .hero       { grid-template-columns: 1fr 1fr; gap: 32px; padding: 40px 0; }
  .hero-copy h1 { font-size: 38px; }
  .hero-image-shell { padding: 6px; }

  .stats-grid      { grid-template-columns: repeat(3, 1fr); }
  .dashboard-panels { grid-template-columns: 1fr; }

  .profile-grid { grid-template-columns: 1fr 240px; gap: 24px; }
  .research-grid { grid-template-columns: 1fr; }
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { position: static; }
  .admin-overview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ── Tablet ───────────────────────────────────────── */
@media (max-width: 820px) {
  /* Show hamburger, hide desktop nav */
  .nav-toggle         { display: inline-flex; }

  /* NavPanel overlay (hidden by default, shown via .nav-open on body) */
  nav.primary-nav {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    transform: translateY(8px);
    opacity: 0;
    pointer-events: none;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    background: var(--surface);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    box-shadow: var(--shadow-nav);
    border: 1px solid var(--border);
    border-top: none;
    max-height: calc(100vh - var(--header-h));
    overflow-y: auto;
    transition:
      opacity     var(--transition),
      transform   var(--transition),
      pointer-events 0ms var(--transition);
  }

  .nav-backdrop {
    display: block;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
  }

  body.nav-open nav.primary-nav,
  body.nav-open .nav-backdrop {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  body.nav-open .nav-backdrop { transition-delay: 0ms; }
  nav.primary-nav a {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    border-radius: var(--radius-md);
    text-align: left;
  }

  .brand-tag   { display: none; }

  /* Hero stacks */
  .hero          { grid-template-columns: 1fr; gap: 28px; padding: 36px 0; }
  .hero-copy h1  { font-size: 32px; }
  .hero-media    { order: -1; }
  .hero-image-shell { width: min(100%, 620px); }

  /* Dashboard stacks */
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-sidebar { position: static; }
  .dashboard-panels { grid-template-columns: 1fr; }
  .dashboard-group-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

  /* Profile stacks */
  .profile-grid        { grid-template-columns: 1fr; }
  .profile-sidebar     { position: static; }
  .research-grid       { grid-template-columns: 1fr; }
  .admin-layout        { grid-template-columns: 1fr; }
  .admin-sidebar       { position: static; }
  .admin-overview-grid  { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Features list — 2 columns */
  .feature-list  { grid-template-columns: 1fr 1fr; }

  /* Group page */
  .group-grid            { grid-template-columns: 1fr; }
  .group-hero .group-meta { flex-wrap: wrap; gap: 8px; }

  .header-grid { align-items: center; }
  .header-right { gap: 8px; }
  .lang-btn  { padding: 5px 8px; font-size: 0.74rem; }
}

/* ── Small mobile ─────────────────────────────────── */
@media (max-width: 640px) {
  :root { --header-h: 56px; }

  .container { padding-inline: 16px; }

  .header-grid { height: var(--header-h); gap: 10px; }
  .site-header .brand { font-size: 1.1rem; }
  .nav-toggle  { width: 34px; height: 34px; }

  .hero { padding: 28px 0; gap: 20px; }
  .hero-copy h1 { font-size: 26px; }
  .hero-copy p  { font-size: 0.95rem; }
  .hero-actions { gap: 8px; }
  .hero-image-shell { padding: 4px; border-radius: 24px; }
  .groups-page-heading h1,
  .create-group-intro h1 { font-size: 1.6rem; }
  .section-panel { padding: 18px; }
  .dashboard-group-grid,
  .groups-page-grid { grid-template-columns: 1fr; }

  .card, .group-card, .form-card,
  .stat-card { padding: 18px; }

  .feature-list     { grid-template-columns: 1fr; }

  .stats-grid  { grid-template-columns: 1fr 1fr; }
  .research-grid { grid-template-columns: 1fr; }
  .admin-overview-grid { grid-template-columns: 1fr; }

  .dashboard-grid   { grid-template-columns: 1fr; }
  .profile-grid     { grid-template-columns: 1fr; }

  .profile-display  { grid-template-columns: 1fr; }

  .search-panel      { flex-direction: column; }
  .search-panel input { min-width: unset; }

  .form-panel, .form-card { padding: 22px; }
  .admin-card { padding: 18px; }
  .admin-member-grid-inner { grid-template-columns: 1fr; }

  .btn { padding: 11px 18px; font-size: 0.88rem; }

  .header-right { gap: 6px; }
  .theme-toggle  { width: 34px; height: 34px; }
  .lang-btn      { padding: 4px 7px; font-size: 0.72rem; }
}

/* ─────────────────────────────────────────────────────────
   DARK THEME
   ───────────────────────────────────────────────────────── */
body.theme-dark {
  --surface:         #0f1724;
  --bg:              #0b1020;
  --text:            #e6eef8;
  --muted:           #9aa6b2;
  --border:          rgba(255, 255, 255, 0.07);
  --surface-soft:    #111b2f;
  --surface-strong:  #0c1426;
  --brand-500:       #60a5fa;
  --brand-600:       #3b82f6;
  --accent-100:      rgba(96, 165, 250, 0.07);
  --accent-200:      rgba(96, 165, 250, 0.14);
  --shadow-sm:       0  2px  8px rgba(0,  0,  0, 0.25);
  --shadow-md:       0  6px 20px rgba(0,  0,  0, 0.30);
  --shadow-lg:       0 10px 30px rgba(0,  0,  0, 0.40);
  --shadow-nav:      0  8px 40px rgba(0,  0,  0, 0.50);
}
body.theme-dark .site-header {
  background: linear-gradient(180deg, #131e38 0%, #0b1020 100%);
}

body.theme-dark .hero-image-shell {
  background:
    radial-gradient(circle at top left, rgba(96, 165, 250, 0.18), transparent 45%),
    linear-gradient(160deg, #12203a 0%, #10192e 58%, #0d1526 100%);
  border: 1px solid rgba(148, 163, 184, 0.12);
  box-shadow: 0 18px 44px rgba(2, 6, 23, 0.48);
}

body.theme-dark .search-panel,
body.theme-dark .section-panel,
body.theme-dark .feature-list li,
body.theme-dark .research-card,
body.theme-dark .group-card,
body.theme-dark .stat-card,
body.theme-dark .form-card {
  background: linear-gradient(180deg, rgba(17, 27, 47, 0.96) 0%, rgba(15, 23, 36, 0.98) 100%);
}

body.theme-dark .research-source a,
body.theme-dark .admin-feed-item strong {
  color: #bfdbfe;
}

body.theme-dark .admin-feed-item {
  background: rgba(15, 23, 36, 0.96);
}

body.theme-dark .search-panel input,
body.theme-dark .form-group input,
body.theme-dark .form-group textarea,
body.theme-dark .form-group select {
  background: #0c1426;
  border-color: rgba(148, 163, 184, 0.14);
}

body.theme-dark .keyword-chip {
  background: #0f1a2d;
  border-color: rgba(148, 163, 184, 0.14);
}

body.theme-dark .keyword-chip-remove {
  background: rgba(96, 165, 250, 0.16);
  color: #bfdbfe;
}

body.theme-dark .primary-nav a#logoutBtn {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.12);
}

body.theme-dark .primary-nav a#logoutBtn:hover,
body.theme-dark .primary-nav a#logoutBtn:focus-visible {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.22);
}
body.theme-dark .chat-card > h2,
body.theme-dark .chat-form,
body.theme-dark .chat-message,
body.theme-dark .chat-card,
body.theme-dark .member-list li span,
body.theme-dark .group-meta span {
  background: #111b2f;
}

body.theme-dark .chat-feed {
  background: #0b1324;
}

body.theme-dark .chat-message strong {
  color: #8ec5ff;
}

body.theme-dark .chat-form textarea,
body.theme-dark .chat-form input {
  background: #0d1628;
  color: var(--text);
}

body.theme-dark .schedule-date-badge {
  background: linear-gradient(180deg, #14532d 0%, #166534 100%);
  color: #dcfce7;
}

body.theme-dark .schedule-event:hover,
body.theme-dark .schedule-event:focus-visible,
body.theme-dark .schedule-event.active {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(74, 222, 128, 0.35);
}

body.theme-dark .schedule-detail-bubble {
  background: linear-gradient(180deg, rgba(20, 83, 45, 0.78) 0%, rgba(15, 23, 36, 0.98) 100%);
  border-color: rgba(74, 222, 128, 0.3);
}

body.theme-dark .member-actions-menu button.danger,
body.theme-dark .status-pill.banned {
  color: #fecaca;
}

body.theme-dark .access-notice {
  color: #f87171;
}

/* ─────────────────────────────────────────────────────────
   TRANSITIONS (theme only, not layout)
   ───────────────────────────────────────────────────────── */
.site-header,
nav.primary-nav,
body,
.card,
.group-card,
.form-card,
.stat-card,
.theme-toggle,
.btn,
.lang-btn,
.site-header .brand {
  transition:
    background-color 200ms ease,
    color             200ms ease,
    border-color      200ms ease,
    box-shadow        200ms ease;
}
