/* ============================================================
   PostHog-style Design System — v1.0
   Based on DESIGN.md
   ============================================================ */

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  /* Colors */
  --color-surface-white: #ffffff;
  --color-canvas-sand: #eeefe9;
  --color-pale-granite: #e5e7e0;
  --color-ink-black: #000000;
  --color-charcoal-black: #111827;
  --color-graphite-grey: #374151;
  --color-faded-grey: #4d4f46;
  --color-ash-grey: #65675e;
  --color-warm-gray-tint: #e1d7c2;
  --color-sky-blue: #2f80fa;
  --color-marigold-yellow: #f1a82c;
  --color-sunset-orange: #eb9d2a;
  --color-vivid-green: #6aa84f;
  --color-stock-up: #d23501;
  --color-stock-down: #6aa84f;
  --color-danger: #dc2626;
  --color-danger-hover: #b91c1c;
  --gradient-dynamic: linear-gradient(90deg, rgb(1,67,203), rgb(43,111,244) 24.04%, rgb(210,52,1) 46.63%, rgb(255,101,31) 65.87%, rgb(251,160,0) 83.17%, rgb(1,67,203));

  /* Typography */
  --font-sans: 'IBM Plex Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Font weights */
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
  --fw-extrabold: 800;

  /* Type scale */
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-md: 15px;
  --text-lg: 16px;
  --text-heading: 18px;
  --text-heading-lg: 24px;
  --text-display: 36px;

  /* Spacing */
  --sp-4: 4px;
  --sp-6: 6px;
  --sp-8: 8px;
  --sp-10: 10px;
  --sp-12: 12px;
  --sp-14: 14px;
  --sp-16: 16px;
  --sp-18: 18px;
  --sp-20: 20px;
  --sp-24: 24px;
  --sp-28: 28px;
  --sp-32: 32px;
  --sp-40: 40px;
  --sp-48: 48px;
  --sp-64: 64px;

  /* Border radius */
  --radius-xs: 3px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 1px 3px rgba(0,0,0,0.08);
  --shadow-xl: rgba(0,0,0,0.25) 0px 25px 50px -12px;

  /* Layout */
  --page-max-width: 958px;
  --section-gap: 48px;
  --element-gap: 8px;
}

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

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--fw-regular);
  color: var(--color-charcoal-black);
  background-color: var(--color-canvas-sand);
  background-image: url('/ui/background.png');
  background-attachment: fixed;
  background-size: 400px auto;
  background-repeat: repeat;
  background-blend-mode: luminosity;
  margin: 0;
  line-height: 1.5;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  color: var(--color-charcoal-black);
  letter-spacing: -0.025em;
  margin: 0 0 var(--sp-8) 0;
  font-weight: var(--fw-bold);
}

h1 { font-size: var(--text-display); line-height: 1; }
h2 { font-size: var(--text-heading-lg); line-height: 1.25; }
h3 { font-size: var(--text-heading); line-height: 1.33; }

p { margin: 0 0 var(--sp-8) 0; line-height: 1.6; }

a { color: var(--color-sky-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navbar ─────────────────────────────────────────────────── */
.ds-navbar {
  background: var(--color-surface-white);
  border-bottom: 1px solid var(--color-pale-granite);
  padding: var(--sp-12) var(--sp-24);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.ds-navbar-logo {
  display: flex;
  align-items: center;
  gap: var(--sp-8);
  text-decoration: none;
}
.ds-navbar-logo img {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
}
.ds-navbar-logo-text {
  font-size: var(--text-heading);
  font-weight: var(--fw-semibold);
  color: var(--color-charcoal-black);
  letter-spacing: -0.025em;
}

.ds-navbar-right {
  display: flex;
  align-items: center;
  gap: var(--sp-6);
}

/* ── App Icon (replaces CSS glyph tiles) ─────────────────────── */
.app-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: block;
  object-fit: cover;
  flex-shrink: 0;
}
.app-icon.locked {
  filter: grayscale(0.4) opacity(0.6);
}

/* ── Icon Button ─────────────────────────────────────────────── */
.ds-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--color-pale-granite);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-graphite-grey);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.08s;
  position: relative;
  text-decoration: none;
  flex-shrink: 0;
}
.ds-icon-btn:hover {
  background: var(--color-canvas-sand);
  border-color: var(--color-pale-granite);
  color: var(--color-charcoal-black);
}
.ds-icon-btn:active {
  transform: translateY(1px);
}
.ds-icon-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(47,128,250,0.35);
}
.ds-icon-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Notification badge on icon-btn */
.ds-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--color-marigold-yellow);
  color: var(--color-ink-black);
  font-size: 10px;
  font-weight: var(--fw-bold);
  border-radius: var(--radius-full);
  min-width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
  pointer-events: none;
}
.ds-badge[hidden] { display: none; }

/* ── Buttons ─────────────────────────────────────────────────── */
.ds-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-6);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.01em;
  border-radius: var(--radius-sm);
  padding: var(--sp-10) var(--sp-16);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.08s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}
.ds-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ds-btn:active:not(:disabled) { transform: translateY(1px); }
.ds-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(47,128,250,0.35);
}

.ds-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  vertical-align: middle;
}

.ds-btn-primary {
  background: var(--color-marigold-yellow);
  color: var(--color-ink-black);
  border-color: var(--color-marigold-yellow);
}
.ds-btn-primary:hover:not(:disabled) { background: var(--color-sunset-orange); border-color: var(--color-sunset-orange); }
.ds-btn-primary:focus-visible { box-shadow: 0 0 0 3px rgba(241,168,44,0.45); }

.ds-btn-ghost {
  background: transparent;
  color: var(--color-charcoal-black);
  border-color: var(--color-graphite-grey);
}
.ds-btn-ghost:hover:not(:disabled) { background: var(--color-canvas-sand); }

.ds-btn-text {
  background: transparent;
  color: var(--color-charcoal-black);
  border-color: transparent;
  padding: var(--sp-4) var(--sp-6);
}
.ds-btn-text:hover:not(:disabled) { background: var(--color-canvas-sand); }

.ds-btn-danger {
  background: transparent;
  color: var(--color-danger);
  border-color: var(--color-danger);
}
.ds-btn-danger:hover:not(:disabled) { background: var(--color-danger); color: #fff; }
.ds-btn-danger:focus-visible { box-shadow: 0 0 0 3px rgba(220,38,38,0.35); }

.ds-btn-sky {
  background: var(--color-sky-blue);
  color: #fff;
  border-color: var(--color-sky-blue);
}
.ds-btn-sky:hover:not(:disabled) { background: #1a6ee8; border-color: #1a6ee8; }

.ds-btn-sm {
  font-size: var(--text-xs);
  padding: var(--sp-6) var(--sp-10);
}

.ds-btn-lg {
  font-size: var(--text-lg);
  padding: 14px var(--sp-32);
}

/* ── Card ────────────────────────────────────────────────────── */
.ds-card {
  background: var(--color-surface-white);
  border: 1px solid var(--color-pale-granite);
  border-radius: var(--radius-sm);
  padding: var(--sp-24);
}

.ds-card-header {
  font-size: var(--text-heading);
  font-weight: var(--fw-semibold);
  color: var(--color-charcoal-black);
  letter-spacing: -0.025em;
  margin-bottom: var(--sp-16);
  padding-bottom: var(--sp-12);
  border-bottom: 1px solid var(--color-pale-granite);
}

/* App card (homepage grid) */
.ds-app-card {
  background: var(--color-surface-white);
  border: 1px solid var(--color-pale-granite);
  border-left: 4px solid var(--color-pale-granite);
  border-radius: var(--radius-lg);
  padding: var(--sp-20) var(--sp-24);
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s, box-shadow 0.15s, border-left-color 0.15s;
  cursor: pointer;
}
.ds-app-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-left-color: var(--color-sky-blue);
  text-decoration: none;
}
.ds-app-card:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(47,128,250,0.35);
}
.ds-app-card.locked {
  opacity: 0.55;
  cursor: not-allowed;
}
.ds-app-card.locked:hover { transform: none; box-shadow: none; border-left-color: var(--color-pale-granite); }
.ds-app-card-icon {
  width: 32px;
  height: 32px;
  color: var(--color-graphite-grey);
  margin-bottom: var(--sp-12);
  flex-shrink: 0;
}
.ds-app-card-icon svg { width: 100%; height: 100%; }
.ds-app-card-title {
  font-size: var(--text-lg);
  font-weight: var(--fw-semibold);
  color: var(--color-charcoal-black);
  margin-bottom: var(--sp-6);
  letter-spacing: -0.025em;
}
.ds-app-card-desc {
  font-size: var(--text-sm);
  color: var(--color-faded-grey);
  line-height: 1.5;
  flex: 1;
}

/* ── Page Layout ─────────────────────────────────────────────── */
.ds-page {
  max-width: var(--page-max-width);
  margin: 0 auto;
  padding: var(--sp-32) var(--sp-24);
}

.ds-page-title {
  font-size: var(--text-heading-lg);
  font-weight: var(--fw-bold);
  color: var(--color-charcoal-black);
  letter-spacing: -0.025em;
  margin-bottom: var(--sp-24);
  padding-bottom: var(--sp-12);
  border-bottom: 1px solid var(--color-pale-granite);
}

.ds-section {
  background: var(--color-surface-white);
  border: 1px solid var(--color-pale-granite);
  border-radius: var(--radius-sm);
  padding: var(--sp-24);
  margin-bottom: var(--sp-24);
}

/* ── Form Elements ───────────────────────────────────────────── */
.ds-form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
  margin-bottom: var(--sp-16);
}

.ds-label {
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  color: var(--color-graphite-grey);
}

.ds-input,
.ds-select,
.ds-textarea {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--color-charcoal-black);
  background: var(--color-surface-white);
  border: 1px solid var(--color-pale-granite);
  border-radius: var(--radius-sm);
  padding: var(--sp-8) var(--sp-12);
  width: 100%;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
  line-height: 1.5;
}
.ds-input:focus,
.ds-select:focus,
.ds-textarea:focus {
  border-color: var(--color-sky-blue);
  box-shadow: 0 0 0 3px rgba(47,128,250,0.1);
}
.ds-input:disabled,
.ds-textarea:disabled {
  background: var(--color-canvas-sand);
  color: var(--color-ash-grey);
  cursor: not-allowed;
}
.ds-textarea { resize: vertical; min-height: 80px; }

.ds-input-group {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--color-pale-granite);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.ds-input-group:focus-within {
  border-color: var(--color-sky-blue);
  box-shadow: 0 0 0 3px rgba(47,128,250,0.1);
}
.ds-input-group-prefix,
.ds-input-group-suffix {
  background: var(--color-canvas-sand);
  color: var(--color-ash-grey);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  padding: var(--sp-8) var(--sp-12);
  border: none;
  display: flex;
  align-items: center;
  white-space: nowrap;
}
.ds-input-group-prefix { border-right: 1px solid var(--color-pale-granite); }
.ds-input-group-suffix { border-left: 1px solid var(--color-pale-granite); }
.ds-input-group .ds-input-bare {
  border: none;
  border-radius: 0;
  flex: 1;
  outline: none;
  padding: var(--sp-8) var(--sp-12);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--color-charcoal-black);
  background: transparent;
  width: 0;
  min-width: 0;
}

/* ── Tabs ────────────────────────────────────────────────────── */
.ds-tabs {
  display: flex;
  border-bottom: 1px solid var(--color-pale-granite);
  gap: 0;
  margin-bottom: var(--sp-24);
}
.ds-tab {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--fw-medium);
  color: var(--color-faded-grey);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: var(--sp-10) var(--sp-16);
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
  white-space: nowrap;
}
.ds-tab:hover { color: var(--color-charcoal-black); }
.ds-tab.active {
  color: var(--color-charcoal-black);
  border-bottom-color: var(--color-sky-blue);
  font-weight: var(--fw-semibold);
}
.ds-tab:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px rgba(47,128,250,0.35);
}

/* ── Dropdown ────────────────────────────────────────────────── */
.ds-dropdown {
  position: relative;
  display: inline-block;
}
/* Invisible bridge that keeps :hover alive as the cursor crosses the gap */
.ds-dropdown::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: calc(var(--sp-6) + 2px);
}
.ds-dropdown-content {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + var(--sp-6));
  background: var(--color-surface-white);
  border: 1px solid var(--color-pale-granite);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  min-width: 180px;
  z-index: 200;
  overflow: hidden;
}
.ds-dropdown:hover .ds-dropdown-content { display: block; }

.ds-dropdown-item {
  display: block;
  width: 100%;
  padding: var(--sp-10) var(--sp-16);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--color-charcoal-black);
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.1s;
  line-height: 1.4;
}
.ds-dropdown-item:hover { background: var(--color-canvas-sand); }
.ds-dropdown-item.danger { color: var(--color-danger); }
.ds-dropdown-item.danger:hover { background: #fef2f2; }
.ds-dropdown-divider {
  height: 1px;
  background: var(--color-pale-granite);
  margin: var(--sp-4) 0;
}
.ds-dropdown-header {
  padding: var(--sp-10) var(--sp-16) var(--sp-6);
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  color: var(--color-ash-grey);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ── Modal ───────────────────────────────────────────────────── */
.ds-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 400;
  align-items: center;
  justify-content: center;
  padding: var(--sp-16);
}
.ds-modal-overlay.open { display: flex; }

.ds-modal {
  background: var(--color-surface-white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
}
.ds-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-20) var(--sp-24) var(--sp-16);
  border-bottom: 1px solid var(--color-pale-granite);
}
.ds-modal-header h3 {
  font-size: var(--text-heading);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.025em;
  margin: 0;
}
.ds-modal-body {
  padding: var(--sp-24);
}
.ds-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-8);
  padding: var(--sp-16) var(--sp-24) var(--sp-20);
  border-top: 1px solid var(--color-pale-granite);
}

/* ── Drawer (slide-in panel) ─────────────────────────────────── */
.ds-drawer {
  position: fixed;
  top: 0;
  right: -400px;
  width: 380px;
  height: 100%;
  background: var(--color-surface-white);
  border-left: 1px solid var(--color-pale-granite);
  box-shadow: -4px 0 24px rgba(0,0,0,0.08);
  z-index: 300;
  display: flex;
  flex-direction: column;
  transition: right 0.25s cubic-bezier(0.4,0,0.2,1);
}
.ds-drawer.open { right: 0; }

.ds-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-16) var(--sp-20);
  border-bottom: 1px solid var(--color-pale-granite);
  flex-shrink: 0;
}
.ds-drawer-header h3 {
  font-size: var(--text-heading);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.025em;
  margin: 0;
}
.ds-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-12) var(--sp-16);
}
.ds-drawer-body.hidden { display: none; }

/* ── Table ───────────────────────────────────────────────────── */
.ds-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.ds-table th {
  text-align: left;
  padding: var(--sp-10) var(--sp-12);
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  color: var(--color-ash-grey);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--color-canvas-sand);
  border-bottom: 1px solid var(--color-pale-granite);
  white-space: nowrap;
}
.ds-table td {
  padding: var(--sp-10) var(--sp-12);
  border-bottom: 1px solid var(--color-pale-granite);
  color: var(--color-charcoal-black);
  vertical-align: middle;
}
.ds-table tbody tr:last-child td { border-bottom: none; }
.ds-table tbody tr:hover td { background: var(--color-canvas-sand); }

/* ── Chip / Tag / Pill ───────────────────────────────────────── */
.ds-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-10);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  border: 1px solid var(--color-pale-granite);
  background: var(--color-surface-white);
  color: var(--color-graphite-grey);
  cursor: pointer;
  user-select: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
}
.ds-chip:hover { background: var(--color-canvas-sand); }
.ds-chip:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(47,128,250,0.35); }
.ds-chip.active {
  background: var(--color-warm-gray-tint);
  border-color: var(--color-warm-gray-tint);
  color: var(--color-ink-black);
}
.ds-chip.selected {
  background: var(--color-sky-blue);
  border-color: var(--color-sky-blue);
  color: #fff;
}

.ds-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--sp-8);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  background: var(--color-warm-gray-tint);
  color: var(--color-graphite-grey);
  white-space: nowrap;
}

/* ── Friend List ─────────────────────────────────────────────── */
.ds-friend-item {
  display: flex;
  align-items: center;
  gap: var(--sp-10);
  padding: var(--sp-8) var(--sp-6);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s;
}
.ds-friend-item:hover { background: var(--color-canvas-sand); }
.ds-friend-item.active { background: var(--color-canvas-sand); }

.ds-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--color-pale-granite);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  color: var(--color-ash-grey);
}
.ds-avatar img { width: 100%; height: 100%; object-fit: cover; }
.ds-avatar svg { width: 18px; height: 18px; }

.ds-online-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: var(--color-vivid-green);
  display: inline-block;
  flex-shrink: 0;
}

.ds-unread-badge {
  background: var(--color-marigold-yellow);
  color: var(--color-ink-black);
  font-size: 10px;
  font-weight: var(--fw-bold);
  border-radius: var(--radius-full);
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  flex-shrink: 0;
}

/* ── Chat ────────────────────────────────────────────────────── */
.ds-chat-panel {
  border-top: 1px solid var(--color-pale-granite);
  display: flex;
  flex-direction: column;
  height: 320px;
  flex-shrink: 0;
}
.ds-chat-panel.hidden { display: none; }

.ds-chat-header {
  padding: var(--sp-10) var(--sp-16);
  background: var(--color-canvas-sand);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  border-bottom: 1px solid var(--color-pale-granite);
}
.ds-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-12) var(--sp-16);
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
}
.ds-msg-row {
  display: flex;
  flex-direction: column;
  max-width: 80%;
}
.ds-msg-row.me { align-self: flex-end; align-items: flex-end; }
.ds-msg-row.them { align-self: flex-start; align-items: flex-start; }
.ds-msg-bubble {
  padding: var(--sp-6) var(--sp-10);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  line-height: 1.45;
  word-break: break-word;
}
.ds-msg-row.me .ds-msg-bubble { background: var(--color-sky-blue); color: #fff; border-bottom-right-radius: 2px; }
.ds-msg-row.them .ds-msg-bubble { background: var(--color-pale-granite); color: var(--color-charcoal-black); border-bottom-left-radius: 2px; }
.ds-msg-time { font-size: 10px; color: var(--color-ash-grey); margin-top: 2px; padding: 0 2px; }
.ds-msg-media { max-width: 180px; border-radius: var(--radius-md); cursor: pointer; }

.ds-chat-input-row {
  display: flex;
  gap: var(--sp-6);
  padding: var(--sp-8) var(--sp-12);
  border-top: 1px solid var(--color-pale-granite);
  flex-shrink: 0;
  align-items: flex-end;
}
.ds-chat-input-row textarea {
  flex: 1;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  border: 1px solid var(--color-pale-granite);
  border-radius: var(--radius-sm);
  padding: var(--sp-6) var(--sp-10);
  resize: none;
  height: 34px;
  max-height: 100px;
  outline: none;
  transition: border-color 0.12s;
}
.ds-chat-input-row textarea:focus { border-color: var(--color-sky-blue); }

/* ── Toast ───────────────────────────────────────────────────── */
.ds-toast {
  position: fixed;
  bottom: var(--sp-24);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-charcoal-black);
  color: #fff;
  padding: var(--sp-10) var(--sp-20);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  z-index: 900;
  display: none;
  pointer-events: none;
  border-left: 3px solid var(--color-marigold-yellow);
}

/* ── Section label / Divider ─────────────────────────────────── */
.ds-section-label {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  color: var(--color-ash-grey);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: var(--sp-16) 0 var(--sp-8) var(--sp-4);
}

.ds-empty {
  text-align: center;
  color: var(--color-ash-grey);
  font-size: var(--text-sm);
  padding: var(--sp-24) 0;
}

/* ── Invite card ─────────────────────────────────────────────── */
.ds-invite-card {
  background: var(--color-canvas-sand);
  border: 1px solid var(--color-pale-granite);
  border-radius: var(--radius-sm);
  padding: var(--sp-12) var(--sp-16);
  margin-bottom: var(--sp-8);
}

/* ── Status dot text ─────────────────────────────────────────── */
.ds-status {
  font-size: 11px;
  color: var(--color-ash-grey);
  display: flex;
  align-items: center;
  gap: 4px;
}
.ds-status.online { color: var(--color-vivid-green); }

/* ── Search row ──────────────────────────────────────────────── */
.ds-search-row {
  display: flex;
  gap: var(--sp-8);
  margin-bottom: var(--sp-12);
}
.ds-search-row .ds-input { flex: 1; }

/* ── Utility ─────────────────────────────────────────────────── */
.ds-hidden { display: none !important; }

.ds-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-16);
}

.ds-flex-row {
  display: flex;
  gap: var(--sp-8);
  align-items: center;
  flex-wrap: wrap;
}

/* ── Lucide icon sizing helper ───────────────────────────────── */
.icon-sm svg { width: 14px; height: 14px; }
.icon-md svg { width: 18px; height: 18px; }
.icon-lg svg { width: 24px; height: 24px; }
.icon-xl svg { width: 32px; height: 32px; }

/* ── Scrollable table wrapper ────────────────────────────────── */
.ds-table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-pale-granite);
}
.ds-table-wrap .ds-table { margin: 0; }

/* ── Call Modal (full-screen WebRTC) ─────────────────────────── */
.ds-call-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 800;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.ds-call-modal.open { display: flex; }

.ds-call-controls {
  position: absolute;
  bottom: var(--sp-24);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: var(--sp-16);
  z-index: 3;
}
.ds-call-ctrl-btn {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
}
.ds-call-ctrl-btn.gray { background: rgba(255,255,255,0.2); color: #fff; }
.ds-call-ctrl-btn.gray:hover { background: rgba(255,255,255,0.35); }
.ds-call-ctrl-btn.red { background: var(--color-danger); color: #fff; }
.ds-call-ctrl-btn.red:hover { background: var(--color-danger-hover); }
.ds-call-ctrl-btn.active { background: rgba(255,255,255,0.45); }
.ds-call-ctrl-btn svg { width: 22px; height: 22px; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .ds-navbar { padding: var(--sp-10) var(--sp-16); }
  .ds-page { padding: var(--sp-16) var(--sp-12); }
  .ds-card { padding: var(--sp-16); }
  .ds-section { padding: var(--sp-16); }
  .ds-modal { max-width: 100%; border-radius: var(--radius-md) var(--radius-md) 0 0; }
  .ds-modal-overlay { align-items: flex-end; padding: 0; }
  .ds-drawer { width: 100%; right: -100%; }
  .ds-grid-2 { grid-template-columns: 1fr; }
  .ds-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

