/* ── design tokens ─────────────────────────────────────── */
:root {
  --void: #0b0a0d;
  --void-raised: #131116;
  --void-line: #221f26;
  --blood: #8a1930;
  --blood-bright: #c22a45;
  --wraith: #3d1f52;
  --wraith-bright: #6b3d94;
  --bone: #e7e2d8;
  --bone-dim: #8f8a82;
  --eye-gold: #c9a227;
  --eye-gold-glow: rgba(201, 162, 39, 0.35);

  --font-display: "Cormorant SC", "Cinzel", Georgia, serif;
  --font-body: -apple-system, "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--void);
  color: var(--bone);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
::selection { background: var(--blood); color: var(--bone); }

/* ── ambient canvas, sits behind everything ─────────────── */
#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ── app shell — glass panels floating over the canvas ──── */
.app {
  position: relative;
  z-index: 1;
  display: flex;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

.sidebar {
  width: 100%;
  height: 100%;
  background: rgba(19, 17, 22, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-right: 1px solid var(--void-line);
  display: flex;
  flex-direction: column;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 1.1rem 1rem; border-bottom: 1px solid var(--void-line);
}
.sidebar__brand-mark {
  color: var(--eye-gold);
  font-size: 1rem;
  animation: brand-flicker 4200ms ease-in-out infinite;
}
@keyframes brand-flicker {
  0%, 100% { opacity: 0.75; text-shadow: 0 0 4px var(--eye-gold-glow); }
  50% { opacity: 1; text-shadow: 0 0 10px var(--eye-gold-glow); }
}
.sidebar__brand-name {
  font-family: var(--font-display); letter-spacing: 0.2em;
  font-size: 0.95rem;
  background: linear-gradient(120deg, var(--bone) 30%, var(--eye-gold) 50%, var(--bone) 70%);
  background-size: 220% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: brand-sheen 7s linear infinite;
}
@keyframes brand-sheen {
  0% { background-position: 0% 50%; }
  100% { background-position: 220% 50%; }
}

.sidebar__list { list-style: none; margin: 0; padding: 0.4rem; overflow-y: auto; }
.sidebar__list--pinned { flex: 0 0 auto; padding-bottom: 0; }

.sidebar__divider {
  padding: 0.55rem 1rem 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--bone-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-top: 1px solid var(--void-line);
  margin-top: 0.3rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar__add-btn {
  background: transparent;
  border: 1px solid var(--void-line);
  color: var(--bone-dim);
  border-radius: 6px;
  width: 20px; height: 20px;
  line-height: 1;
  cursor: pointer;
  font-size: 0.85rem;
}
.sidebar__add-btn:hover { color: var(--eye-gold); border-color: var(--eye-gold); }

#group-channel-list, #channel-list { max-height: 34vh; }

.sidebar-item {
  width: 100%; display: flex; align-items: center; gap: 0.7rem;
  padding: 0.6rem; border: none; background: transparent; border-radius: 10px;
  cursor: pointer; text-align: left; position: relative;
  transition: background 150ms ease;
}
.sidebar-item:hover { background: var(--void-line); }
.sidebar-item--active {
  background: var(--void-line);
  box-shadow: inset 2px 0 0 var(--blood-bright);
}
.sidebar-item__text { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 0.1rem; }
.sidebar-item__name-row { display: flex; align-items: center; gap: 0.35rem; }
.sidebar-item__name { font-family: var(--font-display); font-size: 0.95rem; }
.sidebar-item__preview {
  font-size: 0.78rem; color: var(--bone-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-item__badge {
  background: var(--blood); color: var(--bone); font-family: var(--font-mono);
  font-size: 0.7rem; min-width: 18px; height: 18px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; padding: 0 5px;
  box-shadow: 0 0 6px var(--blood-bright);
}

/* ── mood pill ─────────────────────────────────────────── */
.mood-pill {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.05rem 0.35rem;
  border-radius: 5px;
  border: 1px solid currentColor;
  opacity: 0.85;
}
.mood-content, .mood-affectionate { color: #7fae63; }
.mood-neutral { color: var(--bone-dim); }
.mood-tired { color: #7d90a8; }
.mood-irritable { color: var(--blood-bright); }
.mood-withdrawn { color: var(--wraith-bright); }
.mood-anxious { color: var(--eye-gold); }

/* ── group avatar cluster ─────────────────────────────────── */
.group-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, var(--wraith), var(--void));
  border: 1px solid var(--void-line);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-family: var(--font-display);
  color: var(--eye-gold);
  font-size: 1rem;
}

/* ── eye avatar (signature element) ───────────────────── */
.eye-avatar {
  position: relative; border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, var(--void-raised), var(--void));
  border: 1px solid var(--void-line);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
.eye-avatar__iris {
  width: 62%; height: 62%; border-radius: 50%; background: var(--void);
  border: 1.5px solid var(--iris, var(--wraith-bright));
  display: flex; align-items: center; justify-content: center;
  transition: transform 400ms ease, border-color 600ms ease;
}
.eye-avatar__initial { font-family: var(--font-display); font-size: 0.85em; color: var(--bone-dim); }

.eye-avatar--offline .eye-avatar__iris { transform: scale(0.55); border-color: var(--void-line); }
.eye-avatar--offline .eye-avatar__lid {
  position: absolute; inset: 0;
  background: linear-gradient(var(--void) 50%, transparent 50%); opacity: 0.85;
}
.eye-avatar--away .eye-avatar__half-lid {
  position: absolute; inset: 0;
  background: linear-gradient(var(--void) 30%, transparent 30%); opacity: 0.7;
}
.eye-avatar--online .eye-avatar__iris { border-color: var(--eye-gold); }
.eye-avatar--online .eye-avatar__initial { color: var(--bone); }
.eye-avatar__glow {
  position: absolute; inset: -3px; border-radius: 50%;
  box-shadow: 0 0 10px 1px var(--eye-gold-glow);
  animation: eye-pulse 3200ms ease-in-out infinite;
}
@keyframes eye-pulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }

/* ── chat pane ─────────────────────────────────────────── */
.chat-pane { width: 100%; height: 100%; position: relative; display: flex; flex-direction: column; }
.chat-placeholder {
  margin: auto; color: var(--bone-dim); font-family: var(--font-mono); font-size: 0.85rem;
}
.chat-window {
  display: flex; flex-direction: column; height: 100%;
  background: rgba(11, 10, 13, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.back-button {
  display: none; background: var(--void-raised); color: var(--bone-dim);
  border: none; border-bottom: 1px solid var(--void-line);
  padding: 0.5rem 0.9rem; font-family: var(--font-mono); font-size: 0.75rem;
  text-align: left; cursor: pointer;
}
.chat-header {
  position: relative;
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.7rem 1rem; border-bottom: 1px solid var(--void-line);
  background: rgba(19, 17, 22, 0.6);
}
.chat-header__name-row { display: flex; align-items: center; gap: 0.5rem; }
.chat-header__name { font-family: var(--font-display); font-size: 1.05rem; }
.chat-header__presence {
  font-family: var(--font-mono); font-size: 0.68rem; color: var(--bone-dim);
  text-transform: uppercase; letter-spacing: 0.03em;
}
.profile-button {
  margin-left: auto;
  background: transparent;
  color: var(--bone-dim);
  border: 1px solid var(--void-line);
  border-radius: 8px;
  padding: 0.35rem 0.7rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.profile-button:hover { border-color: var(--eye-gold); color: var(--eye-gold); }

.message-list {
  flex: 1; overflow-y: auto; padding: 0.8rem 0;
  display: flex; flex-direction: column; gap: 0.3rem;
}
.message-list__empty {
  margin: auto; color: var(--bone-dim); font-family: var(--font-mono); font-size: 0.8rem;
}

.bubble-row {
  display: flex; justify-content: flex-start; padding: 0.15rem 1rem;
  animation: bubble-in 220ms ease;
}
@keyframes bubble-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.bubble-row--player { justify-content: flex-end; }
.bubble {
  max-width: 72%; background: rgba(19, 17, 22, 0.9); border: 1px solid var(--void-line);
  border-radius: 12px; padding: 0.5rem 0.75rem; display: flex; flex-direction: column; gap: 0.15rem;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}
.bubble--player {
  background: linear-gradient(135deg, var(--wraith), #2c1740);
  border-color: var(--wraith-bright);
}
.bubble--away { border-style: dashed; border-color: var(--eye-gold); opacity: 0.92; }
.bubble__author { font-family: var(--font-display); font-size: 0.78rem; }
.bubble__body { margin: 0; font-size: 0.92rem; line-height: 1.4; color: var(--bone); }
.bubble__time { font-family: var(--font-mono); font-size: 0.65rem; color: var(--bone-dim); align-self: flex-end; }
.bubble__away-tag { color: var(--eye-gold); }

/* ── composer ──────────────────────────────────────────── */
.composer {
  border-top: 1px solid var(--void-line);
  background: rgba(19, 17, 22, 0.75);
  backdrop-filter: blur(6px);
  padding: 0.6rem 0.8rem calc(0.8rem + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 0.4rem;
}
.composer__row { display: flex; align-items: center; gap: 0.5rem; }
.composer__label {
  font-family: var(--font-mono); font-size: 0.68rem; color: var(--bone-dim);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.composer__select {
  background: var(--void); border: 1px solid var(--void-line); border-radius: 6px;
  padding: 0.2rem 0.4rem; font-family: var(--font-body); font-size: 0.82rem; color: var(--bone);
}
.composer__textarea {
  flex: 1; resize: none; background: var(--void); border: 1px solid var(--void-line);
  border-radius: 10px; color: var(--bone); padding: 0.55rem 0.7rem;
  font-family: var(--font-body); font-size: 0.9rem; max-height: 6rem;
}
.composer__textarea:focus { border-color: var(--wraith-bright); outline: none; }
.composer__send {
  background: var(--blood); color: var(--bone); border: none; border-radius: 10px;
  padding: 0.55rem 0.9rem; font-family: var(--font-mono); font-size: 0.78rem;
  text-transform: uppercase; letter-spacing: 0.04em; cursor: pointer;
  transition: background 150ms ease;
}
.composer__send:disabled { background: var(--void-line); color: var(--bone-dim); cursor: not-allowed; }
.composer__send:not(:disabled):hover { background: var(--blood-bright); }

/* one-on-one: two arrow buttons instead of a picker */
.composer__arrows { display: flex; gap: 0.5rem; }
.composer__arrow-btn {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  background: var(--void); border: 1px solid var(--void-line); border-radius: 10px;
  padding: 0.55rem 0.5rem;
  font-family: var(--font-mono); font-size: 0.72rem;
  color: var(--bone-dim);
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease;
}
.composer__arrow-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.composer__arrow-btn:not(:disabled):hover {
  border-color: var(--iris, var(--eye-gold));
  color: var(--bone);
}
.composer__arrow-btn--you:not(:disabled):hover { background: rgba(61, 31, 82, 0.35); }
.composer__arrow-icon { font-size: 0.9rem; }

:focus-visible { outline: 2px solid var(--eye-gold); outline-offset: 2px; }

/* ── modals ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 50;
  animation: modal-fade 180ms ease;
}
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@media (min-width: 721px) { .modal-overlay { align-items: center; } }
.modal-card {
  background: var(--void-raised);
  border: 1px solid var(--void-line);
  border-top: 2px solid var(--eye-gold);
  border-radius: 14px 14px 0 0;
  width: 100%;
  max-width: 440px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 1rem 1.1rem calc(1.1rem + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
@media (min-width: 721px) { .modal-card { border-radius: 14px; } }
.modal-card__header {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--font-display); font-size: 1rem; color: var(--bone);
}
.modal-card__close { background: transparent; border: none; color: var(--bone-dim); font-size: 0.9rem; cursor: pointer; }
.modal-field { display: flex; flex-direction: column; gap: 0.3rem; }
.modal-field-row { display: flex; gap: 0.6rem; }
.modal-field__label {
  font-family: var(--font-mono); font-size: 0.65rem; color: var(--bone-dim);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.modal-field__input, .modal-field__textarea {
  background: var(--void); border: 1px solid var(--void-line); border-radius: 8px;
  color: var(--bone); padding: 0.5rem 0.6rem; font-family: var(--font-body); font-size: 0.88rem;
}
.modal-field__textarea { resize: vertical; }
.modal-field__input:focus, .modal-field__textarea:focus { border-color: var(--wraith-bright); outline: none; }
.modal-field__color {
  width: 100%; height: 38px; background: var(--void); border: 1px solid var(--void-line);
  border-radius: 8px; padding: 2px; cursor: pointer;
}
.modal-card__actions { display: flex; justify-content: space-between; align-items: center; margin-top: 0.3rem; }
.modal-card__reset {
  background: transparent; border: none; color: var(--bone-dim);
  font-family: var(--font-mono); font-size: 0.7rem; text-decoration: underline; cursor: pointer;
}
.modal-card__save {
  background: var(--blood); color: var(--bone); border: none; border-radius: 10px;
  padding: 0.55rem 1.1rem; font-family: var(--font-mono); font-size: 0.78rem;
  text-transform: uppercase; letter-spacing: 0.04em; cursor: pointer;
}
.modal-card__save:hover { background: var(--blood-bright); }

/* ── care bars ─────────────────────────────────────────── */
.care-block { display: flex; flex-direction: column; gap: 0.4rem; }
.care-row { display: flex; align-items: center; gap: 0.5rem; }
.care-row__label {
  width: 52px; flex-shrink: 0;
  font-family: var(--font-mono); font-size: 0.65rem; color: var(--bone-dim);
  text-transform: uppercase;
}
.care-row__bar {
  flex: 1; height: 7px; border-radius: 4px; background: var(--void);
  border: 1px solid var(--void-line); overflow: hidden;
}
.care-row__fill {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--blood-bright), var(--eye-gold));
  transition: width 400ms ease;
}
.care-actions { display: flex; gap: 0.5rem; margin-top: 0.2rem; }
.care-actions__btn {
  flex: 1;
  background: var(--void); border: 1px solid var(--void-line); border-radius: 8px;
  color: var(--bone-dim); padding: 0.4rem; font-family: var(--font-mono); font-size: 0.68rem;
  text-transform: uppercase; cursor: pointer;
}
.care-actions__btn:hover { border-color: var(--eye-gold); color: var(--eye-gold); }

/* ── group member picker ──────────────────────────────── */
.group-member-list {
  max-height: 34vh; overflow-y: auto;
  border: 1px solid var(--void-line); border-radius: 8px; margin-top: 0.4rem;
}
.group-member-row {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--void-line);
  font-size: 0.85rem;
}
.group-member-row:last-child { border-bottom: none; }
.group-member-row input { accent-color: var(--blood-bright); }

/* ── responsive: one pane at a time on phones ─────────── */
@media (max-width: 720px) {
  .sidebar--hidden, .chat-pane--hidden { display: none; }
  .back-button { display: block; }
}
@media (min-width: 721px) {
  .sidebar { width: 300px; flex-shrink: 0; }
  .back-button { display: none; }
}

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