:root {
  --ink: #1d1d1b;
  --muted: #6f746d;
  --line: #ddded6;
  --bg: #ebece4;
  --purple: #223e2a;
  --purple-light: #e8eee7;
  --green: #223e2a;
  --orange: #be6731;
  --shadow: 0 12px 35px #1d1d1b12;
  --brand-cream: #ebece4;
  --brand-stone: #c8c7bb;
  --brand-terracotta: #be6731;
  --font-body: "Zabal", "Avenir Next", "Century Gothic", "Segoe UI", sans-serif;
  --font-display: "Georgia", "Times New Roman", serif;
}

body {
  font-family: var(--font-body);
  background: var(--brand-cream);
}

.brand,
.auth-brand {
  gap: 9px;
  color: var(--ink);
  letter-spacing: 0;
}

.brand-logo {
  display: block;
  width: 126px;
  height: auto;
  object-fit: contain;
}

.brand-product {
  border-left: 1px solid var(--brand-stone);
  padding-left: 9px;
  color: var(--brand-terracotta);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .4px;
}

.logo {
  width: auto;
  height: auto;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: inherit;
}

.workspace {
  background: #f7f7f2;
  border-color: var(--line);
}

.workspace-mark {
  width: 32px;
  height: 32px;
  padding: 5px;
  border-radius: 8px;
  background: var(--brand-cream);
  object-fit: contain;
}

.nav-label {
  color: #85877f;
}

.nav button.active,
.channel.active {
  background: var(--purple-light);
  color: var(--purple);
}

.nav button:hover,
.channel:hover {
  background: #f0f1eb;
}

.channel:nth-child(2) .dot { background: var(--brand-terracotta); }
.channel:nth-child(3) .dot { background: var(--green); }
.channel:nth-child(4) .dot { background: var(--brand-stone); }
.channel:nth-child(5) .dot { background: #777d72; }

.avatar {
  background: #f1e3d7;
  color: var(--brand-terracotta);
}

.primary {
  background: var(--purple);
  box-shadow: 0 5px 12px #223e2a24;
}

.primary:hover {
  background: #192e20;
}

.welcome h1,
.view-toolbar h2,
.auth-card h1,
.card-title {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0;
}

.eyebrow,
.text-btn,
.filter-pill.active,
.record-action {
  color: var(--brand-terracotta);
}

.stat-icon {
  background: #e8eee7;
  color: var(--green);
}

.stat:nth-child(2) .stat-icon {
  background: #f4e6db;
  color: var(--brand-terracotta);
}

.stat:nth-child(3) .stat-icon {
  background: #e8eee7;
  color: var(--green);
}

.stat:nth-child(4) .stat-icon {
  background: #efeee8;
  color: #626960;
}

.post-icon {
  background: #f4e6db;
  color: var(--brand-terracotta);
}

.post:nth-child(2) .post-icon {
  background: #e8eee7;
  color: var(--green);
}

.post:nth-child(3) .post-icon {
  background: #efeee8;
  color: #626960;
}

.tag {
  background: #f4e6db;
  color: #a74e21;
}

.tag.green,
.role-badge {
  background: #e8eee7;
  color: var(--green);
}

.tag.purple {
  background: #efeee8;
  color: #626960;
}

.check.done {
  background: var(--green);
  border-color: var(--green);
}

.filter-pill.active {
  background: #f4e6db;
  border-color: #e7c3aa;
}

.conv-item:hover,
.conv-item.active {
  background: #eff2eb;
}

.chat-messages {
  background: #f5f4ee;
}

.chat-messages .bubble:not(.mine) {
  color: var(--ink);
}

.chat-messages .bubble.mine {
  background: #e1eadf;
  border-color: #d3dfd0;
  color: #1d1d1b;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--brand-terracotta);
  box-shadow: 0 0 0 3px #be67311a;
}

.modal-back {
  background: #1d1d1b66;
}

.modal,
.auth-card,
.card,
.stat {
  border-color: #dedfd7;
}

.auth-screen {
  background: radial-gradient(circle at 15% 10%, #dfe7dc 0, transparent 36%), var(--brand-cream);
}

.auth-card {
  border-radius: 16px;
}

.auth-submit {
  width: 100%;
}

.auth-link {
  color: var(--brand-terracotta);
}

@media (max-width: 760px) {
  .brand-logo { width: 116px; }
  .brand-product { font-size: 10px; }
}

@media (min-width: 761px) and (max-width: 1000px) {
  .brand-logo { width: 106px; }
  .brand-product { font-size: 10px; }
}

/* Final brand pass: warm neutrals, forest green and terracotta. */
:root {
  --ink: #1d1d1b;
  --muted: #656a62;
  --line: #dedfd7;
  --bg: #f5f5ef;
  --purple: #223e2a;
  --purple-light: #e8eee7;
  --green: #223e2a;
  --orange: #be6731;
  --shadow: 0 12px 32px #1d1d1b0d;
  --brand-cream: #ebece4;
  --brand-stone: #c8c7bb;
  --brand-terracotta: #be6731;
}

body { color: var(--ink); background: #f5f5ef; }
.sidebar { background: #fff; border-color: var(--line); }

.profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.profile-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin: 0; padding: 8px 20px 18px; }
.profile-details > div { min-width: 0; padding: 12px 8px; border-bottom: 1px solid var(--line); }
.profile-details dt { margin: 0 0 5px; color: var(--muted); font-size: 11px; }
.profile-details dd { margin: 0; overflow-wrap: anywhere; font-size: 13px; font-weight: 650; }
.password-form { padding: 8px 20px 20px; }
.password-form .field { margin: 12px 0; }
.profile-reauth-field[hidden] { display: none; }
.password-form .field small { color: var(--muted); font-size: 11px; }
.profile-form-actions { display: flex; justify-content: flex-end; margin-top: 16px; }
.profile-feedback { display: none; margin-top: 10px; border-radius: 9px; padding: 10px 12px; font-size: 12px; line-height: 1.45; }
.profile-feedback.error, .profile-feedback.success { display: block; }
.profile-feedback.error { background: #fff1ef; color: #a82f23; }
.profile-feedback.success { background: #e8eee7; color: #223e2a; }

/* Mobile-first refinements: touch targets, safe areas and a usable chat viewport. */
@media (max-width: 760px) {
  html { -webkit-text-size-adjust: 100%; }
  body { min-width: 320px; }
  .app, .app.authenticated { display: block; min-height: 100dvh; }
  .topbar {
    position: sticky;
    top: 0;
    z-index: 4;
    height: 58px;
    padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
    background: #f5f5eff2;
    backdrop-filter: blur(12px);
  }
  .top-actions { gap: 8px; }
  .icon-btn, .mobile-menu { width: 42px; height: 42px; flex: 0 0 42px; }
  .content { padding: 20px 14px calc(28px + env(safe-area-inset-bottom)); }
  .welcome { align-items: stretch; flex-direction: column; margin-bottom: 18px; }
  .welcome h1 { font-size: clamp(21px, 6vw, 25px); }
  .welcome .primary { width: 100%; min-height: 44px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-bottom: 15px; }
  .stat { min-width: 0; padding: 12px; border-radius: 13px; }
  .stat-top { gap: 6px; font-size: 11px; }
  .stat strong { font-size: 21px; }
  .stat small { font-size: 10px; }
  .grid, .right-col { gap: 13px; }
  .card { border-radius: 14px; }
  .card-head { gap: 9px; padding: 14px; }
  .card-head > * { min-width: 0; }
  .view-toolbar { align-items: stretch; flex-direction: column; gap: 12px; }
  .view-toolbar .primary { min-height: 44px; }
  .profile-grid { grid-template-columns: 1fr; gap: 13px; }
  .profile-details { padding-inline: 12px; }
  .password-form { padding-inline: 14px; }
  .profile-form-actions .primary { width: 100%; min-height: 46px; }
  .back-dashboard { min-height: 42px; }
  .conversation-layout {
    height: calc(100dvh - 148px);
    min-height: 410px;
    max-height: 760px;
    grid-template-rows: 76px minmax(0, 1fr);
    overflow: hidden;
  }
  .conversation-list {
    display: flex;
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px;
    border: 0;
    border-bottom: 1px solid var(--line);
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }
  .conv-item { flex: 0 0 190px; min-width: 190px; padding: 8px; align-items: center; }
  .conv-item .chat-snippet { max-width: 130px; }
  .conversation-chat { min-height: 0; height: 100%; }
  .chat-head { padding: 12px 14px; }
  .chat-messages { min-height: 0; padding: 12px; gap: 9px; }
  .bubble { max-width: 88%; font-size: 14px; }
  .message-stack { max-width: calc(100% - 34px); }
  .composer { padding: 9px; padding-bottom: max(9px, env(safe-area-inset-bottom)); }
  .composer input, .field input, .field textarea, .field select {
    min-height: 44px;
    font-size: 16px;
  }
  .composer .primary { min-width: 72px; min-height: 44px; }
  .modal-back { align-items: flex-end; padding: 0; }
  .modal {
    width: 100%;
    max-height: min(88dvh, 760px);
    overflow-y: auto;
    border-radius: 18px 18px 0 0;
    padding: 22px 18px calc(18px + env(safe-area-inset-bottom));
  }
  .modal-actions { position: sticky; bottom: -18px; background: white; padding: 12px 0 0; }
  .modal-actions button { min-height: 44px; }
  .user-table { min-width: 620px; }
}

@media (max-width: 380px) {
  .content { padding-inline: 10px; }
  .stat { padding: 10px; }
  .stat-top { font-size: 10px; }
  .search { width: 42px; height: 42px; }
  .conv-item { flex-basis: 168px; min-width: 168px; }
}

.mobile-nav-backdrop { display: none; }
@media (max-width: 760px) {
  .sidebar {
    position: fixed;
    z-index: 12;
    inset: 0 auto 0 0;
    width: min(86vw, 330px);
    height: 100dvh;
    overflow-y: auto;
    display: flex;
    gap: 21px;
    padding: max(20px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
    box-shadow: 16px 0 48px #1d1d1b1c;
    transform: translateX(-105%);
    transition: transform .22s ease;
    visibility: hidden;
  }
  .app.mobile-nav-open .sidebar { transform: translateX(0); visibility: visible; }
  .mobile-nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 11;
    border: 0;
    background: #1d1d1b66;
    opacity: 0;
    visibility: hidden;
    transition: opacity .22s ease, visibility .22s ease;
  }
  .app.mobile-nav-open .mobile-nav-backdrop { opacity: 1; visibility: visible; }
  body.mobile-nav-open { overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar, .mobile-nav-backdrop { transition: none; }
}
.topbar { background: #fffdf9; border-color: var(--line); }
.content { color: var(--ink); }
.brand { min-width: 0; gap: 8px; }
.brand-logo { max-width: 100%; flex: 0 1 auto; }
.brand-product { white-space: nowrap; }
.workspace { background: #fbfbf7; }
.nav button, .channel, .breadcrumbs, .card-sub, .post-meta,
.post p, .rem-time, .message-author { color: #656a62; }
.nav button.active, .channel.active { color: #223e2a; background: #e8eee7; }
.nav button:hover, .channel:hover { background: #f2f4ef; }
.channel:nth-child(2) .dot { background: #be6731; }
.channel:nth-child(3) .dot { background: #55735b; }
.channel:nth-child(4) .dot { background: #c8c7bb; }
.channel:nth-child(5) .dot { background: #85877f; }
.welcome h1, .view-toolbar h2, .card-title, .auth-card h1 { color: #1d1d1b; }
.welcome p { color: #656a62; }
.eyebrow, .text-btn, .record-action, .auth-link { color: #a74e21; }
.primary, .auth-submit { background: #223e2a; box-shadow: 0 5px 12px #223e2a20; }
.primary:hover, .auth-submit:hover { background: #192e20; }
.primary:focus-visible, button:focus-visible, a:focus-visible,
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid #be67314d;
  outline-offset: 2px;
}
.stat, .card, .notice-card, .auth-card { border-color: #dedfd7; }
.stat small { color: #777d72; }
.stat-icon { background: #e8eee7; color: #223e2a; }
.stat:nth-child(2) .stat-icon { background: #f4e6db; color: #a74e21; }
.stat:nth-child(3) .stat-icon { background: #e8eee7; color: #223e2a; }
.stat:nth-child(4) .stat-icon { background: #efeee8; color: #626960; }
.post-icon { background: #f4e6db; color: #a74e21; }
.post:nth-child(2) .post-icon { background: #e8eee7; color: #223e2a; }
.post:nth-child(3) .post-icon { background: #efeee8; color: #626960; }
.tag { background: #f4e6db; color: #91421f; }
.tag.green, .role-badge { background: #e8eee7; color: #223e2a; }
.tag.purple { background: #efeee8; color: #626960; }
.count { background: #efeee8; color: #626960; }
.person { background: #efeee8; color: #626960; }
.person.green { background: #e8eee7; color: #223e2a; }
.person.orange { background: #f4e6db; color: #a74e21; }
.filter-pill.active { background: #e8eee7; border-color: #cbd8c9; color: #223e2a; }
.conv-item:hover, .conv-item.active { background: #eff2eb; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: #be6731; }
.chat-messages { background: #f5f4ee; }
.chat-messages .bubble:not(.mine) { background: #fffdf9; border-color: #e5e4dc; color: #1d1d1b; }
.chat-messages .bubble.mine { background: #e1eadf; border-color: #d3dfd0; color: #1d1d1b; }
.message-action-trigger { border-color: #dedfd7; color: #626960; }
.message-action-menu button:hover { background: #f2f4ef; }
.reply-quote { border-left-color: #be6731; background: #f4f1e9; color: #454941; }
.reply-compose-preview { background: #f4f1e9; color: #454941; }
.field input:focus, .field textarea:focus, .field select:focus,
.composer input:focus { border-color: #be6731; box-shadow: 0 0 0 3px #be67311a; }
.auth-screen { background: radial-gradient(circle at 15% 10%, #dfe7dc 0, transparent 36%), #ebece4; }
.record-action.danger, .message-action-menu .danger { color: #a82f23; }

@media (max-width: 760px) {
  .brand-logo { width: 116px; }
  .brand-product { font-size: 10px; }
}
