@import url(https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap);
/**
 * Design Tokens — minimal professional legal-tech system.
 *
 * Soft grayscale palette, subtle borders and shadows,
 * medium rounded corners. No bright colors — neutral tones only.
 * 4px base grid.
 */

:root {
  /* ── Backgrounds ── */
  --hy-bg-base:         #FFFFFF;
  --hy-bg-subtle:       #F7F7F8;
  --hy-bg-elevated:     #EFEFEF;
  --hy-bg-hover:        #F0F0F0;

  /* ── Foreground ── */
  --hy-fg-base:         #111111;
  --hy-fg-subtle:       #6B6B6B;
  --hy-fg-muted:        #999999;
  --hy-fg-on-accent:    #FFFFFF;

  /* ── Borders ── */
  --hy-border-base:     #E5E5E5;
  --hy-border-subtle:   #F0F0F0;
  --hy-border-focus:    #111111;

  /* ── Accents ── */
  --hy-accent-primary:       #000000;
  --hy-accent-primary-hover: #333333;
  --hy-accent-success:       #3D8B3D;
  --hy-accent-success-bg:    rgba(61, 139, 61, 0.08);
  --hy-accent-warning:       #B8860B;
  --hy-accent-warning-bg:    rgba(184, 134, 11, 0.08);
  --hy-accent-danger:        #C45D4A;
  --hy-accent-danger-bg:     rgba(196, 93, 74, 0.06);

  /* ── Typography ── */
  --hy-font-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  --hy-font-mono:  'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  /* Type scale */
  --hy-text-caption:  11px;
  --hy-text-xs:       12px;
  --hy-text-sm:       13px;
  --hy-text-base:     14px;
  --hy-text-md:       16px;
  --hy-text-lg:       20px;
  --hy-text-xl:       24px;

  /* ── Spacing (4px grid) ── */
  --hy-space-1:   4px;
  --hy-space-2:   8px;
  --hy-space-3:   12px;
  --hy-space-4:   16px;
  --hy-space-5:   20px;
  --hy-space-6:   24px;
  --hy-space-8:   32px;
  --hy-space-10:  40px;

  /* ── Radii (medium, clean) ── */
  --hy-radius-sm:   4px;
  --hy-radius-md:   6px;
  --hy-radius-lg:   8px;
  --hy-radius-xl:   12px;
  --hy-radius-full: 9999px;

  /* ── Motion ── */
  --hy-ease-fast:  150ms ease;
  --hy-ease-base:  200ms ease-out;
  --hy-ease-slow:  300ms ease-out;

  /* ── Shadows (subtle) ── */
  --hy-shadow-sm:  0 1px 2px rgba(0,0,0,0.04);
  --hy-shadow-md:  0 2px 8px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --hy-shadow-none: none;
}

/**
 * Reset — minimal normalize + base element styles.
 */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body, #app {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--hy-font-sans);
  font-size: var(--hy-text-base);
  background-color: var(--hy-bg-base);
  color: var(--hy-fg-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

#app {
  display: flex;
  flex-direction: column;
}

::selection {
  background: var(--hy-accent-primary);
  color: var(--hy-fg-on-accent);
}

/**
 * Layout — app shell, page containers, scrollbar.
 */

/* ── App Shell ── */
.app-root {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background-color: var(--hy-bg-base);
  overflow: hidden;
}

.app-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ── Shared page container ── */
.page-container {
  flex: 1;
  overflow-y: auto;
  padding: var(--hy-space-5) var(--hy-space-4);
}

.page-header {
  margin-bottom: var(--hy-space-5);
}

.page-title {
  font-size: var(--hy-text-md);
  font-weight: 600;
  color: var(--hy-fg-base);
  margin: 0 0 var(--hy-space-1) 0;
  letter-spacing: -0.01em;
}

.page-desc {
  font-size: var(--hy-text-sm);
  color: var(--hy-fg-subtle);
  margin: 0;
  line-height: 1.45;
}

/* ── Section headers ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--hy-space-3);
}

.section-title {
  font-size: var(--hy-text-base);
  font-weight: 600;
  color: var(--hy-fg-base);
  margin: 0;
  letter-spacing: -0.005em;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: var(--hy-space-10) var(--hy-space-5);
  color: var(--hy-fg-muted);
}

.empty-state-icon {
  font-size: 36px;
  margin-bottom: var(--hy-space-3);
  opacity: 0.3;
}

.empty-state h3 {
  margin: 0 0 var(--hy-space-1) 0;
  font-size: var(--hy-text-base);
  font-weight: 600;
  color: var(--hy-fg-subtle);
}

.empty-state p {
  margin: 0;
  font-size: var(--hy-text-sm);
  color: var(--hy-fg-muted);
}

/* ── Spacing utilities ── */
.mt-2 { margin-top: var(--hy-space-2); }
.mb-3 { margin-bottom: var(--hy-space-3); }

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--hy-border-base);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--hy-fg-muted);
}

/**
 * Animations — keyframes and utility classes.
 * Motion is restrained: 150ms hovers, 200ms panels, no bounce/spring.
 */

@keyframes hy-spin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes hy-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes hy-msg-appear {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes hy-slide-down {
  from { opacity: 0; max-height: 0; }
  to   { opacity: 1; max-height: 600px; }
}

@keyframes hy-slide-in-down {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes hy-modal-appear {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes hy-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.15); }
  70%  { box-shadow: 0 0 0 8px rgba(0, 0, 0, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0); }
}

@keyframes hy-step-appear {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes hy-step-slide-in {
  0%   { opacity: 0; transform: translateY(8px); max-height: 0; }
  60%  { opacity: 1; transform: translateY(0); }
  100% { opacity: 1; transform: translateY(0); max-height: 120px; }
}

@keyframes hy-icon-check-in {
  0%   { opacity: 0; transform: scale(0.5); }
  60%  { transform: scale(1.15); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes hy-typing-pulse {
  0%, 80%, 100% { transform: scale(0.5); opacity: 0.2; }
  40%           { transform: scale(1);   opacity: 0.9; }
}

/* Utility animation class */
.animate-fade-in {
  animation: hy-fade-in var(--hy-ease-slow);
}

/* ── Focus visible — accessibility ring ── */
:focus-visible {
  outline: 2px solid var(--hy-border-focus);
  outline-offset: 2px;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--hy-border-focus);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/**
 * Header — fixed top bar with logo, breadcrumbs, actions.
 */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--hy-space-3);
  background: var(--hy-bg-base);
  min-height: 48px;
  z-index: 50;
  position: relative;
  border-bottom: 1px solid var(--hy-border-subtle);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--hy-space-2);
  min-width: 0;
  flex: 1;
}

.header-back-btn {
  margin-right: -2px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: var(--hy-space-2);
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}

.header-logo {
  width: 28px;
  height: 28px;
  background: var(--hy-fg-base);
  border-radius: var(--hy-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: var(--hy-fg-on-accent);
  font-family: Georgia, 'Times New Roman', serif;
  letter-spacing: -0.5px;
}

.header-brand-name {
  font-size: var(--hy-text-base);
  font-weight: 600;
  color: var(--hy-fg-base);
  letter-spacing: -0.02em;
}

.header-breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--hy-text-xs);
  color: var(--hy-fg-muted);
  min-width: 0;
  overflow: hidden;
}

.header-breadcrumb-sep {
  color: var(--hy-fg-muted);
  font-size: 13px;
  flex-shrink: 0;
}

.header-breadcrumb-item {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}

.header-breadcrumb-current {
  color: var(--hy-fg-base);
  font-weight: 500;
}

.header-breadcrumb-link {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: var(--hy-fg-muted);
  cursor: pointer;
  border-radius: var(--hy-radius-sm);
  transition: color var(--hy-ease-fast);
}

.header-breadcrumb-link:hover {
  color: var(--hy-fg-base);
  text-decoration: underline;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--hy-space-2);
  flex-shrink: 0;
}

.header-action-btn {
  color: var(--hy-fg-subtle);
  transition: color var(--hy-ease-fast);
}

.header-action-btn:hover {
  color: var(--hy-fg-base);
}

.header-user-avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--hy-radius-full);
  background: var(--hy-bg-elevated);
  border: 1.5px solid var(--hy-border-base);
  color: var(--hy-fg-subtle);
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: var(--hy-font-sans);
  transition: all var(--hy-ease-fast);
  letter-spacing: 0.02em;
}

.header-user-avatar:hover,
.header-user-avatar.active {
  border-color: var(--hy-fg-muted);
  background: var(--hy-bg-hover);
  color: var(--hy-fg-base);
}

/* ─── Profile dropdown ──────────────────────────────────────────────────── */

.header-profile-wrapper {
  position: relative;
}

.header-profile-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  background: var(--hy-bg-base);
  border: 1px solid var(--hy-border-base);
  border-radius: var(--hy-radius-lg, 10px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
  z-index: 200;
  padding: var(--hy-space-1) 0;
  animation: dropdown-fade-in 0.15s ease-out;
}

@keyframes dropdown-fade-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.header-dropdown-user {
  display: flex;
  align-items: center;
  gap: var(--hy-space-2);
  padding: var(--hy-space-2) var(--hy-space-3);
}

.header-dropdown-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--hy-radius-full);
  background: var(--hy-bg-elevated);
  border: 1.5px solid var(--hy-border-base);
  color: var(--hy-fg-subtle);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: var(--hy-font-sans);
  letter-spacing: 0.02em;
}

.header-dropdown-user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.header-dropdown-name {
  font-size: var(--hy-text-sm);
  font-weight: 600;
  color: var(--hy-fg-base);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-dropdown-email {
  font-size: var(--hy-text-xs);
  color: var(--hy-fg-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-dropdown-divider {
  height: 1px;
  background: var(--hy-border-subtle);
  margin: var(--hy-space-1) 0;
}

.header-dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--hy-space-2);
  width: 100%;
  padding: 8px var(--hy-space-3);
  background: none;
  border: none;
  font-size: var(--hy-text-sm);
  color: var(--hy-fg-base);
  cursor: pointer;
  transition: background var(--hy-ease-fast);
  text-align: left;
  font-family: var(--hy-font-sans);
}

.header-dropdown-item:hover {
  background: var(--hy-bg-hover);
}

.header-dropdown-item svg {
  color: var(--hy-fg-muted);
  flex-shrink: 0;
}

.header-dropdown-item--danger {
  color: var(--hy-fg-danger, #dc2626);
}

.header-dropdown-item--danger svg {
  color: var(--hy-fg-danger, #dc2626);
}

.header-dropdown-item--danger:hover {
  background: rgba(220, 38, 38, 0.06);
}

/**
 * Buttons — all variants: primary (black), secondary, outline, subtle, danger, icon.
 */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--hy-space-1);
  padding: var(--hy-space-2) var(--hy-space-4);
  border: none;
  border-radius: var(--hy-radius-md);
  font-size: var(--hy-text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--hy-ease-fast);
  font-family: var(--hy-font-sans);
  text-decoration: none;
  line-height: 1.4;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Primary — solid black ── */
.btn-primary {
  background: var(--hy-accent-primary);
  color: var(--hy-fg-on-accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--hy-accent-primary-hover);
}

.btn-primary:active:not(:disabled) {
  filter: brightness(0.9);
}

/* ── Secondary ── */
.btn-secondary {
  background: var(--hy-bg-elevated);
  color: var(--hy-fg-base);
  border: 1px solid var(--hy-border-base);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--hy-bg-hover);
  border-color: var(--hy-fg-muted);
}

/* ── Outline ── */
.btn-outline {
  background: transparent;
  border: 1px solid var(--hy-border-base);
  color: var(--hy-fg-base);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--hy-accent-primary);
  color: var(--hy-accent-primary);
  background: rgba(0, 0, 0, 0.03);
}

/* ── Subtle / Ghost ── */
.btn-subtle {
  background: transparent;
  color: var(--hy-fg-muted);
  padding: var(--hy-space-1) var(--hy-space-2);
}

.btn-subtle:hover:not(:disabled) {
  background: var(--hy-bg-elevated);
  color: var(--hy-fg-subtle);
}

/* ── Danger ── */
.btn-danger {
  background: var(--hy-accent-danger);
  color: var(--hy-fg-base);
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(1.1);
}

/* ── Size variants ── */
.btn-sm {
  padding: var(--hy-space-1) var(--hy-space-3);
  font-size: var(--hy-text-xs);
}

.btn-full {
  width: 100%;
}

/* ── Icon button ── */
.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: var(--hy-radius-md);
  background: transparent;
  cursor: pointer;
  color: var(--hy-fg-subtle);
  transition: all var(--hy-ease-fast);
}

.btn-icon:hover {
  background: var(--hy-bg-elevated);
  color: var(--hy-fg-base);
}

/**
 * Forms — inputs, textareas, labels, dividers, actions.
 * Clean neutral backgrounds, no italic placeholders.
 */

.form-section {
  display: flex;
  flex-direction: column;
  gap: var(--hy-space-3);
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--hy-space-1);
}

.form-label {
  font-size: var(--hy-text-xs);
  font-weight: 500;
  color: var(--hy-fg-subtle);
  letter-spacing: 0.02em;
}

.form-label .required {
  color: var(--hy-accent-danger);
  margin-left: 2px;
}

.form-input {
  padding: var(--hy-space-2) var(--hy-space-3);
  border: 1px solid var(--hy-border-base);
  border-radius: var(--hy-radius-lg);
  font-size: var(--hy-text-base);
  background: var(--hy-bg-subtle);
  outline: none;
  font-family: var(--hy-font-sans);
  width: 100%;
  color: var(--hy-fg-base);
  transition: border-color var(--hy-ease-fast);
}

.form-input:focus {
  border-color: var(--hy-border-focus);
}

.form-input::placeholder {
  color: var(--hy-fg-muted);
}

.form-textarea {
  padding: var(--hy-space-2) var(--hy-space-3);
  border: 1px solid var(--hy-border-base);
  border-radius: var(--hy-radius-lg);
  font-size: var(--hy-text-base);
  background: var(--hy-bg-subtle);
  outline: none;
  font-family: var(--hy-font-sans);
  resize: vertical;
  min-height: 80px;
  width: 100%;
  color: var(--hy-fg-base);
  transition: border-color var(--hy-ease-fast);
}

.form-textarea:focus {
  border-color: var(--hy-border-focus);
}

.form-textarea::placeholder {
  color: var(--hy-fg-muted);
}

.form-divider {
  height: 1px;
  background: var(--hy-border-subtle);
  margin: var(--hy-space-1) 0;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--hy-space-2);
  margin-top: var(--hy-space-2);
}

.form-actions--modal {
  margin-top: var(--hy-space-4);
}

/**
 * Login — clean minimal login screen, professional legal-tech aesthetic.
 */

.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: var(--hy-bg-subtle);
  position: relative;
  overflow: hidden;
}

.login-form {
  background: var(--hy-bg-base);
  border: 1px solid var(--hy-border-base);
  padding: var(--hy-space-8) var(--hy-space-6);
  border-radius: var(--hy-radius-xl);
  box-shadow: var(--hy-shadow-md);
  display: flex;
  flex-direction: column;
  gap: var(--hy-space-3);
  width: 100%;
  max-width: 340px;
  position: relative;
  z-index: 1;
  animation: hy-login-appear 0.4s var(--hy-ease-base);
}

@keyframes hy-login-appear {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-logo-container {
  display: flex;
  justify-content: center;
  margin-bottom: var(--hy-space-1);
}

.login-logo-text {
  font-size: var(--hy-text-xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--hy-fg-base);
}

.login-subtitle {
  font-size: var(--hy-text-xs);
  color: var(--hy-fg-muted);
  text-align: center;
  margin-bottom: var(--hy-space-1);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
}

.login-label {
  font-size: var(--hy-text-xs);
  color: var(--hy-fg-subtle);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.login-input {
  padding: 10px var(--hy-space-3);
  border: 1px solid var(--hy-border-base);
  border-radius: var(--hy-radius-lg);
  outline: none;
  font-size: var(--hy-text-base);
  background: var(--hy-bg-base);
  color: var(--hy-fg-base);
  font-family: var(--hy-font-sans);
  width: 100%;
  transition: border-color var(--hy-ease-fast);
}

.login-input:focus {
  border-color: var(--hy-border-focus);
}

.login-input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.login-input::placeholder {
  color: var(--hy-fg-muted);
}

.login-submit-btn {
  background: var(--hy-accent-primary);
  color: var(--hy-fg-on-accent);
  padding: 10px;
  border: none;
  border-radius: var(--hy-radius-md);
  font-size: var(--hy-text-base);
  font-weight: 600;
  cursor: pointer;
  font-family: var(--hy-font-sans);
  width: 100%;
  transition: all var(--hy-ease-fast);
}

.login-submit-btn:hover:not(:disabled) {
  background: var(--hy-accent-primary-hover);
}

.login-submit-btn:active:not(:disabled) {
  filter: brightness(0.9);
}

.login-submit-btn:disabled {
  background: var(--hy-border-base);
  color: var(--hy-fg-muted);
  cursor: not-allowed;
}

.login-divider {
  display: flex;
  align-items: center;
  margin: var(--hy-space-1) 0;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--hy-border-base);
}

.login-divider::before { margin-right: var(--hy-space-3); }
.login-divider::after  { margin-left: var(--hy-space-3); }

.login-divider-text {
  color: var(--hy-fg-muted);
  font-size: var(--hy-text-xs);
  font-weight: 500;
}

.login-sso-btn {
  background: var(--hy-bg-base);
  color: var(--hy-fg-base);
  padding: 10px;
  border: 1px solid var(--hy-border-base);
  border-radius: var(--hy-radius-md);
  font-size: var(--hy-text-base);
  font-weight: 600;
  cursor: pointer;
  font-family: var(--hy-font-sans);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--hy-space-2);
  transition: all var(--hy-ease-fast);
}

.login-sso-btn:hover:not(:disabled) {
  background: var(--hy-bg-hover);
  border-color: var(--hy-fg-muted);
}

.login-sso-btn:disabled {
  cursor: not-allowed;
  animation: hy-pulse 2s infinite;
}

.login-error {
  position: relative;
  padding: var(--hy-space-2) var(--hy-space-8) var(--hy-space-2) var(--hy-space-3);
  background: var(--hy-accent-danger-bg);
  color: var(--hy-accent-danger);
  border: 1px solid rgba(196, 93, 74, 0.2);
  border-radius: var(--hy-radius-lg);
  font-size: var(--hy-text-xs);
  line-height: 1.4;
  animation: hy-fade-in var(--hy-ease-slow);
}

.login-error-close {
  position: absolute;
  right: var(--hy-space-2);
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--hy-accent-danger);
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  opacity: 0.6;
  transition: opacity var(--hy-ease-fast);
}

.login-error-close:hover { opacity: 1; }

.login-sso-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(4px);
  z-index: 10;
  border-radius: var(--hy-radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: var(--hy-space-3);
}

.login-sso-overlay-text {
  margin: 0;
  color: var(--hy-fg-base);
  font-weight: 600;
  font-size: var(--hy-text-sm);
}

/**
 * Home — greeting section and tile card grid.
 */

/* ── Home page ── */
.home-container {
  flex: 1;
  overflow-y: auto;
  padding: var(--hy-space-5) var(--hy-space-4);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.home-greeting {
  margin-bottom: var(--hy-space-6);
  text-align: center;
}

.home-title {
  font-size: var(--hy-text-lg);
  font-weight: 600;
  color: var(--hy-fg-base);
  margin: 0;
  letter-spacing: -0.015em;
}


.home-tiles {
  display: flex;
  flex-direction: column;
  gap: var(--hy-space-2);
}

/* ── Tile Cards ── */
.tile-card {
  display: flex;
  align-items: center;
  gap: var(--hy-space-3);
  padding: var(--hy-space-3);
  background: var(--hy-bg-subtle);
  border: 1px solid var(--hy-border-subtle);
  border-radius: var(--hy-radius-lg);
  cursor: pointer;
  transition: all var(--hy-ease-fast);
  text-align: left;
  font-family: var(--hy-font-sans);
  width: 100%;
  position: relative;
}

.tile-card:hover {
  background: var(--hy-bg-elevated);
  border-color: var(--hy-border-base);
}

.tile-card:active {
  background: var(--hy-bg-hover);
}

.tile-card--disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.tile-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--hy-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
}

/* Variant icon styling — soft grayscale tints */
.tile-card--primary .tile-card-icon {
  background: rgba(0, 0, 0, 0.05);
  color: var(--hy-fg-base);
}

.tile-card--secondary .tile-card-icon {
  background: rgba(0, 0, 0, 0.05);
  color: var(--hy-fg-subtle);
}

.tile-card--accent .tile-card-icon {
  background: rgba(0, 0, 0, 0.05);
  color: var(--hy-fg-subtle);
}

.tile-card--default .tile-card-icon {
  background: var(--hy-bg-elevated);
  color: var(--hy-fg-subtle);
}

.tile-card-text {
  flex: 1;
  min-width: 0;
}

.tile-card-title {
  font-size: var(--hy-text-base);
  font-weight: 600;
  color: var(--hy-fg-base);
  margin: 0 0 2px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.005em;
}

.tile-card-subtitle {
  font-size: var(--hy-text-xs);
  color: var(--hy-fg-subtle);
  margin: 0;
  line-height: 1.35;
}

/**
 * Chat — full chat page: container, header, toolbar, messages,
 *        message bubbles, thinking blocks, edit cards, input area.
 */

/* ═══════════════════════════════════════════════
   CHAT PAGE LAYOUT
   ═══════════════════════════════════════════════ */

.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--hy-bg-base);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--hy-space-2) var(--hy-space-3);
  background: var(--hy-bg-base);
  border-bottom: 1px solid var(--hy-border-subtle);
  min-height: 48px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: var(--hy-space-2);
  flex: 1;
  min-width: 0;
}

.chat-header-info {
  flex: 1;
  min-width: 0;
}

.chat-header-title {
  font-size: var(--hy-text-base);
  font-weight: 600;
  color: var(--hy-fg-base);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.005em;
}

.chat-header-meta {
  font-size: var(--hy-text-caption);
  color: var(--hy-fg-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 1px;
}

.chat-header-back {
  margin-right: -2px;
}

.chat-header-brand {
  width: 26px;
  height: 26px;
  background: var(--hy-fg-base);
  border-radius: var(--hy-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--hy-fg-on-accent);
  font-family: Georgia, serif;
  flex-shrink: 0;
  letter-spacing: -0.5px;
}

.chat-header-right {
  display: flex;
  align-items: center;
  gap: var(--hy-space-2);
  flex-shrink: 0;
}

.chat-pending-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--hy-space-2);
  background: var(--hy-accent-warning-bg);
  color: var(--hy-accent-warning);
  font-size: var(--hy-text-caption);
  font-weight: 600;
  border-radius: var(--hy-radius-full);
  flex-shrink: 0;
  border: none;
  cursor: pointer;
  font-family: var(--hy-font-sans);
  transition: background var(--hy-ease-fast);
}

.chat-pending-badge:hover {
  background: rgba(234, 179, 8, 0.15);
}

/* ── Pending changes collapsible panel ── */
.chat-pending-panel {
  background: var(--hy-bg-subtle);
  border-bottom: 1px solid var(--hy-border-subtle);
  padding: var(--hy-space-2) var(--hy-space-3);
  animation: hy-fade-in var(--hy-ease-base);
}

.chat-pending-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--hy-text-xs);
  color: var(--hy-fg-subtle);
  font-weight: 500;
  margin-bottom: var(--hy-space-2);
}

.chat-pending-panel-actions {
  display: flex;
  gap: var(--hy-space-1);
}

.chat-pending-panel-item {
  padding: var(--hy-space-1) 0;
  border-bottom: 1px solid var(--hy-border-subtle);
  font-size: var(--hy-text-xs);
}

.chat-pending-panel-item:last-child {
  border-bottom: none;
}

.chat-pending-panel-desc {
  color: var(--hy-fg-base);
}

.chat-pending-panel-loc {
  display: block;
  color: var(--hy-accent-primary);
  font-family: var(--hy-font-mono);
  font-size: 10px;
  margin-top: 1px;
}

/* ═══════════════════════════════════════════════
   TOOLBAR (mode selector + action buttons) — legacy
   ═══════════════════════════════════════════════ */

.chat-toolbar {
  display: none; /* moved into input area */
}

.chat-actions {
  display: flex;
  gap: var(--hy-space-1);
}

/* ═══════════════════════════════════════════════
   MODE SELECTOR (Ask / Edit toggle — compact square)
   ═══════════════════════════════════════════════ */

.mode-selector {
  display: flex;
  background: var(--hy-bg-base);
  border: 1px solid var(--hy-border-base);
  border-radius: var(--hy-radius-full);
  padding: 2px;
  gap: 2px;
}

.mode-selector-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: none;
  border-radius: var(--hy-radius-full);
  font-size: var(--hy-text-xs);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--hy-ease-fast);
  background: transparent;
  color: var(--hy-fg-muted);
  font-family: var(--hy-font-sans);
  line-height: 1;
}

.mode-selector-btn--active {
  background: var(--hy-bg-elevated);
  color: var(--hy-fg-base);
  font-weight: 600;
}

.mode-selector-btn:hover:not(.mode-selector-btn--active) {
  color: var(--hy-fg-subtle);
  background: var(--hy-bg-subtle);
}

/* ═══════════════════════════════════════════════
   MESSAGES AREA
   ═══════════════════════════════════════════════ */

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--hy-space-4) var(--hy-space-3);
  display: flex;
  flex-direction: column;
  gap: var(--hy-space-3);
}

/* ── Single message row ── */
.chat-message {
  display: flex;
  gap: var(--hy-space-2);
  max-width: 100%;
  animation: hy-msg-appear var(--hy-ease-base);
}

.chat-message--user {
  flex-direction: row-reverse;
}

.chat-message--assistant {
  flex-direction: row;
}

/* ── Avatar ── */
.chat-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--hy-radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--hy-text-caption);
  font-weight: 600;
  flex-shrink: 0;
  text-transform: uppercase;
}

.chat-avatar--user {
  background: var(--hy-bg-elevated);
  color: var(--hy-fg-subtle);
}

.chat-avatar--assistant {
  background: rgba(0, 0, 0, 0.06);
  color: var(--hy-accent-primary);
}

/* ── Message body ── */
.chat-message-body {
  max-width: 85%;
  min-width: 0;
}

/* ── Message content bubble ── */
.chat-message-content {
  padding: var(--hy-space-3) var(--hy-space-4);
  border-radius: var(--hy-radius-xl);
  font-size: var(--hy-text-base);
  line-height: 1.5;
  word-wrap: break-word;
}

.chat-message--user .chat-message-content {
  background: var(--hy-bg-elevated);
  color: var(--hy-fg-base);
  border-bottom-right-radius: var(--hy-radius-sm);
}

.chat-message--assistant .chat-message-content {
  background: transparent;
  color: var(--hy-fg-base);
  border-bottom-left-radius: var(--hy-radius-sm);
  padding-left: 0;
  padding-right: 0;
}

.chat-message-content p {
  margin: 0 0 var(--hy-space-2) 0;
}

.chat-message-content p:last-child {
  margin-bottom: 0;
}

.chat-message-content strong {
  font-weight: 600;
}

/* ── Thinking block (step-based) ── */
.chat-thinking {
  margin-bottom: var(--hy-space-2);
  border: 1px solid var(--hy-border-base);
  border-radius: var(--hy-radius-md);
  background: var(--hy-bg-base);
  overflow: hidden;
}

.chat-thinking-toggle,
.chat-thinking-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--hy-bg-subtle);
  border: none;
  border-bottom: 1px solid var(--hy-border-subtle);
  padding: var(--hy-space-2) var(--hy-space-3);
  font-family: var(--hy-font-sans);
}

.chat-thinking-label {
  font-size: var(--hy-text-xs);
  font-weight: 600;
  color: var(--hy-fg-muted);
  display: flex;
  align-items: center;
  gap: var(--hy-space-2);
}

.chat-thinking-label-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--hy-border-base);
  border-top-color: var(--hy-fg-subtle);
  border-radius: 50%;
  animation: hy-spin 0.8s linear infinite;
}

.chat-thinking-steps {
  padding: var(--hy-space-1) 0;
}

.chat-thinking-step {
  padding: var(--hy-space-2) var(--hy-space-3);
  border-bottom: 1px solid var(--hy-border-subtle);
  animation: hy-step-slide-in 400ms ease-out both;
}

.chat-thinking-step:last-child {
  border-bottom: none;
}

.chat-thinking-step-header {
  display: flex;
  align-items: center;
  gap: var(--hy-space-2);
}

.chat-thinking-step-icon {
  flex-shrink: 0;
}

.chat-thinking-step-icon--done {
  color: var(--hy-accent-success);
  animation: hy-icon-check-in 300ms ease-out both;
}

.chat-thinking-step-icon--loading {
  color: var(--hy-fg-muted);
  animation: hy-spin 0.9s linear infinite;
}

.chat-thinking-step-title {
  font-size: var(--hy-text-xs);
  font-weight: 500;
  color: var(--hy-fg-base);
  flex: 1;
}

.chat-thinking-step-desc {
  font-size: var(--hy-text-xs);
  color: var(--hy-fg-muted);
  line-height: 1.5;
  margin-top: var(--hy-space-1);
  margin-left: 24px;
}

/* Content hidden until thinking completes */
.chat-message-content--hidden {
  display: none;
}

/* Streaming cursor (blinking caret at end of streamed text) */
.chat-streaming-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--hy-fg-base);
  margin-left: 1px;
  vertical-align: text-bottom;
  animation: cursor-blink 0.6s steps(2) infinite;
}

@keyframes cursor-blink {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

/* ═══════════════════════════════════════════════
   EDIT CARDS (suggested document edits)
   ═══════════════════════════════════════════════ */

.chat-edits {
  margin-top: var(--hy-space-2);
  padding-top: var(--hy-space-2);
  border-top: 1px solid var(--hy-border-subtle);
}

.chat-edits-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--hy-space-2);
}

.chat-edits-count {
  font-size: var(--hy-text-xs);
  font-weight: 600;
  color: var(--hy-fg-subtle);
}

.chat-edits-bulk {
  display: flex;
  gap: var(--hy-space-1);
}

.chat-edit-item {
  padding: var(--hy-space-3);
  background: var(--hy-bg-subtle);
  border-radius: var(--hy-radius-lg);
  margin-bottom: var(--hy-space-2);
  border-left: 3px solid var(--hy-accent-primary);
  transition: all var(--hy-ease-fast);
}

.chat-edit-item--pending {
  border-left-color: var(--hy-accent-primary);
}

.chat-edit-item--accepted {
  border-left-color: var(--hy-accent-success);
  background: var(--hy-accent-success-bg);
}

.chat-edit-item--rejected {
  border-left-color: var(--hy-accent-danger);
  background: var(--hy-accent-danger-bg);
  opacity: 0.5;
}

.chat-edit-desc {
  font-size: var(--hy-text-sm);
  color: var(--hy-fg-base);
  font-weight: 500;
  margin-bottom: 2px;
}

.chat-edit-location {
  font-size: var(--hy-text-caption);
  font-weight: 500;
  color: var(--hy-accent-primary);
  margin-bottom: var(--hy-space-1);
  font-family: var(--hy-font-mono);
}

.chat-edit-old {
  font-size: var(--hy-text-xs);
  color: var(--hy-accent-danger);
  text-decoration: line-through;
  margin-bottom: 2px;
}

.chat-edit-new {
  font-size: var(--hy-text-xs);
  color: var(--hy-accent-success);
  font-weight: 500;
}

.chat-edit-actions {
  display: flex;
  gap: var(--hy-space-1);
  margin-top: var(--hy-space-2);
}

.chat-edit-status-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--hy-space-2);
  border-radius: var(--hy-radius-full);
  font-size: var(--hy-text-caption);
  font-weight: 600;
  margin-top: var(--hy-space-1);
}

.chat-edit-status-badge.accepted {
  background: var(--hy-accent-success-bg);
  color: var(--hy-accent-success);
}

.chat-edit-status-badge.rejected {
  background: var(--hy-accent-danger-bg);
  color: var(--hy-accent-danger);
}

/* ── Checkpoint ── */
.chat-checkpoint {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--hy-space-1) 0;
}

.chat-checkpoint-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--hy-space-1);
  padding: 4px var(--hy-space-3);
  background: rgba(0, 0, 0, 0.04);
  color: var(--hy-accent-primary);
  font-size: var(--hy-text-caption);
  font-weight: 600;
  border-radius: var(--hy-radius-full);
  border: 1px solid var(--hy-border-subtle);
  cursor: pointer;
  font-family: var(--hy-font-sans);
  transition: all var(--hy-ease-fast);
}

.chat-checkpoint-badge:hover {
  background: rgba(0, 0, 0, 0.08);
  border-color: var(--hy-border-base);
}

/* ── Timestamp ── */
.chat-message-time {
  font-size: 10px;
  color: var(--hy-fg-muted);
  margin-top: var(--hy-space-1);
}

.chat-message--user .chat-message-time {
  text-align: right;
}

.chat-message--assistant .chat-message-time {
  text-align: left;
}

/* ═══════════════════════════════════════════════
   NEW CHAT WELCOME VIEW
   ═══════════════════════════════════════════════ */

.chat-welcome {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--hy-space-8) var(--hy-space-6);
}

.chat-welcome-logo {
  width: 64px;
  height: 64px;
  background: var(--hy-bg-subtle);
  border-radius: var(--hy-radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 700;
  color: var(--hy-fg-base);
  font-family: Georgia, serif;
  margin-bottom: var(--hy-space-5);
}

.chat-welcome-greeting {
  font-size: var(--hy-text-lg);
  font-weight: 600;
  color: var(--hy-fg-base);
  text-align: center;
  margin: 0 0 var(--hy-space-1) 0;
}

.chat-welcome-subtitle {
  font-size: var(--hy-text-sm);
  color: var(--hy-fg-muted);
  text-align: center;
  margin: 0 0 var(--hy-space-5) 0;
}

.chat-welcome-tabs {
  display: flex;
  gap: var(--hy-space-2);
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: var(--hy-space-5);
}

.chat-welcome-tab {
  padding: var(--hy-space-2) var(--hy-space-4);
  border: 1px solid var(--hy-border-base);
  background: var(--hy-bg-base);
  border-radius: var(--hy-radius-full);
  font-size: var(--hy-text-base);
  color: var(--hy-fg-subtle);
  cursor: pointer;
  transition: all var(--hy-ease-fast);
  white-space: nowrap;
  font-family: var(--hy-font-sans);
}

.chat-welcome-tab:hover {
  border-color: var(--hy-fg-muted);
}

.chat-welcome-tab--active {
  border-color: var(--hy-fg-base);
  color: var(--hy-fg-base);
  font-weight: 500;
}

.chat-welcome-suggestions {
  border: 1px solid var(--hy-border-base);
  border-radius: var(--hy-radius-xl);
  overflow: hidden;
  width: 100%;
}

.chat-welcome-suggestion {
  display: flex;
  align-items: flex-start;
  gap: var(--hy-space-3);
  padding: var(--hy-space-4);
  border-bottom: 1px solid var(--hy-border-subtle);
  cursor: pointer;
  transition: background var(--hy-ease-fast);
  background: transparent;
  border-left: none;
  border-right: none;
  border-top: none;
  width: 100%;
  text-align: left;
  font-family: var(--hy-font-sans);
}

.chat-welcome-suggestion:last-child {
  border-bottom: none;
}

.chat-welcome-suggestion:hover {
  background: var(--hy-bg-subtle);
}

.chat-welcome-suggestion-icon {
  color: var(--hy-fg-muted);
  flex-shrink: 0;
  margin-top: 2px;
}

.chat-welcome-suggestion-text {
  font-size: var(--hy-text-sm);
  color: var(--hy-fg-base);
  line-height: 1.5;
}

/* ── Welcome inline input ── */
.chat-welcome-input-wrapper {
  width: 100%;
  margin-top: var(--hy-space-5);
}

.chat-welcome-input-container {
  display: flex;
  align-items: center;
  gap: var(--hy-space-2);
  background: var(--hy-bg-base);
  border: 1.5px solid var(--hy-border-base);
  border-radius: 9999px;
  padding: 4px 4px 4px var(--hy-space-2);
  box-shadow: var(--hy-shadow-sm);
  transition: border-color var(--hy-ease-fast), box-shadow var(--hy-ease-fast);
}

.chat-welcome-input-container:focus-within {
  border-color: var(--hy-fg-muted);
  box-shadow: var(--hy-shadow-md);
}

.chat-welcome-input-container .mode-selector {
  border: none;
  background: transparent;
  flex-shrink: 0;
}

.chat-welcome-input-container .chat-input--welcome {
  flex: 1;
  border: none;
  background: transparent;
  padding: 6px 0;
  min-height: 32px;
  font-size: var(--hy-text-sm);
  outline: none;
  resize: none;
  border-radius: 0;
}

.chat-welcome-input-container .chat-input--welcome:focus {
  border-color: transparent;
  box-shadow: none;
}

.chat-welcome-input-container .chat-send-btn {
  width: 32px;
  height: 32px;
}

.chat-typing {
  display: flex;
  align-items: center;
  gap: var(--hy-space-2);
  padding: var(--hy-space-2) var(--hy-space-3);
  font-size: var(--hy-text-xs);
  color: var(--hy-fg-muted);
  animation: hy-fade-in var(--hy-ease-base);
}

.chat-typing-dots {
  display: flex;
  gap: 3px;
}

.chat-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--hy-accent-primary);
  opacity: 0.3;
  animation: hy-typing-pulse 1.4s infinite ease-in-out both;
}

.chat-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.chat-typing-dots span:nth-child(2) { animation-delay: -0.16s; }
.chat-typing-dots span:nth-child(3) { animation-delay: 0; }

/* ═══════════════════════════════════════════════
   INPUT AREA
   ═══════════════════════════════════════════════ */

.chat-input-area {
  padding: 0 var(--hy-space-4) var(--hy-space-4);
  padding-top: var(--hy-space-3);
  background: var(--hy-bg-base);
  border-top: none;
}

/* Remove top padding when summary bar is directly above */
.changes-summary + .chat-input-area {
  padding-top: 0;
}

.chat-input-area-inner {
  background: var(--hy-bg-subtle);
  border-radius: var(--hy-radius-xl);
  padding: var(--hy-space-2) var(--hy-space-3) var(--hy-space-3);
}

.chat-input-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--hy-space-2);
}

.chat-input-actions {
  display: flex;
  gap: var(--hy-space-1);
}

.chat-action-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--hy-border-base);
  border-radius: var(--hy-radius-md);
  background: var(--hy-bg-base);
  color: var(--hy-fg-subtle);
  cursor: pointer;
  transition: all var(--hy-ease-fast);
}

.chat-action-btn:hover:not(:disabled) {
  background: var(--hy-bg-elevated);
  color: var(--hy-fg-base);
  border-color: var(--hy-fg-muted);
}

.chat-action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: var(--hy-space-2);
}

.chat-input {
  flex: 1;
  padding: 10px var(--hy-space-3);
  border: 1px solid var(--hy-border-base);
  border-radius: var(--hy-radius-full);
  font-size: var(--hy-text-base);
  color: var(--hy-fg-base);
  background: var(--hy-bg-base);
  outline: none;
  font-family: var(--hy-font-sans);
  resize: none;
  min-height: 40px;
  max-height: 120px;
  transition: border-color var(--hy-ease-fast);
  line-height: 1.5;
}

.chat-input:focus {
  border-color: var(--hy-border-focus);
}

.chat-input::placeholder {
  color: var(--hy-fg-muted);
}

.chat-send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--hy-radius-full);
  background: var(--hy-accent-primary);
  color: var(--hy-fg-on-accent);
  cursor: pointer;
  transition: all var(--hy-ease-fast);
  flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
  background: var(--hy-accent-primary-hover);
}

.chat-send-btn:active:not(:disabled) {
  filter: brightness(0.9);
}

.chat-send-btn:disabled {
  background: var(--hy-bg-elevated);
  color: var(--hy-fg-muted);
  cursor: not-allowed;
}

/* ── Attachment chips ── */
.chat-attachment-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--hy-space-1);
  margin-bottom: var(--hy-space-2);
}

.chat-attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--hy-space-2);
  background: var(--hy-bg-base);
  border: 1px solid var(--hy-border-base);
  border-radius: var(--hy-radius-full);
  font-size: 11px;
  color: var(--hy-fg-subtle);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-attachment-chip-remove {
  background: none;
  border: none;
  color: var(--hy-fg-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  margin-left: 2px;
  font-family: var(--hy-font-sans);
}

.chat-attachment-chip-remove:hover {
  color: var(--hy-accent-danger);
}

/* ═══════════════════════════════════════════════
   DRAG-AND-DROP OVERLAY
   ═══════════════════════════════════════════════ */

.chat-drop-active {
  position: relative;
}

.chat-drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--hy-space-2);
  background: rgba(255, 255, 255, 0.92);
  border: 2px dashed var(--hy-accent-primary);
  border-radius: var(--hy-radius-xl);
  color: var(--hy-fg-base);
  font-size: var(--hy-text-sm);
  font-weight: 600;
  pointer-events: none;
  animation: hy-fade-in 150ms ease-out;
  backdrop-filter: blur(2px);
}

.chat-drop-overlay svg {
  opacity: 0.6;
}

/* ═══════════════════════════════════════════════
   ATTACHED DOCUMENTS (above chat input)
   ═══════════════════════════════════════════════ */

.attached-docs {
  margin-bottom: var(--hy-space-2);
  animation: hy-fade-in var(--hy-ease-base);
}

.attached-docs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--hy-space-1);
}

.attached-docs-count {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--hy-text-xs);
  font-weight: 500;
  color: var(--hy-fg-muted);
}

.attached-docs-clear {
  background: none;
  border: none;
  color: var(--hy-fg-muted);
  font-size: var(--hy-text-caption);
  font-weight: 500;
  cursor: pointer;
  padding: 2px var(--hy-space-1);
  border-radius: var(--hy-radius-sm);
  font-family: var(--hy-font-sans);
  transition: all var(--hy-ease-fast);
}

.attached-docs-clear:hover {
  color: var(--hy-accent-danger);
  background: var(--hy-accent-danger-bg);
}

.attached-docs-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--hy-space-2);
}

.attached-doc-card {
  display: flex;
  align-items: center;
  gap: var(--hy-space-2);
  padding: var(--hy-space-2) var(--hy-space-3);
  background: var(--hy-bg-base);
  border: 1px solid var(--hy-border-base);
  border-radius: var(--hy-radius-lg);
  min-width: 0;
  max-width: 220px;
  transition: all var(--hy-ease-fast);
  animation: hy-fade-in 200ms ease-out;
}

.attached-doc-card:hover {
  border-color: var(--hy-fg-muted);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.attached-doc-ext {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--hy-radius-md);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.attached-doc-ext--word {
  background: rgba(43, 87, 154, 0.1);
  color: #2B579A;
}

.attached-doc-ext--pdf {
  background: rgba(196, 50, 50, 0.1);
  color: #C43232;
}

.attached-doc-ext--excel {
  background: rgba(33, 115, 70, 0.1);
  color: #217346;
}

.attached-doc-ext--generic {
  background: var(--hy-bg-elevated);
  color: var(--hy-fg-subtle);
}

.attached-doc-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.attached-doc-name {
  font-size: var(--hy-text-xs);
  font-weight: 600;
  color: var(--hy-fg-base);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}

.attached-doc-size {
  font-size: var(--hy-text-caption);
  color: var(--hy-fg-muted);
  line-height: 1.3;
}

.attached-doc-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: var(--hy-radius-full);
  background: transparent;
  color: var(--hy-fg-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--hy-ease-fast);
  padding: 0;
}

.attached-doc-remove:hover {
  background: var(--hy-accent-danger-bg);
  color: var(--hy-accent-danger);
}

/* ═══════════════════════════════════════════════
   CHAT LIST (in Document Detail page)
   ═══════════════════════════════════════════════ */

.chat-list {
  display: flex;
  flex-direction: column;
  gap: var(--hy-space-2);
}

.chat-list-item {
  display: flex;
  align-items: center;
  gap: var(--hy-space-3);
  padding: var(--hy-space-3);
  background: var(--hy-bg-subtle);
  border: 1px solid var(--hy-border-subtle);
  border-radius: var(--hy-radius-lg);
  cursor: pointer;
  transition: all var(--hy-ease-fast);
}

.chat-list-item:hover {
  background: var(--hy-bg-elevated);
  border-color: var(--hy-border-base);
}

.chat-list-item-icon {
  color: var(--hy-accent-primary);
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: var(--hy-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.chat-list-item-content {
  flex: 1;
  min-width: 0;
}

.chat-list-item-title {
  font-size: var(--hy-text-sm);
  font-weight: 600;
  color: var(--hy-fg-base);
}

.chat-list-item-preview {
  font-size: var(--hy-text-xs);
  color: var(--hy-fg-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-list-item-meta {
  font-size: var(--hy-text-caption);
  color: var(--hy-fg-muted);
  margin-top: 3px;
}

/* ═══════════════════════════════════════════════
   TRACKED CHANGE CARDS
   ═══════════════════════════════════════════════ */

.tracked-change {
  padding: var(--hy-space-3);
  background: var(--hy-bg-subtle);
  border-radius: var(--hy-radius-lg);
  margin-bottom: var(--hy-space-2);
  border-left: 3px solid var(--hy-accent-primary);
  transition: all var(--hy-ease-fast);
  animation: hy-fade-in var(--hy-ease-base);
}

.tracked-change--pending {
  border-left-color: var(--hy-accent-primary);
}

.tracked-change--accepted {
  border-left-color: var(--hy-accent-success);
  background: var(--hy-accent-success-bg);
}

.tracked-change--rejected {
  border-left-color: var(--hy-accent-danger);
  background: var(--hy-accent-danger-bg);
  opacity: 0.55;
}

.tracked-change-header {
  display: flex;
  align-items: center;
  gap: var(--hy-space-2);
  margin-bottom: var(--hy-space-2);
  flex-wrap: wrap;
}

.tracked-change-index {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: var(--hy-radius-full);
  background: var(--hy-bg-elevated);
  font-size: 10px;
  font-weight: 700;
  color: var(--hy-fg-subtle);
  flex-shrink: 0;
}

.tracked-change-type {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px var(--hy-space-2);
  border-radius: var(--hy-radius-full);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.tracked-change-type--replace {
  background: rgba(0, 0, 0, 0.06);
  color: var(--hy-fg-subtle);
}

.tracked-change-type--insert {
  background: var(--hy-accent-success-bg);
  color: var(--hy-accent-success);
}

.tracked-change-type--delete {
  background: var(--hy-accent-danger-bg);
  color: var(--hy-accent-danger);
}

.tracked-change-location {
  font-size: var(--hy-text-caption);
  font-weight: 500;
  color: var(--hy-accent-primary);
  font-family: var(--hy-font-mono);
  margin-left: auto;
}

.tracked-change-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--hy-space-2);
  border-radius: var(--hy-radius-full);
  font-size: var(--hy-text-caption);
  font-weight: 600;
  margin-left: auto;
}

.tracked-change-badge--accepted {
  background: var(--hy-accent-success-bg);
  color: var(--hy-accent-success);
}

.tracked-change-badge--rejected {
  background: var(--hy-accent-danger-bg);
  color: var(--hy-accent-danger);
}

.tracked-change-desc {
  font-size: var(--hy-text-sm);
  color: var(--hy-fg-base);
  font-weight: 500;
  margin-bottom: var(--hy-space-2);
  line-height: 1.45;
}

/* ── Diff view ── */
.tracked-change-diff {
  border-radius: var(--hy-radius-md);
  overflow: hidden;
  border: 1px solid var(--hy-border-subtle);
  background: var(--hy-bg-base);
  font-family: var(--hy-font-mono);
  font-size: 11px;
  line-height: 1.6;
  margin-bottom: var(--hy-space-2);
}

.tracked-change-diff-line {
  display: flex;
  align-items: flex-start;
  padding: var(--hy-space-1) var(--hy-space-2);
}

.tracked-change-diff-line--old {
  background: rgba(196, 93, 74, 0.06);
  color: var(--hy-accent-danger);
}

.tracked-change-diff-line--new {
  background: rgba(61, 139, 61, 0.06);
  color: var(--hy-accent-success);
}

.tracked-change-diff-marker {
  width: 16px;
  flex-shrink: 0;
  font-weight: 700;
  text-align: center;
  user-select: none;
}

.tracked-change-diff-text {
  flex: 1;
  word-break: break-word;
  white-space: pre-wrap;
}

.tracked-change-actions {
  display: flex;
  gap: var(--hy-space-1);
  margin-top: var(--hy-space-1);
}

/* ═══════════════════════════════════════════════
   CHANGES SUMMARY (above chat input)
   ═══════════════════════════════════════════════ */

.changes-summary {
  border-top: 1px solid var(--hy-border-subtle);
  background: var(--hy-bg-subtle);
  animation: hy-fade-in var(--hy-ease-base);
  margin-bottom: 0;
}

.changes-summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--hy-space-2) var(--hy-space-3);
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: var(--hy-font-sans);
  transition: background var(--hy-ease-fast);
}

.changes-summary-bar:hover {
  background: var(--hy-bg-hover);
}

.changes-summary-bar-left {
  display: flex;
  align-items: center;
  gap: var(--hy-space-2);
}

.changes-summary-bar-right {
  display: flex;
  align-items: center;
}

.changes-summary-icon {
  color: var(--hy-fg-muted);
  flex-shrink: 0;
}

.changes-summary-title {
  font-size: var(--hy-text-sm);
  font-weight: 600;
  color: var(--hy-fg-base);
}

.changes-summary-counts {
  display: flex;
  gap: var(--hy-space-2);
}

.changes-summary-count {
  font-size: var(--hy-text-caption);
  font-weight: 600;
  padding: 1px var(--hy-space-2);
  border-radius: var(--hy-radius-full);
}

.changes-summary-count--pending {
  background: var(--hy-accent-warning-bg);
  color: var(--hy-accent-warning);
}

.changes-summary-count--accepted {
  background: var(--hy-accent-success-bg);
  color: var(--hy-accent-success);
}

.changes-summary-count--rejected {
  background: var(--hy-accent-danger-bg);
  color: var(--hy-accent-danger);
}

.changes-summary-chevron {
  transition: transform var(--hy-ease-fast);
  color: var(--hy-fg-muted);
}

.changes-summary-chevron--up {
  transform: rotate(180deg);
}

.changes-summary-panel {
  padding: 0 var(--hy-space-3) var(--hy-space-3);
  animation: hy-fade-in var(--hy-ease-base);
}

.changes-summary-bulk {
  display: flex;
  gap: var(--hy-space-1);
  margin-bottom: var(--hy-space-2);
}

.changes-summary-list {
  display: flex;
  flex-direction: column;
  gap: var(--hy-space-1);
  max-height: 200px;
  overflow-y: auto;
}

.changes-summary-item {
  display: flex;
  flex-direction: column;
  gap: var(--hy-space-1);
  padding: var(--hy-space-2);
  border-radius: var(--hy-radius-md);
  background: var(--hy-bg-base);
  border: 1px solid var(--hy-border-subtle);
  transition: all var(--hy-ease-fast);
}

.changes-summary-item--accepted {
  border-color: rgba(61, 139, 61, 0.2);
  background: var(--hy-accent-success-bg);
}

.changes-summary-item--rejected {
  border-color: rgba(196, 93, 74, 0.15);
  background: var(--hy-accent-danger-bg);
  opacity: 0.55;
}

.changes-summary-item-header {
  display: flex;
  align-items: center;
  gap: var(--hy-space-2);
  min-width: 0;
}

.changes-summary-item-idx {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: var(--hy-radius-full);
  background: var(--hy-bg-elevated);
  font-size: 10px;
  font-weight: 700;
  color: var(--hy-fg-subtle);
  flex-shrink: 0;
}

.changes-summary-item-type {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 1px 6px;
  border-radius: var(--hy-radius-full);
  flex-shrink: 0;
}

.changes-summary-item-type--replace {
  background: rgba(0, 0, 0, 0.06);
  color: var(--hy-fg-subtle);
}

.changes-summary-item-type--insert {
  background: var(--hy-accent-success-bg);
  color: var(--hy-accent-success);
}

.changes-summary-item-type--delete {
  background: var(--hy-accent-danger-bg);
  color: var(--hy-accent-danger);
}

.changes-summary-item-desc {
  font-size: var(--hy-text-xs);
  color: var(--hy-fg-base);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.changes-summary-item-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--hy-radius-full);
  text-transform: capitalize;
  flex-shrink: 0;
  margin-left: auto;
}

.changes-summary-item-badge--accepted {
  background: var(--hy-accent-success-bg);
  color: var(--hy-accent-success);
}

.changes-summary-item-badge--rejected {
  background: var(--hy-accent-danger-bg);
  color: var(--hy-accent-danger);
}

.changes-summary-item-actions {
  display: flex;
  gap: var(--hy-space-1);
  margin-top: 2px;
}

/* ═══════════════════════════════════════════════
   CHAT SIDEBAR (collapsible history panel)
   ═══════════════════════════════════════════════ */

.chat-sidebar-toggle {
  color: var(--hy-fg-muted);
  transition: color var(--hy-ease-fast);
}

.chat-sidebar-toggle:hover,
.chat-sidebar-toggle--active {
  color: var(--hy-fg-base);
}

.chat-sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.15);
  z-index: 90;
  animation: hy-fade-in 150ms ease;
}

.chat-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 280px;
  max-width: 85%;
  background: var(--hy-bg-base);
  border-left: 1px solid var(--hy-border-subtle);
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.08);
  z-index: 100;
  display: flex;
  flex-direction: column;
  animation: chat-sidebar-slide-in 200ms ease-out;
}

@keyframes chat-sidebar-slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);   opacity: 1; }
}

.chat-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--hy-space-3) var(--hy-space-4);
  border-bottom: 1px solid var(--hy-border-subtle);
  flex-shrink: 0;
}

.chat-sidebar-title {
  font-size: var(--hy-text-sm);
  font-weight: 600;
  color: var(--hy-fg-base);
  letter-spacing: -0.005em;
}

.chat-sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--hy-space-2);
}

.chat-sidebar-empty {
  text-align: center;
  color: var(--hy-fg-muted);
  font-size: var(--hy-text-xs);
  padding: var(--hy-space-6) var(--hy-space-3);
}

.chat-sidebar-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--hy-space-2) var(--hy-space-3);
  background: transparent;
  border: none;
  border-radius: var(--hy-radius-md);
  cursor: pointer;
  transition: background var(--hy-ease-fast);
  font-family: var(--hy-font-sans);
  margin-bottom: 1px;
}

.chat-sidebar-item:hover {
  background: var(--hy-bg-subtle);
}

.chat-sidebar-item--active {
  background: var(--hy-bg-elevated);
}

.chat-sidebar-item-title {
  font-size: var(--hy-text-xs);
  font-weight: 600;
  color: var(--hy-fg-base);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 1px;
}

.chat-sidebar-item-meta {
  font-size: var(--hy-text-caption);
  color: var(--hy-fg-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/**
 * Browse Matters — card-based expandable matter tree with documents & chats.
 */

/* ── Search ── */
.browse-search-wrapper {
  position: relative;
  margin-bottom: var(--hy-space-4);
}

.browse-search-icon {
  position: absolute;
  top: 50%;
  left: var(--hy-space-3);
  transform: translateY(-50%);
  color: var(--hy-fg-muted);
  pointer-events: none;
}

.browse-search-input {
  width: 100%;
  padding: 9px var(--hy-space-3) 9px 34px;
  border: 1px solid var(--hy-border-base);
  border-radius: var(--hy-radius-full);
  background: var(--hy-bg-subtle);
  font-size: var(--hy-text-sm);
  font-family: var(--hy-font-sans);
  color: var(--hy-fg-base);
  outline: none;
  transition: border-color var(--hy-ease-fast), box-shadow var(--hy-ease-fast);
}

.browse-search-input:focus {
  border-color: var(--hy-border-focus);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.04);
}

.browse-search-input::placeholder {
  color: var(--hy-fg-muted);
}

/* ── Matter card ── */
.matter-list {
  display: flex;
  flex-direction: column;
  gap: var(--hy-space-3);
}

.matter-card {
  background: var(--hy-bg-base);
  border: 1px solid var(--hy-border-subtle);
  border-radius: var(--hy-radius-xl);
  overflow: hidden;
  transition: border-color var(--hy-ease-fast), box-shadow var(--hy-ease-fast);
}

.matter-card:hover {
  border-color: var(--hy-border-base);
}

.matter-card--open {
  border-color: var(--hy-border-base);
  box-shadow: var(--hy-shadow-md);
}

.matter-card-header {
  display: flex;
  align-items: center;
  gap: var(--hy-space-3);
  padding: var(--hy-space-3) var(--hy-space-4);
  cursor: pointer;
  transition: background var(--hy-ease-fast);
}

.matter-card-header:hover {
  background: var(--hy-bg-subtle);
}

.matter-card-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--hy-radius-md);
  background: var(--hy-bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--hy-fg-subtle);
}

.matter-card--open .matter-card-icon {
  background: var(--hy-fg-base);
  color: var(--hy-fg-on-accent);
}

.matter-card-info {
  flex: 1;
  min-width: 0;
}

.matter-card-name {
  font-size: var(--hy-text-base);
  font-weight: 600;
  color: var(--hy-fg-base);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.005em;
}

.matter-card-meta {
  font-size: var(--hy-text-xs);
  color: var(--hy-fg-muted);
  margin-top: 1px;
}

.matter-card-chevron {
  flex-shrink: 0;
  color: var(--hy-fg-muted);
  transition: transform var(--hy-ease-base);
}

.matter-card-chevron--open {
  transform: rotate(180deg);
  color: var(--hy-fg-base);
}

/* ── Expanded body ── */
.matter-card-body {
  padding: 0 var(--hy-space-4) var(--hy-space-4);
  animation: hy-slide-down var(--hy-ease-base);
}

.matter-empty-hint {
  font-size: var(--hy-text-xs);
  color: var(--hy-fg-muted);
  text-align: center;
  padding: var(--hy-space-4) 0;
}

/* ── Document list inside matter ── */
.matter-doc-list {
  display: flex;
  flex-direction: column;
  gap: var(--hy-space-2);
}

.matter-doc-card {
  background: var(--hy-bg-subtle);
  border: 1px solid var(--hy-border-subtle);
  border-radius: var(--hy-radius-lg);
  overflow: hidden;
}

.matter-doc-card-header {
  display: flex;
  align-items: center;
  gap: var(--hy-space-2);
  padding: var(--hy-space-3);
  cursor: pointer;
  transition: background var(--hy-ease-fast);
}

.matter-doc-card-header:hover {
  background: var(--hy-bg-elevated);
}

.matter-doc-card-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--hy-radius-sm);
  background: var(--hy-bg-base);
  border: 1px solid var(--hy-border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--hy-fg-subtle);
}

.matter-doc-card-info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: var(--hy-space-2);
}

.matter-doc-card-name {
  font-size: var(--hy-text-sm);
  font-weight: 600;
  color: var(--hy-fg-base);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.matter-doc-card-count {
  font-size: var(--hy-text-caption);
  color: var(--hy-fg-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.matter-doc-card-arrow {
  flex-shrink: 0;
  color: var(--hy-fg-muted);
  opacity: 0;
  transition: opacity var(--hy-ease-fast);
}

.matter-doc-card-header:hover .matter-doc-card-arrow {
  opacity: 1;
}

/* ── Chat list inside document ── */
.matter-chat-list {
  border-top: 1px solid var(--hy-border-subtle);
}

.matter-chat-row {
  display: flex;
  align-items: center;
  gap: var(--hy-space-2);
  padding: 7px var(--hy-space-3) 7px var(--hy-space-4);
  cursor: pointer;
  transition: background var(--hy-ease-fast);
}

.matter-chat-row:hover {
  background: var(--hy-bg-elevated);
}

.matter-chat-row-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--hy-fg-muted);
}

.matter-chat-row:hover .matter-chat-row-icon {
  color: var(--hy-fg-base);
}

.matter-chat-row-title {
  flex: 1;
  font-size: var(--hy-text-xs);
  color: var(--hy-fg-subtle);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.matter-chat-row:hover .matter-chat-row-title {
  color: var(--hy-fg-base);
}

.matter-chat-row-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--hy-fg-muted);
  background: var(--hy-bg-elevated);
  border-radius: var(--hy-radius-full);
  padding: 1px 6px;
  flex-shrink: 0;
  min-width: 18px;
  text-align: center;
}

/* ── Add Document button ── */
.matter-add-doc-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--hy-space-1);
  width: 100%;
  margin-top: var(--hy-space-3);
  padding: var(--hy-space-2) var(--hy-space-3);
  border: 1px dashed var(--hy-border-base);
  border-radius: var(--hy-radius-lg);
  background: transparent;
  font-size: var(--hy-text-xs);
  font-weight: 500;
  font-family: var(--hy-font-sans);
  color: var(--hy-fg-muted);
  cursor: pointer;
  transition: all var(--hy-ease-fast);
}

.matter-add-doc-btn:hover {
  border-color: var(--hy-fg-subtle);
  color: var(--hy-fg-base);
  background: var(--hy-bg-subtle);
}

/**
 * Detail — document detail card with stats and chat list.
 */

.detail-card {
  background: var(--hy-bg-subtle);
  border: 1px solid var(--hy-border-subtle);
  border-radius: var(--hy-radius-lg);
  padding: var(--hy-space-4);
  margin-bottom: var(--hy-space-5);
}

.detail-card-header {
  display: flex;
  align-items: center;
  gap: var(--hy-space-3);
  margin-bottom: var(--hy-space-2);
}

.detail-card-title {
  font-size: var(--hy-text-base);
  font-weight: 600;
  color: var(--hy-fg-base);
  letter-spacing: -0.005em;
}

.detail-card-meta {
  font-size: var(--hy-text-xs);
  color: var(--hy-fg-muted);
  margin-top: 1px;
}

.detail-card-desc {
  font-size: var(--hy-text-sm);
  color: var(--hy-fg-subtle);
  margin: var(--hy-space-2) 0 0;
  line-height: 1.45;
}

.detail-card-stats {
  display: flex;
  gap: var(--hy-space-5);
  margin-top: var(--hy-space-3);
  padding-top: var(--hy-space-3);
  border-top: 1px solid var(--hy-border-subtle);
}

.detail-stat {
  font-size: var(--hy-text-xs);
  color: var(--hy-fg-muted);
}

/* ═══════════════════════════════════════════════
   CROSS-DOCUMENT BANNER
   ═══════════════════════════════════════════════ */

.cross-doc-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--hy-space-3);
  padding: var(--hy-space-3) var(--hy-space-4);
  margin-bottom: var(--hy-space-4);
  background: var(--hy-accent-warning-bg);
  border: 1px solid rgba(184, 134, 11, 0.15);
  border-radius: var(--hy-radius-lg);
}

.cross-doc-banner-content {
  display: flex;
  align-items: center;
  gap: var(--hy-space-2);
  font-size: var(--hy-text-sm);
  color: var(--hy-accent-warning);
  font-weight: 500;
}

.cross-doc-banner-content svg {
  flex-shrink: 0;
  color: var(--hy-accent-warning);
}

/**
 * Settings — profile card, connection info, sign-out, footer.
 */

.settings-card {
  background: var(--hy-bg-subtle);
  border: 1px solid var(--hy-border-subtle);
  border-radius: var(--hy-radius-lg);
  padding: var(--hy-space-4);
  margin-bottom: var(--hy-space-3);
}

.settings-profile-row {
  display: flex;
  align-items: center;
  gap: var(--hy-space-4);
  padding: var(--hy-space-1) 0;
}

.settings-profile-info {
  flex: 1;
  min-width: 0;
}

.settings-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--hy-radius-full);
  background: rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--hy-text-lg);
  font-weight: 600;
  color: var(--hy-fg-base);
  flex-shrink: 0;
}

.settings-profile-name {
  font-weight: 600;
  font-size: var(--hy-text-base);
  color: var(--hy-fg-base);
}

.settings-profile-email {
  font-size: var(--hy-text-xs);
  color: var(--hy-fg-subtle);
  margin-top: 1px;
}

.settings-profile-role {
  font-size: var(--hy-text-caption);
  color: var(--hy-fg-muted);
  margin-top: 2px;
  text-transform: capitalize;
}

.settings-section-title {
  font-weight: 600;
  font-size: var(--hy-text-base);
  color: var(--hy-fg-base);
  margin-bottom: var(--hy-space-2);
  letter-spacing: -0.005em;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: var(--hy-space-2) 0;
}

.settings-row-label {
  font-size: var(--hy-text-sm);
  color: var(--hy-fg-base);
}

.settings-row-value {
  font-size: var(--hy-text-caption);
  color: var(--hy-fg-muted);
  margin-top: 1px;
  word-break: break-all;
}

.settings-footer {
  padding: var(--hy-space-5) var(--hy-space-4);
  text-align: center;
  font-size: var(--hy-text-caption);
  color: var(--hy-fg-muted);
}

/**
 * Shared components — loading, error banner, modal, document source,
 *                     suggested prompts.
 */

/* ═══════════════════════════════════════════════
   LOADING SPINNER
   ═══════════════════════════════════════════════ */

.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--hy-space-10) var(--hy-space-5);
  gap: var(--hy-space-4);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--hy-border-base);
  border-top: 3px solid var(--hy-accent-primary);
  border-radius: 50%;
  animation: hy-spin 0.8s linear infinite;
}

.loading-spinner--small  { width: 22px; height: 22px; border-width: 2.5px; }
.loading-spinner--medium { width: 32px; height: 32px; border-width: 3px; }
.loading-spinner--large  { width: 44px; height: 44px; border-width: 3px; }

.loading-message {
  color: var(--hy-fg-muted);
  font-size: var(--hy-text-sm);
  text-align: center;
}

/* ═══════════════════════════════════════════════
   ERROR BANNER
   ═══════════════════════════════════════════════ */

.error-banner {
  background: var(--hy-accent-danger-bg);
  border: 1px solid rgba(196, 93, 74, 0.15);
  border-radius: var(--hy-radius-lg);
  margin: var(--hy-space-2) var(--hy-space-4);
  color: var(--hy-accent-danger);
  font-size: var(--hy-text-sm);
  animation: hy-slide-in-down var(--hy-ease-slow);
}

.error-banner-content {
  display: flex;
  align-items: flex-start;
  gap: var(--hy-space-2);
  padding: var(--hy-space-3);
}

.error-banner-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: var(--hy-radius-full);
  background: var(--hy-accent-danger);
  color: var(--hy-fg-base);
  font-size: 10px;
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 1px;
}

.error-banner-text-wrapper {
  flex: 1;
  min-width: 0;
}

.error-banner-text {
  font-size: var(--hy-text-xs);
}

.error-banner-close {
  background: none;
  border: none;
  color: var(--hy-accent-danger);
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  margin-left: auto;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity var(--hy-ease-fast);
}

.error-banner-close:hover {
  opacity: 1;
}

/* ═══════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: hy-fade-in 150ms ease;
}

.modal-content {
  background: var(--hy-bg-subtle);
  border: 1px solid var(--hy-border-base);
  border-radius: var(--hy-radius-xl);
  padding: var(--hy-space-6);
  width: 90%;
  max-width: 380px;
  animation: hy-modal-appear var(--hy-ease-base);
}

.modal-title {
  font-size: var(--hy-text-md);
  font-weight: 600;
  color: var(--hy-fg-base);
  margin-bottom: var(--hy-space-3);
  letter-spacing: -0.01em;
}

.modal-desc {
  font-size: var(--hy-text-sm);
  color: var(--hy-fg-subtle);
  margin-bottom: var(--hy-space-4);
  line-height: 1.45;
}

/* ═══════════════════════════════════════════════
   DOCUMENT SOURCE TOGGLE
   ═══════════════════════════════════════════════ */

.doc-source-toggle {
  display: flex;
  flex-direction: column;
  gap: var(--hy-space-2);
}

.doc-source-options {
  display: flex;
  flex-direction: column;
  gap: var(--hy-space-2);
}

.doc-source-option {
  display: flex;
  align-items: flex-start;
  gap: var(--hy-space-2);
  font-size: var(--hy-text-sm);
  cursor: pointer;
  padding: var(--hy-space-3);
  border: 1px solid var(--hy-border-base);
  border-radius: var(--hy-radius-lg);
  transition: all var(--hy-ease-fast);
  background: var(--hy-bg-subtle);
}

.doc-source-option:has(input:checked) {
  border-color: var(--hy-accent-primary);
  background: rgba(0, 0, 0, 0.02);
}

.doc-source-option input[type="radio"] {
  accent-color: var(--hy-accent-primary);
  margin-top: 3px;
}

.doc-source-option-content {
  flex: 1;
}

.doc-source-option-title {
  font-size: var(--hy-text-sm);
  font-weight: 600;
  color: var(--hy-fg-base);
}

.doc-source-option-desc {
  font-size: var(--hy-text-caption);
  color: var(--hy-fg-muted);
  margin-top: 1px;
}

.doc-source-upload {
  margin-top: var(--hy-space-1);
}

.doc-source-dropzone {
  border: 2px dashed var(--hy-border-base);
  border-radius: var(--hy-radius-lg);
  padding: var(--hy-space-6) var(--hy-space-4);
  text-align: center;
  cursor: pointer;
  transition: all var(--hy-ease-fast);
  color: var(--hy-fg-muted);
  font-size: var(--hy-text-sm);
}

.doc-source-dropzone:hover {
  border-color: var(--hy-accent-primary);
  color: var(--hy-accent-primary);
  background: rgba(0, 0, 0, 0.02);
}

.doc-source-file-info {
  display: flex;
  align-items: center;
  gap: var(--hy-space-2);
  padding: var(--hy-space-2) var(--hy-space-3);
  background: var(--hy-bg-elevated);
  border: 1px solid var(--hy-border-base);
  border-radius: var(--hy-radius-lg);
  font-size: var(--hy-text-sm);
}

.doc-source-file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  color: var(--hy-fg-base);
}

/* ═══════════════════════════════════════════════
   INLINE EDIT
   ═══════════════════════════════════════════════ */

.inline-edit {
  display: inline-flex;
  align-items: center;
  gap: var(--hy-space-1);
  max-width: 100%;
  min-width: 0;
}

.inline-edit-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inline-edit-btn {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 2px;
  cursor: pointer;
  color: var(--hy-fg-muted);
  flex-shrink: 0;
  border-radius: var(--hy-radius-sm);
  transition: color var(--hy-ease-fast);
}

.inline-edit:hover .inline-edit-btn {
  display: inline-flex;
}

.inline-edit-btn:hover {
  color: var(--hy-accent-primary);
}

.inline-edit-input {
  font: inherit;
  font-size: inherit;
  font-weight: inherit;
  color: var(--hy-fg-base);
  background: var(--hy-bg-subtle);
  border: 1px solid var(--hy-border-focus);
  border-radius: var(--hy-radius-sm);
  padding: 1px var(--hy-space-1);
  outline: none;
  width: 100%;
  min-width: 60px;
}

/* ═══════════════════════════════════════════════
   MODAL — STEP INDICATOR & NEW MATTER
   ═══════════════════════════════════════════════ */

.modal-steps {
  display: flex;
  align-items: center;
  gap: var(--hy-space-2);
  margin-bottom: var(--hy-space-4);
}

.modal-step-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--hy-radius-full);
  background: var(--hy-border-base);
  transition: background var(--hy-ease-fast);
}

.modal-step-dot--active {
  background: var(--hy-accent-primary);
}

.modal-error {
  font-size: var(--hy-text-xs);
  color: var(--hy-accent-danger);
  padding: var(--hy-space-2) var(--hy-space-3);
  background: var(--hy-accent-danger-bg);
  border-radius: var(--hy-radius-md);
}

.modal-doc-toggle {
  margin-bottom: var(--hy-space-3);
}

.modal-doc-current {
  display: flex;
  align-items: center;
  gap: var(--hy-space-2);
  padding: var(--hy-space-3);
  background: var(--hy-bg-base);
  border: 1px solid var(--hy-border-base);
  border-radius: var(--hy-radius-lg);
  color: var(--hy-accent-primary);
}

.modal-doc-name {
  font-size: var(--hy-text-sm);
  font-weight: 500;
  color: var(--hy-fg-base);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ═══════════════════════════════════════════════
   SUGGESTED PROMPTS
   ═══════════════════════════════════════════════ */

.suggested-prompts {
  position: relative;
}

.suggested-prompts-trigger {
  display: flex;
  align-items: center;
  gap: var(--hy-space-1);
  padding: var(--hy-space-1) var(--hy-space-2);
  background: none;
  border: 1px solid var(--hy-border-subtle);
  font-size: var(--hy-text-xs);
  color: var(--hy-fg-muted);
  cursor: pointer;
  margin-bottom: var(--hy-space-2);
  border-radius: var(--hy-radius-full);
  transition: all var(--hy-ease-fast);
  font-family: var(--hy-font-sans);
}

.suggested-prompts-trigger:hover {
  border-color: var(--hy-accent-primary);
  color: var(--hy-accent-primary);
  background: rgba(0, 0, 0, 0.02);
}

.suggested-prompts-popover {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: var(--hy-space-2);
  padding: var(--hy-space-2);
  background: var(--hy-bg-subtle);
  border: 1px solid var(--hy-border-base);
  border-radius: var(--hy-radius-lg);
  animation: hy-fade-in var(--hy-ease-base);
}

.suggested-prompts-header {
  font-size: var(--hy-text-caption);
  font-weight: 600;
  color: var(--hy-fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--hy-space-1) var(--hy-space-2) var(--hy-space-2);
  border-bottom: 1px solid var(--hy-border-subtle);
  margin-bottom: var(--hy-space-1);
}

.suggested-prompts-item {
  padding: var(--hy-space-2);
  background: transparent;
  border: none;
  border-radius: var(--hy-radius-sm);
  font-size: var(--hy-text-xs);
  color: var(--hy-fg-subtle);
  cursor: pointer;
  text-align: left;
  transition: all var(--hy-ease-fast);
  font-family: var(--hy-font-sans);
  line-height: 1.35;
}

.suggested-prompts-item:hover {
  background: var(--hy-bg-elevated);
  color: var(--hy-accent-primary);
}

/* ═══════════════════════════════════════════════
   CROSS-DOCUMENT DIALOG
   ═══════════════════════════════════════════════ */

.cross-doc-dialog {
  text-align: center;
}

.cross-doc-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin: 0 auto var(--hy-space-4);
  background: var(--hy-bg-elevated);
  border-radius: var(--hy-radius-xl);
}

.cross-doc-title {
  text-align: center;
}

.cross-doc-desc {
  text-align: center;
}

.cross-doc-desc strong {
  color: var(--hy-fg-base);
  font-weight: 600;
}

.cross-doc-info {
  display: flex;
  flex-direction: column;
  gap: var(--hy-space-2);
  padding: var(--hy-space-3);
  background: var(--hy-bg-base);
  border: 1px solid var(--hy-border-base);
  border-radius: var(--hy-radius-lg);
  margin-bottom: var(--hy-space-5);
  text-align: left;
}

.cross-doc-info-row {
  display: flex;
  align-items: center;
  gap: var(--hy-space-2);
  font-size: var(--hy-text-sm);
  color: var(--hy-fg-subtle);
}

.cross-doc-info-row svg {
  flex-shrink: 0;
}

.cross-doc-info-document {
  padding-left: var(--hy-space-4);
}

.cross-doc-actions {
  display: flex;
  gap: var(--hy-space-2);
  justify-content: flex-end;
}

.cross-doc-actions .btn {
  flex: 1;
}

/* Spinner inside button */
.btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: hy-spin 600ms linear infinite;
}

@keyframes hy-spin {
  to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════
   CHAT HISTORY PAGE
   ═══════════════════════════════════════════════ */

.chat-history-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-history-item {
  display: flex;
  align-items: flex-start;
  gap: var(--hy-space-3);
  padding: var(--hy-space-3);
  background: var(--hy-bg-base);
  border: 1px solid transparent;
  border-radius: var(--hy-radius-lg);
  cursor: pointer;
  transition: all var(--hy-ease-fast);
  text-align: left;
  font-family: var(--hy-font-sans);
  width: 100%;
}

.chat-history-item:hover {
  background: var(--hy-bg-subtle);
  border-color: var(--hy-border-subtle);
}

.chat-history-item-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--hy-radius-md);
  background: var(--hy-bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--hy-fg-muted);
}

.chat-history-item:hover .chat-history-item-icon {
  background: var(--hy-fg-base);
  color: var(--hy-fg-on-accent);
}

.chat-history-item-body {
  flex: 1;
  min-width: 0;
}

.chat-history-item-title {
  font-size: var(--hy-text-sm);
  font-weight: 600;
  color: var(--hy-fg-base);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 2px;
}

.chat-history-item-meta {
  display: flex;
  align-items: center;
  gap: var(--hy-space-1);
  font-size: var(--hy-text-xs);
  color: var(--hy-fg-muted);
  overflow: hidden;
  white-space: nowrap;
}

.chat-history-item-sep {
  color: var(--hy-fg-muted);
  font-size: 10px;
}

.chat-history-item-doc {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-history-item-matter {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 1;
}

.chat-history-item-preview {
  font-size: var(--hy-text-xs);
  color: var(--hy-fg-muted);
  margin-top: var(--hy-space-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-history-item-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
}

.chat-history-item-time {
  font-size: var(--hy-text-caption);
  color: var(--hy-fg-muted);
  white-space: nowrap;
}

.chat-history-item-count {
  font-size: 10px;
  font-weight: 600;
  color: var(--hy-fg-muted);
  background: var(--hy-bg-elevated);
  border-radius: var(--hy-radius-full);
  padding: 1px 6px;
}

/**
 * eVnomia Word Add-in — CSS entry point.
 *
 * Modular architecture:
 *   tokens      → design tokens (colors, type, spacing, radii, motion)
 *   reset       → normalize + base element styles
 *   layout      → app shell, page containers, scrollbar
 *   header      → fixed header bar
 *   buttons     → all button variants
 *   forms       → inputs, textareas, labels, dividers
 *   login       → login page
 *   home        → home page + tile cards
 *   chat        → chat page (messages, edits, input, toolbar)
 *   browse      → browse matters tree
 *   detail      → document detail card
 *   settings    → settings page
 *   components  → loading, error banner, modal, doc-source, prompts
 *   animations  → keyframes + utilities + focus-visible
 */

