
/* ═══════════════════════════════════════════════════════
   LOGIN SCREEN
   ═══════════════════════════════════════════════════════ */

#login-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: var(--color-surface-1);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--color-surface-0);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.login-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
}

.login-subtitle {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}

.login-field {
  margin-bottom: var(--space-3);
}

.login-field label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-1);
}

.login-field input {
  width: 100%;
  padding: 10px 12px;
  font-size: var(--text-sm);
  font-family: inherit;
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  background: var(--color-surface-1);
  color: var(--color-text);
  outline: none;
  transition: border-color 0.18s;
  box-sizing: border-box;
}

.login-field input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-highlight);
}

.login-btn {
  width: 100%;
  padding: 10px;
  margin-top: var(--space-3);
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: var(--color-primary);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: opacity 0.18s;
}

.login-btn:hover { opacity: 0.9; }
.login-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.login-error {
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-error);
  text-align: center;
  min-height: 1.4em;
}


/* ═══════════════════════════════════════════════════════
   USER INDICATOR (header)
   ═══════════════════════════════════════════════════════ */

.user-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  background: var(--color-primary-highlight);
  color: var(--color-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
}

.user-name {
  font-weight: 500;
}

.logout-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: color 0.18s;
}

.logout-btn:hover {
  color: var(--color-error);
}

@media (max-width: 768px) {
  .user-name { display: none; }
}


/* ═══════════════════════════════════════════════════════
   CHAT TAB
   ═══════════════════════════════════════════════════════ */

.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
  min-height: 400px;
  max-height: 700px;
  background: var(--color-surface-0);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.chat-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-divider);
  background: var(--color-surface-1);
  flex-shrink: 0;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text);
}

.chat-header-title {
  font-size: var(--text-sm);
  font-weight: 600;
}

.chat-header-model {
  font-size: 11px;
  color: var(--color-text-faint);
  background: var(--color-surface-2);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

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

.chat-usage {
  font-size: 11px;
  color: var(--color-text-faint);
}

.chat-clear-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  transition: color 0.18s;
}

.chat-clear-btn:hover { color: var(--color-error); }


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

.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-6) var(--space-4);
  gap: var(--space-2);
  flex: 1;
}

.chat-welcome-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
}

.chat-welcome-desc {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  max-width: 360px;
  line-height: 1.5;
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: center;
  margin-top: var(--space-3);
}

.chat-suggestion {
  font-family: inherit;
  font-size: var(--text-xs);
  padding: 6px 12px;
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-full);
  background: var(--color-surface-1);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.18s;
}

.chat-suggestion:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-highlight);
}


/* Individual messages */
.chat-message {
  display: flex;
  gap: var(--space-3);
  max-width: 100%;
}

.chat-message-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.chat-avatar--user {
  background: var(--color-primary-highlight);
  color: var(--color-primary);
}

.chat-avatar--assistant {
  background: var(--color-surface-2);
  color: var(--color-text-muted);
}

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

.chat-message-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 2px;
}

.chat-message-content {
  font-size: var(--text-sm);
  line-height: 1.6;
  color: var(--color-text);
  word-wrap: break-word;
}

/* Markdown rendering inside chat bubbles */
.chat-message-content h1,
.chat-message-content h2,
.chat-message-content h3,
.chat-message-content h4 {
  margin: 0.8em 0 0.3em;
  line-height: 1.3;
  color: var(--color-text);
}
.chat-message-content h1 { font-size: 1.15em; }
.chat-message-content h2 { font-size: 1.1em; }
.chat-message-content h3 { font-size: 1.0em; }
.chat-message-content h4 { font-size: 0.95em; }
.chat-message-content h1:first-child,
.chat-message-content h2:first-child,
.chat-message-content h3:first-child { margin-top: 0; }

.chat-message-content p {
  margin: 0.4em 0;
}
.chat-message-content p:first-child { margin-top: 0; }
.chat-message-content p:last-child { margin-bottom: 0; }

.chat-message-content ul,
.chat-message-content ol {
  margin: 0.4em 0;
  padding-left: 1.5em;
}
.chat-message-content li {
  margin: 0.15em 0;
}
.chat-message-content li > ul,
.chat-message-content li > ol {
  margin: 0.1em 0;
}

.chat-message-content blockquote {
  margin: 0.5em 0;
  padding: 0.3em 0.8em;
  border-left: 3px solid var(--color-border);
  color: var(--color-text-faint);
  background: var(--color-surface-2);
  border-radius: 0 4px 4px 0;
}

.chat-message-content pre {
  margin: 0.5em 0;
  padding: 0.6em 0.8em;
  background: var(--color-surface-2);
  border-radius: 6px;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.5;
}
.chat-message-content pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

.chat-message-content code {
  background: var(--color-surface-2);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 12px;
}

.chat-message-content table {
  border-collapse: collapse;
  margin: 0.5em 0;
  font-size: 12px;
  width: 100%;
}
.chat-message-content th,
.chat-message-content td {
  border: 1px solid var(--color-border);
  padding: 4px 8px;
  text-align: left;
}
.chat-message-content th {
  background: var(--color-surface-2);
  font-weight: 600;
}

.chat-message-content hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 0.6em 0;
}

.chat-message-content a {
  color: var(--color-accent);
  text-decoration: underline;
}

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

.chat-typing {
  color: var(--color-text-faint);
  font-style: italic;
}

.chat-error {
  color: var(--color-error);
  font-size: var(--text-xs);
}


/* Input area */
.chat-input-area {
  border-top: 1px solid var(--color-divider);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-1);
  flex-shrink: 0;
}

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

.chat-input {
  flex: 1;
  padding: 8px 12px;
  font-size: var(--text-sm);
  font-family: inherit;
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  background: var(--color-surface-0);
  color: var(--color-text);
  resize: none;
  outline: none;
  max-height: 120px;
  line-height: 1.5;
  transition: border-color 0.18s;
}

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

.chat-send-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.18s;
}

.chat-send-btn:hover { opacity: 0.9; }
.chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ═══════════════════════════════════════════════════════
   NOTIFICATION BELL + PANEL
   ═══════════════════════════════════════════════════════ */

.notif-bell {
  position: relative;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: color 0.15s, border-color 0.15s;
}
.notif-bell:hover {
  color: var(--color-text);
  border-color: var(--color-text-muted);
}

.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--color-error);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  border-radius: 8px;
  padding: 0 4px;
}

/* Notification tab content */
.notif-list {
  max-width: 800px;
}

.notif-item {
  padding: 12px 16px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--color-surface);
  transition: background 0.15s;
}
.notif-item--unread {
  background: color-mix(in srgb, var(--color-accent) 6%, var(--color-surface));
  border-color: color-mix(in srgb, var(--color-accent) 20%, var(--color-border));
}
.notif-item--unread .notif-item-title::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-accent);
  margin-right: 8px;
  vertical-align: middle;
}

.notif-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.notif-item-title {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--color-text);
}
.notif-item-date {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  white-space: nowrap;
}
.notif-item-task-id {
  font-size: var(--text-xs);
  color: var(--color-accent);
  font-weight: 600;
  margin-bottom: 4px;
}
.notif-item-body {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.5;
  white-space: pre-line;
}
.notif-item-source {
  margin-top: 6px;
  font-size: var(--text-xs);
}
.notif-item-source a {
  color: var(--color-accent);
}
.notif-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.notif-mark-all-btn {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  cursor: pointer;
}
.notif-mark-all-btn:hover {
  border-color: var(--color-text-muted);
  color: var(--color-text);
}
.notif-empty {
  padding: 40px;
  text-align: center;
  color: var(--color-text-faint);
  font-size: var(--text-sm);
}

/* Completion record on tasks */
.completion-record {
  margin-top: 10px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--status-complete) 8%, var(--color-surface));
  border: 1px solid color-mix(in srgb, var(--status-complete) 25%, var(--color-border));
  border-radius: 6px;
  font-size: var(--text-xs);
  line-height: 1.5;
}
.completion-record-header {
  font-weight: 600;
  color: var(--status-complete);
  margin-bottom: 4px;
  font-size: var(--text-xs);
}
.completion-record-evidence {
  color: var(--color-text-muted);
  white-space: pre-line;
  margin-top: 4px;
}
.completion-record-source {
  margin-top: 6px;
}
.completion-record-source a {
  color: var(--color-accent);
  font-size: var(--text-xs);
}

/* CP Search */
.cp-search-wrap {
  flex-shrink: 0;
}
.cp-search-wrap .filter-input {
  min-width: 260px;
}
