/* Buzz Django — clean React-like aesthetic */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --border: #e6e9f0;
  --text: #111827;
  --muted: #64748b;
  --accent: #3b6ef5;
  --accent-soft: #eef3ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --danger-border: #fecaca;
  --success-bg: #ecfdf5;
  --success-text: #065f46;
  --success-border: #a7f3d0;
  --info-bg: #eff6ff;
  --info-text: #1e40af;
  --info-border: #bfdbfe;
  --warn-bg: #fffbeb;
  --warn-text: #92400e;
  --warn-border: #fde68a;
  --error-text: #b91c1c;
  --kbd-bg: #f1f5f9;
  --sidebar-w: 240px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.05), 0 4px 14px rgba(16, 24, 40, 0.05);
  --shadow-lg: 0 10px 28px rgba(16, 24, 40, 0.08);
  --ease: 0.15s ease;
  --sidebar-tint: linear-gradient(180deg, color-mix(in srgb, var(--accent) 6%, var(--surface)) 0%, var(--surface) 42%);
  --header-tint: linear-gradient(180deg, color-mix(in srgb, var(--accent) 5%, var(--surface)) 0%, var(--surface) 100%);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --keyboard-inset: 0px;
  --vv-height: 100dvh;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0e1318;
  --surface: #1a2332;
  --border: #2a374a;
  --text: #e8eef7;
  --muted: #9aa8bc;
  --accent: #6babfa;
  --accent-soft: #1a3358;
  --danger: #f87171;
  --danger-soft: #3f1d1d;
  --danger-border: #7f1d1d;
  --success-bg: #064e3b;
  --success-text: #a7f3d0;
  --success-border: #065f46;
  --info-bg: #1e3a5f;
  --info-text: #bfdbfe;
  --info-border: #1e40af;
  --warn-bg: #451a03;
  --warn-text: #fde68a;
  --warn-border: #92400e;
  --error-text: #fca5a5;
  --kbd-bg: #243044;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.32), 0 4px 14px rgba(0, 0, 0, 0.26);
  --shadow-lg: 0 10px 28px rgba(0, 0, 0, 0.42);
  --sidebar-tint: linear-gradient(180deg, color-mix(in srgb, var(--accent) 10%, var(--surface)) 0%, var(--surface) 48%);
  --header-tint: linear-gradient(180deg, color-mix(in srgb, var(--accent) 8%, var(--surface)) 0%, var(--surface) 100%);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: var(--vv-height, 100dvh);
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-tint);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: calc(1rem + var(--safe-top)) calc(0.75rem + var(--safe-right)) calc(1rem + var(--safe-bottom)) calc(0.75rem + var(--safe-left));
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  height: var(--vv-height, 100dvh);
  z-index: 40;
}
.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.brand a,
.brand-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--text);
  padding: 0.5rem 0.75rem;
  text-decoration: none;
}
.brand-logo {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 6px;
  object-fit: contain;
  background: #fff;
}
.brand-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-close {
  display: none;
  position: relative;
  z-index: 2;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
}

.nav { display: flex; flex-direction: column; gap: 0.25rem; margin-top: 1rem; flex: 1; }
.nav-item {
  display: block;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  font-size: 0.9375rem;
  min-height: 44px;
}
.nav-item:hover { background: var(--bg); text-decoration: none; }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item.is-disabled { color: var(--muted); pointer-events: none; opacity: 0.7; }

.sidebar-footer { padding: 0.75rem; font-size: 0.75rem; }
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.4);
  z-index: 150;
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 100vh; min-height: 100dvh; min-height: var(--vv-height, 100dvh); }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: calc(0.85rem + var(--safe-top)) calc(1.5rem + var(--safe-right)) 0.85rem calc(1.5rem + var(--safe-left));
  background: var(--header-tint);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.nav-toggle { display: none; }
.page-heading { margin: 0; font-size: 1.125rem; font-weight: 600; }
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  flex-shrink: 0;
}
.user-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.7rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.875rem;
  min-height: 36px;
}
.user-chip:hover { border-color: var(--accent); text-decoration: none; }

.content { padding: 1.5rem; max-width: 960px; width: 100%; margin: 0 auto; }
.content-channel {
  max-width: 880px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: calc(100vh - 64px);
  min-height: calc(var(--vv-height, 100dvh) - 64px);
  padding-bottom: 0;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}
.hero h2, .dashboard-hero h2 { margin-top: 0; font-size: 1.6rem; letter-spacing: -0.02em; }
.eyebrow {
  display: inline-block;
  margin: 0 0 0.5rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
}
.lead { color: var(--muted); font-size: 1.05rem; max-width: 42rem; }
.value-props {
  list-style: none;
  padding: 0;
  margin: 1.25rem 0;
  display: grid;
  gap: 0.85rem;
}
.value-props li {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.85rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.feature-list { padding-left: 1.25rem; }
.feature-list li { margin: 0.35rem 0; }
.muted { color: var(--muted); font-size: 0.875rem; }
.empty-hint h3 { margin-top: 0; font-size: 1rem; }

/* Toasts */
.toast-stack {
  position: sticky;
  top: calc(0.75rem + var(--safe-top));
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.toast {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.toast.is-leaving { opacity: 0; transform: translateY(-4px); }
.toast-text { flex: 1; }
.toast-dismiss {
  border: none;
  background: transparent;
  color: inherit;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
  min-width: 32px;
  min-height: 32px;
}
.toast-dismiss:hover { background: color-mix(in srgb, var(--text) 8%, transparent); }
.message { padding: 0.75rem 1rem; border-radius: 8px; background: var(--accent-soft); margin-bottom: 0.5rem; }
.message-success, .toast.message-success { background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }
.message-info, .toast.message-info { background: var(--info-bg); color: var(--info-text); border-color: var(--info-border); }
.message-error, .toast.message-error { background: var(--danger-soft); color: var(--error-text); border-color: var(--danger-border); }
.message-warning, .toast.message-warning { background: var(--warn-bg); color: var(--warn-text); border-color: var(--warn-border); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.25;
  min-height: 44px;
}
.btn:hover { text-decoration: none; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { filter: brightness(0.95); color: #fff; }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg); }
.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { filter: brightness(0.95); color: #fff; }
.btn-danger-ghost {
  color: var(--danger);
  border-color: var(--danger-border);
}
.btn-danger-ghost:hover { background: var(--danger-soft); color: var(--danger); }
.btn-sm {
  padding: 0.3rem 0.75rem;
  font-size: 0.8125rem;
  min-height: 36px;
}
.inline-form { display: inline; margin: 0; }

/* Auth forms */
.auth-card {
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}
.auth-card h2 { margin-top: 0; font-size: 1.25rem; }
.auth-form { margin-top: 1rem; }
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
}
.form-control {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 16px; /* iOS: avoid auto-zoom on focus */
  background: var(--surface);
  color: var(--text);
  min-height: 44px;
}
.form-control:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.help-text {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}
.field-errors, .form-errors {
  list-style: none;
  padding: 0;
  margin: 0.35rem 0 0;
  color: var(--error-text);
  font-size: 0.8125rem;
}
.form-errors {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: var(--danger-soft);
  border-radius: 8px;
  border: 1px solid var(--danger-border);
}
.auth-footer { margin-top: 1.25rem; margin-bottom: 0; }
.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.25rem 0;
}

/* Page headers */
.page-header-bar,
.page-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.page-header-copy { min-width: 0; flex: 1; }
.page-section-title { margin: 0 0 0.25rem; font-size: 1.25rem; }
.header-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.section-header h3 { margin: 0; font-size: 1rem; }
.empty-state h2, .empty-state h3 { margin-top: 0; font-size: 1.125rem; }
.empty-state.compact { margin: 0; color: var(--muted); }
.empty-state.compact-block { text-align: left; }
.timeline-empty {
  text-align: center;
  padding: 2.5rem 1rem;
}
.empty-illustration { font-size: 1.75rem; margin-bottom: 0.5rem; }
.form-card { max-width: 560px; }
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Avatars */
.avatar,
.msg-avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
}
.avatar-sm { width: 32px; height: 32px; font-size: 0.75rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.25rem; }

/* Shortcuts / dashboard */
.shortcut-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.85rem;
  margin: 1.25rem 0;
}
.shortcut-card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: inherit;
  text-decoration: none;
  min-height: 100px;
}
.shortcut-card:hover {
  border-color: var(--accent);
  text-decoration: none;
  box-shadow: var(--shadow);
}
.shortcut-icon {
  font-size: 1.1rem;
  color: var(--accent);
  margin-bottom: 0.25rem;
}
.recent-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.recent-list a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.35rem;
  color: inherit;
  text-decoration: none;
  border-radius: 8px;
  min-height: 44px;
}
.recent-list a:hover { background: var(--bg); text-decoration: none; }

/* Search */
.search-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  padding: 0.85rem 1rem;
}
.search-bar .form-control { flex: 1; min-width: 180px; }

/* Channel list */
.channel-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.85rem; }
.channel-card { margin-bottom: 0; transition: box-shadow 0.15s, border-color 0.15s; }
.channel-card:hover { box-shadow: var(--shadow-lg); border-color: var(--border); }
.channel-card-link { color: inherit; text-decoration: none; display: block; }
.channel-card-link:hover { text-decoration: none; }
.channel-card-link:hover .channel-name { color: var(--accent); }
.channel-card-top { display: flex; gap: 0.85rem; align-items: flex-start; }
.channel-name-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.channel-name { font-size: 1.05rem; }
.channel-desc { margin: 0.35rem 0 0; }
.channel-preview {
  margin: 0.75rem 0 0;
  padding: 0.55rem 0.75rem;
  background: var(--bg);
  border-radius: 8px;
  font-size: 0.8125rem;
}
.channel-card-meta { margin-top: 0.75rem; font-size: 0.8125rem; }
.channel-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.channel-title { margin: 0 0 0.35rem; font-size: 1.25rem; }

/* Channel detail layout */
.channel-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: calc(100vh - 96px);
  min-height: calc(var(--vv-height, 100dvh) - 96px);
  gap: 0.75rem;
}
.channel-layout .channel-header { margin-bottom: 0; flex-shrink: 0; }
.timeline {
  flex: 1;
  min-height: 420px;
  max-height: none;
  overflow-y: auto;
  padding: 1.25rem 1.35rem;
  margin-bottom: 0;
}
.msg-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.65rem; }
.msg-item { display: flex; gap: 0.65rem; align-items: flex-start; max-width: 100%; }
.msg-item-own { flex-direction: row-reverse; }
.msg-item-own .msg-body-wrap { display: flex; justify-content: flex-end; }
.msg-item-own .msg-meta { justify-content: flex-end; }
.msg-item-own .msg-avatar { background: var(--accent); color: #fff; }
.msg-bubble {
  display: inline-block;
  max-width: min(720px, 100%);
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--border);
}
.msg-item-own .msg-bubble {
  background: var(--accent-soft);
  border-color: transparent;
}
.msg-item-other .msg-bubble {
  background: var(--surface);
}
.msg-meta { display: flex; align-items: baseline; gap: 0.5rem; margin-bottom: 0.15rem; flex-wrap: wrap; }
.msg-author { font-size: 0.875rem; }
.msg-text { font-size: 0.9375rem; line-height: 1.5; word-break: break-word; }
.composer {
  position: sticky;
  bottom: var(--keyboard-inset, 0px);
  margin-bottom: 0;
  z-index: 10;
  box-shadow: 0 -6px 16px rgba(16, 24, 40, 0.05);
  padding-bottom: max(0px, calc(var(--safe-bottom) - var(--keyboard-inset, 0px)));
  background: var(--surface);
}
.composer-form {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}
.composer-group { flex: 1; margin-bottom: 0; }
.message-input { resize: vertical; min-height: 52px; font-size: 16px; }

/* Message edit / soft-delete */
.msg-body-wrap { flex: 1; min-width: 0; }
.msg-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0.25rem;
  opacity: 0.85;
}
.msg-item:hover .msg-actions { opacity: 1; }
.msg-action-form { display: inline; margin: 0; padding: 0; }
.msg-action {
  background: none;
  border: none;
  padding: 0.1rem 0.35rem;
  font: inherit;
  font-size: 0.75rem;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  border-radius: 4px;
  min-height: 28px;
}
.msg-action:hover {
  color: var(--accent);
  background: var(--accent-soft);
  text-decoration: none;
}
.msg-action-danger:hover {
  color: var(--danger);
  background: var(--danger-soft);
}
.msg-edited { font-size: 0.75rem; font-style: italic; }
.msg-deleted {
  font-style: italic;
  color: var(--muted);
}
.msg-item-deleted { opacity: 0.85; }
.msg-preview-quote {
  margin: 0.75rem 0 1.25rem;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--border);
  background: var(--bg);
  border-radius: 0 8px 8px 0;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}


/* Members */
.member-cell {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.25rem;
  font-size: 0.9375rem;
}
.data-table th,
.data-table td {
  text-align: left;
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table th { color: var(--muted); font-weight: 500; font-size: 0.8125rem; }
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.75rem;
}
.badge-agent {
  background: var(--accent-soft);
  border-color: #bfdbfe;
  color: var(--accent);
  font-weight: 600;
}
.badge-unread {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
  min-width: 1.35rem;
  text-align: center;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}
[data-theme="dark"] .badge-agent {
  border-color: #3b82f6;
}
[data-theme="dark"] .badge-unread {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b1220;
}
.badge-mention {
  background: #7c3aed;
  border-color: #7c3aed;
  color: #fff;
  font-weight: 700;
}
[data-theme="dark"] .badge-mention {
  background: #a78bfa;
  border-color: #a78bfa;
  color: #0b1220;
}
.badge-muted {
  background: transparent;
  color: var(--muted);
  border-style: dashed;
  font-weight: 500;
}
.msg-mention {
  color: var(--accent);
  font-weight: 600;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 0.25rem;
  padding: 0 0.15em;
}
.msg-mention-channel {
  color: #b45309;
  background: color-mix(in srgb, #f59e0b 18%, transparent);
}
[data-theme="dark"] .msg-mention-channel {
  color: #fbbf24;
}
.msg-item-mentioned .msg-bubble {
  box-shadow: inset 3px 0 0 #7c3aed;
}
.msg-mentioned { /* body container when viewer mentioned */ }
.notify-select {
  max-width: 11rem;
  font-size: 0.8125rem;
}
.notify-form { display: inline-flex; align-items: center; }

/* Projects */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
.project-card {
  display: block;
  color: inherit;
  text-decoration: none;
  margin-bottom: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-height: 140px;
}
.project-card:hover {
  text-decoration: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
}
.project-card-top {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.5rem;
}
.project-card strong { display: block; }
.project-card-meta { margin-top: 0.75rem; font-size: 0.8125rem; }
.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin: 0.25rem 0;
}
.stat-card {
  display: flex;
  flex-direction: column;
  min-width: 132px;
  padding: 1rem 1.25rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  min-height: 88px;
}
.stat-card:hover { border-color: var(--accent); text-decoration: none; box-shadow: var(--shadow); }
.stat-num { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.stat-label { font-size: 0.8125rem; color: var(--muted); }
.simple-list { padding-left: 1.25rem; margin: 0.5rem 0; }
.simple-list li { margin: 0.35rem 0; }
.checkbox-list { display: flex; flex-direction: column; gap: 0.35rem; }
.checkbox-list label { font-weight: 400; display: flex; align-items: center; gap: 0.5rem; min-height: 44px; }

/* Profile */
.profile-card { max-width: 640px; }
.profile-identity {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.profile-name { margin: 0 0 0.25rem; font-size: 1.25rem; }
.profile-meta {
  display: grid;
  gap: 0.85rem;
  margin: 0;
}
.profile-meta div {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}
.profile-meta dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.8125rem;
}
.profile-meta dd { margin: 0; font-weight: 500; }


.composer-hint { margin: 0.4rem 0 0; font-size: 0.75rem; }
.composer-hint kbd,
kbd {
  display: inline-block;
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--kbd-bg);
  font-size: 0.7rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.danger-zone {
  border-color: var(--danger-border);
  background: var(--danger-soft);
}
.danger-zone h2, .danger-zone h3 { margin-top: 0; color: var(--error-text); }
.theme-toggle { min-width: 64px; }

/* Focus visibility (a11y) */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
a:focus-visible, button:focus-visible, .btn:focus-visible, .form-control:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#message-timeline { min-height: 2rem; }
#timeline-end { height: 1px; }

@media (max-width: 768px) {
  .app-shell { flex-direction: column; }
  .nav-toggle { display: inline-flex; min-width: 44px; min-height: 44px; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(280px, 86vw);
    height: 100vh;
    height: 100dvh;
    height: var(--vv-height, 100dvh);
    padding-top: calc(1rem + var(--safe-top));
    padding-bottom: calc(1rem + var(--safe-bottom));
    padding-left: calc(0.75rem + var(--safe-left));
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    z-index: 200;
  }
  .sidebar-backdrop { z-index: 150; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { display: block; }
  body.sidebar-open .sidebar-close { display: inline-flex !important; }
  .nav { flex-direction: column; margin-top: 0.75rem; }
  .topbar {
    padding-left: calc(1rem + var(--safe-left));
    padding-right: calc(1rem + var(--safe-right));
  }
  .content {
    padding: 1rem;
    padding-left: calc(1rem + var(--safe-left));
    padding-right: calc(1rem + var(--safe-right));
    padding-bottom: calc(1rem + var(--safe-bottom));
  }
  .content-channel {
    min-height: calc(100vh - 56px);
    min-height: calc(var(--vv-height, 100dvh) - 56px);
    padding-bottom: 0;
  }
  .channel-layout {
    min-height: calc(100vh - 72px);
    min-height: calc(var(--vv-height, 100dvh) - 72px);
  }
  .timeline { min-height: 280px; }
  .composer-form { flex-direction: column; align-items: stretch; }
  .composer-form .btn { width: 100%; min-height: 44px; }
  .page-header-bar { flex-direction: column; align-items: stretch; }
  .page-header-bar .btn,
  .header-actions .btn { width: 100%; }
  .profile-meta div { grid-template-columns: 1fr; gap: 0.2rem; }
  .btn, .btn-primary, .btn-ghost { min-height: 44px; }
  .btn-sm { min-height: 44px; }
  /* Form cards full-width on small screens */
  .form-card,
  .auth-card,
  .profile-card {
    max-width: none;
    width: 100%;
  }
  .card {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}


/* Pass 3 polish */
.channel-msg-search { margin-top: 0.85rem; padding: 0.65rem 0; border: none; box-shadow: none; background: transparent; }
.channel-header .channel-msg-search { border-top: 1px solid var(--border); border-radius: 0; }
.search-result-meta { margin: 0.35rem 0 0; font-size: 0.8125rem; }
.search-hit {
  background: #fef08a;
  color: inherit;
  padding: 0 0.15em;
  border-radius: 3px;
}
[data-theme="dark"] .search-hit {
  background: #854d0e;
  color: #fef9c3;
}
.poll-status {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.poll-status.is-loading::before {
  content: "";
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 999px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: buzz-spin 0.7s linear infinite;
}
@keyframes buzz-spin { to { transform: rotate(360deg); } }
.search-composer-hint { margin-bottom: 0; }
.header-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.empty-state { text-align: center; }
.empty-state .empty-illustration { opacity: 0.9; }
.msg-item-own .msg-actions { opacity: 0.7; }

/* Pass 4 polish — pins, a11y, members badges */
.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -100px;
  z-index: 1000;
  padding: 0.55rem 0.9rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-lg);
}
.skip-link:focus,
.skip-link:focus-visible {
  top: calc(0.75rem + var(--safe-top));
  outline: 2px solid #fff;
  outline-offset: 2px;
  color: #fff;
  text-decoration: none;
}
.nav-item[aria-current="page"] { /* keep is-active styling */ }

.channel-card-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}
.channel-card-row .channel-card-link { flex: 1; min-width: 0; }
.pin-form { margin: 0.15rem 0 0; flex-shrink: 0; }
.pin-toggle {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  width: 2.25rem;
  height: 2.25rem;
  min-width: 44px;
  min-height: 44px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pin-toggle:hover {
  background: var(--bg);
  border-color: var(--border);
  color: var(--accent);
}
.pin-toggle.is-pinned {
  color: #d97706;
}
.pin-toggle.is-pinned:hover {
  color: #b45309;
}
[data-theme="dark"] .pin-toggle.is-pinned { color: #fbbf24; }
.badge-pinned {
  background: #fff7ed;
  border-color: #fdba74;
  color: #c2410c;
  font-weight: 600;
}
[data-theme="dark"] .badge-pinned {
  background: #431407;
  border-color: #c2410c;
  color: #fdba74;
}
.channel-card.is-pinned {
  border-color: #fdba74;
}

.badge-role { font-weight: 600; }
.badge-role-owner {
  background: #ecfdf5;
  border-color: #6ee7b7;
  color: #047857;
}
.badge-role-member {
  background: var(--bg);
  border-color: var(--border);
  color: var(--muted);
  font-weight: 500;
}
.badge-human {
  background: var(--bg);
  border-color: var(--border);
  color: var(--text);
}
[data-theme="dark"] .badge-role-owner {
  background: #064e3b;
  border-color: #34d399;
  color: #a7f3d0;
}
.avatar-agent {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}
.members-empty {
  text-align: center;
  padding: 1.5rem 1rem;
}
.members-empty .cta-row { justify-content: center; }
.member-edit-link { margin-left: 0.35rem; font-size: 0.8125rem; }
.members-table td { padding-top: 0.85rem; padding-bottom: 0.85rem; }


/* Pass 5 — mobile harden: safe-area, keyboard, tables, PWA */
.table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
.table-scroll .data-table {
  min-width: 28rem;
}
.list-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
body.keyboard-open {
  /* visualViewport shrink active — composer lifts via --keyboard-inset */
}
body.keyboard-open .composer {
  box-shadow: 0 -8px 24px rgba(16, 24, 40, 0.12);
}
[data-theme="dark"] body.keyboard-open .composer,
[data-theme="dark"] .composer {
  box-shadow: 0 -6px 16px rgba(0, 0, 0, 0.35);
}


/* --- P1: profile avatar · visibility · pagination --- */
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  max-width: 12rem;
}
.user-chip .avatar,
.user-chip img.avatar {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}
.user-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
img.avatar,
img.msg-avatar {
  object-fit: cover;
  border-radius: 50%;
  display: block;
}
.avatar-preview {
  margin-bottom: 0.5rem;
}
.form-check {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.form-check-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}
.badge-visibility,
.badge-open,
.badge-private {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  vertical-align: middle;
}
.badge-open {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
}
.badge-private {
  background: color-mix(in srgb, var(--muted) 22%, transparent);
  color: var(--text-muted, var(--muted));
}
[data-theme="dark"] .badge-open {
  background: color-mix(in srgb, var(--accent) 28%, transparent);
}
.timeline-load-more {
  display: flex;
  justify-content: center;
  padding: 0.5rem 0 0.75rem;
}
.pin-spacer {
  width: 2rem;
  flex-shrink: 0;
}
.form-select-sm {
  max-width: 8rem;
  flex: 0 0 auto;
}
.join-prompt {
  text-align: center;
}
.join-prompt p { margin-bottom: 0.75rem; }
.inline-rename-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
}
.inline-rename-form .form-group {
  flex: 1 1 12rem;
  margin-bottom: 0;
}
.workspace-rename-card h3 { margin-top: 0; }
@media (max-width: 640px) {
  .user-chip-name { max-width: 6rem; }
  .search-bar .form-select-sm { max-width: none; width: 100%; }
}


/* ---- P2: DM · reactions · reply · attachments · search ---- */
.badge-dm {
  background: color-mix(in srgb, #a855f7 22%, transparent);
  color: #7e22ce;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  vertical-align: middle;
}
[data-theme="dark"] .badge-dm {
  background: color-mix(in srgb, #c084fc 28%, transparent);
  color: #e9d5ff;
}
.msg-reply-ref {
  border-left: 3px solid var(--accent, #2563eb);
  padding: 0.25rem 0.5rem;
  margin: 0.25rem 0 0.5rem;
  font-size: 0.85rem;
  background: color-mix(in srgb, var(--accent, #2563eb) 8%, transparent);
  border-radius: 0 0.35rem 0.35rem 0;
}
.msg-reply-snippet {
  display: block;
  color: var(--text-muted, var(--muted));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.composer-reply-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.65rem;
  border-radius: 0.5rem;
  background: color-mix(in srgb, var(--accent, #2563eb) 10%, transparent);
  font-size: 0.9rem;
}
.composer-reply-snippet {
  flex: 1 1 8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted, var(--muted));
}
.composer-extras {
  margin-top: 0.5rem;
}
.composer-file-label {
  display: block;
  font-size: 0.8rem;
  margin-bottom: 0.25rem;
}
.form-file {
  font-size: 0.85rem;
  max-width: 100%;
}
.msg-attachments {
  margin-top: 0.5rem;
}
.msg-attachment-img {
  display: block;
  max-width: min(100%, 360px);
  max-height: 280px;
  width: auto;
  height: auto;
  border-radius: 0.5rem;
  object-fit: contain;
  background: color-mix(in srgb, var(--muted) 12%, transparent);
}
.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
  margin-top: 0.4rem;
}
.reaction-form {
  display: inline;
  margin: 0;
}
.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  border: 1px solid color-mix(in srgb, var(--muted) 35%, transparent);
  background: color-mix(in srgb, var(--muted) 10%, transparent);
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  font-size: 0.85rem;
  cursor: pointer;
  line-height: 1.3;
  color: inherit;
}
.reaction-chip.is-mine {
  border-color: var(--accent, #2563eb);
  background: color-mix(in srgb, var(--accent, #2563eb) 16%, transparent);
}
.reaction-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted, var(--muted));
}
.reaction-picker {
  position: relative;
}
.reaction-picker > summary {
  list-style: none;
  cursor: pointer;
}
.reaction-picker > summary::-webkit-details-marker { display: none; }
.reaction-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 999px;
  border: 1px dashed color-mix(in srgb, var(--muted) 45%, transparent);
  color: var(--text-muted, var(--muted));
  font-size: 0.95rem;
  line-height: 1;
}
.reaction-picker-menu {
  position: absolute;
  z-index: 5;
  bottom: 100%;
  left: 0;
  display: flex;
  gap: 0.15rem;
  padding: 0.35rem;
  margin-bottom: 0.25rem;
  background: var(--card-bg, var(--bg, #fff));
  border: 1px solid color-mix(in srgb, var(--muted) 35%, transparent);
  border-radius: 0.5rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
[data-theme="dark"] .reaction-picker-menu {
  background: #1e293b;
  box-shadow: 0 4px 16px rgba(0,0,0,0.45);
}
.reaction-choice {
  border: none;
  background: transparent;
  font-size: 1.15rem;
  cursor: pointer;
  padding: 0.2rem 0.3rem;
  border-radius: 0.35rem;
}
.reaction-choice:hover {
  background: color-mix(in srgb, var(--accent, #2563eb) 18%, transparent);
}
.search-section {
  margin-top: 1rem;
}
.search-hit-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.search-hit-list > li {
  padding: 0.55rem 0;
  border-bottom: 1px solid color-mix(in srgb, var(--muted) 25%, transparent);
}
.search-hit-list > li:last-child { border-bottom: none; }
.search-msg-preview {
  margin: 0.25rem 0 0;
  color: var(--text-muted, var(--muted));
  font-size: 0.9rem;
}
@media (max-width: 640px) {
  .msg-attachment-img { max-width: 100%; }
  .composer-reply-banner { font-size: 0.85rem; }
}


/* Huddle lite */
.huddle-panel {
  margin: 0.75rem 0;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  background: var(--card-bg, #fff);
}
.huddle-panel-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.huddle-note { font-size: 0.85rem; margin: 0.25rem 0 0.5rem; }
.huddle-participants {
  list-style: none;
  margin: 0.4rem 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.huddle-participants li {
  background: var(--chip-bg, #f3f4f6);
  border-radius: 999px;
  padding: 0.15rem 0.65rem;
  font-size: 0.85rem;
}
.huddle-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.workflow-list { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: 0.75rem; }
.workflow-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
}
.badge-muted { opacity: 0.75; }


/* —— Message threads (feature 2) —— */
.msg-thread-footer {
  margin-top: 0.45rem;
  padding-top: 0.35rem;
  border-top: 1px dashed color-mix(in srgb, var(--border, #e5e7eb) 80%, transparent);
}
.msg-thread-footer-empty { border-top: none; padding-top: 0.15rem; }
.msg-thread-link {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent, #2563eb);
  text-decoration: none;
}
.msg-thread-link:hover { text-decoration: underline; }
.thread-layout .thread-back { margin: 0 0 0.35rem; font-size: 0.9rem; }
.thread-layout .thread-back a { color: var(--accent, #2563eb); text-decoration: none; }
.thread-layout .thread-back a:hover { text-decoration: underline; }
.thread-replies-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.75rem 0 0.35rem;
  padding: 0 0.25rem;
}
.thread-replies-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
}
.thread-root-block {
  padding-bottom: 0.5rem;
  border-bottom: 2px solid color-mix(in srgb, var(--accent, #2563eb) 25%, var(--border, #e5e7eb));
}
.thread-replies-block .msg-list { margin-top: 0.25rem; }
.thread-empty { padding: 1rem 0.5rem; }
.thread-timeline { min-height: 200px; }


/* --- Parity P3 feature 3: presence / status --- */
.user-chip-avatar-wrap {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}
.user-chip-avatar-wrap .presence-indicator {
  position: absolute;
  right: -2px;
  bottom: -2px;
  line-height: 0;
}
.user-chip-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0.05rem;
}
.user-chip-status {
  font-size: 0.6875rem;
  line-height: 1.2;
  max-width: 9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.presence-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  vertical-align: middle;
}
.presence-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  border: 2px solid var(--bg-elevated, var(--bg));
  background: #94a3b8;
  box-sizing: content-box;
  flex-shrink: 0;
}
.presence-dot-online { background: #22c55e; }
.presence-dot-away { background: #eab308; }
.presence-dot-dnd { background: #ef4444; }
.presence-dot-offline { background: #94a3b8; }
.presence-label {
  font-size: 0.8125rem;
  color: var(--text);
}
.presence-custom {
  font-size: 0.75rem;
}
.presence-custom-line {
  font-size: 0.75rem;
  margin: 0.15rem 0 0;
  max-width: 18rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.presence-inline {
  display: inline-flex;
  margin-left: 0.25rem;
}
.presence-inline .presence-label {
  font-size: 0.75rem;
  color: var(--muted);
}
.sidebar-presence {
  margin-bottom: 0.5rem;
}
.sidebar-presence .presence-label {
  font-size: 0.75rem;
  color: var(--muted);
}
.presence-meta-dd {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
[data-theme="dark"] .presence-dot {
  border-color: var(--panel, #1e293b);
}

/* Feature 4 — bookmarks & scheduled */
.bookmark-list { list-style: none; margin: 0; padding: 0; }
.bookmark-item {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.bookmark-item:last-child { border-bottom: none; }
.bookmark-item.is-deleted { opacity: 0.75; }
.bookmark-meta { font-size: 0.85rem; margin-bottom: 0.25rem; }
.bookmark-preview { margin: 0.35rem 0 0.5rem; white-space: pre-wrap; }
.bookmark-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.msg-action.is-active { font-weight: 600; color: var(--accent, #2563eb); }
.scheduled-panel .card-title { font-size: 1rem; margin: 0 0 0.5rem; }
.scheduled-list { list-style: none; margin: 0; padding: 0; }
.scheduled-item {
  display: grid;
  gap: 0.25rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.scheduled-item:last-child { border-bottom: none; }
.composer-extras .form-datetime { max-width: 16rem; margin-top: 0.25rem; }


/* Feature 5 — channel message pins + mute polish */
.pinned-strip { margin-bottom: 0.75rem; }
.pinned-strip .card-title { font-size: 1rem; margin: 0 0 0.5rem; }
.pinned-list { list-style: none; margin: 0; padding: 0; }
.pinned-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.pinned-item:last-child { border-bottom: none; }
.pinned-item.is-deleted { opacity: 0.75; }
.pinned-link {
  flex: 1;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}
.pinned-link:hover .pinned-preview { text-decoration: underline; }
.pinned-author {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.15rem;
}
.pinned-preview {
  display: block;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mute-quick-btn.is-muted {
  color: var(--accent, #2563eb);
  font-weight: 600;
}
.msg-action.is-active { font-weight: 600; color: var(--accent, #2563eb); }

/* —— Light 꾸미기 polish (2026-09-07) —— soft tokens + micro-motion; not a redesign */
.nav-item {
  transition: background-color var(--ease), color var(--ease), box-shadow var(--ease);
}
.nav-item:hover {
  background: color-mix(in srgb, var(--accent) 7%, var(--bg));
}
.nav-item.is-active {
  box-shadow: inset 3px 0 0 var(--accent);
}
.btn {
  transition: background-color var(--ease), border-color var(--ease), filter var(--ease), box-shadow var(--ease), transform var(--ease);
}
.btn-primary:hover {
  box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 35%, transparent);
}
.btn-ghost:hover,
.user-chip:hover,
.shortcut-card:hover,
.stat-card:hover,
.project-card:hover,
.channel-card:hover {
  transition: border-color var(--ease), box-shadow var(--ease), background-color var(--ease);
}
.user-chip {
  transition: border-color var(--ease), background-color var(--ease);
}
.card {
  transition: box-shadow var(--ease), border-color var(--ease);
}
.msg-bubble {
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  animation: buzz-bubble-in 0.18s ease-out;
}
[data-theme="dark"] .msg-bubble {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
@keyframes buzz-bubble-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.value-props li,
.shortcut-card,
.huddle-panel,
.workflow-item {
  border-radius: var(--radius-sm);
}
.form-errors,
.message,
.toast {
  border-radius: var(--radius-sm);
}
.brand a,
.brand-link {
  border-radius: var(--radius-sm);
  transition: background-color var(--ease);
}
.brand a:hover,
.brand-link:hover {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  text-decoration: none;
}
.reaction-chip {
  transition: background-color var(--ease), border-color var(--ease);
}
@media (prefers-reduced-motion: reduce) {
  .msg-bubble { animation: none; }
  .nav-item, .btn, .user-chip, .card, .brand a, .reaction-chip {
    transition: none;
  }
}

/* --- AI 설정 (LLM 프로필) ------------------------------------------------ */
.badge-grade,
.badge-internal,
.badge-external {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-grade-public { background: var(--success-bg); color: var(--success-text); }
.badge-grade-internal { background: var(--info-bg); color: var(--info-text); }
.badge-grade-sensitive { background: var(--danger-soft); color: var(--error-text); }
.badge-internal { background: var(--info-bg); color: var(--info-text); }
.badge-external { background: var(--warn-bg); color: var(--warn-text); }
.text-danger { color: var(--error-text); }
.ai-status-row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}
.preset-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  transition: border-color var(--ease), background var(--ease);
}
.preset-card:hover { border-color: var(--accent); background: var(--accent-soft); }
.preset-card .muted { font-size: 0.85rem; }
.llm-card.is-inactive { opacity: 0.6; }
.llm-card .project-card-top { flex-wrap: wrap; gap: 0.4rem; }
.llm-form { max-width: 760px; }
.llm-fieldset { border: 1px solid var(--border); margin: 0 0 1rem; }
.llm-fieldset legend { font-weight: 600; padding: 0 0.4rem; }
.model-list { max-height: 320px; overflow: auto; columns: 2; font-size: 0.85rem; }
@media (max-width: 640px) { .model-list { columns: 1; } }

/* --- AI 메시지·요약·작성 보조 ------------------------------------------- */
.badge-ai {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  white-space: nowrap;
}
.btn-ai::before { content: "✦ "; color: var(--accent); }
.ai-md { line-height: 1.6; overflow-wrap: anywhere; }
.ai-md > :first-child { margin-top: 0; }
.ai-md > :last-child { margin-bottom: 0; }
.ai-md p, .ai-md ul, .ai-md ol, .ai-md blockquote, .ai-md pre, .ai-md .md-table { margin: 0 0 0.6rem; }
.ai-md ul, .ai-md ol { padding-left: 1.3rem; }
.ai-md h3, .ai-md h4, .ai-md h5, .ai-md h6 { margin: 0.8rem 0 0.35rem; font-size: 1rem; }
.ai-md blockquote { border-left: 3px solid var(--border); padding-left: 0.75rem; color: var(--muted); }
.ai-md pre { background: var(--kbd-bg); border-radius: var(--radius-sm); padding: 0.6rem 0.8rem; overflow-x: auto; font-size: 0.85rem; }
.ai-md code { background: var(--kbd-bg); border-radius: 4px; padding: 0 0.25rem; font-size: 0.9em; }
.ai-md pre code { background: none; padding: 0; }
.ai-md .md-table { overflow-x: auto; }
.ai-md table { border-collapse: collapse; font-size: 0.9rem; }
.ai-md th, .ai-md td { border: 1px solid var(--border); padding: 0.3rem 0.55rem; text-align: left; vertical-align: top; }
.ai-md th { background: var(--accent-soft); }
.ai-md a.msg-ref { font-size: 0.8em; font-weight: 600; text-decoration: none; padding: 0 0.2rem; border-radius: 4px; background: var(--accent-soft); }
.ai-result { max-width: 820px; }
.ai-result-head h2 { display: flex; align-items: center; gap: 0.5rem; }
.ai-result-status { display: flex; align-items: center; gap: 0.5rem; margin: 0.75rem 0; }
.ai-result-note { margin-top: 1rem; font-size: 0.85rem; }
.ai-spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--accent);
  animation: ai-spin 0.8s linear infinite;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ai-spinner { animation: none; } }
.ai-assist { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; margin: 0.4rem 0; }
.ai-assist-panel { flex-basis: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.6rem 0.75rem; background: var(--accent-soft); }
.ai-assist-preview { white-space: pre-wrap; margin: 0.4rem 0; }
.ai-assist-actions { display: flex; gap: 0.4rem; }

/* --- C단계: 봇 배지·피드백·물어보기·캔버스·워크플로 ---------------------- */
.badge-bot {
  font-size: 0.7rem; font-weight: 600; padding: 0.1rem 0.45rem; border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 18%, transparent); color: var(--muted);
}
.ai-feedback-inline { display: inline-flex; gap: 0.15rem; margin-top: 0.2rem; }
.ai-feedback-inline .msg-action { font-size: 0.85rem; opacity: 0.6; }
.ai-feedback-inline .msg-action.is-active, .ai-feedback-inline .msg-action:hover { opacity: 1; }
.ai-feedback .btn.is-active { background: var(--accent-soft); border-color: var(--accent); }
.ai-result-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.75rem; align-items: center;
  border-top: 1px solid var(--border); margin-top: 1rem; padding-top: 0.75rem; }
.ai-publish { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.ai-question { background: var(--accent-soft); border-radius: var(--radius-sm); padding: 0.5rem 0.75rem; }
.ai-ask-pop { position: relative; display: inline-block; }
.ai-ask-pop > summary { list-style: none; cursor: pointer; }
.ai-ask-pop > summary::-webkit-details-marker { display: none; }
.ai-ask-form {
  position: absolute; right: 0; top: calc(100% + 0.35rem); z-index: 30; width: min(360px, 86vw);
  display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0.75rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
}
.ai-ask-form .form-control { flex: 1 1 200px; }
.ai-ask-form .help-text { flex-basis: 100%; margin: 0; }
.ai-ask-card { display: flex; align-items: center; }
.canvas-body { margin-top: 0.75rem; }
.canvas-textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9rem; min-height: 360px; }
.canvas-conflict, .canvas-revision { border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem; margin-bottom: 0.75rem; }
.canvas-conflict summary, .canvas-revision summary { cursor: pointer; }
.prompt-default { white-space: pre-wrap; background: var(--kbd-bg); padding: 0.75rem; border-radius: var(--radius-sm); font-size: 0.85rem; }
.workflow-runs { font-size: 0.8rem; }
[data-wf-field="schedule_days"] ul { display: flex; flex-wrap: wrap; gap: 0.6rem; list-style: none; padding: 0; margin: 0; }
[data-wf-field="schedule_days"] label { display: inline-flex; align-items: center; gap: 0.2rem; }

/* --- 사용자 매뉴얼 팝업 (모달·탭) ----------------------------------------- */
.manual-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.manual-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.manual-modal-backdrop[hidden] {
  display: none !important;
}
.manual-dialog {
  width: min(980px, 100%);
  max-height: min(88vh, 860px);
  max-height: min(88dvh, 860px);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: buzz-bubble-in 0.16s ease-out;
}
.manual-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: var(--header-tint);
  border-bottom: 1px solid var(--border);
}
.manual-header-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}
.manual-header-icon {
  font-size: 1.5rem;
  line-height: 1;
}
.manual-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.manual-badge-ver {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}
.manual-subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}
.manual-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.manual-search-input {
  width: 250px;
  max-width: 65vw;
  padding: 0.38rem 0.65rem;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.manual-search-input:focus {
  outline: 2px solid var(--accent);
  border-color: var(--accent);
}
.manual-tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.55rem 1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: thin;
}
.manual-tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 0.48rem 0.8rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--ease), color var(--ease), border-color var(--ease);
}
.manual-tab:hover {
  background: var(--surface);
  color: var(--text);
}
.manual-tab.is-active {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--border);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}
.manual-search-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 1.25rem;
  background: var(--info-bg);
  color: var(--info-text);
  border-bottom: 1px solid var(--info-border);
  font-size: 0.84rem;
}
.manual-search-status[hidden] {
  display: none !important;
}
.manual-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  flex: 1;
  font-size: 0.92rem;
  line-height: 1.65;
}
.manual-panel[hidden] {
  display: none !important;
}
.manual-panel + .manual-panel {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 2px dashed var(--border);
}
.manual-hero-box {
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--border));
  border-radius: var(--radius-sm);
  padding: 0.9rem 1.15rem;
  margin-bottom: 1.15rem;
}
.manual-hero-box h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  color: var(--accent);
}
.manual-hero-box p {
  margin: 0;
  font-size: 0.9rem;
}
.manual-sec-title {
  margin: 1.25rem 0 0.65rem;
  font-size: 1rem;
  font-weight: 700;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}
.manual-panel > .manual-sec-title:first-child {
  margin-top: 0;
}
.manual-steps {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.manual-step-card {
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
}
.manual-step-num {
  flex-shrink: 0;
  background: var(--accent);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  min-width: 58px;
  text-align: center;
  margin-top: 0.1rem;
}
.manual-step-content {
  flex: 1;
  min-width: 0;
}
.manual-step-content h5 {
  margin: 0 0 0.3rem;
  font-size: 0.96rem;
}
.manual-step-content p {
  margin: 0 0 0.4rem;
}
.manual-step-content ul,
.manual-step-content ol {
  margin: 0.25rem 0 0;
  padding-left: 1.2rem;
}
.manual-step-content li {
  margin-bottom: 0.2rem;
}
.manual-quick-link {
  margin: 0.5rem 0 0 !important;
}
.manual-ui-tag {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.08rem 0.45rem;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--accent);
  white-space: nowrap;
}
.manual-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}
.manual-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.85rem;
  margin-bottom: 0.85rem;
}
.manual-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1.05rem;
}
.manual-card h5 {
  margin: 0 0 0.45rem;
  font-size: 0.95rem;
}
.manual-card p {
  margin: 0 0 0.45rem;
}
.manual-card ul,
.manual-card ol {
  margin: 0;
  padding-left: 1.2rem;
}
.manual-card li {
  margin-bottom: 0.28rem;
}
.manual-callout {
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 0.9rem;
  font-size: 0.88rem;
}
.manual-callout.is-tip {
  background: var(--info-bg);
  color: var(--info-text);
  border: 1px solid var(--info-border);
}
.manual-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
  margin-bottom: 0.9rem;
}
.manual-table th,
.manual-table td {
  border: 1px solid var(--border);
  padding: 0.55rem 0.75rem;
  text-align: left;
  vertical-align: top;
}
.manual-table th {
  background: var(--bg);
  font-weight: 600;
  white-space: nowrap;
}
.manual-faq-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.manual-faq-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.9rem;
}
.manual-faq-item summary {
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
}
.manual-faq-item p {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}
.manual-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  background: var(--bg);
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
}
.manual-footer-nav,
.manual-footer-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
@media (max-width: 640px) {
  .manual-modal-backdrop {
    padding: 0.35rem;
  }
  .manual-dialog {
    max-height: 94dvh;
  }
  .manual-header {
    padding: 0.75rem 0.9rem;
  }
  .manual-body {
    padding: 0.9rem;
  }
  .manual-step-card {
    flex-direction: column;
    gap: 0.45rem;
  }
  .manual-search-input {
    width: 100%;
  }
  .manual-table {
    display: block;
    overflow-x: auto;
  }
}

.invite-copy-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.25rem;
}
.invite-copy-row .invite-link {
  flex: 1 1 200px;
}


