/*
 * SoulBridge AI - application shell.
 *
 * One design system across the home, chat and auth screens. Each character has
 * an accent, set per-scope as --accent, but the surfaces, spacing and type stay
 * identical so five characters read as one platform rather than five apps.
 *
 * Glow is deliberately restrained: a soft accent shadow on the focused or
 * hovered element, never ambient neon on everything.
 */

:root {
  /* Ground: dark navy rather than pure black, so panels can sit above it. */
  --bg:            #080b14;
  --bg-raised:     #0e1420;
  --panel:         #121a28;
  --panel-hover:   #172032;
  --line:          #1f2b3d;
  --line-strong:   #2b3a52;

  --text:          #e6edf6;
  --text-dim:      #9aabc0;
  --text-faint:    #647893;

  /* Platform accent. Characters override --accent within their own scope. */
  --accent:        #22d3ee;
  --accent-dim:    #0e7490;

  --danger:        #f87171;
  --danger-bg:     #2a1416;
  --ok:            #4ade80;

  --radius:        14px;
  --radius-sm:     9px;
  --gap:           18px;

  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

/* Keyboard focus must always be visible - several legacy screens removed it. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------------------------------------------------------------- app bar */

.sb-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 22px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
}

.sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.sb-mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #22d3ee, #6366f1);
  color: #04121a;
  font-weight: 800;
  font-size: 0.78rem;
  flex: none;
}

.sb-bar-spacer { flex: 1; }

.sb-bar nav { display: flex; align-items: center; gap: 6px; }

.sb-navlink {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.92rem;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
}
.sb-navlink:hover { color: var(--text); background: var(--panel); }

/* ---------------------------------------------------------------- layout */

.sb-page { max-width: 1140px; margin: 0 auto; padding: 34px 22px 72px; }

.sb-hello { margin: 0 0 4px; font-size: 1.85rem; font-weight: 700; letter-spacing: -0.02em; }
.sb-sub { margin: 0 0 30px; color: var(--text-dim); font-size: 1.02rem; }

.sb-section-label {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 34px 0 12px;
  font-weight: 600;
}

/* ------------------------------------------------------------- guide card */

.sb-guide {
  display: flex;
  align-items: center;
  gap: 20px;
  background: linear-gradient(135deg, rgba(56,189,248,0.10), rgba(99,102,241,0.06));
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 20px 22px;
}

.sb-guide-art {
  width: 76px; height: 76px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #38bdf8;
  background: var(--panel);
  flex: none;
}

.sb-guide-body { flex: 1; min-width: 0; }
.sb-guide h2 { margin: 0; font-size: 1.15rem; color: #7dd3fc; }
.sb-guide .role {
  margin: 1px 0 7px;
  font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-faint); font-weight: 600;
}
.sb-guide p { margin: 0 0 14px; color: var(--text-dim); font-size: 0.94rem; }
.sb-guide-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ------------------------------------------------------------- specialists */

.sb-grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.sb-card {
  --accent: #22d3ee;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 20px;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.sb-card:hover {
  background: var(--panel-hover);
  border-color: var(--line-strong);
  border-top-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}

.sb-card-head { display: flex; align-items: center; gap: 12px; }
.sb-card-art {
  width: 46px; height: 46px; border-radius: 11px;
  object-fit: cover; background: var(--bg-raised);
  border: 1px solid var(--line);
  flex: none;
}
.sb-card h3 { margin: 0; font-size: 1.06rem; color: var(--accent); }
.sb-card .role {
  margin: 0;
  font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-faint); font-weight: 600;
}
.sb-card p { margin: 0; color: var(--text-dim); font-size: 0.9rem; }

.sb-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.sb-tag {
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  color: var(--text-faint);
}

/* ---------------------------------------------------------------- buttons */

.sb-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--text);
  font: inherit; font-size: 0.92rem; font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}
.sb-btn:hover { background: var(--panel-hover); border-color: var(--accent); }

.sb-btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  border-color: transparent;
  color: #04121a;
  font-weight: 600;
}
.sb-btn-primary:hover { filter: brightness(1.08); }

.sb-btn-danger { border-color: #7f2427; color: var(--danger); background: var(--danger-bg); }
.sb-btn-danger:hover { background: #3a1a1d; border-color: var(--danger); }

.sb-btn-sm { padding: 5px 11px; font-size: 0.84rem; }

/* ------------------------------------------------------- recent list */

.sb-list { display: flex; flex-direction: column; gap: 8px; }

.sb-item {
  display: flex; align-items: center; gap: 13px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent, var(--line-strong));
  border-radius: var(--radius-sm);
  padding: 12px 15px;
}
.sb-item:hover { background: var(--panel-hover); }
.sb-item-main { flex: 1; min-width: 0; }
.sb-item-title {
  margin: 0; font-size: 0.95rem; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sb-item-meta { margin: 2px 0 0; font-size: 0.78rem; color: var(--text-faint); }
.sb-item-actions { display: flex; gap: 6px; flex: none; }

.sb-empty {
  padding: 26px;
  text-align: center;
  color: var(--text-faint);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  font-size: 0.92rem;
}

/* ---------------------------------------------------------------- auth */

.sb-auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}
.sb-auth {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 32px 28px;
}
.sb-auth-brand { text-align: center; margin-bottom: 24px; }
.sb-auth-brand .sb-mark { width: 44px; height: 44px; font-size: 1rem; margin: 0 auto 12px; }
.sb-auth-brand h1 { margin: 0 0 4px; font-size: 1.4rem; letter-spacing: -0.02em; }
.sb-auth-brand p { margin: 0; color: var(--text-dim); font-size: 0.92rem; }

.sb-field { margin-bottom: 15px; }
.sb-field label {
  display: block; margin-bottom: 6px;
  font-size: 0.85rem; color: var(--text-dim); font-weight: 500;
}
.sb-field input {
  width: 100%;
  padding: 11px 13px;
  background: var(--bg-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit; font-size: 0.95rem;
}
.sb-field input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(34,211,238,.14); }

.sb-auth .sb-btn-primary { width: 100%; justify-content: center; padding: 11px; margin-top: 4px; }
.sb-auth-alt { margin-top: 18px; text-align: center; font-size: 0.9rem; color: var(--text-dim); }
.sb-auth-links { margin-top: 10px; text-align: center; font-size: 0.86rem; }

.sb-msg { padding: 10px 13px; border-radius: var(--radius-sm); font-size: 0.88rem; margin-bottom: 15px; }
.sb-msg-error { background: var(--danger-bg); border: 1px solid #7f2427; color: #fca5a5; }
.sb-msg-ok { background: #0d2818; border: 1px solid #166534; color: #86efac; }

/* ---------------------------------------------------------------- chat */

.sb-chat { display: flex; height: calc(100vh - 53px); overflow: hidden; }

.sb-side {
  width: 268px; flex: none;
  background: var(--bg-raised);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
}
.sb-side-head { padding: 14px; border-bottom: 1px solid var(--line); }
.sb-side-head .sb-btn { width: 100%; justify-content: center; }
.sb-side-list { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 5px; }

.sb-conv {
  display: block; width: 100%; text-align: left;
  background: none; border: 1px solid transparent;
  border-left: 3px solid var(--accent, var(--line-strong));
  border-radius: var(--radius-sm);
  padding: 9px 11px; color: var(--text-dim);
  font: inherit; font-size: 0.87rem; cursor: pointer;
}
.sb-conv:hover { background: var(--panel); color: var(--text); }
.sb-conv.active { background: var(--panel); color: var(--text); border-color: var(--line-strong); border-left-color: var(--accent); }
.sb-conv-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-conv-meta { font-size: 0.72rem; color: var(--text-faint); margin-top: 1px; }

.sb-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.sb-chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-raised);
}
.sb-chat-art { width: 38px; height: 38px; border-radius: 10px; object-fit: cover; border: 1px solid var(--line); flex: none; }
.sb-chat-who { flex: 1; min-width: 0; }
.sb-chat-who h2 { margin: 0; font-size: 1rem; color: var(--accent); }
.sb-chat-who p { margin: 0; font-size: 0.78rem; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sb-thread { flex: 1; overflow-y: auto; padding: 22px 20px; display: flex; flex-direction: column; gap: 14px; }

.sb-msg-row { display: flex; gap: 10px; max-width: 760px; }
.sb-msg-row.me { align-self: flex-end; flex-direction: row-reverse; }

.sb-bubble {
  padding: 11px 15px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 0.94rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.sb-msg-row.me .sb-bubble {
  background: linear-gradient(135deg, rgba(34,211,238,.14), rgba(99,102,241,.12));
  border-color: var(--line-strong);
}

.sb-composer { border-top: 1px solid var(--line); padding: 14px 20px; background: var(--bg-raised); }
.sb-composer form { display: flex; gap: 10px; align-items: flex-end; }
.sb-composer textarea {
  flex: 1;
  min-height: 46px; max-height: 180px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--text); font: inherit; font-size: 0.94rem;
  resize: vertical;
}
.sb-composer textarea:focus { border-color: var(--accent); outline: none; }
.sb-hint { margin: 7px 0 0; font-size: 0.76rem; color: var(--text-faint); min-height: 1.1em; }
.sb-hint.error { color: var(--danger); }

.sb-typing { color: var(--text-faint); font-size: 0.88rem; font-style: italic; }

/* --------------------------------------------------------------- mobile */

.sb-side-toggle { display: none; }

@media (max-width: 820px) {
  .sb-page { padding: 24px 16px 60px; }
  .sb-hello { font-size: 1.5rem; }

  .sb-guide { flex-direction: column; align-items: flex-start; gap: 14px; }
  .sb-guide-art { width: 60px; height: 60px; }

  .sb-grid { grid-template-columns: 1fr; }

  /* The history rail slides over the thread rather than squeezing it. */
  .sb-side-toggle { display: inline-flex; }
  .sb-side {
    position: fixed; top: 53px; bottom: 0; left: 0; z-index: 30;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.5);
  }
  .sb-side.open { transform: translateX(0); }

  .sb-thread { padding: 16px 14px; }

  /* Not 100%: at full width both sides fill the column and align-self has no
     visible effect, so you cannot tell your own messages from the reply. */
  .sb-msg-row { max-width: 88%; }

  .sb-composer { padding: 11px 14px; }

  .sb-bar { padding: 10px 12px; gap: 10px; }
  .sb-bar nav { gap: 2px; }
  .sb-bar nav .sb-navlink { padding: 6px 8px; font-size: 0.84rem; white-space: nowrap; }
  /* The SB mark alone carries the brand once space is tight; the wordmark was
     wrapping onto two lines and pushing the nav out of shape. */
  .sb-brand { font-size: 0; gap: 0; }
  .sb-brand .sb-mark { font-size: 0.78rem; }
}

@media (max-width: 420px) {
  .sb-bar nav .sb-navlink { padding: 6px 6px; font-size: 0.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .sb-card:hover { transform: none; }
}
