/* ═══════════════════════════════════════════════════════════════
   Relay — design system (from DESIGN.md, "Raycast-design-analysis")
   Dark-only. Surface ladder for elevation. Hairline borders.
   White CTA pill. Inter with ss03. No drop shadows.
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

:root {
  /* Brand & primary */
  --primary: #ffffff;
  --primary-pressed: #e8e8e8;
  --on-primary: #000000;

  /* Surface ladder */
  --canvas: #07080a;
  --surface: #0d0d0d;
  --surface-elevated: #101111;
  --surface-card: #121212;
  --button-fg: #18191a;

  /* Hairlines */
  --hairline: #242728;
  --hairline-soft: rgba(255, 255, 255, 0.08);
  --hairline-strong: rgba(255, 255, 255, 0.16);

  /* Text */
  --ink: #f4f4f6;
  --body: #cdcdcd;
  --charcoal: #d3d3d4;
  --mute: #9c9c9d;
  --ash: #6a6b6c;
  --stone: #434345;
  --on-dark: #ffffff;
  --on-dark-mute: rgba(255, 255, 255, 0.72);

  /* Accents (illustration only) */
  --accent-blue: #57c1ff;   --accent-blue-soft: rgba(87, 193, 255, 0.15);
  --accent-red: #ff6161;    --accent-red-soft: rgba(255, 97, 97, 0.15);
  --accent-green: #59d499;  --accent-green-soft: rgba(89, 212, 153, 0.15);
  --accent-yellow: #ffc533; --accent-yellow-soft: rgba(255, 197, 51, 0.15);

  /* Hero stripe gradient */
  --hero-stripe-start: #ff5757;
  --hero-stripe-end: #a1131a;
  --key-bg-start: #121212;
  --key-bg-end: #0d0d0d;

  /* Radii */
  --r-xs: 4px; --r-sm: 6px; --r-md: 8px; --r-lg: 10px; --r-xl: 16px; --r-full: 9999px;

  /* Spacing */
  --s-xxs: 2px; --s-xs: 4px; --s-sm: 8px; --s-md: 12px; --s-lg: 16px;
  --s-xl: 24px; --s-xxl: 32px; --s-section: 96px;
}

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

html, body { height: 100%; }

body {
  font-family: 'Inter', 'Inter Fallback', system-ui, sans-serif;
  font-feature-settings: "calt", "kern", "liga", "ss03"; /* signature ss03 */
  background: var(--canvas);
  color: var(--body);
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { color: var(--ink); font-weight: 500; letter-spacing: 0.2px; }
a { color: var(--on-dark); text-decoration: none; }
a:focus-visible { text-decoration: underline; }

/* ── Typography helpers ──────────────────────────────────── */
.display-xl { font-size: 64px; font-weight: 600; line-height: 1.1; letter-spacing: 0; color: var(--ink); }
.display-lg { font-size: 56px; font-weight: 500; line-height: 1.17; }
.heading-xl { font-size: 24px; font-weight: 500; line-height: 1.6; }
.heading-md { font-size: 20px; font-weight: 500; line-height: 1.4; }
.heading-sm { font-size: 18px; font-weight: 500; line-height: 1.4; }
.body-md { font-size: 16px; }
.body-sm { font-size: 14px; color: var(--body); }
.caption { font-size: 13px; color: var(--mute); letter-spacing: 0.1px; }
.caption-sm { font-size: 12px; color: var(--mute); letter-spacing: 0.4px; }
.mute { color: var(--mute); }
.ash { color: var(--ash); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  font: 500 14px/1.6 'Inter', sans-serif;
  letter-spacing: 0.2px;
  border-radius: var(--r-md);
  padding: 8px 16px;
  min-height: 36px;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background-color .12s ease, border-color .12s ease, opacity .12s ease;
}
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:active { background: var(--primary-pressed); }
.btn-secondary { background: transparent; color: var(--on-dark); }
.btn-secondary:hover { background: var(--surface-elevated); }
.btn-tertiary { background: var(--surface-elevated); color: var(--on-dark); border-color: var(--hairline); }
.btn-tertiary:hover { border-color: var(--hairline-strong); }
.btn[disabled] { background: var(--surface-elevated); color: var(--ash); cursor: not-allowed; }
.btn-full { width: 100%; }
.btn-sm { min-height: 32px; padding: 6px 14px; }

.install-btn {
  background: transparent; color: var(--on-dark);
  border: 1px solid var(--hairline-strong); border-radius: var(--r-md);
  padding: 6px 14px; font: 500 14px/1.6 'Inter'; cursor: pointer;
}

/* ── Inputs ──────────────────────────────────────────────── */
.input, .textarea {
  width: 100%;
  background: var(--surface-elevated);
  color: var(--on-dark);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 8px 12px;
  min-height: 36px;
  font: 400 16px/1.6 'Inter';
  font-feature-settings: "calt", "kern", "liga", "ss03";
}
.textarea { resize: none; min-height: 44px; }
.input::placeholder, .textarea::placeholder { color: var(--ash); }
.input:focus, .textarea:focus { outline: none; border-color: var(--hairline-strong); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--s-lg); }
.field label { font-size: 14px; font-weight: 500; color: var(--body); letter-spacing: 0.2px; }

/* ── Badges / pills ──────────────────────────────────────── */
.badge {
  background: var(--surface-elevated); color: var(--on-dark-mute);
  font-size: 12px; letter-spacing: 0.4px; padding: 2px 6px; border-radius: var(--r-xs);
}
.badge-info { background: var(--accent-blue-soft); color: var(--accent-blue); padding: 2px 8px; }
.badge-green { background: var(--accent-green-soft); color: var(--accent-green); padding: 2px 8px; }

.pill {
  background: transparent; color: var(--body); border: none;
  font-size: 14px; padding: 4px 10px; border-radius: var(--r-full); cursor: pointer;
}
.pill.active { background: var(--surface-elevated); color: var(--on-dark); }

/* Keycap */
.keycap {
  display: inline-flex; align-items: center; height: 20px; padding: 1px 6px;
  background: linear-gradient(var(--key-bg-start), var(--key-bg-end));
  color: var(--body); font-size: 13px; border-radius: var(--r-xs);
  border: 1px solid var(--hairline);
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-lg); padding: var(--s-xl);
}
.card-elevated { background: var(--surface-elevated); }

/* Avatar */
.avatar {
  border-radius: var(--r-full); background: var(--surface-card);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--mute); font-weight: 500; overflow: hidden; flex: none;
  object-fit: cover;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-32 { width: 32px; height: 32px; font-size: 13px; }
.avatar-40 { width: 40px; height: 40px; font-size: 15px; }
.avatar-48 { width: 48px; height: 48px; font-size: 16px; }
.avatar-64 { width: 64px; height: 64px; font-size: 20px; }

/* ═══════════════ Auth (landing) ═══════════════ */
.hero-band {
  position: relative; background: var(--canvas); overflow: hidden;
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: var(--s-section) 48px;
}
/* Signature red diagonal stripe gradient — once, at the top of the hero */
.hero-band::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 46%;
  background:
    repeating-linear-gradient(
      115deg,
      transparent 0 60px,
      var(--hero-stripe-start) 60px 120px,
      var(--hero-stripe-end) 120px 190px,
      transparent 190px 250px
    );
  opacity: 0.5;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0%, transparent 100%);
  pointer-events: none;
}
.auth-wrap { position: relative; z-index: 1; width: 100%; max-width: 420px; }
.brand-mark { display: flex; align-items: center; gap: 10px; margin-bottom: var(--s-xl); }
.brand-mark .logo {
  width: 34px; height: 34px; border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--hero-stripe-start), var(--hero-stripe-end));
  display: grid; place-items: center; color: #fff; font-weight: 600;
}
.brand-mark .name { font-size: 20px; font-weight: 600; color: var(--ink); letter-spacing: 0.2px; }
.auth-card { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-xl); padding: 28px; }
.auth-card h1 { font-size: 24px; margin-bottom: 6px; }
.auth-sub { color: var(--mute); font-size: 14px; margin-bottom: var(--s-xl); }
.auth-switch { text-align: center; margin-top: var(--s-lg); color: var(--mute); font-size: 14px; }
.auth-switch button { background: none; border: none; color: var(--on-dark); cursor: pointer; font: inherit; font-weight: 500; }
.form-error { background: var(--accent-red-soft); color: var(--accent-red); font-size: 13px; padding: 8px 12px; border-radius: var(--r-sm); margin-bottom: var(--s-lg); display: none; }
.form-error.show { display: block; }

/* ═══════════════ App shell ═══════════════ */
.app { display: grid; grid-template-columns: 300px 1fr; height: 100vh; }

/* Sidebar */
.sidebar { background: var(--surface); border-right: 1px solid var(--hairline); display: flex; flex-direction: column; min-height: 0; }
.sidebar-head { height: 56px; display: flex; align-items: center; justify-content: space-between; padding: 0 var(--s-lg); border-bottom: 1px solid var(--hairline); }
.sidebar-nav { display: flex; gap: 4px; padding: var(--s-md) var(--s-lg) 0; flex-wrap: wrap; }
.sidebar-search { padding: var(--s-md) var(--s-lg); }
.chat-list { flex: 1; overflow-y: auto; padding: 0 var(--s-sm) var(--s-lg); min-height: 0; }
.chat-row {
  display: flex; gap: var(--s-md); align-items: center; padding: 10px 8px;
  border-radius: var(--r-sm); cursor: pointer;
}
.chat-row:hover { background: var(--surface-card); }
.chat-row.active { background: var(--surface-card); }
.chat-row .meta { min-width: 0; flex: 1; }
.chat-row .title { color: var(--on-dark); font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-row .preview { color: var(--mute); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Sidebar footer / current user */
.sidebar-foot { border-top: 1px solid var(--hairline); padding: var(--s-md); display: flex; align-items: center; gap: var(--s-md); cursor: pointer; }
.sidebar-foot:hover { background: var(--surface-card); }
.sidebar-foot .meta { flex: 1; min-width: 0; }
.sidebar-foot .u { color: var(--on-dark); font-size: 14px; font-weight: 500; }

/* Verify banner */
.verify-banner {
  margin: var(--s-md) var(--s-lg); padding: var(--s-md);
  background: var(--surface-elevated); border: 1px solid var(--hairline);
  border-radius: var(--r-md); font-size: 13px; color: var(--body);
}
.verify-banner .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; }
.progress { height: 4px; background: var(--surface-card); border-radius: var(--r-full); overflow: hidden; margin-top: 6px; }
.progress > i { display: block; height: 100%; background: var(--accent-green); }

/* Main pane */
.main { display: flex; flex-direction: column; min-width: 0; background: var(--canvas); }
.main-head { height: 56px; border-bottom: 1px solid var(--hairline); display: flex; align-items: center; gap: var(--s-md); padding: 0 var(--s-xl); }
.main-head .title { color: var(--ink); font-size: 16px; font-weight: 500; }
.main-head .sub { color: var(--mute); font-size: 13px; }
.head-actions { margin-left: auto; display: flex; gap: 8px; }

/* Messages */
.messages { flex: 1; overflow-y: auto; padding: var(--s-xl); display: flex; flex-direction: column; gap: var(--s-md); }
.msg { display: flex; gap: var(--s-md); max-width: 720px; }
.msg .bubble { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-lg); padding: 10px 14px; color: var(--body); }
.msg .bubble .name { font-size: 13px; font-weight: 500; color: var(--on-dark); margin-bottom: 2px; }
.msg .bubble .time { font-size: 12px; color: var(--ash); margin-top: 4px; }
.msg.me { flex-direction: row-reverse; margin-left: auto; }
.msg.me .bubble { background: var(--surface-elevated); }
.msg.system { justify-content: center; max-width: none; }
.msg.system .bubble { background: transparent; border: none; color: var(--mute); font-size: 13px; text-align: center; }
.msg .file-att { display: flex; align-items: center; gap: 10px; }
.msg img.att { max-width: 320px; border-radius: var(--r-md); border: 1px solid var(--hairline); }

/* Composer */
.composer { border-top: 1px solid var(--hairline); padding: var(--s-md) var(--s-xl); display: flex; gap: var(--s-sm); align-items: flex-end; }
.composer .textarea { flex: 1; max-height: 160px; }
.icon-btn { width: 36px; height: 36px; border-radius: var(--r-md); background: var(--surface-elevated); border: 1px solid var(--hairline); color: var(--body); cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { border-color: var(--hairline-strong); }

/* Empty / centered states */
.empty { flex: 1; display: grid; place-items: center; text-align: center; color: var(--mute); padding: var(--s-section); }
.empty .heading-md { color: var(--ink); margin-bottom: 6px; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: none; align-items: center; justify-content: center; z-index: 50; padding: 24px; }
.modal-backdrop.show { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-xl); padding: var(--s-xl); width: 100%; max-width: 460px; max-height: 86vh; overflow-y: auto; }
.modal h2 { font-size: 20px; margin-bottom: var(--s-lg); }
.modal-close { float: right; background: none; border: none; color: var(--mute); font-size: 20px; cursor: pointer; }

/* Search result rows */
.result-row { display: flex; gap: var(--s-md); align-items: center; padding: 8px; border-radius: var(--r-sm); cursor: pointer; }
.result-row:hover { background: var(--surface-card); }

/* Broadcast / discover cards */
.bc-card { display: flex; gap: var(--s-md); align-items: center; padding: var(--s-lg); background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-md); margin-bottom: var(--s-md); }
.bc-card .meta { flex: 1; min-width: 0; }

/* Toggle switch */
.toggle { position: relative; width: 40px; height: 24px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .track { position: absolute; inset: 0; background: var(--surface-card); border: 1px solid var(--hairline); border-radius: var(--r-full); transition: .15s; }
.toggle .track::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: var(--mute); border-radius: var(--r-full); transition: .15s; }
.toggle input:checked + .track { background: var(--accent-green-soft); border-color: var(--accent-green); }
.toggle input:checked + .track::before { transform: translateX(16px); background: var(--accent-green); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-lg); padding: var(--s-md) 0; border-bottom: 1px solid var(--hairline); }
.setting-row .label { font-size: 14px; color: var(--on-dark); font-weight: 500; }
.setting-row .desc { font-size: 13px; color: var(--mute); }

/* Toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--surface-elevated); border: 1px solid var(--hairline-strong); color: var(--on-dark); padding: 10px 16px; border-radius: var(--r-md); font-size: 14px; z-index: 100; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }

/* Segmented (de/en, chat type) */
.segmented { display: inline-flex; background: var(--surface-card); border: 1px solid var(--hairline); border-radius: var(--r-full); padding: 3px; gap: 2px; }

.hidden { display: none !important; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--hairline-strong); border-top-color: var(--on-dark); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-thumb { background: var(--stone); border-radius: var(--r-full); border: 3px solid var(--surface); }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .app.show-list .sidebar { display: flex; }
  .app.show-list .main { display: none; }
  .display-xl { font-size: 40px; }
}
