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

/* Design tokens — canonical navy/periwinkle palette.
   Visual-consolidation commit 1: define the high-frequency structural colors
   as variables and swap the literals for var(). Pure no-op — every var()
   resolves to the exact hex it replaced. The drifted admin/today greys
   (#1a1a1a / #333 / #1a1a25 / #2a2a35) and the type-badge jewel tones are
   intentionally left as raw literals; they are reconciled in later commits. */
:root {
  --bg: #1a1a2e;
  --card-bg: #16213e;
  --inset-bg: #0f1525;
  --border: #2a2a4a;
  --accent: #5a7bc4;
  --text: #e0e0e0;
  --heading: #a8b2d1;
  --text-muted: #888;
  --amber: #f0b070;
  --radius: 8px;
}

/* Base */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Layout */
.app-header {
  text-align: center;
  padding: 1.5rem 1rem 0.5rem;
}

.app-header h1 {
  font-size: 1.5rem;
  color: var(--heading);
}

#app {
  flex: 1;
  padding: 1rem;
  padding-bottom: 5rem;
  max-width: 700px;
  width: 100%;
  margin: 0 auto;
}

/* Login */
.login-section {
  text-align: center;
  margin-top: 3rem;
}

.login-section p {
  margin-bottom: 1rem;
  color: var(--text-muted);
}

.login-section a {
  display: inline-block;
  padding: 0.8rem 2rem;
  background: var(--accent);
  color: white;
  text-decoration: none;
  border-radius: var(--radius);
  font-size: 1rem;
}

.login-section a:hover { background: #4a6bb4; }

/* User info bar */
.user-info {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.user-info .sign-out-btn {
  background: none;
  border: 1px solid #555;
  color: var(--text-muted);
  padding: 0.3rem 0.8rem;
  font-size: 0.8rem;
  width: auto;
  margin-left: 0.5rem;
  cursor: pointer;
  border-radius: 4px;
}

.user-info .sign-out-btn:hover { border-color: var(--text-muted); color: #ccc; }

/* Bottom nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 0.5rem 0;
  z-index: 100;
}

.bottom-nav button {
  background: none;
  border: none;
  color: #666;
  font-size: 0.7rem;
  padding: 0.4rem 0.5rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  min-width: 3.5rem;
}

.bottom-nav button .nav-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.bottom-nav button.active {
  color: var(--accent);
}

.bottom-nav button:hover {
  color: var(--heading);
}

/* Form elements */
textarea {
  width: 100%;
  min-height: 150px;
  padding: 1rem;
  border: 1px solid #333;
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
}

textarea:focus { outline: none; border-color: var(--accent); }

input[type="text"],
input[type="search"],
input[type="date"],
select {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 1px solid #333;
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}

input:focus, select:focus { outline: none; border-color: var(--accent); }

/* Buttons */
.btn {
  padding: 0.8rem 2rem;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: white;
  font-size: 1rem;
  cursor: pointer;
  width: 100%;
}

.btn:hover { background: #4a6bb4; }
.btn:disabled { background: #333; cursor: not-allowed; }

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  width: auto;
  border-radius: 6px;
}

.btn-danger {
  background: #6a2d2d;
}

.btn-danger:hover { background: #7a3d3d; }

.btn-success {
  background: #2d6a4f;
}

.btn-success:hover { background: #3d7a5f; }

.btn-secondary {
  background: #3a3a5a;
}

.btn-secondary:hover { background: #4a4a6a; }

.btn-outline {
  background: none;
  border: 1px solid #555;
  color: #ccc;
}

.btn-outline:hover { border-color: var(--text-muted); }

/* Status message */
.status-msg {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: var(--radius);
  display: none;
}

.status-msg.success { background: #1a3a2a; border: 1px solid #2d6a4f; display: block; }
.status-msg.error { background: #3a1a1a; border: 1px solid #6a2d2d; display: block; }

/* Thought cards */
.thought-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
  cursor: pointer;
  transition: border-color 0.15s;
}

.thought-card:hover { border-color: var(--accent); }

.thought-card.expanded {
  cursor: default;
}

.thought-card.expanded .thought-card-content {
  user-select: text;
  -webkit-user-select: text;
}

.thought-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.type-badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  white-space: nowrap;
}

.type-badge.decision     { background: #1a3a6a; color: #7ab2ff; }
.type-badge.observation  { background: #2a2a3a; color: #aaa; }
.type-badge.reference    { background: #1a3a2a; color: #7adf9a; }
.type-badge.action_item  { background: #3a2a1a; color: #ffb87a; }
.type-badge.idea         { background: #2a1a3a; color: #c07aff; }
.type-badge.insight      { background: #1a3a3a; color: #7adfe0; }
.type-badge.person_note  { background: #3a1a2a; color: #ff7aaf; }
.type-badge.meeting_note { background: #2a2a1a; color: #c0a87a; }

.status-badge {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-weight: 600;
  text-transform: uppercase;
}

.status-badge.active   { background: #2a3a5a; color: #9ab8e0; }
.status-badge.done     { background: #2d6a4f; color: #b0e0c0; }
.status-badge.archived { background: #3a3a5a; color: #aaa; }
.status-badge.deleted  { background: #6a2d2d; color: #e0b0b0; }

.flag-badge {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-weight: 600;
  text-transform: uppercase;
  cursor: help;
}

.flag-badge.needs_review { background: #5a3a1a; color: #ffc87a; }
.flag-badge.needs_update { background: #5a1a1a; color: #ff9a9a; }
.flag-badge.needs_merge  { background: #3a1a5a; color: #d4a8ff; }

.provenance-badge,
.confidence-badge {
  font-size: 0.6rem;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-weight: 600;
  text-transform: uppercase;
  margin-left: 0.3rem;
}

.provenance-badge.agent  { background: #3a3a5a; color: var(--heading); cursor: help; }
.confidence-badge.medium { background: #3a2a5a; color: #c4a8d1; }
.confidence-badge.low    { background: #2a2a3a; color: #8a8a9a; }

.link-promote-btn {
  margin-left: auto;
}

.thought-card-date {
  font-size: 0.75rem;
  color: #666;
  margin-left: auto;
}

.thought-card-lineage {
  font-size: 0.65rem;
  color: #555;
  font-family: monospace;
  margin-left: 0.4rem;
}

.thought-card-lineage.copyable {
  cursor: pointer;
}

.thought-card-lineage.copyable:hover {
  color: var(--accent);
}

/* Icon buttons (copy, chevron) in card header */
.icon-btn {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  padding: 0.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  transition: color 0.15s, background 0.15s;
  width: auto;
  flex-shrink: 0;
}

.icon-btn:hover {
  color: var(--accent);
  background: rgba(90, 123, 196, 0.1);
}

.chevron-btn svg {
  transition: transform 0.2s;
}

.thought-card.expanded .chevron-btn svg {
  transform: rotate(180deg);
}

.thought-card-content {
  font-size: 0.9rem;
  line-height: 1.5;
  color: #ccc;
}

.thought-card-content.truncated {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.thought-card-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.5rem;
}

.topic-tag {
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  background: var(--border);
  color: var(--heading);
}

.thought-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.thought-card-score {
  font-size: 0.7rem;
  color: var(--accent);
  margin-left: auto;
}

/* Edit mode */
.edit-textarea {
  width: 100%;
  min-height: 120px;
  padding: 0.75rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--inset-bg);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
  margin-top: 0.5rem;
}

.edit-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* Expiration display */
.expiration-info {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.expiration-info.expiring-soon {
  color: #ffb87a;
}

/* Search */
.search-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.search-form input {
  flex: 1;
}

.search-form .btn {
  width: auto;
  white-space: nowrap;
}

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.filter-bar select,
.filter-bar input {
  width: auto;
  flex: 1;
  min-width: 100px;
}

.filter-bar .days-input {
  max-width: 70px;
}

/* Stats dashboard */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}

.stat-card .stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.stats-section {
  margin-bottom: 1.5rem;
}

.stats-section h3 {
  font-size: 1rem;
  color: var(--heading);
  margin-bottom: 0.75rem;
}

.stats-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.stats-bar-label {
  font-size: 0.85rem;
  color: #ccc;
  width: 150px;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-bar-fill {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.stats-bar-fill-inner {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
}

/* Width utilities for stats bars (CSP-safe, no inline styles) */
.w-0  { width: 0%; }   .w-5  { width: 5%; }   .w-10 { width: 10%; }
.w-15 { width: 15%; }  .w-20 { width: 20%; }  .w-25 { width: 25%; }
.w-30 { width: 30%; }  .w-35 { width: 35%; }  .w-40 { width: 40%; }
.w-45 { width: 45%; }  .w-50 { width: 50%; }  .w-55 { width: 55%; }
.w-60 { width: 60%; }  .w-65 { width: 65%; }  .w-70 { width: 70%; }
.w-75 { width: 75%; }  .w-80 { width: 80%; }  .w-85 { width: 85%; }
.w-90 { width: 90%; }  .w-95 { width: 95%; }  .w-100 { width: 100%; }

.stats-bar-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 2rem;
  text-align: right;
}

/* Trash extras */
.trash-warning {
  font-size: 0.75rem;
  color: #ff7a7a;
  margin-top: 0.25rem;
}

.provenance-link {
  font-size: 0.75rem;
  color: var(--accent);
  margin-top: 0.25rem;
}

/* Confirm dialog */
.confirm-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}

.confirm-dialog {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 500px;
  width: 100%;
}

.confirm-dialog h3 {
  color: #ff7a7a;
  margin-bottom: 1rem;
}

.confirm-dialog .confirm-text {
  color: #ccc;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.confirm-dialog .preview {
  background: var(--inset-bg);
  border-radius: 6px;
  padding: 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: #ccc;
  max-height: 150px;
  overflow-y: auto;
}

.confirm-dialog .confirm-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.conflict-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  margin-top: 0.5rem;
}

.conflict-label:first-of-type {
  margin-top: 0;
}

.conflict-actions {
  flex-wrap: wrap;
}

/* Edit Modal */
.edit-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}

.edit-modal {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 800px;
  height: 90vh;
  display: flex;
  flex-direction: column;
}

.edit-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.edit-modal-header h3 {
  color: var(--text);
  font-size: 1.1rem;
}

.edit-modal-close {
  font-size: 1.4rem;
  line-height: 1;
  padding: 0.2rem 0.5rem;
  border: none;
  width: auto;
}

.edit-modal-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.edit-modal-textarea {
  flex: 1;
  width: 100%;
  background: var(--inset-bg);
  color: var(--text);
  border: none;
  padding: 1rem 1.25rem;
  font-family: monospace;
  font-size: 0.9rem;
  resize: none;
  outline: none;
}

.edit-modal-preview {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
}

.edit-modal-footer {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.edit-modal-footer .btn {
  width: auto;
}

.edit-modal-aliases {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  background: #0a0f1c;
}

.edit-modal-aliases-label {
  font-size: 0.8rem;
  color: #9aa0b5;
}

.edit-modal-aliases-input {
  background: var(--inset-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
}

.edit-modal-aliases-input:focus {
  border-color: #4a5a8a;
}

/* Toast */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  pointer-events: auto;
  animation: toast-in 0.3s ease;
  max-width: 350px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.toast-text { flex: 1; }

.toast-action {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  color: inherit;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}
.toast-action:hover { background: rgba(255,255,255,0.22); }

.toast.success { background: #1a3a2a; border: 1px solid #2d6a4f; color: #b0e0c0; }
.toast.error { background: #3a1a1a; border: 1px solid #6a2d2d; color: #e0b0b0; }
.toast.info { background: #1a2a3a; border: 1px solid #2d4f6a; color: #b0c0e0; }

.toast.fade-out {
  animation: toast-out 0.3s ease forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(1rem); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(1rem); }
}

/* Loading spinner */
.loading {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
}

/* Empty state */
.empty-state {
  text-align: center;
  color: #666;
  padding: 2rem;
  font-size: 0.95rem;
}

/* Detail view */
.detail-back-btn {
  width: auto;
  margin-bottom: 1rem;
}

/* Linked thoughts */
.linked-thoughts-section {
  margin-top: 0.75rem;
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
}

.linked-thoughts-heading {
  font-size: 0.75rem;
  color: var(--heading);
  cursor: pointer;
  padding: 0.25rem 0;
  user-select: none;
}

.linked-thoughts-heading:hover {
  color: var(--accent);
}

.linked-thought-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--bg);
  font-size: 0.8rem;
}

.linked-thought-item.clickable {
  cursor: pointer;
}

.linked-thought-item.clickable:hover {
  background: rgba(90, 123, 196, 0.1);
  border-radius: 4px;
}

.linked-thought-item:last-child {
  border-bottom: none;
}

.link-type-label {
  font-size: 0.7rem;
  color: var(--accent);
  white-space: nowrap;
  min-width: 5rem;
}

.linked-thought-snippet {
  color: #999;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.linked-empty {
  font-size: 0.75rem;
  color: #555;
  padding: 0.25rem 0;
}

.loading-small {
  font-size: 0.75rem;
  color: #666;
}

/* JSON viewer */
.json-viewer {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  background: var(--inset-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem;
  overflow-x: auto;
  white-space: pre;
  cursor: default;
}

.json-viewer.json-collapsible {
  cursor: pointer;
}

.json-viewer.json-collapsed {
  max-height: 6rem;
  overflow: hidden;
  position: relative;
}

.json-viewer.json-collapsed::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2rem;
  background: linear-gradient(transparent, var(--inset-bg));
  pointer-events: none;
}

.json-key       { color: #7ab2ff; }
.json-string    { color: #7adf9a; }
.json-number    { color: #ffb87a; }
.json-boolean   { color: #c07aff; }
.json-null      { color: #666; }
.json-punctuation { color: var(--text-muted); }

.json-show-full {
  display: block;
  margin-top: 0.5rem;
  font-family: inherit;
}

/* Markdown content */
.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
  color: var(--heading);
  margin: 0.75em 0 0.25em;
  line-height: 1.3;
}

.markdown-content h1 { font-size: 1.3em; }
.markdown-content h2 { font-size: 1.15em; }
.markdown-content h3 { font-size: 1.05em; }
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 { font-size: 0.95em; }

.markdown-content h1:first-child,
.markdown-content h2:first-child,
.markdown-content h3:first-child {
  margin-top: 0;
}

.markdown-content p {
  margin: 0.5em 0;
}

.markdown-content p:first-child {
  margin-top: 0;
}

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

.markdown-content strong {
  color: var(--text);
  font-weight: 600;
}

.markdown-content em {
  color: #c0c8e0;
}

.markdown-content a {
  color: var(--accent);
  text-decoration: none;
}

.markdown-content a:hover {
  text-decoration: underline;
}

.markdown-content a.lineage-link {
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}

.markdown-content code {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  background: var(--inset-bg);
  padding: 0.15em 0.35em;
  border-radius: 3px;
  font-size: 0.85em;
  color: #7adf9a;
}

.markdown-content pre {
  background: var(--inset-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem;
  overflow-x: auto;
  margin: 0.5em 0;
}

.markdown-content pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: 0.8rem;
  color: #ccc;
}

.markdown-content ul,
.markdown-content ol {
  padding-left: 1.5em;
  margin: 0.5em 0;
}

.markdown-content li {
  margin: 0.2em 0;
}

.markdown-content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 0.75em;
  margin: 0.5em 0;
  color: #aaa;
}

.markdown-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.75em 0;
}

.markdown-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.5em 0;
  font-size: 0.85em;
  overflow-x: auto;
  display: block;
}

.markdown-content th,
.markdown-content td {
  border: 1px solid var(--border);
  padding: 0.4em 0.6em;
  text-align: left;
}

.markdown-content th {
  background: var(--inset-bg);
  color: var(--heading);
}

.markdown-content del {
  color: var(--text-muted);
}

/* Hidden */
.hidden { display: none !important; }

/* Admin — Google Account Management */
.admin-connect {
  display: flex;
  align-items: center;
  gap: 8px;
  /* Inset to match the account cards' content (1px border + 16px padding) so the
     Connect Account button's right edge lines up with the cards' Disconnect buttons. */
  padding: 0 17px;
  margin-bottom: 20px;
}

.admin-input {
  flex: 1;
  /* Allow the flex input to shrink below its intrinsic width so the connect row
     (input + 150px button + 17px insets) can't overflow on narrow viewports. */
  min-width: 0;
  padding: 10px 12px;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
}

.admin-input::placeholder { color: #666; }
.admin-input:focus { outline: none; border-color: #555; }

.admin-btn {
  padding: 10px 16px;
  border: 1px solid #333;
  border-radius: var(--radius);
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  /* Shared floor so every admin button (Connect Account, Re-authenticate,
     Disconnect, Connect Basecamp) renders the same width regardless of label. */
  min-width: 150px;
}

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

.admin-btn-primary {
  background: #1a3a2a;
  color: #7fcc7f;
  border-color: #2a5a3a;
}

.admin-btn-primary:hover:not(:disabled) { background: #1f4a34; }

.admin-btn-danger {
  background: #2a1a1a;
  color: #cc7f7f;
  border-color: #4a2a2a;
}

.admin-btn-danger:hover:not(:disabled) { background: #3a2020; }

.admin-account-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  margin-bottom: 10px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
}

.admin-account-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-account-info strong {
  font-size: 1.05rem;
  color: var(--text);
}

.admin-account-email {
  color: #aaa;
  font-size: 0.9rem;
}

.admin-account-scopes {
  color: #777;
  font-size: 0.8rem;
}

.admin-account-date {
  color: #666;
  font-size: 0.8rem;
}

.admin-account-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-account-card-warning {
  border-color: #5a3a2a;
  background: #1f1812;
}

.admin-account-warning {
  color: var(--amber);
  font-size: 0.85rem;
  padding: 6px 8px;
  margin-bottom: 4px;
  background: #2a1e12;
  border-left: 3px solid #b06a2a;
  border-radius: 4px;
}

.admin-account-warning strong {
  color: var(--amber);
  font-size: 0.9rem;
}

.admin-account-warning-summary {
  color: #9e7e5a;
  font-size: 0.75rem;
  margin-top: 4px;
  font-family: ui-monospace, monospace;
  word-break: break-word;
}

.admin-btn-warning {
  background: #3a2812;
  color: var(--amber);
  border-color: #5a3a1a;
}

.admin-btn-warning:hover:not(:disabled) { background: #4a3420; }

/* Today view */
.today-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.today-dayframe-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.today-dayframe-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

/* Dashboard HUD modal — sandboxed iframe over GET /dashboard (Phase 2). */
.dashboard-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
  padding: 16px;
}

.dashboard-modal-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1220px;
  height: 100%;
  background: #0a0e14;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.dashboard-modal-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  flex: none;
}

.dashboard-modal-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
  margin-right: auto;
}

.dashboard-modal-close {
  background: none;
  border: 1px solid var(--border);
  color: #ccc;
  font-size: 1rem;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.dashboard-modal-close:hover { background: #1f2a4a; }

.dashboard-modal-frame {
  flex: 1;
  width: 100%;
  border: none;
  background: #0a0e14;
}

@media (max-width: 760px) {
  .dashboard-modal-overlay { padding: 0; }
  .dashboard-modal-panel { border-radius: 0; border: none; }
}

.today-heading {
  margin: 0 0 8px 0;
  font-size: 1.2rem;
  color: #ddd;
}

.today-dayframe-header .today-heading {
  margin: 0;
}

.today-dayframe-body {
  background: #1a1a25;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 12px 16px;
  color: #cfcfcf;
  font-size: 0.95rem;
  line-height: 1.4;
}

.today-stale-banner {
  background: #3a2812;
  border: 1px solid #5a3a1a;
  color: var(--amber);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.today-section-heading {
  margin: 0 0 8px 0;
  font-size: 0.9rem;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.today-section-toggle {
  background: none;
  border: none;
  color: #aaa;
  font-size: 0.9rem;
  text-align: left;
  padding: 4px 0;
  cursor: pointer;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.today-section-toggle:hover { color: #ddd; }

.today-section-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.today-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  /* Match the canonical .thought-card chrome (list/search) for a uniform surface. */
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s;
}

.today-row:hover { border-color: var(--accent); }

.today-row-strike .today-row-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

.today-row-text {
  flex: 1;
  background: none;
  border: none;
  color: #ccc;
  text-align: left;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1.5;
  padding: 0;
  word-break: break-word;
  /* Match the list view's content preview: same size/color, 3-line clamp. */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.today-row-text:hover { color: #fff; }

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

.today-row-btn {
  min-width: 36px;
  padding: 6px 10px;
  font-size: 1rem;
}

.today-row-pending { opacity: 0.5; }

/* Detail view: for_date setter for action_items */
.detail-for-date {
  margin-top: 12px;
  padding: 12px 14px;
  background: #1a1a25;
  border: 1px solid #2a2a35;
  border-radius: 6px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.detail-for-date-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-for-date-value {
  flex: 1;
  color: #ddd;
  font-size: 0.95rem;
}

.detail-for-date-actions {
  display: flex;
  gap: 6px;
}

/* ============ To-Do Management view (#/todos) ============ */
.todos-view {
  padding-bottom: 5rem; /* clear the fixed bottom nav */
}

.todos-stale-banner {
  background: #3a2812;
  border: 1px solid #5a3a1a;
  color: var(--amber);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 0.85rem;
  margin-bottom: 10px;
}

/* Mode switch (group by workstream vs. flat by date) — a segmented control,
   visually distinct from the round filter chips below it. */
.todos-sort {
  display: inline-flex;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.todos-sort-btn {
  background: var(--card-bg);
  border: none;
  color: #aaa;
  padding: 5px 14px;
  font-size: 0.82rem;
  cursor: pointer;
}

.todos-sort-btn + .todos-sort-btn {
  border-left: 1px solid var(--border);
}

.todos-sort-btn:hover { color: #ddd; }

.todos-sort-btn.active {
  background: #2a3a5a;
  color: #fff;
}

.todos-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.todos-chip {
  background: #1a1a25;
  border: 1px solid #2a2a35;
  color: #aaa;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.82rem;
  cursor: pointer;
}

.todos-chip:hover { color: #ddd; }

.todos-chip.active {
  background: #2a3a5a;
  border-color: var(--accent);
  color: #fff;
}

.todos-group {
  margin-bottom: 18px;
}

.todos-group-heading {
  margin: 0 0 8px 0;
  font-size: 0.9rem;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.todos-group-unsorted .todos-group-heading {
  color: var(--amber); /* draw the eye to the triage queue */
}

.todos-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 6px;
  /* Match the canonical .thought-card chrome (list/search) for a uniform surface. */
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s;
}

.todos-row:hover { border-color: var(--accent); }

.todos-row-strike .todos-row-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

.todos-row-main {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.todos-row-text {
  flex: 1;
  min-width: 60%;
  background: none;
  border: none;
  color: #ccc;
  text-align: left;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1.5;
  padding: 0;
  word-break: break-word;
  /* Match the list view's content preview: same size/color, 3-line clamp. */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.todos-row-text:hover { color: #fff; }

.todos-due {
  font-size: 0.75rem;
  color: #6a8;
  white-space: nowrap;
}

.todos-due-past {
  color: #c97a7a;
}

/* Per-row workstream tag, shown only in "by date" mode where categories mix. */
.todos-row-ws {
  font-size: 0.7rem;
  color: #8a9ac0;
  background: #1f2a44;
  border-radius: 999px;
  padding: 1px 8px;
  white-space: nowrap;
}

/* Date-cluster band header between rows (inserted on every for_date change). */
.todos-date-divider {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #8a8a9a;
  margin: 14px 0 6px;
  padding-top: 8px;
  border-top: 1px dashed #2f2f3d;
}

/* First band sits right under the group heading — drop the top rule + gap. */
.todos-group-heading + .todos-date-divider {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.todos-date-divider-today { color: var(--amber); }
.todos-date-divider-past { color: #c97a7a; }

/* The undated tail gets a solid rule so the crossover reads clearly on scroll. */
.todos-date-divider-undated {
  color: #7a90c0;
  border-top-style: solid;
}

.todos-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.todos-row-btn {
  min-width: 36px;
  padding: 6px 10px;
  font-size: 1rem;
}

.todos-done {
  margin-top: 20px;
}

.todos-section-toggle {
  background: none;
  border: none;
  color: #aaa;
  font-size: 0.9rem;
  text-align: left;
  padding: 4px 0;
  cursor: pointer;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.todos-section-toggle:hover { color: #ddd; }

.todos-done-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

/* Workstream picker (popup sheet) */
.todos-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 300;
}

.todos-picker-sheet {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px 10px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 70vh;
  overflow-y: auto;
  padding: 12px;
}

.todos-picker-title {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 8px 10px;
}

.todos-picker-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: #ddd;
  font-size: 0.95rem;
  padding: 12px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.todos-picker-item:hover { background: #1f2a4a; }

.todos-picker-item.active {
  color: var(--accent);
  font-weight: 600;
}

.todos-picker-date {
  display: block;
  width: 100%;
  background: #0f1830;
  border: 1px solid var(--border);
  color: #ddd;
  font-size: 1rem;
  padding: 12px 10px;
  border-radius: 6px;
  margin: 0 0 12px;
}

.todos-picker-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 2px 4px;
}

/* "More" overflow popup in the bottom nav */
.nav-more-menu {
  position: fixed;
  bottom: 4.2rem;
  right: 0.5rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  padding: 6px;
  z-index: 200;
  min-width: 9rem;
}

.nav-more-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  color: var(--heading);
  font-size: 0.9rem;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
}

.nav-more-item .nav-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.nav-more-item:hover { background: #1f2a4a; color: #fff; }

.nav-more-item.active { color: var(--accent); }

/* Responsive */
@media (max-width: 400px) {
  .bottom-nav button {
    font-size: 0.65rem;
    min-width: 3rem;
  }

  .bottom-nav button .nav-icon {
    font-size: 1.1rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Version history view */
.history-heading {
  font-size: 1.2rem;
  margin-bottom: 0.25rem;
}

.history-retention-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.history-lineage-label {
  font-size: 0.8rem;
  color: var(--heading);
  margin-bottom: 0.75rem;
}

.history-entry {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem;
  margin-bottom: 1rem;
  background: #20203a;
}

.history-entry-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.history-badge.latest {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-weight: 600;
  text-transform: uppercase;
  background: #1a3a3a;
  color: #7adfe0;
}

.history-entry-date {
  font-size: 0.78rem;
  color: #ccc;
}

.history-entry-rowid {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-left: auto;
}

.history-meta-diff {
  font-size: 0.75rem;
  color: #c0a87a;
  margin-bottom: 0.5rem;
}

.history-baseline-label,
.history-no-change {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 0.4rem;
}

.history-diff {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow-x: auto;
  margin: 0;
}

.diff-line { display: block; }
.diff-add { background: #14361f; color: #b0e0c0; }
.diff-del { background: #3a1a1a; color: #e0b0b0; }
.diff-ctx { color: var(--text-muted); }
