/* ═══════════════════════════════════════════════════════
   Ocean Memory Dashboard — Light Theme
   ═══════════════════════════════════════════════════════ */

:root {
  /* Light theme colors */
  --bg: #f5f5f5;
  --bg-card: #ffffff;
  --bg-secondary: #ffffff;
  --bg-hover: #e8e8e8;
  --bg-input: #ffffff;
  --border: #d0d0d0;
  --text: #1a1a1a;
  --text-dim: #4a4a4a;
  --text-muted: #7a7a7a;
  --accent: #0066cc;
  --accent-dim: #0052a3;
  --green: #28a745;
  --orange: #fd7e14;
  --red: #dc3545;
  --purple: #6f42c1;
  --mono: "SF Mono", "Cascadia Code", "Fira Code", Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --radius: 6px;
}

/* ── Dark Theme ───────────────────────────────────────── */
:root.dark {
  --bg: #141414;
  --bg-card: #1e1e1e;
  --bg-secondary: #1e1e1e;
  --bg-hover: #2a2a2a;
  --bg-input: #252525;
  --border: #383838;
  --text: #e4e4e4;
  --text-dim: #a0a0a0;
  --text-muted: #666666;
  --accent: #4d9fff;
  --accent-dim: #3a8de0;
  --green: #3dbf5c;
  --orange: #ff9a3c;
  --red: #f05060;
  --purple: #9d73e8;
}

/* Theme toggle button */
#btn-theme {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius);
  padding: 4px 8px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
#btn-theme:hover { background: var(--bg-hover); color: var(--text); }

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Login ────────────────────────────────────────── */

#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 48px 40px;
  text-align: center;
  max-width: 400px;
  width: 100%;
}

.login-box h1 {
  font-size: 24px;
  margin-bottom: 8px;
  color: var(--accent);
}

.login-box p {
  color: var(--text-dim);
  margin-bottom: 24px;
  font-size: 14px;
}

.login-box input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  margin-bottom: 16px;
}

.login-box input:focus {
  outline: none;
  border-color: var(--accent);
}

.login-box button {
  width: 100%;
  padding: 10px;
  background: var(--accent-dim);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.login-box button:hover { background: var(--accent); }

.login-footer {
  margin-top: 12px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
}

.link-btn:hover { color: var(--text-dim); }

.error {
  color: var(--red);
  font-size: 13px;
  margin-top: 12px;
}

/* ── Header ───────────────────────────────────────── */

header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.header-left h1 {
  font-size: 16px;
  color: var(--accent);
  white-space: nowrap;
}

.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--green);
  color: #000;
  font-weight: 600;
}

nav { display: flex; gap: 2px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }

.tab {
  padding: 6px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  font-weight: 500;
  white-space: nowrap;
}

.tab:hover { color: var(--text); background: var(--bg-hover); }
.tab.active { color: var(--text); background: var(--bg-hover); border-color: var(--border); }

#btn-logout {
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  margin-left: 8px;
}

#btn-logout:hover { color: var(--red); border-color: var(--red); }

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

/* ── Tab Content ──────────────────────────────────── */

.tab-content { display: none; }
.tab-content.active { display: flex; }

#tab-notes { flex-direction: column; padding: 0; overflow: hidden; }

#tab-news {
  justify-content: center;
}

/* ── Browse Tab ───────────────────────────────────── */

#tab-browse {
  height: calc(100vh - 49px);
}

#sidebar {
  width: 240px;
  min-width: 240px;
  border-right: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
  height: 100%;
}

#sidebar h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.route-group {
  margin-bottom: 12px;
}

.route-group-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  padding: 4px 8px;
  cursor: default;
}

.route-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 5px 8px 5px 20px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  font-family: var(--mono);
  cursor: pointer;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.route-item:hover { background: var(--bg-hover); color: var(--text); }
.route-item.active { background: var(--accent-dim); color: #fff; }

.route-children {
  margin-left: 12px;
  border-left: 1px solid var(--border);
  padding-left: 4px;
}

.route-item.child {
  font-size: 11px;
  padding: 3px 8px 3px 12px;
  color: var(--text-muted);
}

.route-item.child:hover { color: var(--text-dim); }
.route-item.child.active { color: #fff; }

/* Project Memory section */
.route-group-title--project {
  color: var(--text-muted);
  user-select: none;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 8px;
}
.route-group-title--project:hover { color: var(--text-dim); }
.route-group--project { margin-bottom: 6px; }
.route-group-title--sub {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 3px 8px 2px 16px;
}
.route-item--project {
  font-size: 12px;
  padding: 4px 8px 4px 28px;
  color: var(--text-muted);
}
.route-item--project:hover { background: var(--bg-hover); color: var(--text-dim); }
.route-item--project.active { background: var(--accent-dim); color: #fff; }

#browse-main {
  flex: 1;
  overflow: auto;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  min-height: 48px;
}

.toolbar h2 {
  font-size: 14px;
  font-weight: 600;
  font-family: var(--mono);
  color: var(--text);
}

.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 0;
  font-size: 13px;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  margin-top: 12px;
}

.pagination-info {
  font-weight: 500;
  color: var(--text);
  margin-right: 8px;
}

.pagination-label {
  margin-left: auto;
  margin-right: 4px;
  font-size: 12px;
}

.pagination-select {
  padding: 4px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}

.pagination-select:hover {
  border-color: var(--accent);
}

.pagination-dots {
  padding: 0 4px;
  color: var(--text-dim);
  user-select: none;
}

.pagination button {
  min-width: 32px;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.pagination button:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--accent);
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 500;
}

#browse-table-wrap {
  flex: 1;
  overflow: auto;
}

/* ── Tables ───────────────────────────────────────── */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--bg-card);
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--bg-hover); }

td.key-cell {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

td.type-cell {
  white-space: nowrap;
}

.type-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-hover);
  border: 1px solid var(--border);
}

td.route-cell {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--purple);
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

td.content-cell {
  color: var(--text-dim);
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

td.date-cell {
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 12px;
}

td.score-cell {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--green);
  white-space: nowrap;
}

.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ── Search Tab ───────────────────────────────────── */

#tab-search {
  flex-direction: column;
  height: calc(100vh - 49px);
}

.search-bar {
  display: flex;
  gap: 8px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.search-bar input {
  flex: 1;
  padding: 8px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
}

.search-bar input:focus { outline: none; border-color: var(--accent); }

.search-bar select {
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
}

.search-bar button {
  padding: 8px 20px;
  background: var(--accent-dim);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.search-bar button:hover { background: var(--accent); }

#search-results {
  flex: 1;
  overflow: auto;
}

/* ── Entity Modal ─────────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

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

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

.modal-header h2 {
  font-size: 16px;
  font-family: var(--mono);
  color: var(--accent);
}

#btn-close-modal {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}

#btn-close-modal:hover { color: var(--text); }

.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.modal-body h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin: 20px 0 8px;
}

.modal-body h3:first-child { margin-top: 0; }

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}

.meta-item {
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 4px;
  border: 1px solid var(--border);
}

.meta-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.meta-value {
  font-size: 13px;
  font-family: var(--mono);
  word-break: break-all;
}

pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 400px;
}

/* History */
.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 4px;
  font-size: 12px;
  cursor: pointer;
}

.history-item:hover { background: var(--bg-hover); }

.history-date { color: var(--text-dim); font-family: var(--mono); }
.history-size { color: var(--text-muted); }
.history-deleted { color: var(--red); font-weight: 600; }

/* ── Edit/Delete Actions ──────────────────────────── */

.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 16px;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-icon:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.btn-danger:hover {
  background: var(--red);
  border-color: var(--red);
  color: var(--bg);
}

#edit-mode {
  margin-top: 16px;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

#edit-textarea {
  width: 100%;
  min-height: 300px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  line-height: 1.5;
  resize: vertical;
}

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

.edit-actions, .delete-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.btn-primary, .btn-secondary {
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: var(--bg);
}

.btn-primary:hover {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
}

.btn-secondary {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--bg-hover);
}

.modal-small .modal-content {
  max-width: 400px;
}

#delete-confirm-text {
  margin-bottom: 16px;
  color: var(--text-dim);
}

.error {
  margin-top: 12px;
  padding: 8px 12px;
  background: rgba(220, 53, 69, 0.1);
  border: 1px solid var(--red);
  border-radius: 4px;
  color: var(--red);
  font-size: 12px;
}

.success {
  margin-top: 12px;
  padding: 8px 12px;
  background: rgba(40, 167, 69, 0.1);
  border: 1px solid var(--green);
  border-radius: 4px;
  color: var(--green);
  font-size: 12px;
}

/* ── Change Credentials ──────────────────────────────── */

.modal-medium .modal-content {
  max-width: 500px;
}

#change-creds-form label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  margin: 16px 0 4px;
}

#change-creds-form label:first-of-type {
  margin-top: 0;
}

#change-creds-form input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
  color: var(--text);
  font-family: var(--sans);
}

#change-creds-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}

/* ── Spinner ──────────────────────────────────────── */

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ── Responsive ───────────────────────────────────── */

/* Sidebar toggle button — hidden on desktop, shown on mobile */
.sidebar-toggle-btn { display: none; }

/* Sidebar backdrop overlay — hidden by default */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 199;
  background: rgba(0, 0, 0, 0.45);
}
.sidebar-backdrop.active { display: block; }

/* Sidebar header (title + close button) */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.sidebar-close-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
}
.sidebar-close-btn:hover { color: var(--text); background: var(--bg-hover); }

/* Tablet (≤ 900px) — collapse Browse sidebar, stack projects */
@media (max-width: 900px) {
  /* Header: wrap tabs to second line */
  header { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  nav { order: 3; width: 100%; justify-content: flex-start; }

  /* Projects layout: stack list + detail vertically */
  .projects-layout { flex-direction: column; gap: 16px; }
  .projects-list { min-width: 0; }
  .project-detail { min-width: 0; }

  /* Browse tab sidebar narrower */
  #sidebar { width: 180px; min-width: 180px; }
}

/* Mobile (≤ 600px) — single column everything */
@media (max-width: 600px) {
  /* Header collapses */
  header { padding: 6px 10px; gap: 6px; }
  .header-left h1 { font-size: 14px; }
  nav { gap: 1px; }
  .tab { padding: 4px 8px; font-size: 11px; }

  /* ── Browse tab: off-canvas sidebar drawer ─────── */
  #tab-browse { flex-direction: row; position: relative; overflow: hidden; }

  /* Sidebar becomes a fixed off-canvas drawer */
  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: 280px;
    min-width: 280px;
    z-index: 200;
    background: var(--bg2);
    border-right: 1px solid var(--border);
    padding: 16px;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  #sidebar.sidebar-open { transform: translateX(0); }

  /* Show close button inside drawer */
  .sidebar-close-btn { display: flex; }

  /* Show sidebar toggle button in toolbar */
  .sidebar-toggle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-dim);
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .sidebar-toggle-btn:hover { border-color: var(--accent); color: var(--text); }

  /* Toolbar: stack vertically, full width */
  .toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
  }
  .toolbar h2 { font-size: 13px; word-break: break-all; }

  /* Pagination: stack vertically, wrap buttons */
  .pagination {
    flex-wrap: wrap;
    gap: 4px;
    padding: 10px 0;
    font-size: 12px;
  }
  .pagination-info { margin-right: 4px; }
  .pagination-label { margin-left: 0; }
  .pagination button { min-width: 28px; padding: 4px 8px; font-size: 12px; }

  /* Browse table: card view on mobile */
  #browse-table { border-collapse: collapse; }
  #browse-table thead { display: none; }
  #browse-table tbody tr {
    display: block;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 10px;
    padding: 10px 12px;
  }
  #browse-table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    padding: 4px 0;
    font-size: 12px;
    border: none;
    min-height: 0;
  }
  #browse-table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-dim);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
    width: 70px;
    padding-top: 1px;
  }
  /* Content cell: allow wrapping */
  td.content-cell { max-width: none; word-break: break-word; flex-direction: column; }
  td.content-cell::before { width: auto; }

  /* ── Other sections ────────────────────────────── */

  /* Project detail tabs: scrollable */
  .project-detail-tabs { overflow-x: auto; white-space: nowrap; padding: 0 12px; }
  .project-detail-content { padding: 12px; }

  /* Cards: full width, smaller padding */
  .project-card { padding: 10px 12px; }
  .project-memory-item { padding: 8px 10px; }

  /* Filter rows: wrap */
  .th-subtab-bar { flex-wrap: wrap; }

  /* Modals: full screen, leave room for bottom nav */
  .modal { padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px)); align-items: flex-end; }
  .modal-content { width: 100vw; max-width: 100vw; max-height: calc(100vh - 56px); border-radius: 12px 12px 0 0; margin: 0; }

  /* Non-browse tables: horizontal scroll */
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Search bar */
  .search-bar { padding: 10px; }
  .search-bar input { font-size: 14px; }
}

/* ═══════════════════════════════════════════════════════
   Browse Quick Nav + Filter Bar
   ═══════════════════════════════════════════════════════ */

#browse-quick-nav {
  padding: 8px 16px 6px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.qnav-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.qnav-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 4px;
  flex-shrink: 0;
  min-width: 54px;
}

.qnav-btn {
  font-size: 12px;
  padding: 3px 8px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
  font-family: var(--mono);
  white-space: nowrap;
}

.qnav-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--text);
}

.qnav-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #fff;
}

.qnav-btn--project {
  color: var(--text-muted);
  border-style: dashed;
}

.qnav-btn--project:hover { color: var(--text); border-style: solid; }
.qnav-btn--project.active { color: #fff; border-style: solid; }

#browse-filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

#browse-key-filter {
  flex: 1;
  max-width: 380px;
  padding: 5px 10px;
  font-size: 13px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--mono);
}

#browse-key-filter:focus {
  outline: none;
  border-color: var(--accent);
}

.browse-toggle-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.browse-toggle-label input[type=checkbox] {
  accent-color: var(--accent);
  cursor: pointer;
}

tr.row-deleted td {
  opacity: 0.45;
  text-decoration: line-through;
  font-style: italic;
}

/* ═══════════════════════════════════════════════════════
   Analytics Tab
   ═══════════════════════════════════════════════════════ */

.analytics-container {
  padding: 24px 28px;
  max-width: 1400px;
  margin: 0 auto;
}

.analytics-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

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

.stat-card h3 {
  margin: 0 0 6px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat-value {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--accent);
  margin: 4px 0 6px;
  line-height: 1;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.charts-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 900px) {
  .charts-row { grid-template-columns: 1fr; }
}

.chart-card, .projects-card {
  background: var(--bg-card);
  padding: 20px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.chart-card h3, .projects-card h3 {
  margin: 0 0 16px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.chart-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chart-bar {
  display: grid;
  grid-template-columns: 130px 1fr 36px;
  align-items: center;
  gap: 10px;
}

.chart-bar-label {
  font-size: 0.82rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-bar-track {
  height: 22px;
  background: var(--bg-secondary, var(--bg));
  border-radius: 4px;
  overflow: hidden;
}

.chart-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-dim, var(--accent)) 100%);
  border-radius: 4px;
  transition: width 0.4s ease;
  min-width: 4px;
}

.chart-bar-value {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  text-align: right;
}

/* Memory Health Widget */
.health-widget {
  background: var(--bg-card);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
}
.health-widget h3 {
  margin: 0 0 14px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.health-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
.health-card {
  background: var(--bg);
  border-radius: 8px;
  padding: 14px 12px;
  text-align: center;
}
.health-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
}
.health-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.health-bar-track {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}
.health-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease, background 0.3s ease;
}

/* ═══════════════════════════════════════════════════════
   Sources Tab
   ═══════════════════════════════════════════════════════ */

.sources-container {
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 20px;
  align-items: start;
}

.sources-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  height: 100%;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.section-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

/* RSS Feeds List */
.feeds-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.feed-item {
  display: flex;
  flex-direction: column;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  transition: all 0.15s;
}

.feed-item:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.feed-info {
  flex: 1;
  margin-bottom: 12px;
}

.feed-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.feed-url {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-dim);
  word-break: break-all;
  line-height: 1.4;
}

.feed-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

.feed-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.feed-actions button {
  padding: 4px 12px;
  font-size: 12px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  cursor: pointer;
}

.feed-actions button:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.feed-actions button.btn-remove:hover {
  border-color: var(--red);
  color: var(--red);
}

/* Drive Config */
.drive-config {
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.drive-config-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.drive-config-item:last-child {
  border-bottom: none;
}

.drive-config-label {
  font-size: 13px;
  color: var(--text-dim);
}

.drive-config-value {
  font-size: 13px;
  font-family: var(--mono);
  color: var(--text);
}

.drive-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
}

.drive-status.active {
  background: rgba(40, 167, 69, 0.1);
  color: var(--green);
}

.drive-status.inactive {
  background: rgba(220, 53, 69, 0.1);
  color: var(--red);
}

/* Ingestion History Section - Full Width */
.sources-section:has(#ingestion-history-wrap) {
  grid-column: 1 / -1;
}

/* Ingestion History Table */
#ingestion-history-wrap {
  overflow-x: auto;
}

#ingestion-history-table {
  width: 100%;
}

#ingestion-history-table td {
  padding: 10px 12px;
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
}

.status-badge.success {
  background: rgba(40, 167, 69, 0.1);
  color: var(--green);
}

.status-badge.pending {
  background: rgba(253, 126, 20, 0.1);
  color: var(--orange);
}

.status-badge.failed {
  background: rgba(220, 53, 69, 0.1);
  color: var(--red);
}

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

.history-actions button {
  padding: 4px 8px;
  font-size: 11px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-dim);
  cursor: pointer;
}

.history-actions button:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.history-actions button.btn-retry:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Form styles for modals */
#add-rss-form label,
#configure-drive-form label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  margin: 16px 0 4px;
}

#add-rss-form label:first-of-type,
#configure-drive-form label:first-of-type {
  margin-top: 0;
}

#add-rss-form input,
#configure-drive-form input[type="text"],
#configure-drive-form input[type="url"],
#configure-drive-form input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
  color: var(--text);
  font-family: var(--sans);
}

#add-rss-form input:focus,
#configure-drive-form input:focus {
  outline: none;
  border-color: var(--accent);
}

#configure-drive-form label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0;
}

#configure-drive-form input[type="checkbox"] {
  width: auto;
}

/* ── Repos Tab ─────────────────────────────────────── */

.repos-container {
  padding: 20px;
  max-width: 100%;
  width: 100%;
  margin: 0 auto;
}

.repos-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.repos-header h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.repos-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)) !important;
  gap: 24px !important;
  width: 100%;
}

.repo-card {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 280px;
}

.repo-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  transform: translateY(-2px);
}

.repo-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.repo-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  font-family: var(--mono);
}

.repo-status {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.repo-status.active {
  background: rgba(0, 255, 0, 0.1);
  color: #0f0;
  border: 1px solid rgba(0, 255, 0, 0.3);
}

.repo-status.idle {
  background: rgba(255, 255, 0, 0.1);
  color: #ff0;
  border: 1px solid rgba(255, 255, 0, 0.3);
}

.repo-status.error {
  background: rgba(255, 0, 0, 0.1);
  color: #f55;
  border: 1px solid rgba(255, 0, 0, 0.3);
}

.repo-description {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 16px;
  line-height: 1.4;
}

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

.repo-stat {
  display: flex;
  flex-direction: column;
}

.repo-stat-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.repo-stat-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  font-family: var(--mono);
}

.repo-last-commit {
  margin-bottom: 16px;
  padding: 12px;
  background: var(--bg-input);
  border-radius: 4px;
}

.repo-commit-msg {
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--mono);
  margin-top: 4px;
  line-height: 1.4;
}

.repo-card-footer {
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.repo-actions {
  display: flex;
  gap: 8px;
}

.repo-actions button {
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.repo-actions button:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--text);
}

/* ── SSE Notifications ───────────────────────────────── */

.repo-notification {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #1a1a2e;
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  border-left: 4px solid var(--green);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 1000;
  animation: slideIn 0.3s ease, fadeOut 0.3s ease 4.7s forwards;
  max-width: 350px;
}

.repo-notification .notification-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
  color: var(--green);
}

.repo-notification .notification-message {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.4;
}

@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateX(400px);
  }
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

/* ── Responsive Design ───────────────────────────────── */

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) {
  .repos-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
  }

  .sources-container {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
    padding: 16px;
  }

  .feeds-list {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }

  .repo-card {
    padding: 16px;
  }

  .feed-item {
    padding: 14px;
  }

  .sources-section {
    padding: 16px;
  }
}

/* Mobile (max-width: 767px) */
@media (max-width: 767px) {
  /* Single column layout for all grids */
  .repos-grid,
  .feeds-list,
  .sources-container {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .sources-container {
    padding: 12px;
  }

  /* Adjust card padding */
  .repo-card,
  .feed-item,
  .sources-section {
    padding: 12px;
  }

  /* Smaller fonts on mobile */
  .repo-name {
    font-size: 14px;
  }

  .repo-stat-value {
    font-size: 16px;
  }

  .feed-name {
    font-size: 13px;
  }

  /* Stack repo stats vertically on very small screens */
  .repo-stats {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  /* Notification toast smaller on mobile */
  .repo-notification {
    max-width: 90%;
    right: 5%;
    bottom: 10px;
  }

  /* Sources section spacing */
  .sources-section {
    margin-bottom: 20px;
  }

  .section-header h2 {
    font-size: 14px;
  }
}

/* Large Desktop (min-width: 1440px) */
@media (min-width: 1440px) {
  .repos-grid {
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  }

  .feeds-list {
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  }
}

/* ══════════════════════════════════════════════════════════════════════════
   NOTES TAB
   ══════════════════════════════════════════════════════════════════════════ */

.notes-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 20px;
  padding: 20px;
  height: calc(100vh - 98px);
  overflow: hidden;
  flex: 1;
}

/* ── Notes Sidebar ─────────────────────────────────────────── */

.notes-sidebar {
  border-right: 1px solid var(--border);
  padding-right: 20px;
  overflow-y: auto;
}

.notes-sidebar h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 12px 0;
}

.category-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.category-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.category-item:hover {
  background: var(--bg-hover);
}

.category-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}

.category-icon {
  font-size: 16px;
}

.category-name {
  flex: 1;
  font-size: 13px;
}

.category-count {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--mono);
}

/* ── Notes Main Content ────────────────────────────────────── */

.notes-main {
  overflow-y: auto;
  padding-right: 8px;
}

/* ── Toolbar (Search + Sort) ───────────────────────────────── */

.notes-toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  padding: 0 16px;
}

.notes-toolbar input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
}

.notes-toolbar input:focus {
  outline: none;
  border-color: var(--accent);
}

.notes-toolbar select {
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

/* ── Tag Cloud ─────────────────────────────────────────────── */

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  padding: 0 16px;
}

.cloud-tag {
  padding: 4px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.cloud-tag:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--text);
}

.cloud-tag.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.cloud-tag.freq-high {
  font-size: 14px;
  font-weight: 700;
}

.cloud-tag.freq-medium {
  font-size: 13px;
  font-weight: 600;
}

.cloud-tag.freq-low {
  font-size: 11px;
}

.tag-count {
  opacity: 0.7;
  font-size: 0.9em;
}

/* ── Notes Grid (Masonry) ──────────────────────────────────── */

.notes-grid {
  columns: 3;
  column-gap: 16px;
  padding: 0 16px;
}

.note-card {
  break-inside: avoid;
  margin-bottom: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
  z-index: 1;
}

.note-card:hover:not(.focused) {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  transform: translateY(-2px);
  border-color: var(--accent);
}

/* Focused note card (zoom-in effect) */
.note-card.focused {
  position: fixed;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) scale(1.2);
  z-index: 10002;
  max-width: 700px;
  width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  border-color: var(--accent);
  cursor: default;
}

/* Dimmed cards when one is focused */
.note-card.dimmed {
  opacity: 0.3;
  filter: blur(2px);
  pointer-events: none;
}

/* Backdrop overlay */
.note-focus-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  z-index: 10001;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.note-focus-backdrop.active {
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
  opacity: 1;
  pointer-events: all;
  cursor: pointer;
}

.note-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.4;
}

.note-preview {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 8px 0 12px;
  transition: all 0.3s ease;
}

.note-preview.full-text {
  display: block;
  -webkit-line-clamp: unset;
  overflow-y: auto;
  max-height: 50vh;
  padding-right: 8px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.7;
}

.note-meta {
  margin-bottom: 8px;
}

.note-category {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* Category colors */
.cat-business {
  background: #E3F2FD;
  color: #1565C0;
}

.cat-ideas {
  background: #FFF3E0;
  color: #E65100;
}

.cat-tech {
  background: #E8F5E9;
  color: #2E7D32;
}

.cat-personal {
  background: #F3E5F5;
  color: #7B1FA2;
}

.cat-fitness {
  background: #FFF8E1;
  color: #F57F17;
}

.cat-bugs {
  background: #FFEBEE;
  color: #C62828;
}

.cat-tasks {
  background: #E0F2F1;
  color: #00695C;
}

.cat-uncategorized {
  background: #F5F5F5;
  color: #616161;
}

.note-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.note-tag {
  padding: 2px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 10px;
  color: var(--text-muted);
}

.note-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
}

.note-source {
  font-family: var(--mono);
}

.note-date {
  font-family: var(--mono);
}

/* ── Note Detail Modal ─────────────────────────────────────── */

.note-detail {
  padding: 8px 0;
}

.note-detail-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.note-detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.note-detail-text {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
}

/* ── Notes Pagination ──────────────────────────────────────── */

#notes-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 16px;
  margin-top: 20px;
  border-top: 1px solid var(--border);
}

#notes-pagination .pagination-controls {
  display: flex;
  gap: 12px;
  align-items: center;
}

#notes-pagination button {
  padding: 6px 14px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

#notes-pagination button:hover:not(:disabled) {
  background: var(--accent);
  color: white;
}

#notes-pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Responsive Notes ──────────────────────────────────────── */

@media (max-width: 1024px) {
  .notes-grid {
    columns: 2;
  }

  .notes-layout {
    grid-template-columns: 180px 1fr;
  }
}

@media (max-width: 767px) {
  .notes-layout {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .notes-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-right: 0;
    padding-bottom: 16px;
    margin-bottom: 16px;
    max-height: 200px;
  }

  .notes-grid {
    columns: 1;
  }

  .notes-toolbar {
    flex-direction: column;
    padding: 0;
  }

  .tag-cloud {
    padding: 0;
  }

  .notes-main {
    padding-right: 0;
  }
}

/* ── Notes Sub-tabs ────────────────────────────────────────── */

.notes-subtab-bar {
  display: flex;
  gap: 4px;
  padding: 12px 20px 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.notes-subtab {
  padding: 8px 18px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  bottom: -1px;
}

.notes-subtab:hover { color: var(--text); background: var(--bg-hover); }

.notes-subtab.active {
  background: var(--bg-card);
  color: var(--accent);
  border-color: var(--border);
  border-bottom-color: var(--bg-card);
  font-weight: 600;
}

/* ── Notes Tasks Panel ─────────────────────────────────────── */

.notes-tasks-panel {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 100px);
  overflow: hidden;
}

.notes-tasks-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.notes-tasks-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex: 1;
}

.notes-tasks-filters select {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.nt-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}

.notes-tasks-actions { display: flex; gap: 8px; flex-shrink: 0; }

#notes-tasks-grid {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  columns: 3 280px;
  column-gap: 16px;
}

/* Task card — extends .note-card */
.note-card.task-card { break-inside: avoid; cursor: pointer; }

.task-status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 6px;
}

.task-status-badge.status-todo    { background: #e3f2fd; color: #1565c0; }
.task-status-badge.status-doing   { background: #fff8e1; color: #f57f17; }
.task-status-badge.status-done    { background: #e8f5e9; color: #2e7d32; }
.task-status-badge.status-blocked { background: #fce4ec; color: #b71c1c; }

.task-priority-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  margin-left: 4px;
}

.task-priority-badge.priority-critical { background: #fce4ec; color: #c62828; }
.task-priority-badge.priority-high     { background: #fff3e0; color: #e65100; }
.task-priority-badge.priority-medium   { background: #e8f5e9; color: #2e7d32; }
.task-priority-badge.priority-low      { background: #f5f5f5; color: #616161; }

.task-project-label {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--mono);
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid var(--border);
}

.task-due-date { font-size: 11px; color: var(--text-muted); }
.task-due-date.overdue { color: var(--red); font-weight: 600; }

/* ── Task Edit Modal ───────────────────────────────────────── */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.form-input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 13px;
  font-family: var(--sans);
  width: 100%;
}

.form-input:focus { outline: none; border-color: var(--accent); }

textarea.form-input { resize: vertical; min-height: 70px; line-height: 1.5; }

.modal-footer {
  display: flex;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.btn-danger {
  padding: 8px 16px;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
}

.btn-danger:hover { background: #b71c1c; }

/* ═══════════════════════════════════════════════════════
   MONITOR TAB — System Monitoring
   ═══════════════════════════════════════════════════════ */

.monitor-container {
  padding: 24px;
  max-width: 1600px;
  margin: 0 auto;
}

.monitor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  align-items: start;
}

.monitor-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: box-shadow 0.2s;
}

.monitor-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.monitor-card .card-header {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Balance Card */
.balance-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
}

.balance-card .card-header {
  color: white;
  opacity: 0.95;
}

#balance-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.balance-display {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 48px;
  font-weight: 700;
  color: white;
}

.balance-icon {
  font-size: 36px;
}

.balance-amount {
  font-family: var(--mono);
}

.balance-high { color: #10b981; }
.balance-medium { color: #f59e0b; }
.balance-low { color: #ef4444; }

.balance-card .balance-high,
.balance-card .balance-medium,
.balance-card .balance-low {
  color: white;
}

.btn-refresh {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s;
}

.btn-refresh:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.3);
}

.btn-refresh:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Functions/Tools Lists */
.compact-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
}

.compact-list li {
  font-size: 13px;
  color: var(--text-dim);
  padding: 6px 10px;
  background: var(--bg);
  border-radius: 4px;
  border: 1px solid var(--border);
  transition: background 0.15s, border-color 0.15s;
}

.compact-list li:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.compact-list li code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
}

.more-info {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

.btn-show-all {
  margin-top: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim);
  transition: background 0.2s, border-color 0.2s;
}

.btn-show-all:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--accent);
}

/* Cron Jobs List */
.cron-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cron-job {
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: background 0.15s;
}

.cron-job:hover {
  background: var(--bg-hover);
}

.cron-name {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
}

.cron-schedule {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.cron-desc {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.4;
}

/* Stats Rows */
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--bg);
}

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

.stat-row.total {
  border-top: 2px solid var(--border);
  padding-top: 12px;
  margin-top: 8px;
  font-weight: 600;
}

.stat-label {
  font-size: 14px;
  color: var(--text-dim);
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--accent);
}

.stat-row.total .stat-value {
  font-size: 20px;
}

/* Responsive Monitor Grid */
@media (max-width: 1024px) {
  .monitor-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }

  .compact-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 767px) {
  .monitor-container {
    padding: 16px;
  }

  .monitor-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .balance-display {
    font-size: 36px;
  }

  .balance-icon {
    font-size: 28px;
  }
}

/* ═══════════════════════════════════════════════════════
   NEWS TAB — Lightweight RSS Reader
   ═══════════════════════════════════════════════════════ */

.news-container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 24px;
}

/* Toolbar */
.news-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.btn-add-feed,
.btn-refresh-feeds {
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-add-feed:hover,
.btn-refresh-feeds:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.btn-add-feed {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn-add-feed:hover {
  background: var(--accent-dim);
}

/* Feed Filters */
.feed-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}

.feed-filter {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  color: var(--text-dim);
}

.feed-filter:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.feed-filter.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.feed-filter.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  text-decoration: line-through;
}

.feed-name {
  flex: 1;
}

.feed-menu-trigger {
  margin-left: 4px;
  padding: 0 4px;
  font-size: 16px;
  font-weight: bold;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.feed-menu-trigger:hover {
  opacity: 1;
}

/* Feed Context Menu */
.feed-context-menu {
  position: fixed;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 6px;
  z-index: 10003;
  min-width: 140px;
}

.feed-context-menu button {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s;
}

.feed-context-menu button:hover {
  background: var(--bg-hover);
}

.feed-context-menu button.danger {
  color: var(--red);
}

.feed-context-menu button.danger:hover {
  background: #FEE;
}

.source-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Add Feed Dialog */
.add-feed-dialog {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.add-feed-dialog input[type="text"],
.add-feed-dialog input[type="url"] {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  flex: 1;
  min-width: 180px;
  background: var(--bg-input);
  color: var(--text);
}

.add-feed-dialog input[type="color"] {
  width: 42px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  background: none;
}

/* Date Group */
.news-date-group {
  margin-bottom: 32px;
}

.news-date-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--bg);
}

/* Article Card */
.news-article {
  display: flex;
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid var(--bg);
  cursor: pointer;
  transition: all 0.15s;
}

.news-article:hover {
  background: var(--bg-hover);
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
  padding-top: 16px;
  padding-bottom: 16px;
  border-radius: var(--radius);
}

.news-article:last-child {
  border-bottom: none;
}

.article-thumbnail {
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
}

.article-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.article-content {
  flex: 1;
  min-width: 0;
}

.article-source {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.source-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.article-time {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: auto;
  opacity: 0.7;
}

.article-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.4;
}

.article-preview {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Translate Button in Reader */
.btn-translate-reader {
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn-translate-reader:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-translate-reader.translated {
  background: #E3F2FD;
  border-color: #2196F3;
  color: #1976D2;
}

.btn-translate-reader.loading {
  opacity: 0.6;
  cursor: wait;
}

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

.translate-icon {
  font-size: 16px;
  line-height: 1;
}

.translate-text {
  font-size: 13px;
}

/* Loading State */
.news-loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.news-loading .spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 16px;
  border: 3px solid var(--bg);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.news-loading p {
  font-size: 14px;
}

/* Error State */
.news-error {
  background: #FEE;
  border: 1px solid #ECC;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
  color: var(--red);
  font-size: 14px;
}

/* Empty State */
.news-empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

.news-empty h3 {
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--text-dim);
}

.news-empty p {
  font-size: 14px;
}

/* Article Reader (Focus Mode) */
.article-reader-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  z-index: 10001;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.article-reader-backdrop.active {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  opacity: 1;
  pointer-events: all;
  cursor: pointer;
}

.article-reader {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  width: 700px;
  max-width: 92vw;
  height: 90vh;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  z-index: 10002;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
  pointer-events: none;
}

.article-reader.active {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  pointer-events: all;
}

.reader-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.reader-close {
  background: none;
  border: none;
  font-size: 32px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
}

.reader-close:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.reader-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
}

.reader-title {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 12px;
  color: var(--text);
}

.reader-author {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.reader-image {
  margin: 20px 0;
  border-radius: var(--radius);
  overflow: hidden;
}

.reader-image img {
  width: 100%;
  height: auto;
  display: block;
}

.reader-content {
  font-size: 16px;
  line-height: 1.8;
  color: var(--text-dim);
}

.reader-content p {
  margin-bottom: 16px;
}

.reader-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin: 16px 0;
}

.reader-loading-more {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 0;
  color: var(--text-muted);
  font-size: 14px;
}

.reader-loading-more .spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--bg);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.reader-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

/* Responsive News Tab */
@media (max-width: 767px) {
  .news-container {
    padding: 16px;
  }

  .news-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .feed-filters {
    margin-left: 0;
    width: 100%;
  }

  .add-feed-dialog {
    flex-direction: column;
    align-items: stretch;
  }

  .add-feed-dialog input {
    min-width: 100%;
  }

  .article-title {
    font-size: 15px;
  }

  .article-preview {
    font-size: 13px;
  }
}

/* ── Projects Tab ──────────────────────────────────── */

.projects-container {
  padding: 20px;
  max-width: 100%;
  width: 100%;
  margin: 0 auto;
}

.projects-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.projects-header h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.projects-header-actions {
  display: flex;
  gap: 8px;
}

.projects-layout {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 400px;
}

.projects-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
}

.project-card {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  cursor: pointer;
  transition: all 0.2s;
}

.project-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.project-card.active {
  border-color: var(--accent);
  background: var(--sidebar-bg);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.project-card.project-card-active {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.06);
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.3), 0 2px 12px rgba(0, 0, 0, 0.15);
}

.project-active-indicator {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #f59e0b;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.project-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.project-card-key {
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--mono);
  margin-bottom: 8px;
}

.project-card-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.project-badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.project-badge.phase {
  background: rgba(33, 150, 243, 0.15);
  color: #2196F3;
  border: 1px solid rgba(33, 150, 243, 0.3);
}

.project-badge.status-active {
  background: rgba(76, 175, 80, 0.15);
  color: #4CAF50;
  border: 1px solid rgba(76, 175, 80, 0.3);
}

.project-badge.status-complete {
  background: rgba(156, 39, 176, 0.15);
  color: #CE93D8;
  border: 1px solid rgba(156, 39, 176, 0.3);
}

.project-badge.tag {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.project-badge.agent {
  background: rgba(255, 152, 0, 0.12);
  color: #ff9800;
  border: 1px solid rgba(255, 152, 0, 0.3);
}

/* ── Compact project rows ───────────────────────────── */
.project-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  overflow: hidden;
  margin-bottom: 4px;
}
.project-row:hover { background: var(--bg-hover); border-color: var(--accent); }
.project-row.project-row-open {
  border-color: var(--accent);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  margin-bottom: 0;
  background: var(--sidebar-bg);
}
.project-row.project-row-active-session { border-left: 3px solid #f59e0b; }
.project-row-chevron { font-size: 10px; color: var(--text-dim); flex-shrink: 0; width: 12px; }
.project-row-thumb { height: 22px; width: 36px; object-fit: cover; border-radius: 3px; border: 1px solid var(--border); flex-shrink: 0; cursor: zoom-in; }
.proj-snapshot-screenshot { margin-bottom: 16px; }
.proj-screenshot-upload-prompt { display:flex;align-items:center;justify-content:center;gap:6px;padding:12px;border:2px dashed var(--border);border-radius:6px;cursor:pointer;color:var(--text-dim);font-size:13px;background:var(--bg2); }
.project-row-name  { font-weight: 600; font-size: 14px; color: var(--text); flex-shrink: 0; }
.project-row-key   { font-size: 11px; color: var(--text-dim); font-family: var(--mono); flex-shrink: 0; }
.project-row-badge { flex-shrink: 0; }
.project-row-counts { font-size: 11px; color: var(--text-dim); flex-shrink: 0; white-space: nowrap; }
.project-row-date  { font-size: 11px; color: var(--text-dim); margin-left: auto; flex-shrink: 0; white-space: nowrap; }

/* Project Detail Panel */
.project-detail {
  flex: 1;
  background: var(--bg);
  border: 2px solid var(--accent);
  border-top: none;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.project-detail-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.project-detail-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  flex: 1;
}

.project-detail-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-dim);
}

.project-detail-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.project-detail-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.project-detail-tabs::-webkit-scrollbar { display: none; }

.proj-tab {
  padding: 10px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}

.proj-tab:hover {
  color: var(--text);
}

.proj-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.project-detail-content {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  max-height: 70vh;
}

/* WAT doc rendered markdown */
.project-detail-content h1 {
  font-size: 20px;
  margin: 0 0 16px;
  color: var(--text);
}

.project-detail-content h2 {
  font-size: 16px;
  margin: 20px 0 10px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.project-detail-content h3 {
  font-size: 14px;
  margin: 16px 0 8px;
  color: var(--text);
}

.project-detail-content p {
  margin: 8px 0;
  line-height: 1.6;
  color: var(--text-dim);
}

.project-detail-content ul, .project-detail-content ol {
  margin: 8px 0;
  padding-left: 20px;
}

.project-detail-content li {
  margin: 4px 0;
  line-height: 1.5;
  color: var(--text-dim);
}

.project-detail-content li input[type="checkbox"] {
  margin-right: 6px;
}

.project-detail-content code {
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: var(--mono);
}

.project-detail-content pre {
  background: rgba(0, 0, 0, 0.3);
  padding: 12px 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 12px 0;
}

.project-detail-content pre code {
  background: none;
  padding: 0;
}

.project-detail-content strong {
  color: var(--text);
}

.project-detail-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* Memories list in project detail */
.project-memories-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.project-memory-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
}

.project-memory-item .memory-type {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}

.project-memory-item .memory-content {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
}

.project-memory-item .memory-date {
  font-size: 11px;
  color: var(--text-dim);
  opacity: 0.6;
  margin-top: 4px;
}

.project-memory-item .memory-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.project-memory-item .memory-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.project-memory-item .memory-tags .project-badge {
  font-size: 10px;
  padding: 1px 6px;
}

/* Create Project Modal */
.create-project-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.create-project-form label {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}

.create-project-form input,
.create-project-form textarea {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--sidebar-bg);
  color: var(--text);
  font-size: 14px;
}

.create-project-form textarea {
  resize: vertical;
  min-height: 60px;
}

.project-empty-detail {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-dim);
  font-size: 14px;
  flex: 1;
  background: var(--bg);
  border: 2px dashed var(--border);
  border-radius: 12px;
  min-height: 400px;
}

/* Responsive Projects */
@media (max-width: 900px) {
  .projects-layout {
    flex-direction: column;
  }
  .projects-list {
    max-width: 100%;
    min-width: auto;
  }
}

/* ═══════════════════════════════════════════════════════════
   Posts / Stories / Leads — Shared Content Tab Layout
   ═══════════════════════════════════════════════════════════ */

.content-tab-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 20px;
  padding: 20px;
  height: calc(100vh - 49px);
  overflow: hidden;
}

.content-sidebar {
  border-right: 1px solid var(--border);
  padding-right: 16px;
  overflow-y: auto;
}

.content-sidebar h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 10px 0;
}

.filter-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-dim);
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-item:hover { background: var(--bg-hover); color: var(--text); }
.filter-item.active { background: #0066cc18; color: var(--accent); font-weight: 500; }

.filter-count {
  margin-left: auto;
  font-size: 11px;
  opacity: 0.6;
  flex-shrink: 0;
}

.content-main {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.content-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
}

.content-toolbar input {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 12px;
  font-size: 14px;
}

.content-toolbar input:focus {
  outline: none;
  border-color: var(--accent);
}

.content-toolbar select {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
}

/* ── Content Cards Grid ──────────────────────────────────── */

.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  align-content: start;
  width: 100%;
}

.content-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  cursor: pointer;
  position: relative;
}

.content-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  transform: translateY(-2px);
}

/* Focused content card (full-content modal) */
.content-card.focused {
  position: fixed;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%);
  z-index: 10002;
  max-width: 720px;
  width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  border-color: var(--accent);
  cursor: default;
}

.content-card.dimmed {
  opacity: 0.3;
  filter: blur(2px);
  pointer-events: none;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}

.card-preview {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
  flex: 1;
}

.card-preview.full-text {
  overflow-y: auto;
  max-height: 50vh;
  white-space: pre-wrap;
  font-size: 13px;
  color: var(--text);
}

.card-company,
.card-contact {
  font-size: 12px;
  color: var(--text-dim);
}

.card-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 4px;
}

.card-date {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.card-tag {
  font-size: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-dim);
}

/* ── Platform badges (Posts) ─────────────────────────────── */

.card-platform-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 2px 8px;
  border-radius: 6px;
  width: fit-content;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.card-platform-badge.linkedin  { background: #0a66c215; border-color: #0a66c250; color: #0a66c2; }
.card-platform-badge.twitter   { background: #1da1f215; border-color: #1da1f250; color: #1da1f2; }
.card-platform-badge.blog      { background: #f59e0b15; border-color: #f59e0b50; color: #f59e0b; }
.card-platform-badge.instagram { background: #e1306c15; border-color: #e1306c50; color: #e1306c; }
.card-platform-badge.work      { background: #3b82f615; border-color: #3b82f650; color: #3b82f6; }
.card-platform-badge.technical { background: #8b5cf615; border-color: #8b5cf650; color: #8b5cf6; }
.card-platform-badge.personal  { background: #10b98115; border-color: #10b98150; color: #10b981; }
.card-platform-badge.post      { background: #64748b15; border-color: #64748b50; color: #475569; }
.card-platform-badge.other     { background: #64748b15; border-color: #64748b50; color: #475569; }

.card-status {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 5px;
  font-weight: 500;
}

.status-draft     { background: #64748b20; color: #94a3b8; }
.status-published { background: #22c55e20; color: #4ade80; }
.status-scheduled { background: #3b82f620; color: #60a5fa; }
.status-archived  { background: #78716c20; color: #a8a29e; }

/* ── Category badge (Stories) ────────────────────────────── */

.card-category-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 2px 8px;
  border-radius: 6px;
  width: fit-content;
  background: var(--accent-dim);
  color: var(--accent);
}

.card-author {
  font-size: 11px;
  color: var(--text-dim);
}

/* ── Stage badges (Leads) ────────────────────────────────── */

.card-stage-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 6px;
  width: fit-content;
}

.stage-new       .card-stage-badge, .card-stage-badge.stage-new       { background: #3b82f620; color: #60a5fa; }
.stage-contacted .card-stage-badge, .card-stage-badge.stage-contacted { background: #8b5cf620; color: #a78bfa; }
.stage-proposal  .card-stage-badge, .card-stage-badge.stage-proposal  { background: #f59e0b20; color: #fbbf24; }
.stage-won       .card-stage-badge, .card-stage-badge.stage-won       { background: #22c55e20; color: #4ade80; }
.stage-lost      .card-stage-badge, .card-stage-badge.stage-lost      { background: #ef444420; color: #f87171; }
.stage-nurture   .card-stage-badge, .card-stage-badge.stage-nurture   { background: #06b6d420; color: #22d3ee; }

.card-value {
  font-size: 12px;
  font-weight: 600;
  color: #4ade80;
}

.card-followup {
  font-size: 11px;
  color: #fbbf24;
}

/* ── Responsive ─────────────────────────────────────────── */

@media (max-width: 900px) {
  .content-tab-layout {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }
  .content-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0 0 12px 0;
  }
  .filter-list {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .content-grid {
    grid-template-columns: 1fr;
  }
}

/* ═══════════════════════════════════════════════════════════
   Task History — Sub-tabs + Compliance View
   ═══════════════════════════════════════════════════════════ */

.th-subtab-bar {
  display: flex;
  gap: 6px;
  padding: 12px 16px 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.th-subtab {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.th-subtab:hover { background: var(--hover); color: var(--text); }
.th-subtab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--bg);
}

/* Compliance view container */
.compliance-view {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 900px;
}

.compliance-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
}

.compliance-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 14px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.compliance-legend {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 400;
}

.compliance-ok {
  color: #4CAF50;
  font-size: 13px;
  padding: 8px 0;
}

/* Stuck tasks */
.compliance-stuck-header {
  font-size: 13px;
  font-weight: 500;
  color: #FF9800;
  margin-bottom: 10px;
}

.compliance-stuck-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.compliance-stuck-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 8px;
  border-left: 3px solid #f44336;
  font-size: 13px;
}

.cmp-stuck-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.cmp-stuck-duration {
  font-weight: 700;
  font-size: 12px;
  margin-left: auto;
}

.cmp-stuck-summary {
  font-size: 12px;
  color: var(--text-dim);
  padding-left: 20px;
  font-style: italic;
}

.cmp-badge-warn {
  background: #FF9800;
  color: #fff;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 700;
}

.cmp-more {
  font-size: 12px;
  color: var(--text-dim);
  padding: 4px 10px;
  font-style: italic;
}

/* Score bars */
.compliance-scores {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.compliance-score-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.cmp-name {
  min-width: 140px;
  color: var(--text);
  font-size: 12px;
  flex-shrink: 0;
}

.cmp-pct {
  font-weight: 600;
  font-size: 13px;
  min-width: 36px;
  flex-shrink: 0;
}

.cmp-detail {
  font-size: 11px;
  color: var(--text-dim);
}

.cmp-tag {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
  color: var(--text-dim);
  font-family: monospace;
}

.cmp-agent {
  color: var(--accent);
  border-color: var(--accent);
  opacity: 0.8;
}

.cmp-status {
  font-size: 11px;
  padding: 1px 6px;
  background: var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  text-transform: uppercase;
  font-weight: 600;
}

.cmp-empty {
  color: var(--text-dim);
  font-size: 13px;
  font-style: italic;
}

/* Orphaned tasks */
.compliance-orphan-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.compliance-orphan-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 13px;
  flex-wrap: wrap;
}

/* ── Bugs view in Compliance tab ─────────────────────────── */

.compliance-bugs-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.compliance-bug-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 8px;
  border-left: 3px solid #f44336;
  font-size: 13px;
}

.cmp-bug-icon {
  font-size: 16px;
  flex-shrink: 0;
  line-height: 1.4;
}

.cmp-bug-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.cmp-bug-fn {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.cmp-bug-err {
  color: var(--text-dim);
  font-size: 12px;
  font-family: monospace;
  word-break: break-all;
}

.cmp-bug-date {
  color: var(--text-dim);
  font-size: 11px;
}

/* ── Planner Tab ──────────────────────────────────────────────────────────── */

#tab-planner {
  flex-direction: column;
  height: calc(100vh - 49px);
  overflow: hidden;
}

/* ── Planner toolbar ── */
.planner-toolbar {
  flex-shrink: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.planner-toolbar-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.planner-filter-bar { display: flex; gap: 4px; flex-wrap: wrap; }
.planner-select-all-wrap { display:flex;align-items:center;cursor:pointer;padding:0 2px; }
.planner-select-all-wrap input { width:15px;height:15px;cursor:pointer;accent-color:var(--accent); }
.planner-bulk-btn { font-size:12px;padding:4px 10px; }
.btn-danger { border-color:#f44336;color:#f44336; }
.btn-danger:hover { background:rgba(244,67,54,0.1); }

/* ── Planner list ── */
.planner-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  columns: 2;
  column-gap: 16px;
}
@media (max-width: 900px) { .planner-list { columns: 1; } }
@media (min-width: 1400px) { .planner-list { columns: 3; } }

/* ── Task cards — same feel as note-card ── */
.planner-card {
  break-inside: avoid;
  margin-bottom: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  position: relative;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.planner-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  transform: translateY(-1px);
  border-color: var(--accent);
}
.planner-card-done { opacity: 0.4; }
.planner-card-overdue { border-left: 3px solid #f44336; }
.planner-card-selected { border-color: var(--accent); background: rgba(0,102,204,0.04); }

/* Focused card — full detail overlay like Notes */
.planner-card.focused {
  position: fixed;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  z-index: 10002;
  max-width: 680px;
  width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  border-color: var(--accent);
  cursor: default;
  border-radius: 14px;
  padding: 20px 24px;
}
.planner-card.focused .planner-card-actions { opacity: 1; }
.planner-card.dimmed { opacity: 0.25; filter: blur(2px); pointer-events: none; }

/* Card content */
.planner-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 8px;
  word-break: break-word;
}
.planner-card.focused .planner-card-title { font-size: 17px; margin-bottom: 12px; }

.planner-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  margin-bottom: 8px;
}

.planner-card-desc {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 8px;
  display: none;
}
.planner-card.focused .planner-card-desc { display: block; }

.planner-card-key {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 10px;
  display: none;
}
.planner-card.focused .planner-card-key { display: block; }

/* Action buttons — shown on focused card */
.planner-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 14px;
  flex-wrap: wrap;
  opacity: 0;
  pointer-events: none;
}
.planner-card.focused .planner-card-actions {
  opacity: 1;
  pointer-events: auto;
}
.planner-action-btn {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim);
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.planner-action-btn:hover { background: var(--bg-hover); color: var(--text); }
.planner-btn-complete:hover { background: rgba(76,175,80,0.15); border-color:#4caf50; color:#4caf50; }
.planner-btn-archive:hover  { background: rgba(255,152,0,0.15); border-color:#ff9800; color:#ff9800; }
.planner-btn-delete:hover   { background: rgba(244,67,54,0.15);  border-color:#f44336; color:#f44336; }

/* Badges */
.planner-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--bg-hover);
  color: var(--text-dim);
  white-space: nowrap;
}
.planner-badge-done    { background: rgba(76,175,80,0.12);  color: #4caf50; }
.planner-badge-doing   { background: rgba(74,158,255,0.12); color: #4a9eff; }
.planner-badge-overdue { background: rgba(244,67,54,0.12);  color: #f44336; }
.planner-badge-dim     { color: var(--text-muted); background: none; }

/* Checkbox in card corner */
.planner-cb {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 14px;
  height: 14px;
  cursor: pointer;
  accent-color: var(--accent);
  opacity: 0.4;
}
.planner-card:hover .planner-cb,
.planner-card-selected .planner-cb { opacity: 1; }

/* ─── Content card actions (edit/delete on focus) ────────── */
.content-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* Sticky edit actions inside focused note card */
.note-card.focused .content-card-actions {
  position: sticky;
  bottom: 0;
  background: var(--bg-card);
  z-index: 2;
  margin-top: 14px;
  padding-top: 10px;
}

/* Project notes kanban grid override */
.proj-notes-grid {
  padding: 0;
}

.proj-note-card {
  border-radius: 0 0 12px 12px !important;
}

/* ─── Edit modal ─────────────────────────────────────────── */
.edit-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.edit-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 90vh;
  overflow-y: auto;
}
.edit-modal-header {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.edit-modal-label {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.edit-modal-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 14px;
  width: 100%;
  box-sizing: border-box;
}
.edit-modal-textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 14px;
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
}
.edit-modal-input:focus, .edit-modal-textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.edit-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}

/* ─── Toast notification ─────────────────────────────────── */
.action-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--accent);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  z-index: 20000;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.action-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Workspace note card — edit/delete in footer, always accessible */

/* ─── Tasks Tab ──────────────────────────────────────────── */
.tasks-toolbar {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tasks-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
  align-items: center;
}
.tasks-stat { color: var(--text-muted); }
.tasks-stat-sep { color: var(--border); }
.tasks-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.tasks-filters select {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 5px 10px;
  font-size: 13px;
  cursor: pointer;
}
.tasks-filters select:focus { outline: none; border-color: var(--accent); }
.tasks-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tasks-table th {
  text-align: left;
  padding: 8px 12px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 1;
}
.tasks-row {
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.tasks-row:hover { background: var(--bg-secondary); }
.tasks-row.tasks-row-open { background: var(--bg-secondary); }
.tasks-table td {
  padding: 10px 12px;
  vertical-align: middle;
  min-height: 80px;
}
.tasks-cell-key {
  font-family: monospace;
  font-size: 12px;
  color: var(--text-muted);
  width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tasks-cell-title {
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  min-width: 200px;
  line-height: 1.4;
}
.tasks-cell-proj { width: 140px; }
.tasks-cell-pri  { width: 90px;  white-space: nowrap; }
.tasks-cell-stat { width: 110px; white-space: nowrap; }
.tasks-cell-actions { width: 72px; white-space: nowrap; text-align: right; padding-right: 8px; }
.tasks-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.tasks-row-expand { border-bottom: 1px solid var(--border); }
.tasks-expand-cell { padding: 0 !important; }
.tasks-expand-body {
  padding: 14px 16px 14px 32px;
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.tasks-expand-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.tasks-expand-desc {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  max-width: 800px;
}
.tasks-expand-desc code {
  background: var(--bg-secondary);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 12px;
}
.tasks-expand-desc ul { margin: 6px 0; }
.tasks-expand-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.tasks-action-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 5px;
  padding: 3px 8px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  line-height: 1.4;
}
.tasks-action-btn:hover { background: var(--bg-tertiary, #333); color: var(--text); }
.tasks-archive-btn:hover { border-color: #ffaa00; color: #ffaa00; }
.tasks-delete-btn:hover  { border-color: #ff4444; color: #ff4444; }
/* compact inline action buttons in the row */
.tasks-cell-actions .tasks-action-btn {
  padding: 2px 6px;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}
.tasks-row:hover .tasks-action-btn { opacity: 1; }
@media (max-width: 700px) {
  .tasks-cell-key     { width: 100px; }
  .tasks-cell-proj    { display: none; }
  .tasks-cell-pri     { width: 60px; }
  .tasks-cell-actions { width: 60px; }
  .tasks-table th.tasks-cell-proj { display: none; }
  .tasks-cell-actions .tasks-action-btn { opacity: 1; }
}

/* ══════════════════════════════════════════════════════════════
   ФАЗА Б/В — PWA + Mobile Bottom Navigation
   ══════════════════════════════════════════════════════════════ */

/* ── Bottom Nav — hidden on desktop ─────────────────────────── */
#bottom-nav {
  display: none;
}

/* ── More popup menu — hidden by default ───────────────────── */
.bnav-more-menu {
  position: fixed;
  bottom: 68px;
  right: 12px;
  z-index: 9999;
  background: var(--bg-card, #1e1e1e);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  min-width: 190px;
  max-height: 70vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.bnav-more-menu[hidden] { display: none !important; }
.bnav-more-menu button {
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
}
.bnav-more-menu button:hover {
  background: var(--bg-hover);
}

/* ── Mobile (≤ 620px) — full bottom nav treatment ──────────── */
@media (max-width: 620px) {
  /* Show bottom nav */
  #bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 500;
    background: var(--bg2);
    border-top: 1px solid var(--border);
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    height: 56px;
    align-items: stretch;
  }

  /* Bottom nav buttons */
  .bnav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px 2px;
    transition: color 0.15s;
    min-width: 48px;
    min-height: 48px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  .bnav-btn:active { background: var(--bg-hover); }
  .bnav-btn.active { color: var(--accent); }
  .bnav-icon { font-size: 20px; line-height: 1; }
  .bnav-label { font-size: 9px; font-weight: 500; letter-spacing: 0.3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 56px; }

  /* Hide header nav on mobile — bottom nav replaces it */
  header nav { display: none !important; }

  /* Compact header on mobile */
  header {
    padding: 6px 10px;
    gap: 4px;
    height: auto;
    min-height: 48px;
  }
  header .header-left h1 { display: none; }
  header .header-left #badge-status { display: none; }
  #project-selector {
    margin-right: 6px !important;
    padding: 5px 8px !important;
    font-size: 12px !important;
    max-width: 130px;
  }
  .header-actions { gap: 4px; }
  .header-actions button { font-size: 15px; padding: 4px 6px; }
  #btn-logout { font-size: 11px; padding: 4px 8px; }

  /* Main content — add bottom padding so content isn't hidden behind bottom nav */
  .tab-content.active {
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 12px);
  }

  /* Login screen — centered and touch-friendly */
  .login-box { padding: 24px 20px; }
  #auth-user, #auth-pass, #auth-key { font-size: 16px; padding: 10px 12px; }
  #btn-auth { font-size: 16px; padding: 12px; }

  /* Browse: make table scroll horizontally */
  #content-table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Cards: touch-friendly tap targets */
  .project-card, .notes-card, .planner-card {
    -webkit-tap-highlight-color: transparent;
  }

  /* Modal fullscreen on mobile */
  .modal-content {
    max-height: 90vh;
    border-radius: 16px 16px 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0;
    width: 100% !important;
    max-width: 100% !important;
  }
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
}

/* ── Tablet + phone: also improve header nav wrap ───────────── */
@media (max-width: 900px) {
  /* Make header nav horizontally scrollable on tablets instead of wrapping */
  header nav {
    overflow-x: auto;
    scrollbar-width: none;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  header nav::-webkit-scrollbar { display: none; }
}

/* ═══ ASSISTANTS ═══════════════════════════════════════ */

#tab-assistants {
  flex-direction: column;
  align-items: center;
  padding: 24px 16px;
  overflow-y: auto;
}

.assistants-wrap {
  width: 100%;
  max-width: 900px;
}

.assistants-header {
  margin-bottom: 24px;
}

.assistants-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 4px;
}

.assistants-subtitle {
  color: var(--text-dim);
  font-size: 14px;
  margin: 0;
}

.assistants-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.assistant-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 20px 16px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
  position: relative;
  overflow: hidden;
}

.assistant-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--acolor, var(--accent));
  border-radius: 12px 12px 0 0;
}

.assistant-card:hover {
  border-color: var(--acolor, var(--accent));
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.assistant-card:active {
  transform: translateY(0);
}

.assistant-card-icon {
  font-size: 2rem;
  margin-bottom: 10px;
  line-height: 1;
}

.assistant-card-label {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.assistant-card-desc {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.4;
}

.assistant-card-ext {
  margin-top: 8px;
  font-size: 11px;
  color: var(--acolor, var(--accent));
  font-weight: 600;
}

/* ── Assistant form ────────────────────────────────── */

.assistant-form {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.assistant-label {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 600;
  margin-bottom: 4px;
}

.assistant-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  box-sizing: border-box;
  transition: border-color 0.15s;
}

.assistant-input:focus {
  outline: none;
  border-color: var(--accent);
}

.assistant-textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  box-sizing: border-box;
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
  transition: border-color 0.15s;
}

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

.assistant-submit {
  margin-top: 14px;
  padding: 11px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.assistant-submit:hover { opacity: 0.85; }
.assistant-submit:disabled { opacity: 0.5; cursor: not-allowed; }

/* Priority buttons */
.asst-priority-btn {
  flex: 1;
  padding: 8px 6px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-transform: capitalize;
}

.asst-priority-btn.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 15%, var(--bg-input));
}

/* ── Result area ───────────────────────────────────── */

.asst-result {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.asst-loading {
  color: var(--text-dim);
  font-size: 14px;
  padding: 8px 0;
}

.asst-success {
  color: var(--success, #4CAF50);
  font-size: 14px;
}

.asst-error {
  color: var(--error, #f44336);
  font-size: 14px;
}

.asst-empty {
  color: var(--text-dim);
  font-size: 14px;
  text-align: center;
  padding: 16px 0;
}

.asst-result-item {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  overflow: hidden;
}

.asst-result-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.asst-result-content {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ── Mobile ────────────────────────────────────────── */

@media (max-width: 620px) {
  .assistants-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .assistant-card {
    padding: 16px 12px;
  }

  .assistant-card-icon { font-size: 1.6rem; }
  .assistant-card-label { font-size: 14px; }
  .assistant-card-desc { font-size: 11px; }
}

/* ═══════════════════════════════════════════════════════════
   SKELETON LOADERS — Phase E
   ══════════════════════════════════════════════════════════*/
@keyframes skel-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

.skel {
  display: block;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    var(--bg-hover, #f0f0f0) 25%,
    var(--border,   #e0e0e0) 50%,
    var(--bg-hover, #f0f0f0) 75%
  );
  background-size: 200% 100%;
  animation: skel-shimmer 1.5s ease-in-out infinite;
  margin-bottom: 6px;
}
.skel-title { height: 15px; width: 55%; }
.skel-text  { height: 12px; width: 88%; }
.skel-short { width: 40% !important; }

.skeleton-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--border, #eee);
}
.skeleton-card {
  padding: 14px 12px;
  background: var(--bg-card, #fff);
  border-radius: 8px;
  border: 1px solid var(--border, #eee);
}
.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  padding: 16px;
}
.skeleton-list { padding: 0 4px; }

/* ─── Bottom Nav — active dot indicator ─────────────────── */
@media (max-width: 620px) {
  .bnav-btn { position: relative; }

  /* Dot indicator below active tab icon */
  .bnav-btn.active::after {
    content: '';
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    width: 5px;
    height: 5px;
    background: var(--accent);
    border-radius: 50%;
  }

  /* Scale up icon on active */
  .bnav-btn.active .bnav-icon {
    display: inline-block;
    transform: scale(1.15);
    transition: transform 0.15s ease;
  }

  /* Smooth transition for all bnav icons */
  .bnav-icon { transition: transform 0.15s ease; }

  /* Mobile modal — prevent keyboard from covering input */
  .modal-content {
    max-height: calc(100dvh - 56px);
    overflow: hidden;
  }
  .modal-body {
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  }
  .modal-content input,
  .modal-content textarea,
  .modal-content select {
    font-size: 16px; /* prevents iOS auto-zoom */
  }
}

/* ═══════════════════════════════════════════════════════
   SETTINGS TAB — З3 Multi-user auth
   ═══════════════════════════════════════════════════════ */
.settings-wrap {
  width: 100%;
  max-width: 700px;
}

.settings-header {
  margin-bottom: 24px;
}

.settings-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 4px;
}

.settings-subtitle {
  color: var(--text-dim);
  font-size: 14px;
  margin: 0;
}

.settings-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.settings-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 0 0 16px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.settings-item {
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.settings-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.settings-value {
  font-size: 14px;
  color: var(--text);
}

.settings-value code {
  font-family: monospace;
  font-size: 12px;
  background: rgba(255,255,255,0.05);
  padding: 2px 5px;
  border-radius: 4px;
}

/* Feature flags */
.settings-features {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-feature-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

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

.settings-feature-name {
  text-transform: capitalize;
  color: var(--text);
}

.settings-feature-status.on  { color: #4CAF50; font-weight: 600; }
.settings-feature-status.off { color: var(--text-dim); font-weight: 600; }

/* User list */
.settings-users {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-users-header {
  display: grid;
  grid-template-columns: 1fr 80px 80px;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 8px 8px;
  border-bottom: 1px solid var(--border);
}

.settings-user-row {
  display: grid;
  grid-template-columns: 1fr 80px 80px;
  align-items: center;
  padding: 8px;
  font-size: 13px;
  background: var(--bg);
  border-radius: 6px;
  gap: 8px;
}

.settings-user-hash {
  font-family: monospace;
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-user-role {
  font-weight: 600;
  font-size: 12px;
  text-align: center;
}

.settings-user-date {
  font-size: 11px;
  color: var(--text-dim);
  text-align: right;
}

/* Input + buttons */
.settings-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 6px 10px;
  font-size: 13px;
  outline: none;
}

.settings-input:focus {
  border-color: var(--accent, #6c8ef4);
}

.settings-btn {
  background: var(--accent, #6c8ef4);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.settings-btn:hover { opacity: 0.85; }

.settings-btn-danger {
  background: rgba(244, 67, 54, 0.12);
  color: #f44336;
  border: 1px solid rgba(244, 67, 54, 0.3);
  border-radius: 6px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.settings-btn-danger:hover {
  background: rgba(244, 67, 54, 0.22);
}

@media (max-width: 480px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
  .settings-users-header,
  .settings-user-row {
    grid-template-columns: 1fr 70px;
  }
  .settings-users-header span:last-child,
  .settings-user-date {
    display: none;
  }
}

/* ═══════════════════════════════════════════════════════
   З5 — Onboarding Overlay
   ═══════════════════════════════════════════════════════ */
#onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
#onboarding-overlay[hidden] { display: none; }

.ob-card {
  background: var(--bg-card, #1a1d2e);
  border: 1px solid var(--border, #2a2d3e);
  border-radius: 16px;
  padding: 36px 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.ob-progress {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.ob-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border, #2a2d3e);
  transition: background 0.2s, transform 0.2s;
}
.ob-dot.active {
  background: var(--accent, #6c63ff);
  transform: scale(1.3);
}
.ob-dot.done {
  background: var(--accent, #6c63ff);
  opacity: 0.5;
}

.ob-step {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ob-icon {
  font-size: 2.8rem;
  text-align: center;
}
.ob-step h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text, #e8eaf6);
  margin: 0;
  text-align: center;
}
.ob-desc {
  font-size: 0.95rem;
  color: var(--text-muted, #888);
  text-align: center;
  line-height: 1.5;
  margin: 0;
}
.ob-step input[type="text"],
.ob-step input[type="password"] {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 14px;
  background: var(--bg-input, #0f1117);
  border: 1px solid var(--border, #2a2d3e);
  border-radius: 8px;
  color: var(--text, #e8eaf6);
  font-size: 0.95rem;
  outline: none;
}
.ob-step input:focus {
  border-color: var(--accent, #6c63ff);
}
.ob-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}
.ob-btn {
  padding: 9px 22px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, transform 0.1s;
}
.ob-btn:active { transform: scale(0.97); }
.ob-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ob-primary {
  background: var(--accent, #6c63ff);
  color: #fff;
}
.ob-primary:hover:not(:disabled) { opacity: 0.85; }
.ob-secondary {
  background: var(--bg-input, #0f1117);
  color: var(--text, #e8eaf6);
  border: 1px solid var(--border, #2a2d3e);
}
.ob-secondary:hover { border-color: var(--accent, #6c63ff); }
.ob-ghost {
  background: transparent;
  color: var(--text-muted, #888);
  border: 1px solid transparent;
}
.ob-ghost:hover { color: var(--text, #e8eaf6); }
.ob-status {
  font-size: 0.88rem;
  min-height: 1.2em;
  color: var(--text-muted, #888);
  text-align: center;
}
.ob-success { color: #4caf50 !important; }
.ob-error   { color: #f44336 !important; }

.ob-themes {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.ob-theme-btn {
  flex: 1;
  padding: 14px 12px;
  border-radius: 10px;
  border: 2px solid var(--border, #2a2d3e);
  background: var(--bg-input, #0f1117);
  color: var(--text, #e8eaf6);
  font-size: 0.98rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s;
}
.ob-theme-btn:hover { border-color: var(--accent, #6c63ff); }
.ob-theme-btn.selected { border-color: var(--accent, #6c63ff); background: rgba(108,99,255,0.12); }

@media (max-width: 480px) {
  .ob-card { padding: 24px 20px; }
  .ob-step h2 { font-size: 1.2rem; }
}

/* ── Live Activity ─────────────────────────────────── */
.live-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.live-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  animation: none;
  flex-shrink: 0;
}

.live-dot.connected {
  background: #22c55e;
  animation: pulse-live 2s ease-in-out infinite;
}

@keyframes pulse-live {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34,197,94,0.4); }
  50% { opacity: 0.8; box-shadow: 0 0 0 6px rgba(34,197,94,0); }
}

.live-count {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.live-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.live-feed {
  max-height: calc(100vh - 180px);
  overflow-y: auto;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.8125rem;
  line-height: 1.6;
}

.live-item {
  display: grid;
  grid-template-columns: 70px auto 1fr;
  gap: 0.5rem;
  padding: 0.375rem 1rem;
  border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.05));
  align-items: center;
  transition: background 0.15s;
}

.live-item:hover {
  background: var(--bg-hover, rgba(255,255,255,0.03));
}

.live-item.is-new {
  animation: flash-new 1s ease-out;
}

@keyframes flash-new {
  0% { background: rgba(34,197,94,0.15); }
  100% { background: transparent; }
}

.live-time {
  color: var(--text-muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

.live-route {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 3px;
  font-size: 0.6875rem;
  font-weight: 600;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Route color coding */
.live-route[data-type="memory"]  { background: #7c3aed20; color: #a78bfa; }
.live-route[data-type="planner"] { background: #2563eb20; color: #60a5fa; }
.live-route[data-type="repo"]    { background: #06b6d420; color: #22d3ee; }
.live-route[data-type="docs"]    { background: #16a34a20; color: #4ade80; }
.live-route[data-type="session"] { background: #ea580c20; color: #fb923c; }
.live-route[data-type="project"] { background: #d9731620; color: #f59e0b; }
.live-route[data-type="other"]   { background: #64748b20; color: #94a3b8; }

.live-payload {
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.live-payload .live-key {
  color: #22d3ee;
  margin-right: 0.5rem;
}

.live-paused-banner {
  text-align: center;
  padding: 0.5rem;
  background: #f59e0b20;
  color: #f59e0b;
  font-size: 0.8125rem;
  font-weight: 600;
}

/*  Clone Version Picker  */
.clone-btn-group { display:inline-flex; gap:0; }
.clone-btn-group button:first-child { border-radius:6px 0 0 6px !important; border-right:none !important; }
.clone-dropdown-arrow {
  border-radius:0 6px 6px 0 !important; padding:4px 10px !important;
  border-left:1px solid rgba(255,255,255,.12) !important; font-size:11px;
}
.clone-version-popup {
  background:var(--bg2, #1e2130); border:1px solid var(--border, #2d3148);
  border-radius:10px; box-shadow:0 12px 32px rgba(0,0,0,.55);
  padding:4px 0; min-width:280px; overflow:hidden;
}
.cvp-item {
  padding:10px 16px; cursor:pointer; font-size:13px; color:var(--text, #cdd6f4);
  display:flex; align-items:center; gap:10px; border-left:3px solid transparent;
  transition:background .12s, border-color .12s;
}
.cvp-item:hover { background:var(--bg-hover,#2d3148); border-left-color:var(--accent,#6c8ef4); }
.cvp-date-row { gap:6px; flex-wrap:wrap; }

/*  File History Panel  */
#file-history-panel { position:fixed; right:20px; bottom:20px; width:520px; max-width:95vw; max-height:60vh; overflow-y:auto; background:#1e2130; border:1px solid #2d3148; border-radius:10px; box-shadow:0 10px 32px rgba(0,0,0,.6); z-index:8000; font-size:13px; }
.fhp-header { display:flex; justify-content:space-between; align-items:center; padding:10px 14px; border-bottom:1px solid #2d3148; font-size:13px; color:#cdd6f4; position:sticky; top:0; background:#1e2130; }
.fhp-header button { background:none; border:none; color:#888; cursor:pointer; font-size:16px; padding:0 4px; }
.fhp-header button:hover { color:#fff; }
.fhp-body { padding:8px 0; }
.fhp-row { display:flex; align-items:center; gap:8px; padding:6px 14px; border-bottom:1px solid #2d314820; }
.fhp-row:last-child { border-bottom:none; }
.fhp-num { color:#6c8ef4; font-weight:600; min-width:28px; font-size:12px; }
.fhp-date { color:#8892b0; flex:1; font-size:12px; }
.fhp-current { background:#4caf5033; color:#4caf50; border-radius:3px; padding:1px 5px; font-size:10px; margin-left:4px; }
.fhp-actions { display:flex; gap:4px; }
.fhp-actions button { font-size:11px; padding:2px 8px; border-radius:4px; background:#2d3148; border:none; color:#cdd6f4; cursor:pointer; white-space:nowrap; }
.fhp-actions button:hover { background:#3d4168; }

/* History button in browse rows */
.btn-hist { font-size:11px; padding:2px 8px; border-radius:4px; background:#2d3148; border:none; color:#8892b0; cursor:pointer; white-space:nowrap; }
.btn-hist:hover { color:#cdd6f4; background:#3d4168; }
.hist-cell { width:1%; white-space:nowrap; }

/*  Repos Filter Bar  */
.repos-filter-bar { display:flex; align-items:center; gap:8px; flex-wrap:wrap; padding:10px 0 14px; }
.repos-filter-bar input[type=search] {
  flex:1; min-width:160px; max-width:360px;
  background:var(--bg2,#131520); border:1px solid var(--border,#2d3148);
  border-radius:8px; color:var(--text,#cdd6f4); padding:8px 14px; font-size:13px; outline:none;
}
.repos-filter-bar input[type=search]:focus { border-color:var(--accent,#6c8ef4); box-shadow:0 0 0 2px rgba(108,142,244,.15); }
.repos-filter-bar select {
  background:var(--bg2,#131520); border:1px solid var(--border,#2d3148);
  border-radius:8px; color:var(--text,#cdd6f4); padding:7px 12px; font-size:13px; cursor:pointer;
  min-height:38px;
}
.repos-owner-pills { display:flex; gap:6px; flex-wrap:wrap; }
.repo-owner-pill {
  background:var(--bg2,#1e2130); border:1px solid var(--border,#2d3148);
  border-radius:20px; color:var(--text-dim,#8892b0); font-size:12px; padding:4px 14px;
  cursor:pointer; transition:all .15s; min-height:30px;
}
.repo-owner-pill:hover { border-color:var(--accent,#6c8ef4); color:var(--text,#cdd6f4); }
.repo-owner-pill.active { background:rgba(108,142,244,.15); border-color:var(--accent,#6c8ef4); color:var(--accent,#6c8ef4); }
.repos-count { color:var(--text-dim,#8892b0); font-size:12px; white-space:nowrap; margin-left:auto; }

/*  Clone version list sections  */
.cvp-divider { height:1px; background:var(--border, #2d3148); margin:6px 0; }
.cvp-section-label {
  padding:6px 16px 4px; font-size:10px; font-weight:700;
  color:var(--accent, #6c8ef4); text-transform:uppercase; letter-spacing:.06em;
}
.cvp-versions-list { max-height:280px; overflow-y:auto; }
.cvp-versions-list::-webkit-scrollbar { width:4px; }
.cvp-versions-list::-webkit-scrollbar-thumb { background:var(--border,#2d3148); border-radius:4px; }
.cvp-ver-item { padding:10px 16px !important; }
.cvp-ver-date { font-size:12px; font-family:monospace; color:var(--text,#cdd6f4); }
.cvp-more { padding:6px 16px; font-size:11px; color:var(--text-dim,#8892b0); font-style:italic; }

/*  Repos List / Grid toggle  */
.btn-repos-view { background:#1e2130; border:1px solid #2d3148; border-radius:7px; color:#8892b0; font-size:16px; padding:4px 10px; cursor:pointer; line-height:1; }
.btn-repos-view:hover { color:#cdd6f4; border-color:#6c8ef4; }

.repos-list { display:flex; flex-direction:column; gap:3px; padding:2px 0; }
.repo-row {
  display:flex; align-items:center; gap:12px; padding:9px 14px;
  background:var(--bg); border:1px solid var(--border); border-radius:8px;
  transition:background .12s, border-color .12s;
}
.repo-row:hover { background:var(--bg-hover); border-color:var(--accent); }
.repo-row-name { font-weight:600; font-size:13px; color:var(--text); min-width:140px; flex-shrink:0; }
.repo-row-desc { font-size:12px; color:var(--text-dim); flex:1; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; min-width:0; }
.repo-row-meta { font-size:11px; color:var(--text-dim); white-space:nowrap; flex-shrink:0; }
.repo-row-actions { margin-left:auto; display:flex; gap:6px; align-items:center; flex-shrink:0; }
.repo-row-actions button { font-size:12px; padding:3px 10px; }

/*  Repo collapsible rows (Projects-style)  */
.repos-list { display: flex; flex-direction: column; gap: 0; }

.repo-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px; cursor: pointer; border: 1px solid var(--border);
  border-radius: 6px; margin-bottom: 3px; background: var(--bg2);
  transition: background .15s, border-color .15s; user-select: none;
}
.repo-row:hover { background: var(--bg-hover); border-color: var(--accent); }
.repo-row.repo-row-open {
  background: var(--bg-hover); border-color: var(--accent);
  border-bottom-left-radius: 0; border-bottom-right-radius: 0; margin-bottom: 0;
}
.repo-row-name { font-weight: 600; font-size: 13px; color: var(--text); flex-shrink: 0; }
.repo-row-desc { font-size: 11px; color: var(--text-dim); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.repo-row-commit { font-size: 11px; color: var(--text-dim); flex: 2; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-style: italic; }
.repo-row-meta { font-size: 11px; color: var(--text-dim); flex-shrink: 0; }
.repo-row-date { font-size: 11px; color: var(--text-dim); flex-shrink: 0; margin-left: auto; }

/*  Repo inline detail panel  */
.repo-detail {
  border: 1px solid var(--accent); border-top: none;
  border-radius: 0 0 8px 8px; background: var(--bg3, var(--bg2));
  margin-bottom: 3px; overflow: hidden;
}
.repo-detail-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--border); gap: 12px; flex-wrap: wrap;
}
.repo-detail-title { font-size: 14px; font-weight: 700; color: var(--text); }
.repo-detail-desc { font-size: 12px; color: var(--text-dim); margin-left: 8px; }
.repo-detail-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.repo-detail-close { margin-left: 4px; }
.repo-detail-stats {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 6px 14px; font-size: 11px; color: var(--text-dim);
  border-bottom: 1px solid var(--border); background: var(--bg2);
}
.repo-detail-commit { max-width: 400px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/*  Repo file list  */
.repo-file-list {
  max-height: 400px; overflow-y: auto; padding: 6px 0;
}
.repo-file-row {
  display: flex; align-items: center; padding: 4px 14px; gap: 8px;
  border-bottom: 1px solid var(--border); font-size: 12px;
}
.repo-file-row:hover { background: var(--bg-hover); }
.repo-file-name { font-family: monospace; color: var(--text); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.repo-file-actions { display: flex; gap: 4px; flex-shrink: 0; }
.btn-xs {
  font-size: 11px; padding: 2px 6px; border-radius: 4px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg2); color: var(--text);
  line-height: 1.4;
}
.btn-xs:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-sm {
  font-size: 12px; padding: 4px 10px; border-radius: 5px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg2); color: var(--text);
}
.btn-sm:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* --- Repo drag-and-drop --- */
.repo-drag-handle {
  color: var(--text-dim, #8892b0); cursor: grab; font-size: 14px;
  padding: 0 4px; flex-shrink: 0; opacity: 0.4; transition: opacity .15s;
  user-select: none; line-height: 1;
}
.repo-row:hover .repo-drag-handle { opacity: 1; }
.repo-drag-handle:active { cursor: grabbing; }

.repo-row-dragging {
  opacity: 0.45; background: var(--bg-hover, #2d3148) !important;
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
.repo-drop-above { border-top: 2px solid var(--accent, #6c8ef4) !important; }
.repo-drop-below { border-bottom: 2px solid var(--accent, #6c8ef4) !important; }

/* ── 📌 Pinned Rules ───────────────────────────────────── */
.rules-wrap { max-width: 760px; margin: 0 auto; padding: 20px 16px; }
.rules-header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.rules-header h2 { font-size: 18px; font-weight: 700; flex: 1; }
.rules-subtitle { font-size: 13px; color: var(--text-dim); width: 100%; margin-top: -10px; }
.rules-container { display: flex; flex-direction: column; gap: 4px; }

.rule-row {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color .15s;
}
.rule-row:hover { border-color: var(--accent, #6c8ef4); }
.rule-row.rule-inactive { opacity: 0.55; }

.rule-row-main {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
}

.rule-priority {
  min-width: 22px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent, #6c8ef4);
  background: var(--accent-dim, rgba(108,142,244,.15));
  border-radius: 4px;
  padding: 2px 5px;
  flex-shrink: 0;
}

.rule-body { flex: 1; min-width: 0; }
.rule-title { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rule-short { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

.rule-actions { display: flex; gap: 4px; flex-shrink: 0; }
.rule-chevron { font-size: 11px; color: var(--text-muted); flex-shrink: 0; transition: transform .15s; }

.rule-expand {
  padding: 0 14px 12px 48px;
  border-top: 1px solid var(--border);
}
.rule-full-text {
  font-size: 13px;
  color: var(--text);
  white-space: pre-wrap;
  line-height: 1.6;
  padding-top: 10px;
}
.rule-meta { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

.btn-active  { background: none; border: none; cursor: pointer; font-size: 14px; padding: 2px 4px; }
.btn-inactive { background: none; border: none; cursor: pointer; font-size: 14px; padding: 2px 4px; opacity: 0.5; }
.btn-danger-xs { background: none; border: none; cursor: pointer; font-size: 14px; padding: 2px 4px; color: var(--red, #e57373); }

.rules-toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: var(--bg-card); border: 1px solid var(--border);
  padding: 8px 18px; border-radius: 20px; font-size: 13px; color: var(--text);
  box-shadow: 0 4px 16px rgba(0,0,0,.3); z-index: 999;
}
.rules-toast-error { border-color: var(--red, #e57373); color: var(--red, #e57373); }

/* ═══════════════════════════════════════════
   Calendar Tab — P9.3
   ═══════════════════════════════════════════ */
#tab-calendar { padding: 0 0 60px; }
#cal-wrap { min-height: 400px; }

/* Header */
.cal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  flex-wrap: wrap; gap: 8px;
}
.cal-nav, .cal-view-btns { display: flex; align-items: center; gap: 6px; }
.cal-label { font-size: 15px; font-weight: 600; color: var(--text); margin-left: 8px; }
.cal-btn {
  background: var(--bg-secondary); border: 1px solid var(--border);
  color: var(--text-muted); border-radius: 5px; padding: 4px 10px;
  font-size: 13px; cursor: pointer; transition: background .15s, color .15s;
}
.cal-btn:hover { background: var(--bg-tertiary, #333); color: var(--text); }
.cal-btn-active { background: var(--accent); color: #fff; border-color: var(--accent); }
.cal-subscribe-btn { border-color: #3B82F6; color: #3B82F6; }
.cal-today-btn { font-weight: 600; }

/* Week grid */
.cal-week-grid { overflow-x: auto; }
.cal-week-header, .cal-week-body {
  display: grid; grid-template-columns: repeat(7, minmax(120px, 1fr));
}
.cal-day-head {
  padding: 8px 10px 6px; border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border); text-align: center;
}
.cal-day-name { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.cal-day-num { font-size: 18px; font-weight: 600; color: var(--text); margin-top: 2px; }
.cal-today-col { background: var(--accent, #3B82F6)08; }
.cal-today-num { color: var(--accent, #3B82F6); }
.cal-day-col {
  min-height: 160px; padding: 6px 4px;
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 4px;
}

/* Event cards */
.cal-event-card {
  border-radius: 4px; padding: 4px 7px; cursor: pointer;
  transition: opacity .15s;
}
.cal-event-card:hover { opacity: .8; }
.cal-ev-title { font-size: 12px; font-weight: 500; color: var(--text); line-height: 1.3; }
.cal-ev-meta { font-size: 11px; color: var(--text-muted); margin-top: 1px; display: flex; gap: 6px; }
.cal-ev-proj { opacity: .7; }
.cal-ev-recurring { opacity: .65; }

/* Month grid */
.cal-month-grid { overflow-x: auto; }
.cal-month-heads, .cal-month-cells {
  display: grid; grid-template-columns: repeat(7, 1fr);
}
.cal-month-head {
  padding: 6px; text-align: center; font-size: 11px; font-weight: 600;
  color: var(--text-muted); border-bottom: 1px solid var(--border); text-transform: uppercase;
}
.cal-month-cell {
  min-height: 96px; padding: 4px 6px; border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border); cursor: pointer; transition: background .1s;
}
.cal-month-cell:hover { background: var(--bg-secondary); }
.cal-month-empty { background: var(--bg-secondary); opacity: .4; cursor: default; }
.cal-today-cell { background: var(--accent, #3B82F6)0d; }
.cal-month-daynum { font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 3px; }
.cal-today-cell .cal-month-daynum { color: var(--accent, #3B82F6); }
.cal-month-dots { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 3px; }
.cal-month-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.cal-month-more { font-size: 10px; color: var(--text-muted); }
.cal-month-ev {
  font-size: 11px; padding: 1px 4px; border-radius: 3px;
  margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text);
}

/* Quick add slot button */
.cal-quick-add { padding: 12px 16px; border-top: 1px solid var(--border); }
.cal-add-slot {
  margin-top: 6px;
  text-align: center;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  padding: 2px 0;
  opacity: 0;
  transition: opacity 0.15s;
}
.cal-day-col:hover .cal-add-slot { opacity: 1; }
.cal-add-slot:hover { background: var(--bg-hover, rgba(255,255,255,0.05)); color: var(--accent); }

/* Quick Add Modal */
.qa-container { position: fixed; inset: 0; z-index: 9000; display: flex; align-items: center; justify-content: center; }
.qa-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.qa-modal {
  position: relative; z-index: 1;
  background: var(--bg-card);
  border-radius: 12px;
  padding: 0;
  width: min(420px, 95vw);
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  overflow: hidden;
}
.qa-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 0.9rem;
}
.qa-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 16px; cursor: pointer; padding: 2px 6px; border-radius: 4px;
}
.qa-close:hover { background: var(--bg-hover, rgba(255,255,255,0.05)); }
.qa-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.qa-row { display: flex; gap: 8px; }
.qa-input {
  width: 100%; padding: 8px 12px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 0.9rem;
  box-sizing: border-box;
}
.qa-input:focus { outline: none; border-color: var(--accent); }
.qa-time { width: 120px; flex-shrink: 0; }
.qa-select {
  flex: 1; padding: 8px 10px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 0.85rem;
}
.qa-footer {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 12px 18px; border-top: 1px solid var(--border);
}

/* Event detail modal specifics */
.det-title-input {
  flex: 1; background: none; border: none; color: var(--text);
  font-size: 1rem; font-weight: 600; padding: 0 4px; min-width: 0;
}
.det-title-input:focus { outline: none; border-bottom: 1px solid var(--accent); }
.det-meta { display: flex; gap: 16px; font-size: 0.82rem; color: var(--text-muted); flex-wrap: wrap; padding-bottom: 4px; }
.det-label { font-size: 0.78rem; color: var(--text-muted); min-width: 80px; align-self: center; }
.det-desc { font-size: 0.82rem; color: var(--text-muted); padding: 8px; background: var(--bg); border-radius: 6px; }
.det-footer { justify-content: space-between !important; }

/* ── Mobile responsive ── */
@media (max-width: 700px) {
  /* Header: stack nav + view btns */
  .cal-header { flex-direction: column; align-items: flex-start; gap: 8px; padding: 8px 12px; }
  .cal-nav, .cal-view-btns { flex-wrap: wrap; }
  .cal-label { font-size: 13px; }

  /* 3-day mode: show only 3 columns */
  .cal-week-header, .cal-week-body { grid-template-columns: repeat(3, 1fr); }
  .cal-day-head.cal-hidden, .cal-day-col.cal-hidden { display: none; }

  .cal-day-num { font-size: 15px; }
  .cal-day-head { padding: 6px 6px 4px; }
  .cal-day-col { min-height: 120px; padding: 4px 3px; }
  .cal-ev-title { font-size: 11px; }
  .cal-ev-meta { font-size: 10px; }

  /* Month: dots only */
  .cal-month-cell { min-height: 52px; padding: 2px 3px; }
  .cal-month-ev { display: none; }
  .cal-month-daynum { font-size: 12px; }
  .cal-month-head { font-size: 10px; padding: 4px 2px; }
}

/* ── PWA Install Banner ─────────────────────────────── */
.pwa-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface, #1a1d2e);
  border-top: 1px solid var(--border, #2a2d3e);
  box-shadow: 0 -4px 20px rgba(0,0,0,.4);
  font-size: 14px;
  color: var(--text, #e2e8f0);
  flex-wrap: wrap;
}
.pwa-banner-actions { display: flex; gap: 8px; align-items: center; }
.pwa-install-btn { font-size: 13px; padding: 6px 14px; }
.pwa-dismiss-btn { background: none; border: none; cursor: pointer; color: var(--text-muted, #94a3b8); font-size: 16px; padding: 4px; }

/* ── Push toggle in Settings ─────────────────────────── */
.push-settings-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border, #2a2d3e); }
