*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }

:root {
  --font-display: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:    'IBM Plex Mono', ui-monospace, monospace;

  /* Dark theme (default) */
  --bg:           #0a0a0e;
  --surface:      #131319;
  --surface-hover:#191a22;
  --line:         rgba(255,255,255,0.09);
  --line-strong:  rgba(255,255,255,0.20);
  --ink:          #eef0f4;
  --ink-dim:      #8d90a0;
  --ink-faint:    #787c93;
  --red:          #ff2a5f;
  --red-solid:    #d1123f;
  --red-solid-hov:#b30f37;
  --red-dim:      rgba(255,42,95,0.16);
  --rail:         #363a63;
  --success:      #22c07d;
  --radius:       12px;
  --radius-sm:    8px;
}

[data-theme="light"] {
  --bg:           #f7f5f1;
  --surface:      #ffffff;
  --surface-hover:#f2f0ec;
  --line:         rgba(0,0,0,0.09);
  --line-strong:  rgba(0,0,0,0.20);
  --ink:          #111118;
  --ink-dim:      #555770;
  --ink-faint:    #888aa0;
  --red:          #d1123f;
  --red-solid:    #d1123f;
  --red-solid-hov:#b30f37;
  --red-dim:      rgba(209,18,63,0.12);
  --rail:         #c8c6be;
  --success:      #15803d;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration:0.01ms !important; transition-duration:0.01ms !important; }
}

::selection { background: var(--red-dim); color: var(--ink); }

html { font-size:15px; scroll-behavior:smooth; }

@media (min-width: 768px) { html { font-size: 16px; } }

body {
  font-family: var(--font-mono);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  padding: 48px 16px 64px;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s, color 0.25s;
  overflow-x: hidden;
}

/* ── Sheet (main container) ── */
.sheet {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
}

/* ── Rail grid ── */
.rail-row {
  display: grid;
  grid-template-columns: 20px 1fr;
  column-gap: 20px;
}

.rail-col {
  position: relative;
  display: flex;
  justify-content: center;
}

.rail-line {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--rail);
  transform: translateX(-50%);
}

.rail-row--root .rail-line { top: 44px; }

.rail-row--last .rail-line {
  bottom: auto;
  height: 28px;
}

.rail-node {
  position: absolute;
  left: 50%;
  top: 6px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--bg);
  border: 1.5px solid var(--red);
  transform: translateX(-50%);
  z-index: 1;
}

.content-col {
  padding-bottom: 40px;
  min-width: 0;
}

.rail-row--last .content-col { padding-bottom: 0; }

/* ── Identity block ── */
.id-col { padding-top: 0; }

.id-block {
  display: flex;
  align-items: center;
  gap: 20px;
  padding-bottom: 48px;
}

/* ── Avatar ── */
.avatar-wrap {
  position: relative;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.avatar-wrap::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1.5px dashed var(--red);
  opacity: 0.55;
  animation: spinRing 22s linear infinite;
  pointer-events: none;
}

@keyframes spinRing {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.avatar-wrap:hover::after { opacity: 0.9; border-style: solid; }

.avatar-img {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

/* Theme badge */
.theme-badge {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-dim);
  pointer-events: none;
  transition: border-color 0.2s;
}

.avatar-wrap:hover .theme-badge { border-color: var(--red); color: var(--red); }

/* Dark mode → show moon; Light mode → show sun */
.badge-sun  { display: none; }
.badge-moon { display: block; }
[data-theme="light"] .badge-sun  { display: block; }
[data-theme="light"] .badge-moon { display: none; }

/* ── Wordmark ── */
.id-text {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wordmark {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1;
}

.glyph-5 {
  font-family: var(--font-mono);
  color: var(--red);
}

.bio {
  font-size: 0.82rem;
  color: var(--ink-dim);
  line-height: 1.65;
  font-weight: 400;
}

/* ── Eyebrow ── */
.eyebrow {
  font-size: 0.75rem;
  color: var(--ink-faint);
  font-weight: 500;
  letter-spacing: 0.02em;
  margin-bottom: 12px;
}

/* ── Surface card (orgs / channels) ── */
.surface-card,
.channel-list {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

/* ── Intro card ── */
.intro-card {
  padding: 16px 18px;
}

.intro-text {
  font-size: 0.83rem;
  color: var(--ink-dim);
  line-height: 1.7;
  font-family: var(--font-mono);
}

/* ── Rich Formatting Elements (Bio & Intro) ── */
.bio strong,
.intro-text strong {
  font-weight: 600;
  color: var(--ink);
}

.bio em,
.intro-text em {
  font-style: italic;
  color: var(--ink);
}

.bio u,
.intro-text u {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.rich-link {
  color: var(--red);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: opacity 0.18s;
  cursor: pointer;
}

.rich-link:hover {
  opacity: 0.8;
}

.rich-code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface-hover);
  border: 1px solid var(--line);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--red);
}

.rich-quote {
  border-left: 2px solid var(--red);
  padding-left: 10px;
  margin: 6px 0;
  color: var(--ink-faint);
  font-style: italic;
}

/* ── Org rows ── */
.org-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  color: var(--ink-dim);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  transition: background 0.18s, color 0.18s;
}

.org-row:last-child { border-bottom: none; }

.org-row:hover { background: var(--surface-hover); color: var(--ink); }

.org-row-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--line);
}

.project-avatar {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--surface-hover);
  border: 1px solid var(--line-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--ink-dim);
  transition: border-color 0.18s, color 0.18s, background-color 0.18s;
}

.org-row:hover .project-avatar {
  border-color: var(--red);
  color: var(--red);
  background: var(--red-dim);
}

/* ─── Boneyard Pixel-Perfect Skeleton Screen ─── */
.bone-row {
  pointer-events: none;
  cursor: default;
}

.bone {
  background: var(--surface-hover);
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-sm);
}

.bone::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.04) 35%,
    rgba(255, 255, 255, 0.12) 50%,
    rgba(255, 255, 255, 0.04) 65%,
    transparent 100%
  );
  animation: boneyardShimmer 1.7s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

[data-theme="light"] .bone::after {
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(0, 0, 0, 0.02) 35%,
    rgba(0, 0, 0, 0.07) 50%,
    rgba(0, 0, 0, 0.02) 65%,
    transparent 100%
  );
}

@keyframes boneyardShimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.bone-title {
  height: 15px;
  width: 42%;
  border-radius: 4px;
}

.bone-desc {
  height: 11px;
  width: 78%;
  border-radius: 3px;
  margin-top: 4px;
}

.bone-stat-top {
  height: 13px;
  width: 28px;
  border-radius: 3px;
}

.bone-stat-bot {
  height: 10px;
  width: 42px;
  border-radius: 3px;
  margin-top: 4px;
}

.org-row-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.org-row-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  font-family: var(--font-display);
}

.org-row-name .glyph-5 {
  color: var(--red);
  font-family: inherit;
}

.org-row-desc {
  font-size: 0.74rem;
  color: var(--ink-dim);
  line-height: 1.5;
}

.org-row-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
  margin-left: 8px;
}

.org-row-star {
  font-size: 0.8rem;
  color: #22c07d;
  font-weight: 600;
  white-space: nowrap;
}

.org-row-repos {
  font-size: 0.7rem;
  color: var(--ink-faint);
  white-space: nowrap;
}

/* ── Channel rows ── */
.channel-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  color: var(--ink-dim);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  transition: background 0.18s, color 0.18s;
}

.channel-row:last-child { border-bottom: none; }

.channel-row:hover { background: var(--surface-hover); color: var(--ink); }

.channel-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.channel-name {
  font-size: 0.85rem;
  font-weight: 500;
  flex: 1;
}

.channel-arrow {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.45;
  transition: opacity 0.18s, transform 0.18s;
}

.channel-row:hover .channel-arrow {
  opacity: 0.9;
  transform: translate(2px, -2px);
}

/* ── Message ── */
.msg-field {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  margin-bottom: 12px;
  transition: border-color 0.2s;
}

.msg-field:focus-within { border-color: var(--line-strong); }

.msg-field textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  padding: 14px 16px;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.83rem;
  line-height: 1.65;
  resize: vertical;
  min-height: 100px;
  caret-color: var(--red);
}

.msg-field textarea::placeholder { color: var(--ink-faint); }

.msg-hint {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--red);
  margin-top: -4px;
  margin-bottom: 14px;
  line-height: 1.5;
}

/* ── hCaptcha Theme Match ── */
.h-captcha {
  min-height: 78px;
  display: flex;
  justify-content: flex-start;
  margin-bottom: 14px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.h-captcha iframe {
  border-radius: var(--radius-sm) !important;
  max-width: 100% !important;
}

[data-theme="dark"] .h-captcha {
  color-scheme: dark;
}

[data-theme="light"] .h-captcha {
  color-scheme: light;
}

.send-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--red-solid);
  color: #ffffff;
  border: none;
  border-radius: var(--radius);
  padding: 13px 22px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: background 0.2s, transform 0.15s;
  margin-bottom: 10px;
}

.send-btn:hover { background: var(--red-solid-hov); }
.send-btn:active { transform: scale(0.98); }
.send-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.send-btn svg { transition: transform 0.2s; }
.send-btn:hover svg { transform: translateX(3px); }

.status-msg {
  font-size: 0.78rem;
  color: var(--ink-faint);
  min-height: 1.2em;
}

/* ── Footer ── */
.footer-row {
  display: flex;
  justify-content: flex-end;
  padding-top: 28px;
  padding-bottom: 8px;
}

.corner-tag {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-faint);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.02em;
  transition: color 0.18s, border-color 0.18s, background 0.18s, transform 0.18s;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.corner-tag:hover {
  color: var(--ink);
  border-color: var(--red);
  background: var(--surface-hover);
  transform: translateY(-1px);
}

.corner-tag:active {
  transform: scale(0.95);
}

/* ── Android-style Dev Toast ── */
.dev-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(19, 19, 25, 0.95);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 8px 18px;
  border-radius: 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
  z-index: 999;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.dev-toast.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

[data-theme="light"] .dev-toast {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(0, 0, 0, 0.15);
  color: var(--ink);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* ── Modal Overlay & Dialog ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal-dialog {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
  transform: scale(0.96) translateY(12px);
  transition: transform 0.22s ease;
  padding: 22px 20px;
}

.modal-overlay.open .modal-dialog {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 6px;
}

.modal-close-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-dim);
  font-size: 1.25rem;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.modal-close-btn:hover {
  border-color: var(--red);
  color: var(--ink);
  background: var(--surface-hover);
}

/* Auth Denied State */
.auth-denied {
  text-align: center;
  padding: 32px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.auth-denied-icon {
  font-size: 2.2rem;
  line-height: 1;
  margin-bottom: 4px;
}

.auth-denied-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
}

.auth-denied-desc {
  font-size: 0.83rem;
  color: var(--ink-dim);
  max-width: 360px;
  line-height: 1.6;
}

.btn-signout {
  background: var(--surface-hover);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 10px;
}

.btn-signout:hover {
  border-color: var(--red);
  color: var(--red);
}

/* ── Google & Clerk Sign In Buttons ── */
.btn-google-signin {
  width: 100%;
  max-width: 340px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #ffffff;
  color: #1f1f1f;
  border: 1px solid #dadce0;
  border-radius: var(--radius);
  padding: 13px 20px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  transition: background 0.18s, transform 0.15s, box-shadow 0.18s;
  outline: none;
}

.btn-google-signin:hover {
  background: #f8f9fa;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
  transform: translateY(-1px);
}

.btn-google-signin:active {
  transform: scale(0.99);
}

.btn-clerk-more {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-dim);
  border-radius: var(--radius);
  padding: 10px 18px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.18s;
  width: 100%;
  max-width: 340px;
}

.btn-clerk-more:hover {
  border-color: var(--red);
  color: var(--ink);
  background: var(--surface-hover);
}

/* Modal Form Fields */
.m-field-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}

.m-field-label {
  font-size: 0.73rem;
  color: var(--ink-faint);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.m-field-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--ink);
  outline: none;
  transition: border-color 0.18s;
}

.m-field-textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--ink);
  outline: none;
  transition: border-color 0.18s;
  resize: vertical;
}

.m-field-input:focus,
.m-field-textarea:focus {
  border-color: var(--red);
}

.m-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 520px) {
  .m-grid-2 {
    grid-template-columns: 1fr;
  }
}

.m-format-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  background: var(--surface-hover);
  border: 1px solid var(--line);
  border-bottom: none;
  border-top-left-radius: var(--radius-sm);
  border-top-right-radius: var(--radius-sm);
  padding: 4px 6px;
}

.m-toolbar-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-dim);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 3px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.m-toolbar-btn:hover {
  border-color: var(--red);
  color: var(--ink);
  background: var(--surface-hover);
}

.m-textarea-toolbar {
  border-top-left-radius: 0 !important;
  border-top-right-radius: 0 !important;
}

.m-preview-box {
  background: var(--bg);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.8rem;
  color: var(--ink-dim);
  line-height: 1.5;
  margin-top: 4px;
}

.m-save-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--red-solid);
  color: #ffffff;
  border: none;
  border-radius: var(--radius);
  padding: 12px 20px;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 6px;
}

.m-save-btn:hover {
  background: var(--red-solid-hov);
}

/* ── Utility ── */
.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;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  html { font-size: 14px; }
  body { padding: 32px 12px 56px; }
  .rail-row { column-gap: 12px; }
  .id-block { gap: 16px; }
  .avatar-wrap, .avatar-img { width: 84px; height: 84px; }
  .wordmark { font-size: 1.2rem; }
}