/* ── Screen visibility ────────────────────────────────────── */

.screen {
  display: none;
}

.screen.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

/* ── Inbox screen ────────────────────────────────────────── */

.bundle-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}

.bundle-card:hover {
  background: var(--card-hover);
  box-shadow: 0 1px 3px rgba(42, 33, 25, 0.06);
}

.bundle-card-left {
  flex: 1;
}

.bundle-card-name {
  font-family: var(--font-heading);
  font-size: 18px;
  margin-bottom: 2px;
}

.bundle-card-preview {
  font-size: 14px;
  color: var(--secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 560px;
}

.bundle-card-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.bundle-card-peek {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--secondary);
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.bundle-card-peek:hover {
  color: var(--foreground);
  background: rgba(61, 46, 31, 0.06);
}

.bundle-card-peek svg {
  width: 15px;
  height: 15px;
}

.bundle-card-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 9999px;
  min-width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.bundle-card-badge.attention {
  background: var(--bundle-attention-bg);
  color: var(--bundle-attention-text);
}

.bundle-card-badge.standard {
  background: var(--bundle-standard-bg);
  color: var(--bundle-standard-text);
}

.bundle-card-badge.bulk {
  background: var(--bundle-bulk-bg);
  color: var(--bundle-bulk-text);
}

.bundle-card.empty {
  opacity: 0.6;
}

.bundle-card.empty .bundle-card-name {
  color: var(--secondary);
}

/* ── Peek tray ──────────────────────────────────────────── */

.peek-tray {
  background: var(--card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  box-shadow: 0 4px 12px rgba(42, 33, 25, 0.08);
  max-height: 320px;
  overflow-y: auto;
  margin-top: -9px;
  margin-bottom: 8px;
}

.peek-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.peek-row:last-child {
  border-bottom: none;
}

.peek-row:hover {
  background: var(--card-hover);
}

.peek-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--secondary);
  flex-shrink: 0;
}

.peek-sender {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 120px;
  flex-shrink: 0;
}

.peek-subject {
  flex: 1;
  font-size: 13px;
  color: var(--secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.peek-time {
  font-size: 12px;
  color: var(--tertiary);
  flex-shrink: 0;
  font-family: var(--font-mono);
}

.peek-chevron {
  color: var(--tertiary);
  flex-shrink: 0;
}

.peek-chevron svg {
  width: 14px;
  height: 14px;
}

.bundle-card-peek.active {
  color: var(--foreground);
  background: rgba(61, 46, 31, 0.06);
}

/* ── Thread screen ───────────────────────────────────────── */

.thread-content {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.thread-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.thread-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.thread-title {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 500;
}
.thread-header-sender {
  display: flex;
  align-items: center;
  gap: 8px;
}
.thread-header-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--secondary);
  flex-shrink: 0;
}
.thread-header-sender-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--foreground);
}

.back-btn {
  background: none;
  border: none;
  color: var(--foreground);
  cursor: pointer;
  font-size: 16px;
  padding: 6px 8px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
}

.back-btn:hover {
  background: rgba(61, 46, 31, 0.06);
}

.back-btn svg {
  width: 20px;
  height: 20px;
}

.thread-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.thread-progress {
  font-size: 14px;
  color: var(--secondary);
  font-family: var(--font-mono);
}

.bundle-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 500;
}

.bundle-tag.attention {
  background: var(--bundle-attention-bg);
  color: var(--bundle-attention-text);
}

.bundle-tag.standard {
  background: var(--bundle-standard-bg);
  color: var(--bundle-standard-text);
}

.bundle-tag.bulk {
  background: var(--bundle-bulk-bg);
  color: var(--bundle-bulk-text);
}

/* Thread left panel */

.thread-left {
  flex: 7;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Message list */

.message-list {
  flex: 1;
  overflow-y: auto;
}

.message-item {
  border-bottom: 1px solid var(--border);
  background: #FFFFFF;
  overflow: hidden;
}

.message-trigger {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  background: #FFFFFF;
  transition: background 0.15s;
}

.message-trigger:hover {
  background: var(--card-hover);
}

.message-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--secondary);
  flex-shrink: 0;
}

.message-meta {
  flex: 1;
  min-width: 0;
}

.message-sender-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.message-sender {
  font-size: 14px;
  font-weight: 600;
}

.message-date {
  font-size: 12px;
  color: var(--tertiary);
}

.message-to-line {
  font-size: 12px;
  color: var(--tertiary);
}

.message-chevron {
  flex-shrink: 0;
  color: var(--tertiary);
  transition: transform 0.3s;
}

.message-item[data-state="open"] .message-chevron {
  transform: rotate(180deg);
}

.message-preview {
  font-size: 13px;
  color: var(--tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}

.message-body-wrap {
  overflow: hidden;
  transition: max-height 0.3s ease;
  background: #FFFFFF;
}

.message-body-spacer {
  padding: 0 16px 20px 68px;
}

.message-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--foreground);
}

/* Reply form */

.reply-form {
  background: #FFFFFF;
  border-top: 1px solid var(--border);
  padding: 0;
}

.field-row {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  gap: 8px;
}

.field-label {
  width: 48px;
  font-size: 13px;
  color: var(--tertiary);
  flex-shrink: 0;
}

.field-value {
  flex: 1;
  font-size: 14px;
  color: var(--foreground);
}

.field-actions {
  display: flex;
  gap: 4px;
}

.field-action-btn {
  background: none;
  border: none;
  color: var(--tertiary);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius);
  font-size: 12px;
}

.field-action-btn:hover {
  background: rgba(61, 46, 31, 0.06);
  color: var(--foreground);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--border);
}

.toolbar-btn {
  background: none;
  border: none;
  color: var(--tertiary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
}

.toolbar-btn:hover {
  background: rgba(61, 46, 31, 0.06);
  color: var(--foreground);
}

.toolbar-btn svg {
  width: 16px;
  height: 16px;
}

.toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

.editor-area {
  min-height: 80px;
  padding: 12px 20px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--foreground);
  outline: none;
}

.ai-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

.ai-input-group {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 0 0 12px;
  overflow: hidden;
}

.ai-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--foreground);
  outline: none;
  padding: 8px 0;
}

.ai-input::placeholder {
  color: var(--tertiary);
}

.ai-regen-btn {
  background: none;
  border: none;
  color: var(--secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
}

.ai-regen-btn:hover {
  color: var(--primary);
}

.ai-regen-btn svg {
  width: 16px;
  height: 16px;
}

.send-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  background: var(--primary);
  color: var(--primary-foreground);
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.send-btn:hover {
  background: var(--primary-hover);
}

.send-done-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  background: var(--foreground);
  color: var(--primary-foreground);
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.send-done-btn:hover {
  opacity: 0.9;
}

.cancel-reply-btn {
  background: none;
  border: none;
  font-size: 13px;
  color: var(--tertiary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  margin-left: auto;
}

.cancel-reply-btn:hover {
  color: var(--foreground);
  background: rgba(61, 46, 31, 0.06);
}

.generate-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: none;
  border: none;
  border-left: 1px solid var(--border);
  color: var(--primary);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 0;
}

.generate-btn:hover {
  background: rgba(194, 87, 42, 0.08);
}

/* Thread right sidebar */

.thread-right {
  flex: 3;
  max-width: 380px;
  min-width: 280px;
  border-left: 1px solid var(--border);
  background: var(--card);
  overflow-y: auto;
}

.sender-header {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 116px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
}

.sender-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--secondary);
  flex-shrink: 0;
}

.sender-name {
  font-size: 14px;
  font-weight: 500;
}

.sender-subtitle {
  font-size: 12px;
  color: var(--tertiary);
}

.sidebar-section-card {
  border-bottom: 1px solid var(--border);
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  cursor: pointer;
}

.sidebar-section-title {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  color: var(--tertiary);
}

.sidebar-section-title-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-section-title-group svg {
  width: 14px;
  height: 14px;
  color: var(--tertiary);
}

.sidebar-section-chevron {
  width: 16px;
  height: 16px;
  color: var(--tertiary);
  transition: transform 0.3s;
}

.sidebar-section-body {
  padding: 0 12px 12px;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease;
}

.sidebar-section-header:hover {
  background: rgba(61, 46, 31, 0.03);
}

.sidebar-section-card.collapsed .sidebar-section-chevron {
  transform: rotate(-90deg);
}

.sidebar-section-card.collapsed .sidebar-section-body {
  max-height: 0 !important;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
}

.info-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  font-size: 13px;
}

.info-label {
  color: var(--tertiary);
}

.info-value {
  color: var(--foreground);
}

.insight-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--foreground);
}

.insight-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
  margin-top: 6px;
}

.timeline-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}

.timeline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  flex-shrink: 0;
  margin-top: 5px;
}

.timeline-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--foreground);
}

.timeline-sub {
  font-size: 12px;
  color: var(--tertiary);
}

/* ── AI Summary panel ────────────────────────────────────── */

.ai-summary-panel {
  padding: 16px 20px;
}

.ai-summary-text {
  font-size: 14px;
  line-height: 1.7;
  color: var(--foreground);
}

.ai-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.ai-action-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--card);
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.ai-action-chip:hover {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}

.ai-action-chip.done {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}

.draft-reply-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 8px 20px;
  background: var(--primary);
  color: var(--primary-foreground);
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  justify-content: center;
}

.draft-reply-btn:hover {
  background: var(--primary-hover);
}

/* ── Triage screen ───────────────────────────────────────── */

.triage-container {
  padding: 32px 24px;
  max-width: 1064px;
  margin: 0 auto;
}

.triage-header {
  text-align: center;
  margin-bottom: 32px;
}

.triage-header h1 {
  font-size: 28px;
  margin-bottom: 8px;
}

.triage-subtitle {
  font-size: 16px;
  color: var(--secondary);
  margin-bottom: 20px;
}

.triage-progress {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--secondary);
  margin-bottom: 16px;
}

.triage-progress-bar {
  width: 100%;
  max-width: 400px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto;
  overflow: hidden;
}

.triage-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

.triage-start-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 32px;
  background: var(--primary);
  color: var(--primary-foreground);
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 16px;
}

.triage-start-btn:hover {
  background: var(--primary-hover);
}

.triage-start-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.triage-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 24px;
}

.triage-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  transition: all 0.4s ease;
  opacity: 1;
}

.triage-card.categorized {
  border-left: 3px solid var(--primary);
}

.triage-card-from {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.triage-card-subject {
  font-size: 13px;
  color: var(--secondary);
  margin-bottom: 8px;
}

.triage-card-badge {
  display: inline-flex;
  padding: 2px 10px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.triage-card-badge.visible {
  opacity: 1;
}

/* ── Metrics screen ──────────────────────────────────────── */

.metrics-container {
  padding: 32px 24px;
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
}

.metrics-container h1 {
  font-size: 28px;
  margin-bottom: 8px;
}

.metrics-subtitle {
  font-size: 16px;
  color: var(--secondary);
  margin-bottom: 32px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 40px;
}

.metric-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.metric-value {
  font-family: var(--font-heading);
  font-size: 48px;
  color: var(--primary);
  margin-bottom: 4px;
}

.metric-label {
  font-size: 14px;
  color: var(--secondary);
}

.metrics-cta {
  padding: 32px;
}

.metrics-cta h2 {
  font-size: 22px;
  margin-bottom: 12px;
}

.metrics-cta p {
  font-size: 15px;
  color: var(--secondary);
  margin-bottom: 20px;
}

.cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 32px;
  background: var(--primary);
  color: var(--primary-foreground);
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}

.cta-btn:hover {
  background: var(--primary-hover);
}

/* ── Toast notification ──────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--foreground);
  color: var(--primary-foreground);
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  z-index: 1000;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ===== CONTENT HEADER ===== */
.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.content-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.content-header-title {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 700;
}
.content-header-peek {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  color: var(--secondary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
}
.content-header-peek:hover {
  color: var(--foreground);
  background: rgba(61, 46, 31, 0.06);
}
.content-header-peek svg {
  flex-shrink: 0;
}
.content-header-progress {
  font-size: 13px;
  color: var(--secondary);
  font-family: var(--font-mono);
}

/* ===== SPLIT BUTTONS ===== */
.split-btn-group {
  display: inline-flex;
  border-radius: var(--radius);
  overflow: hidden;
}
.split-btn-group.outline {
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}
.split-btn-main {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-body);
  border: none;
  cursor: pointer;
  white-space: nowrap;
  border-radius: 0;
  transition: background 0.15s;
}
.split-btn-group.outline .split-btn-main {
  background: var(--background);
  color: var(--foreground);
}
.split-btn-group.outline .split-btn-main:hover {
  background: var(--card-hover);
}
.split-btn-group.primary .split-btn-main {
  background: var(--primary);
  color: var(--primary-foreground);
}
.split-btn-group.primary .split-btn-main:hover {
  background: var(--primary-hover);
}
.split-btn-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border: none;
  cursor: pointer;
  border-radius: 0;
  transition: background 0.15s;
}
.split-btn-group.outline .split-btn-chevron {
  background: var(--background);
  color: var(--foreground);
  border-left: 1px solid var(--border);
}
.split-btn-group.outline .split-btn-chevron:hover {
  background: var(--card-hover);
}
.split-btn-group.primary .split-btn-chevron {
  background: var(--primary);
  color: var(--primary-foreground);
  border-left: 1px solid rgba(255, 255, 255, 0.2);
}
.split-btn-group.primary .split-btn-chevron:hover {
  background: var(--primary-hover);
}
.split-btn-chevron svg {
  width: 12px;
  height: 12px;
}
.split-btn-main svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ===== ACTION BUTTONS BAR ===== */
.action-buttons {
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.action-buttons-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
}
.action-buttons-left,
.action-buttons-right {
  display: flex;
  gap: 8px;
}
