@import url("/partials/ui-tokens.css?v=force-20260314112341");
@import url("/partials/sidebar-shell.css?v=force-20260314112341");
@import url("/partials/sidebar-list.css?v=force-20260314112341");

:root {
  color-scheme: light;
  --ink: #111118;
  --paper: #f7f1e6;
  --sand: #efe3d2;
  --terra: #d88f6a;
  --sage: #5e7c73;
  --charcoal: #1d232b;
  --fog: rgba(255, 255, 255, 0.6);
  --shadow: 0 24px 60px rgba(15, 20, 28, 0.16);
  --radius-xl: 26px;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #fff1d6 0%, #f2e6d5 40%, #e3d6c5 80%);
  color: var(--ink);
  font-family: "Avenir Next", "Gill Sans", "Segoe UI", sans-serif;
}

.page {
  display: grid;
  gap: 0.8rem;
  padding: 0.9rem clamp(0.8rem, 2.5vw, 1.6rem);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.primary-button {
  border: none;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  background: var(--charcoal);
  color: #fff8ef;
  cursor: pointer;
  font-size: 0.85rem;
  transition: box-shadow 0.2s ease;
}

.primary-button:hover {
  box-shadow: 0 10px 20px rgba(24, 33, 44, 0.2);
}

.primary-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ghost-button {
  border: none;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  background: #f1e3cf;
  color: #5a4c40;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s ease, color 0.2s ease;
}

.ghost-button:hover {
  background: #e6d4bc;
  color: #3f342b;
}

.danger-button {
  border: none;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  background: #e8443a;
  color: #fff;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s ease;
}

.danger-button:hover {
  background: #cc362d;
}

/* ── Shell layout (shared classes from chat) ── */

.shell {
  display: grid;
  grid-template-columns: minmax(0, var(--sidebar-width)) minmax(0, 1fr);
  grid-template-areas: "sidebar main";
  gap: 0.9rem;
}

.shell .sidebar-panel {
  grid-area: sidebar;
  min-height: 380px;
}

.shell .main-panel {
  grid-area: main;
}

.panel {
  background: #fff8ef;
  border-radius: var(--radius-xl);
  border: 1px solid #ecdcc7;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.stream {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-height: 380px;
  max-height: 56vh;
  overflow-y: auto;
  padding: 1rem;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem;
  align-items: end;
  padding: 0.8rem 1rem;
  border-top: 1px solid #ecdcc7;
}

/* ── Sidebar ── */

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid #ecdcc7;
}

.sidebar-top h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.sidebar-top-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.mute-toggle {
  border: none;
  background: none;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 6px;
  color: #8a7f6f;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, background 0.2s ease;
}

.mute-toggle:hover {
  background: #f1e3cf;
  color: #5a4c40;
}

.mute-toggle .mute-icon--off {
  display: none;
}

.mute-toggle.muted .mute-icon--on {
  display: none;
}

.mute-toggle.muted .mute-icon--off {
  display: block;
}

.mute-toggle.muted {
  color: #b23b2b;
}

.group-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.4rem 0;
}

.group-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 1rem;
  padding-right: 2.4rem;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.15s ease;
}

.group-item:hover {
  background: #f6ecdd;
}

.group-item.active {
  background: #f6ecdd;
  border-left-color: var(--terra);
}

.group-item-info {
  flex: 1;
  min-width: 0;
}

.group-item-name {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.group-item-preview {
  font-size: 0.75rem;
  color: #8a7f6f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.15rem;
}

.group-item-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
  flex-shrink: 0;
}

.group-item-time {
  font-size: 0.65rem;
  color: #a89d91;
}

.unread-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--terra);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Main panel ── */

.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid #ecdcc7;
}

.main-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.main-header-actions {
  display: flex;
  gap: 0.4rem;
}

.msg-bubble-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.msg-bubble-wrap.msg-new {
  animation: rise 0.25s ease;
}

.msg-bubble-wrap.own {
  align-items: flex-end;
}

.msg-bubble-sender {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #8a7f6f;
  padding: 0 0.3rem;
}

.msg-bubble {
  max-width: min(80%, 480px);
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-md);
  background: var(--sand);
  color: var(--charcoal);
  line-height: 1.5;
  font-size: 0.92rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-bubble-wrap.own .msg-bubble {
  background: #dce8e3;
  border-bottom-right-radius: 4px;
}

.msg-bubble-wrap.bot .msg-bubble {
  background: #e8dff0;
  border-bottom-left-radius: 4px;
}

.msg-bubble-wrap.bot .msg-bubble-sender {
  color: #7b5ea7;
  font-weight: 600;
}

.msg-bubble-wrap:not(.own) .msg-bubble {
  border-bottom-left-radius: 4px;
}

.msg-bubble-time {
  font-size: 0.6rem;
  color: #a89d91;
  padding: 0 0.3rem;
}

.msg-system {
  text-align: center;
  font-size: 0.78rem;
  color: #8a7f6f;
  padding: 0.4rem 0;
}

/* Reactions */
.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding: 0.15rem 0.3rem 0;
  position: relative;
}

.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid #e0d6ca;
  background: #fff;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.reaction-pill:hover {
  background: #f5f0ea;
}
.reaction-pill.own {
  background: #dce8e3;
  border-color: #9ec3b0;
}

.reaction-add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: 1px dashed #ccc;
  background: transparent;
  font-size: 0.85rem;
  color: #999;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.msg-bubble-wrap:hover .reaction-add-btn {
  opacity: 1;
}
.reaction-add-btn:hover {
  background: #f5f0ea;
  color: #666;
}

.reaction-picker {
  position: absolute;
  bottom: 100%;
  left: 0;
  display: flex;
  gap: 0.2rem;
  padding: 0.35rem 0.5rem;
  background: #fff;
  border: 1px solid #e0d6ca;
  border-radius: var(--radius-md);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  z-index: 100;
}

.reaction-picker-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  font-size: 1.2rem;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}
.reaction-picker-btn:hover {
  background: #f5f0ea;
}

.composer textarea {
  width: 100%;
  border: 1px solid #e6d4bc;
  border-radius: var(--radius-md);
  padding: 0.65rem 0.8rem;
  font-size: 0.92rem;
  background: #fff;
  resize: none;
  line-height: 1.4;
  max-height: 120px;
  overflow-y: auto;
  font-family: inherit;
}

.composer button {
  padding: 0.65rem 1.1rem;
  border: none;
  border-radius: var(--radius-md);
  background: var(--terra);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  font-size: 0.85rem;
}

.composer button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(24, 33, 44, 0.16);
}

/* ── Empty states ── */

.msg-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  color: #8a7f6f;
  padding: 2rem;
  text-align: center;
}

.msg-empty h3 {
  margin: 0;
  color: var(--ink);
  font-size: 1.1rem;
}

.msg-empty p {
  margin: 0;
  font-size: 0.85rem;
  max-width: 320px;
}

.login-prompt {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem;
  text-align: center;
}

.login-prompt h2 {
  margin: 0;
  font-size: 1.3rem;
}

.login-prompt p {
  margin: 0;
  color: #8a7f6f;
  font-size: 0.9rem;
  max-width: 340px;
}

/* ── Modals ── */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: #fff8ef;
  border: 1px solid #ecdcc7;
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(15, 20, 28, 0.2);
  padding: 1.4rem;
  width: min(440px, 92vw);
  max-height: 80vh;
  overflow-y: auto;
}

.modal-card h3 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
}

.modal-field {
  margin-bottom: 0.8rem;
}

.modal-field label {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #8a7f6f;
  margin-bottom: 0.25rem;
}

.modal-field input,
.modal-field select {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border: 1px solid #ecdcc7;
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 0.9rem;
  font-family: inherit;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.modal-error {
  color: #b23b2b;
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
}

/* ── User search results ── */

.search-results {
  border: 1px solid #d7c4a8;
  border-radius: var(--radius-md);
  background: #fff;
  max-height: 160px;
  overflow-y: auto;
  margin-top: 0.3rem;
  box-shadow: 0 8px 24px rgba(15, 20, 28, 0.15);
  position: relative;
  z-index: 10;
}

.search-result-item {
  padding: 0.5rem 0.7rem;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.search-result-item + .search-result-item {
  border-top: 1px solid #f0e6d6;
}

.search-result-item:hover {
  background: #f6ecdd;
}

.search-result-name {
  color: #8a7f6f;
  font-size: 0.75rem;
}

/* ── Members list in settings ── */

.member-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.8rem;
}

.member-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius-sm);
}

.member-item:hover {
  background: #f6ecdd;
}

.member-name {
  font-size: 0.85rem;
}

.member-role {
  font-size: 0.7rem;
  color: #8a7f6f;
}

.member-remove {
  border: none;
  background: none;
  color: #b23b2b;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
}

.member-remove:hover {
  background: #fdecea;
}

/* ── Username modal ── */

.username-hint {
  font-size: 0.75rem;
  color: #8a7f6f;
  margin-top: -0.4rem;
}

/* ── Recipient input ── */

.recipient-input-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  border: 1px solid #ecdcc7;
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 0.35rem 0.5rem;
  cursor: text;
}

.recipient-input-wrap input {
  flex: 1;
  min-width: 100px;
  border: none;
  outline: none;
  background: none;
  font-size: 0.9rem;
  font-family: inherit;
  padding: 0.15rem 0.2rem;
}

.recipient-chips {
  display: contents;
}

.recipient-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  background: #e6d4bc;
  font-size: 0.78rem;
  white-space: nowrap;
}

.recipient-chip .chip-remove {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.85rem;
  color: #8a7f6f;
  padding: 0;
  line-height: 1;
}

.recipient-chip .chip-remove:hover {
  color: #b23b2b;
}

/* ── Invite chips ── */

.invite-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.3rem;
}

.invite-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  background: #f1e3cf;
  font-size: 0.75rem;
}

.invite-chip button {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.7rem;
  color: #8a7f6f;
  padding: 0;
  line-height: 1;
}

/* ── Pending invites sidebar section ── */

.invite-section {
  border-top: 1px solid #ecdcc7;
  padding: 0.6rem 1rem;
}

.invite-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #8a7f6f;
  margin-bottom: 0.4rem;
}

.invite-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0;
  gap: 0.5rem;
}

.invite-item-info {
  flex: 1;
  min-width: 0;
  font-size: 0.8rem;
}

.invite-actions {
  display: flex;
  gap: 0.3rem;
}

.invite-accept {
  border: none;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--sage);
  color: #fff;
  cursor: pointer;
  font-size: 0.7rem;
}

.invite-decline {
  border: none;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: #e8e2d8;
  color: #5a4c40;
  cursor: pointer;
  font-size: 0.7rem;
}

/* ── Responsive ── */

@media (max-width: 960px) {
  .page {
    min-height: 100dvh;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 0.7rem;
    padding: 0.9rem clamp(0.8rem, 3vw, 1.2rem);
  }

  .shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "main"
      "sidebar";
    min-height: 0;
  }

  .sidebar-panel {
    max-height: 35vh;
  }

  .main-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .stream {
    flex: 1;
    min-height: 0;
    max-height: none;
  }

  .composer {
    position: sticky;
    bottom: 0;
    background: #fff8ef;
    padding-bottom: calc(0.8rem + env(safe-area-inset-bottom));
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
