/* MEDNET v2 — Modern Clinical
   Geist Sans + Geist Mono. Cobalt-indigo primary, warm off-white surfaces,
   soft shadows, rounded 12-16px corners. No serifs.
   Vibe: Linear × Notion × Attio × Reforge. */

@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700;800&family=Geist+Mono:wght@400;500&display=swap');

:root {
  /* Brand — cobalt-indigo default */
  --brand: #3A4FE0;
  --brand-2: #5B7FFF;
  --brand-3: #E7EBFF;         /* tinted surface */
  --brand-ink: #FFFFFF;

  /* Warm neutrals — light mode */
  --bg: #F7F5F1;
  --surface: #FFFFFF;
  --surface-2: #F1EEE7;
  --surface-3: #E9E5DB;
  --rule: #EBE7DC;
  --rule-strong: #D9D3C4;
  --ink: #0E0F13;
  --ink-2: #2B2E37;
  --ink-3: #64697A;
  --ink-4: #9AA0B0;

  /* Semantic — brighter, app-native */
  --verified: #00A374;
  --verified-2: #00C48F;
  --verified-bg: #DFF5EC;
  --urgent: #FF6B4A;
  --urgent-2: #E85539;
  --urgent-bg: #FFEBE4;
  --sponsored: #A87A26;
  --sponsored-bg: #FBF0D6;
  --warn: #E9A93A;

  /* Type */
  --font-sans: 'Geist', -apple-system, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  /* Legacy alias for pages that referenced --font-display */
  --font-display: var(--font-sans);

  /* Radius */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-2xl: 28px;

  /* Shadow */
  --shadow-sm: 0 1px 2px rgba(14, 15, 19, 0.04);
  --shadow: 0 1px 2px rgba(14, 15, 19, 0.04), 0 4px 12px rgba(14, 15, 19, 0.04);
  --shadow-lg: 0 1px 2px rgba(14, 15, 19, 0.04), 0 12px 32px rgba(14, 15, 19, 0.06);
  --shadow-brand: 0 1px 2px rgba(58, 79, 224, 0.08), 0 12px 32px rgba(58, 79, 224, 0.12);

  /* ============ MEDNET spring — the signature curve ============
     Used sitewide on buttons, chips, cards, icons.
     `--ease-mednet-out` is a silky "out-expo" for hover states and entrance.
     `--ease-mednet` has a slight overshoot for pops (badges, particles).
     Keep them consistent — the *feel* is what makes it "MEDNET". */
  --ease-mednet-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-mednet:     cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast:  150ms;
  --dur-med:   250ms;
  --dur-long:  480ms;

  /* Layout */
  --max-w: 1280px;
  --shell-nav-w: 240px;
  --shell-right-w: 320px;
  --shell-top-h: 60px;
}

[data-theme="dark"] {
  --bg: #0B0C11;
  --surface: #14161E;
  --surface-2: #1B1E28;
  --surface-3: #232735;
  --rule: #262A38;
  --rule-strong: #363B4C;
  --ink: #F0F2F6;
  --ink-2: #C9CCD6;
  --ink-3: #8B90A2;
  --ink-4: #5B617A;
  --brand-3: #1D2447;

  --verified-bg: #0E2A21;
  --urgent-bg: #2E1913;
  --sponsored-bg: #2A2213;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 1px 2px rgba(0, 0, 0, 0.3), 0 20px 48px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'ss01', 'ss03', 'cv11';
}

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

/* Typography */
.display {
  font-family: var(--font-sans);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.03em;
}
.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-3);
  font-weight: 500;
}
.mono { font-family: var(--font-mono); }
.serif { font-family: var(--font-sans); }   /* legacy alias */

h1, h2, h3, h4, h5 {
  font-family: var(--font-sans);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-mednet-out),
              box-shadow var(--dur-fast) var(--ease-mednet-out),
              border-color var(--dur-fast) var(--ease-mednet-out),
              background var(--dur-fast) var(--ease-mednet-out),
              color var(--dur-fast) var(--ease-mednet-out);
  white-space: nowrap;
  letter-spacing: -0.005em;
}
.btn:hover {
  border-color: var(--ink-3);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.btn:active { transform: translateY(0); }
.btn.primary {
  background: var(--brand);
  color: var(--brand-ink);
  border-color: var(--brand);
  box-shadow: var(--shadow-brand);
}
.btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn.accent {
  background: var(--urgent);
  color: white;
  border-color: var(--urgent);
}
.btn.accent:hover { background: var(--urgent-2); border-color: var(--urgent-2); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }
.btn.lg { padding: 12px 22px; font-size: 14px; border-radius: 12px; }

/* Chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--ink-2);
  background: var(--surface);
  letter-spacing: -0.005em;
}
.chip.verified { color: var(--verified); border-color: var(--verified-2); background: var(--verified-bg); }
.chip.sponsored { color: var(--sponsored); border-color: transparent; background: var(--sponsored-bg); font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; }
.chip.urgent { color: var(--urgent-2); border-color: var(--urgent); background: var(--urgent-bg); }
.chip.brand { color: var(--brand); border-color: transparent; background: var(--brand-3); }

/* Verified badge — solid mint circle with check */
.vbadge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  background: var(--verified-2);
  color: white;
  border-radius: 50%;
  vertical-align: -2px;
}
.vbadge svg { width: 9px; height: 9px; stroke: white; stroke-width: 3.5; }

/* Avatar — initials with soft gradient background */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--ink);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.02em;
  position: relative;
  flex-shrink: 0;
  background: linear-gradient(135deg, #E7EBFF 0%, #C7D0FF 100%);
}
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.lg { width: 64px; height: 64px; font-size: 20px; }
.avatar.xl { width: 96px; height: 96px; font-size: 30px; }
/* deterministic-by-initial variants (used via data-color) */
.avatar[data-c="a"] { background: linear-gradient(135deg, #FFE1D6, #FFB89A); color: #7A2E10; }
.avatar[data-c="b"] { background: linear-gradient(135deg, #D9F3E7, #86D8B9); color: #0B4A32; }
.avatar[data-c="c"] { background: linear-gradient(135deg, #E7EBFF, #A7B4FF); color: #1A237E; }
.avatar[data-c="d"] { background: linear-gradient(135deg, #FDE7F1, #F5A7CB); color: #6B1240; }
.avatar[data-c="e"] { background: linear-gradient(135deg, #FEF3D0, #F7DA82); color: #6B4A0F; }
.avatar[data-c="f"] { background: linear-gradient(135deg, #DDF0FA, #7ECBEC); color: #0E4867; }
.avatar[data-c="g"] { background: linear-gradient(135deg, #EBE0F7, #C4A5EA); color: #431B75; }
.avatar[data-c="h"] { background: linear-gradient(135deg, #FFE3E0, #FF9F92); color: #7A1C10; }

.avatar.verified::after {
  content: '';
  position: absolute;
  bottom: -2px; right: -2px;
  width: 14px; height: 14px;
  background: var(--verified-2);
  border: 2.5px solid var(--surface);
  border-radius: 50%;
}
.avatar.lg.verified::after, .avatar.xl.verified::after { width: 20px; height: 20px; border-width: 3px; }

/* ============ PRESENCE RING (online) ============
   Adds a mint ring around the entire avatar when the user is currently online.
   Stacks cleanly with .verified (which keeps its bottom-right dot).
   Use `.avatar.online` on any avatar to indicate presence.
   `.avatar.online.live` adds a subtle pulse for members active in a live case. */
.avatar.online {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--verified-2);
}
/* Slightly thicker rings on larger sizes so the effect stays proportional */
.avatar.lg.online  { box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--verified-2); }
.avatar.xl.online  { box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--verified-2); }
/* Thinner on small avatars so it doesn't overwhelm a 28px chip */
.avatar.sm.online  { box-shadow: 0 0 0 1.5px var(--surface), 0 0 0 3px var(--verified-2); }

/* Pulsing ring for members active in a live case */
.avatar.online.live {
  animation: presence-pulse 2s ease-in-out infinite;
}
@keyframes presence-pulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--verified-2), 0 0 0 4px color-mix(in oklab, var(--verified-2) 0%, transparent); }
  50%      { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--verified-2), 0 0 0 10px color-mix(in oklab, var(--verified-2) 25%, transparent); }
}
/* Larger-size pulse ring */
.avatar.lg.online.live, .avatar.xl.online.live {
  animation: presence-pulse-lg 2s ease-in-out infinite;
}
@keyframes presence-pulse-lg {
  0%, 100% { box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--verified-2), 0 0 0 6px color-mix(in oklab, var(--verified-2) 0%, transparent); }
  50%      { box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--verified-2), 0 0 0 14px color-mix(in oklab, var(--verified-2) 25%, transparent); }
}
.avatar.sm.online.live {
  animation: presence-pulse-sm 2s ease-in-out infinite;
}
@keyframes presence-pulse-sm {
  0%, 100% { box-shadow: 0 0 0 1.5px var(--surface), 0 0 0 3px var(--verified-2), 0 0 0 3px color-mix(in oklab, var(--verified-2) 0%, transparent); }
  50%      { box-shadow: 0 0 0 1.5px var(--surface), 0 0 0 3px var(--verified-2), 0 0 0 8px color-mix(in oklab, var(--verified-2) 25%, transparent); }
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card.raised { box-shadow: var(--shadow); }
.card .card-body { padding: 20px; }
.card .card-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Utility */
.hstack { display: flex; align-items: center; gap: 8px; }
.vstack { display: flex; flex-direction: column; gap: 8px; }
.muted { color: var(--ink-3); }
.subtle { color: var(--ink-4); }
.container { max-width: var(--max-w); margin: 0 auto; padding: 0 32px; }

/* App shell */
.app-shell {
  display: grid;
  grid-template-columns: var(--shell-nav-w) 1fr var(--shell-right-w);
  min-height: 100vh;
}
.shell-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--shell-top-h);
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px) saturate(1.1);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
}
.shell-nav {
  padding: 20px 12px;
  position: sticky;
  top: var(--shell-top-h);
  height: calc(100vh - var(--shell-top-h));
  overflow-y: auto;
  background: var(--bg);
}
.shell-main {
  padding: 32px 40px;
  min-width: 0;
}
.shell-right {
  padding: 32px 24px;
  position: sticky;
  top: var(--shell-top-h);
  height: calc(100vh - var(--shell-top-h));
  overflow-y: auto;
  background: var(--bg);
  border-left: 1px solid var(--rule);
}

/* Nav items */
.nav-section {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-4);
  padding: 18px 12px 6px;
  letter-spacing: 0;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.nav-item .icon-wrap {
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-3);
}
.nav-item.active .icon-wrap { color: var(--brand); }
.nav-item .badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-3);
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 999px;
}
.nav-item.active .badge { background: var(--brand-3); color: var(--brand); }

/* Role-tinted nav items (View profiles by role submenu) */
.nav-item[data-tint="md"] .icon-wrap  { color: #3A4FE0; }
.nav-item[data-tint="rn"] .icon-wrap  { color: #C42976; }
.nav-item[data-tint="pt"] .icon-wrap  { color: #C87A0B; }
.nav-item[data-tint="mls"] .icon-wrap { color: #1E86BB; }
.nav-item[data-tint="stu"] .icon-wrap { color: #8B5FE8; }
.nav-item[data-tint].active { background: var(--surface); box-shadow: var(--shadow-sm); }
.nav-item[data-tint="md"].active  .icon-wrap { color: #3A4FE0; }
.nav-item[data-tint="rn"].active  { background: color-mix(in oklab, #C42976 6%, var(--surface)); }
.nav-item[data-tint="pt"].active  { background: color-mix(in oklab, #C87A0B 6%, var(--surface)); }
.nav-item[data-tint="mls"].active { background: color-mix(in oklab, #1E86BB 6%, var(--surface)); }

.nav-avatar {
  width: 18px; height: 18px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 8px;
  font-weight: 600;
  color: var(--ink-2);
}

/* Search input (top bar) */
.search-input {
  flex: 1;
  max-width: 460px;
  height: 36px;
  padding: 0 14px 0 38px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--ink);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364697A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 14px center;
  transition: box-shadow .15s, border-color .15s;
}
.search-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand) 15%, transparent); }
.search-input::placeholder { color: var(--ink-4); }

/* Logo */
.logo {
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
}
.logo .mark {
  width: 24px; height: 24px;
  border-radius: 7px;
  background: var(--brand);
  color: white;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo .mark svg { width: 14px; height: 14px; }

/* Post card (feed) */
.post {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 12px;
  transition: box-shadow .2s, border-color .15s;
}
.post:hover { box-shadow: var(--shadow); border-color: var(--rule-strong); }
.post-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.post-author { flex: 1; min-width: 0; }
.post-author .name { font-weight: 600; font-size: 14px; color: var(--ink); display: flex; align-items: center; gap: 6px; letter-spacing: -0.01em; }
.post-author .meta { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.post-body h3 {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 18px;
  line-height: 1.3;
  margin: 4px 0 8px;
  color: var(--ink);
  letter-spacing: -0.015em;
}
.post-body p { color: var(--ink-2); margin: 0 0 12px; line-height: 1.55; }
.post-actions {
  display: flex;
  gap: 4px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  font-size: 12px;
  color: var(--ink-3);
}
.post-actions .act {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, color .15s;
  font-weight: 500;
}
.post-actions .act:hover { background: var(--surface-2); color: var(--ink); }
.post-actions .act.primary { color: var(--brand); }

/* Data readouts */
.datum { display: flex; flex-direction: column; gap: 4px; }
.datum .val {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 28px;
  line-height: 1;
  color: var(--ink);
  letter-spacing: -0.03em;
}
.datum .lbl {
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: -0.005em;
}

/* Sidebar list */
.side-list { display: flex; flex-direction: column; gap: 2px; }
.side-list .item {
  padding: 10px 12px;
  border-radius: 8px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  cursor: pointer;
  transition: background .15s;
}
.side-list .item:hover { background: var(--surface-2); }
.side-list .idx {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-4);
  padding-top: 3px;
  min-width: 22px;
}
.side-list .title { font-size: 13px; color: var(--ink); line-height: 1.35; font-weight: 500; letter-spacing: -0.005em; }
.side-list .sub { font-size: 11px; color: var(--ink-3); margin-top: 3px; }

/* Tweaks panel */
.tweak-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 16px;
  width: 280px;
  box-shadow: var(--shadow-lg);
  display: none;
}
.tweak-panel.active { display: block; }
.tweak-panel h4 {
  margin: 0 0 14px;
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 500;
  letter-spacing: -0.005em;
}
.tweak-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--rule); }
.tweak-row:first-of-type { border-top: none; padding-top: 4px; }
.tweak-row label { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.swatch-row { display: flex; gap: 8px; }
.swatch {
  width: 24px; height: 24px; border-radius: 50%; cursor: pointer;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--rule-strong);
  transition: transform .12s;
}
.swatch.active { box-shadow: 0 0 0 2px var(--ink); transform: scale(1.08); }
.toggle {
  width: 36px; height: 20px; background: var(--rule-strong); border-radius: 999px; position: relative; cursor: pointer;
  transition: background .15s;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: white;
  border-radius: 50%;
  transition: transform .15s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle.on { background: var(--brand); }
.toggle.on::after { transform: translateX(16px); }

/* Segmented control */
.segmented {
  display: inline-flex;
  background: var(--surface-2);
  padding: 3px;
  border-radius: 10px;
}
.segmented button {
  padding: 6px 14px;
  background: transparent;
  border: none;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
  cursor: pointer;
  border-radius: 7px;
  transition: all .12s;
  letter-spacing: -0.005em;
}
.segmented button:hover { color: var(--ink-2); }
.segmented button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* Icon helper */
.icon { width: 16px; height: 16px; flex-shrink: 0; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 20px; height: 20px; }

/* Responsive */
@media (max-width: 1200px) {
  .app-shell { grid-template-columns: var(--shell-nav-w) 1fr; }
  .shell-right { display: none; }
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .shell-nav { display: none; }
  .shell-main { padding: 20px; }
}

/* Legacy .plus-grid stays working */
.plus-grid {
  background-image:
    linear-gradient(var(--rule) 1px, transparent 1px),
    linear-gradient(90deg, var(--rule) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: .4;
}

/* Legacy .rule-label used on some pages */
.rule-label {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
}
.rule-label .num { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); }
