/* Loci v2 — Global Styles */

/* ── Display-settings CSS variables (set via loci-view.js / calendar.js) ───── */
:root {
  --loci-node-font-size:      14px;
  --loci-detail-font-size:    13px;
  --loci-detail-font-family:  system-ui, -apple-system, sans-serif;
  --loci-cal-font-size:       12px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: #1a1a1a;
  background: #f5f5f5;
}

/* ── Login ─────────────────────────────────────────────────────────────── */

body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #f0f2f5;
}

.login-box {
  background: #fff;
  border-radius: 10px;
  padding: 40px 36px;
  width: 340px;
  box-shadow: 0 4px 24px rgba(0,0,0,.1);
}

.login-title {
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 28px;
  color: #1a1a1a;
  letter-spacing: -0.5px;
}

.login-error {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #dc2626;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: #374151;
}

.form-group input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}

.form-group input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

/* ── Buttons ────────────────────────────────────────────────────────────── */

.btn-primary {
  background: #6366f1;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover { background: #4f46e5; }

.btn-secondary {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}
.btn-secondary:hover { background: #e5e7eb; }

.btn-danger {
  background: #dc2626;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.btn-danger:hover { background: #b91c1c; }

.btn-full { width: 100%; }

/* ── Mind Map page ──────────────────────────────────────────────────────── */

html { height: 100%; }

body.mindmap-page {
  height: 100%;
  min-height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
}

/* ── Toolbar ────────────────────────────────────────────────────────────── */

.toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.toolbar-btn {
  background: none;
  border: 1px solid #e5e7eb;
  border-radius: 5px;
  padding: 4px 10px;
  font-size: 16px;
  cursor: pointer;
  color: #374151;
  line-height: 1;
  transition: background .1s;
}
.toolbar-btn:hover { background: #f3f4f6; }
.toolbar-btn:disabled { color: #d1d5db; cursor: not-allowed; }
.toolbar-btn-sm { font-size: 12px; padding: 3px 10px; }

.toolbar-sep {
  width: 1px;
  height: 20px;
  background: #e5e7eb;
  margin: 0 4px;
}

/* Phase 3H: deterministic toolbar order (independent of JS insertion timing).
   .toolbar is display:flex with gap, so flex `order` controls visual sequence
   and the gap replaces the now-redundant separators. */
#toolbar .toolbar-sep   { display: none; }
#interface-wrap         { order: 1; }
#node-settings-wrap     { order: 2; }
#tags-dropdown-wrap     { order: 3; }
#view-settings-wrap     { order: 4; }
#account-settings-wrap  { order: 5; }
#btn-undo               { order: 6; }
#btn-redo               { order: 7; }
#logout-btn             { order: 100; margin-left: auto; }
/* Account name chip emphasis */
#account-settings-btn   { font-weight: 600; }

/* Phase 3H batch2: node selection / cut highlights (class-based so they survive
   re-render via decorator and don't fight the inline-style indicator dots). */
me-tpc.loci-multi-sel { outline: 2px solid #6366f1 !important; outline-offset: 1px; }
me-tpc.loci-cut       { outline: 2px dashed #f59e0b !important; outline-offset: 1px; }
me-tpc { font-size: var(--loci-node-font-size) !important; }
#mind-elixir.density-compact me-tpc { padding: 2px 8px !important; line-height: 1.2 !important; }

.toolbar-hoist {
  font-size: 12px;
  color: #6b7280;
  display: flex;
  align-items: center;
  gap: 6px;
}
.toolbar-hoist.hidden { display: none; }

.toolbar-btn-back {
  color: #6366f1;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
}

#mind-elixir {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  overflow: hidden;
}

/* ── Mode banner ────────────────────────────────────────────────────────── */

.mode-banner {
  background: #fef3c7;
  color: #92400e;
  text-align: center;
  padding: 8px;
  font-size: 13px;
  font-weight: 500;
  border-bottom: 1px solid #fde68a;
  flex-shrink: 0;
}
.mode-banner-backup {
  background: #fee2e2;
  color: #991b1b;
  border-bottom-color: #fca5a5;
}
/* Sync heartbeat older than sync_stale_warn_minutes — loud red alert */
.mode-banner-stale {
  background: #dc2626;
  color: #fff;
  border-bottom-color: #991b1b;
}
.mode-banner-age {
  opacity: 0.85;
  font-weight: 400;
}
/* Tempbox node styling — amber dashed border to indicate draft/temporary storage */
me-tpc.loci-tempbox-node {
  border: 2px dashed #d97706 !important;
  background: #fffbeb !important;
  color: #92400e !important;
}

/* ── Context menu ───────────────────────────────────────────────────────── */

.context-menu {
  position: fixed;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  min-width: 180px;
  z-index: 1000;
  padding: 4px 0;
}

.context-menu.hidden { display: none; }

.ctx-item {
  display: block;
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  padding: 9px 16px;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
  transition: background .1s;
}
.ctx-item:hover { background: #f3f4f6; }
.ctx-item.disabled { color: #9ca3af; cursor: not-allowed; }
.ctx-item.disabled:hover { background: none; }
.ctx-item.danger { color: #dc2626; }
.ctx-item.danger:hover { background: #fef2f2; }

/* ── Detail panel ───────────────────────────────────────────────────────── */

.detail-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 340px;
  background: #fff;
  border-left: 1px solid #e5e7eb;
  box-shadow: -4px 0 16px rgba(0,0,0,.08);
  z-index: 500;
  overflow-y: auto;
  padding: 20px;
}

.detail-panel.hidden { display: none; }

.detail-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  font-size: 20px;
  color: #9ca3af;
  cursor: pointer;
  line-height: 1;
}
.detail-close:hover { color: #374151; }

.detail-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
  padding-right: 24px;
  word-break: break-word;
}

.detail-meta {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 8px;
}

.detail-badge {
  display: inline-block;
  background: #f3f4f6;
  color: #374151;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  margin-bottom: 12px;
}
.detail-system-badge {
  display: inline-block;
  background: #ede9fe;
  color: #6d28d9;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
  margin-left: 6px;
  vertical-align: middle;
}

.detail-text {
  font-size: var(--loci-detail-font-size);
  font-family: var(--loci-detail-font-family);
  line-height: 1.6;
  color: #374151;
  border-top: 1px solid #f3f4f6;
  padding-top: 12px;
  margin-top: 4px;
}

.detail-text p { margin-bottom: 8px; }

/* ── Modals ─────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-overlay.hidden { display: none; }

.modal-box {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
}

.modal-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
  color: #1a1a1a;
}

.modal-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  margin-bottom: 16px;
}
.modal-input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── Color popup ────────────────────────────────────────────────────────── */

.color-popup {
  position: fixed;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  padding: 14px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}
.color-popup.hidden { display: none; }

#color-picker {
  width: 80px;
  height: 40px;
  border: none;
  cursor: pointer;
  border-radius: 4px;
}

.color-actions {
  display: flex;
  gap: 8px;
}

/* ── Hoist bar ──────────────────────────────────────────────────────────── */

.hoist-bar {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  border-radius: 20px;
  padding: 6px 18px;
  font-size: 13px;
  z-index: 800;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
}
.hoist-bar.hidden { display: none; }

#hoist-exit {
  background: none;
  border: 1px solid rgba(255,255,255,.4);
  color: #fff;
  border-radius: 12px;
  padding: 2px 12px;
  font-size: 12px;
  cursor: pointer;
}

/* ── Toast ──────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  color: #fff;
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 13px;
  z-index: 3000;
  max-width: 320px;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  transition: opacity .3s;
}
.toast.hidden { display: none; }
.toast.error  { background: #dc2626; }
.toast.success { background: #16a34a; }
.toast.info   { background: #2563eb; }

/* ── Phase 4a: Tag dots ─────────────────────────────────────────────────── */

.loci-tag-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

me-tpc.tag-dimmed {
  opacity: 0.2;
  transition: opacity 0.15s ease;
}

/* ── Tags dropdown, filter badge, popover ────────────────────────────────── */

.tags-dropdown-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  position: relative;
}
.tags-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
  min-width: 150px;
  padding: 4px 0;
  margin-top: 2px;
}
.tags-dropdown-menu.hidden { display: none; }
.tags-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 14px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  color: #374151;
  white-space: nowrap;
}
.tags-menu-item:hover { background: #f3f4f6; }
/* Backup/read-only mode: write-only menu items shown greyed-out (cf. .ctx-item.disabled). */
.tags-menu-item.disabled,
.tags-menu-item:disabled { color: #9ca3af; cursor: not-allowed; }
.tags-menu-item.disabled:hover,
.tags-menu-item:disabled:hover { background: none; }
.tags-menu-header {
  padding: 6px 12px 2px;
  font-size: 11px;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  pointer-events: none;
  user-select: none;
}
.filter-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px 2px 8px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  font-size: 12px;
  color: #1d4ed8;
  white-space: nowrap;
}
.filter-badge-clear {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: #6b7280;
  padding: 0 2px;
  line-height: 1;
}
.filter-badge-clear:hover { color: #dc2626; }
.tag-popover {
  position: fixed;
  z-index: 2000;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
  min-width: 160px;
  padding: 6px 0;
}
.tag-popover-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 8px 14px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  color: #374151;
}
.tag-popover-item:hover { background: #f3f4f6; }
.tag-popover-item.active { background: #eff6ff; color: #1d4ed8; }

/* ── Cluster page (dark theme) ───────────────────────────────────────────── */

body.cluster-page {
  background: #0f172a;
  color: #e2e8f0;
  max-width: 800px;
  margin: 0 auto;
  padding: 32px 24px;
}
.cluster-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #1e293b;
  flex-wrap: wrap;
}
.cluster-tag-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cluster-title {
  font-size: 22px;
  font-weight: 600;
  color: #f1f5f9;
  margin: 0;
}
.cluster-count {
  font-size: 13px;
  color: #64748b;
  margin-left: auto;
}
.cluster-empty {
  color: #475569;
  padding: 48px 0;
  text-align: center;
}
.cluster-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cluster-card {
  padding: 12px 16px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  transition: border-color .15s, background .15s;
}
.cluster-card:hover {
  background: #1e3a5f;
  border-color: #3b5f8a;
}
.cluster-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
}
.cluster-crumb {
  text-decoration: none;
  border-radius: 4px;
  padding: 2px 6px;
  white-space: nowrap;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cluster-crumb-anc {
  font-size: 13px;
  color: #64748b;
}
.cluster-crumb-anc:hover { background: #334155; color: #94a3b8; }
.cluster-crumb-self {
  font-size: 15px;
  font-weight: 500;
  color: #e2e8f0;
}
.cluster-crumb-self:hover { background: #1e3a5f; color: #93c5fd; }
.cluster-crumb-sep {
  color: #334155;
  font-size: 13px;
  padding: 0 1px;
  user-select: none;
}
.cluster-card-excerpt {
  font-size: 13px;
  color: #475569;
  margin-top: 6px;
}
/* Back button on dark cluster page */
body.cluster-page .toolbar-btn {
  color: #94a3b8;
  border-color: #334155;
  background: #1e293b;
}
body.cluster-page .toolbar-btn:hover {
  background: #334155;
  color: #e2e8f0;
}

/* ── Phase 4b: Attachment panel & decorators ─────────────────────────────── */

.attachment-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 340px;
  background: #fff;
  border-left: 1px solid #e5e7eb;
  box-shadow: -4px 0 16px rgba(0,0,0,.08);
  z-index: 500;
  overflow-y: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.attachment-panel.hidden { display: none; }

.att-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}
.att-panel-back {
  background: none;
  border: none;
  font-size: 14px;
  color: #6b7280;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
}
.att-panel-back:hover { background: #f3f4f6; color: #111827; }
.att-panel-title {
  font-size: 15px;
  font-weight: 600;
  color: #111827;
}
.att-section {
  padding: 16px;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.att-section-label {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.att-note-textarea {
  width: 100%;
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 8px;
  resize: vertical;
  font-family: monospace;
  color: #111827;
  box-sizing: border-box;
}
.att-note-textarea:focus { outline: none; border-color: #6366f1; }
.att-note-save { align-self: flex-end; }

.att-add-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.att-input {
  width: 100%;
  font-size: 13px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 6px 8px;
  box-sizing: border-box;
  color: #111827;
}
.att-input:focus { outline: none; border-color: #6366f1; }

.att-links-list { display: flex; flex-direction: column; gap: 6px; }
.att-links-empty { font-size: 13px; color: #9ca3af; }
.att-link-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}
.att-link-info { flex: 1; min-width: 0; }
.att-link-name {
  font-size: 13px;
  font-weight: 500;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.att-link-url {
  display: block;
  font-size: 11px;
  color: #6366f1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
}
.att-link-url:hover { text-decoration: underline; }
.att-link-delete { flex-shrink: 0; }

/* Phase 4c: File/Image upload UI */
.att-upload-form { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; }
.att-file-input  { display: none; }   /* hidden — triggered by label click */
.att-file-label  {
  cursor: pointer;
  padding: 5px 12px;
  font-size: 13px;
  border-radius: 6px;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  color: #374151;
  white-space: nowrap;
  user-select: none;
}
.att-file-label:hover { background: #e5e7eb; }
.att-filename-display {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: #6b7280;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.att-paste-hint {
  font-size: 11px;
  color: #9ca3af;
  padding: 2px 0 0 0;
}

/* Phase 4c: Image list in attachment panel */
.att-images-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}
.att-image-item {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}
.att-image-thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid #e5e7eb;
  display: block;
}
.att-image-thumb:hover { border-color: #6366f1; opacity: .9; }
.att-img-delete { flex-shrink: 0; }

/* Phase 4c: File list in attachment panel */
.att-files-list { display: flex; flex-direction: column; gap: 6px; }
.att-file-download { color: #6366f1; text-decoration: none; }
.att-file-download:hover { text-decoration: underline; }

/* Detail panel attachment section */
.detail-attachments-section { margin-top: 12px; }
.detail-att-title {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 6px;
}
.detail-att-row { margin-bottom: 4px; }
.detail-att-link {
  font-size: 13px;
  color: #6366f1;
  text-decoration: none;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.detail-att-link:hover { text-decoration: underline; }

/* Detail panel image grid — Phase 4c */
.detail-images-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.detail-image-thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid #e5e7eb;
}
.detail-image-thumb:hover { border-color: #6366f1; opacity: .9; }

.detail-att-manage-btn {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 8px;
  font-size: 13px;
  text-align: center;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  cursor: pointer;
  color: #374151;
}
.detail-att-manage-btn:hover { background: #e5e7eb; }

.detail-text-showall {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.78rem;
  color: #6366f1;
  text-decoration: none;
}
.detail-text-showall:hover { text-decoration: underline; }

/* Node attachment indicator dots — 8x8 circles (container uses inline style like old tag dots) */
.loci-note-dot,
.loci-hyperlink-dot,
.loci-extlink-dot,
.loci-image-dot,
.loci-file-dot,
.loci-dot-enc,
.loci-dot-nosearch,
.loci-cal-dot,
.loci-system-dot,
.loci-share-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.loci-note-dot      { background: #94a3b8; }
.loci-hyperlink-dot { background: #f59e0b; }
.loci-extlink-dot   { background: #3b82f6; }
.loci-image-dot     { background: #f9a8d4; }  /* pink  — Phase 4c */
.loci-file-dot      { background: #10b981; }  /* green — Phase 4c */
.loci-dot-enc       { background: #475569; }  /* slate — Phase 4d encryption */
.loci-dot-nosearch  { background: #f97316; }  /* orange — 靜搜節點 */
.loci-cal-dot       { background: #ef4444; }  /* red    — Phase 5e pending event */
.loci-system-dot    { background: #8b5cf6; }  /* purple — system node */
.loci-share-dot     { background: #14b8a6; }  /* teal   — public share link */

/* ── Phase 4a: Tag manager modal ────────────────────────────────────────── */

.tag-manager-box { min-width: 340px; max-width: 480px; }
.modal-close-btn {
  float: right;
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: #6b7280;
  padding: 0;
}
.modal-close-btn:hover { color: #374151; }
.tag-manager-list { margin: 12px 0; max-height: 300px; overflow-y: auto; }
.tag-manager-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid #f3f4f6;
}
.tag-manager-row:last-child { border-bottom: none; }
.tag-manager-name { flex: 1; font-size: 14px; color: #1a1a1a; }
.tag-manager-empty { color: #9ca3af; font-size: 13px; padding: 8px 0; }
.tag-color-input {
  width: 32px;
  height: 26px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  padding: 2px;
  cursor: pointer;
  background: none;
}
.tag-create-form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #f3f4f6;
  align-items: center;
}
.btn-small {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 5px;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn-small.btn-danger {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
}
.btn-small.btn-danger:hover { background: #fca5a5; }

/* ── Phase 4a: Detail panel tag section ─────────────────────────────────── */

.detail-tags-section {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid #f3f4f6;
}
.detail-tags-title {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.detail-tags-assigned {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.detail-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  font-size: 12px;
  background: #f9fafb;
  color: #374151;
}
.detail-tag-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: #9ca3af;
  font-size: 14px;
  padding: 0 0 0 2px;
  line-height: 1;
}
.detail-tag-remove:hover { color: #ef4444; }
.detail-tag-select {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  color: #374151;
  cursor: pointer;
}
.detail-tag-select:hover { border-color: #9ca3af; }
.detail-tags-empty { font-size: 12px; color: #9ca3af; margin-top: 2px; }

/* Phase 3F: loading spinner for nodes being fetched from server */
me-tpc.loci-node-loading::after {
  content: ' \21BB';
  font-size: 10px;
  opacity: 0.5;
  display: inline-block;
  animation: loci-spin 0.8s linear infinite;
}
@keyframes loci-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ── Phase 4c: detail panel tabs ───────────────────────────────────────── */

.detail-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 4px;
}

.detail-tab {
  background: none;
  border: none;
  padding: 4px 12px;
  font-size: 13px;
  color: #6b7280;
  cursor: pointer;
  border-radius: 4px 4px 0 0;
  border-bottom: 2px solid transparent;
}
.detail-tab:hover { color: #374151; }
.detail-tab.detail-tab-active {
  color: #2563eb;
  border-bottom-color: #2563eb;
  font-weight: 600;
}

.detail-pane.hidden { display: none; }

/* ── Advanced tab sections ───────────────────────────────────────────────── */

.adv-section { padding: 8px 0; border-bottom: 1px solid #e5e7eb; }
.adv-section:last-child { border-bottom: none; }
.adv-section-hdr {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #9ca3af;
  margin-bottom: 6px;
}

/* ── Share link section (advanced tab) ──────────────────────────────────── */

.share-url-box {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}
.share-url-text {
  flex: 1;
  font-size: 11px;
  font-family: monospace;
  color: #374151;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  padding: 4px 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: text;
  user-select: all;
}
.share-copy-btn, .share-revoke-btn, .share-create-btn {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 4px;
  border: 1px solid #d1d5db;
  cursor: pointer;
  background: #fff;
  color: #374151;
  white-space: nowrap;
  flex-shrink: 0;
}
.share-copy-btn:hover   { background: #f0fdf4; border-color: #14b8a6; color: #0f766e; }
.share-create-btn:hover { background: #f0fdf9; border-color: #14b8a6; color: #0f766e; }
.share-revoke-btn:hover { background: #fef2f2; border-color: #fca5a5; color: #dc2626; }
.share-status-none { font-size: 13px; color: #6b7280; }
.share-created-at  { font-size: 11px; color: #9ca3af; margin-top: 4px; }
.share-type-label  { font-size: 11px; font-weight: 600; color: #6b7280; margin-bottom: 3px; letter-spacing: .03em; }

/* ── Phase 4c: history timeline ─────────────────────────────────────────── */

.history-timeline { padding: 4px 0; }
.history-loading, .history-error, .history-empty {
  font-size: 13px;
  color: #6b7280;
  padding: 12px 0;
}
.history-error { color: #dc2626; }

.history-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
}
.history-item:last-child { border-bottom: none; }
.history-item-current { background: #f0f9ff; border-radius: 6px; padding: 10px 8px; }

.history-dot { font-size: 14px; margin-top: 2px; flex-shrink: 0; }

.history-item-body { flex: 1; min-width: 0; }
.history-date { font-size: 12px; font-weight: 600; color: #374151; }
.history-by   { font-size: 12px; color: #6b7280; margin: 2px 0 6px; }
.history-current-label { color: #2563eb; }

.history-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.history-preview-btn, .history-restore-btn {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid #d1d5db;
}
.history-preview-btn { background: #f9fafb; color: #374151; }
.history-preview-btn:hover { background: #f3f4f6; }
.history-restore-btn { background: #2563eb; color: #fff; border-color: #2563eb; }
.history-restore-btn:hover { background: #1d4ed8; }

/* ── Phase 4c: version preview modal ───────────────────────────────────── */

.version-preview-box {
  width: 520px;
  max-width: 95vw;
}

.version-preview-meta {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 12px;
}

.version-preview-body { display: flex; flex-direction: column; gap: 8px; }
.version-preview-field-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #9ca3af;
}

.version-preview-pre {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #374151;
  margin: 0;
}
.version-preview-text { min-height: 80px; max-height: 300px; overflow-y: auto; }

/* ── Phase 4d: encryption UI ────────────────────────────────────────────── */

.detail-tab-locked {
  opacity: 0.4;
  cursor: not-allowed !important;
  pointer-events: none;
}

.enc-section {
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.enc-label {
  font-size: 13px;
  color: #374151;
  font-weight: 500;
}

.enc-label.enc-unlocked { color: #059669; }

.enc-hint {
  font-size: 12px;
  color: #6b7280;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 8px 10px;
}

.enc-type-row,
.enc-scope-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: #374151;
}

.enc-type-row label,
.enc-scope-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.enc-b-pw-row { display: flex; flex-direction: column; }

.enc-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.enc-error.hidden            { display: none; }
.enc-b-pw-row.hidden         { display: none; }
.enc-scope-row.hidden        { display: none; }
.enc-a-old-pw-row.hidden     { display: none; }
.enc-a-confirm-pw-row.hidden { display: none; }

.enc-error {
  font-size: 12px;
  color: #dc2626;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 6px 10px;
}

.enc-real-content {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.enc-field-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #9ca3af;
}

.enc-field-value {
  font-size: 13px;
  color: #111827;
  word-break: break-word;
}

.enc-text1 {
  white-space: pre-wrap;
  max-height: 120px;
  overflow-y: auto;
}

/* ── Phase 5e: Calendar ─────────────────────────────────────────────────── */

/* Compact button size used by calendar modals */
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* FullCalendar completed event: strikethrough + 60% opacity */
.loci-ev-done {
  opacity: 0.6;
  text-decoration: line-through;
}

/* FullCalendar recurring event indicator (structural only; color comes from eventContent) */
.loci-ev-recur .fc-event-title { font-style: italic; }

/* Timed-event time prefix: muted so it doesn't compete with the title */
.fc-daygrid-dot-event .fc-event-time { color: #999; flex-shrink: 0; }

/* Keyboard shortcut reference modal */
.shortcuts-modal-box { width: 660px; max-width: 96vw; padding: 20px 24px 16px; }
.shortcut-group-hdr { color: #6b7280; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin: 10px 0 2px; }
.shortcut-group-hdr:first-child { margin-top: 0; }
.shortcut-table { width: 100%; border-collapse: collapse; margin-bottom: 0; }
.shortcut-table td { padding: 1px 4px 1px 0; font-size: 13px; color: #374151; vertical-align: top; line-height: 1.6; }
.shortcut-table td:first-child { color: #111827; font-family: monospace; white-space: nowrap; min-width: 140px; }

/* Calendar page layout */
.cal-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.cal-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #1e293b;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.cal-toolbar-title {
  font-weight: 700;
  font-size: 16px;
  color: #f1f5f9;
  margin-right: 8px;
}

.cal-main {
  flex: 1;
  overflow: auto;
  padding: 12px 16px;
  background: #0f172a;
}

/* Generic hidden utility — required for buttons/divs inside calendar modals */
.hidden { display: none !important; }

#fc-container {
  background: #1e293b;
  border-radius: 8px;
  padding: 12px;
  min-height: 400px;
  font-size: var(--loci-cal-font-size);
}
#fc-container .fc-event-title,
#fc-container .fc-event-time { font-size: inherit; }
/* Calendar compact density */
#fc-container.cal-density-compact .fc-daygrid-day-frame { min-height: 32px !important; }
#fc-container.cal-density-compact .fc-daygrid-event-harness { margin-top: 1px !important; }
#fc-container.cal-density-compact .fc-event { padding: 0 2px !important; }

/* FullCalendar dark-theme overrides */
#fc-container .fc {
  color: #e2e8f0;
}
#fc-container .fc-button {
  background: #334155;
  border-color: #475569;
  color: #e2e8f0;
  font-size: 13px;
}
#fc-container .fc-button:hover,
#fc-container .fc-button-active {
  background: #3b82f6 !important;
  border-color: #3b82f6 !important;
}
#fc-container .fc-day-today { background: rgba(59,130,246,.12) !important; }
#fc-container .fc-toolbar-title { color: #e2e8f0; }
#fc-container .fc-col-header-cell-cushion,
#fc-container .fc-daygrid-day-number,
#fc-container .fc-list-day-text,
#fc-container .fc-list-day-side-text { color: #94a3b8; }
#fc-container .fc-list-event-title a { color: #e2e8f0; text-decoration: none; }
#fc-container .fc-list-event .fc-event-title { color: #ffffff; }
#fc-container .fc-list-event td { color: #e2e8f0; }
#fc-container .fc-list-event:hover td { background: rgba(255,255,255,.10) !important; }
/* TimeGrid: time slot labels (上午1時 etc.) */
#fc-container .fc-timegrid-slot-label-cushion,
#fc-container .fc-timegrid-axis-cushion { color: #94a3b8; }
/* TimeGrid: timed event text */
#fc-container .fc-timegrid-event .fc-event-main { color: #ffffff; }
#fc-container .fc-timegrid-event .fc-event-main .fc-event-title { color: #ffffff; }
/* Holiday background events: white title text */
#fc-container .fc-bg-event .fc-event-title { color: #ffffff !important; }
/* DayGrid: event title text */
#fc-container .fc-daygrid-event .fc-event-title { color: #ffffff; }
/* DayGrid: more-events link ("還有N個") */
#fc-container .fc-daygrid-more-link { color: #93c5fd; font-size: 11px; }
#fc-container .fc-daygrid-more-link:hover { color: #bfdbfe; }
/* More-events popover dark theme */
.fc-popover { background: #1e293b !important; border: 1px solid #334155 !important; border-radius: 6px !important; }
.fc-popover-header { background: #0f172a !important; color: #e2e8f0 !important; padding: 6px 10px !important; }
.fc-popover-body { padding: 4px 6px !important; }

/* Toast */
.cal-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #f1f5f9;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 9999;
  pointer-events: none;
  border: 1px solid #334155;
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
}
.cal-toast.cal-toast-error { background: #7f1d1d; border-color: #ef4444; }
.cal-toast.hidden { display: none; }

/* Modals */
.cal-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 8000;
}
.cal-modal-overlay.hidden { display: none; }
/* Pending-tasks panel */
.pending-tasks-box { max-height: 70vh; display: flex; flex-direction: column; min-width: 340px; }
.pending-tasks-list { flex: 1; overflow-y: auto; padding: 4px 0; }
.pending-task-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 16px;
  cursor: pointer;
  border-bottom: 1px solid #1e293b;
  transition: background .12s;
}
.pending-task-item:last-child { border-bottom: none; }
.pending-task-item:hover { background: rgba(255,255,255,.06); }
.pending-task-date { font-size: 11px; color: #64748b; white-space: nowrap; flex-shrink: 0; }
.pending-task-date.overdue { color: #f87171; }
.pending-task-title { font-size: 13px; color: #e2e8f0; flex: 1; }
.pending-tasks-empty { padding: 20px; text-align: center; color: #64748b; font-size: 13px; }
#ev-modal-type-badge:hover { opacity: 0.75; }

.cal-modal-box {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 24px;
  min-width: 320px;
  max-width: 480px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  color: #e2e8f0;
}

.cal-modal-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cal-modal-close {
  margin-left: auto;
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 0;
}

.cal-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.cal-field label {
  font-size: 12px;
  color: #94a3b8;
  font-weight: 500;
}

.cal-field input[type=text],
.cal-field input[type=date],
.cal-field input[type=time],
.cal-field select,
.cal-field textarea {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  color: #e2e8f0;
  padding: 7px 10px;
  font-size: 14px;
  width: 100%;
  box-sizing: border-box;
}

.cal-field input[type=checkbox] { width: auto; margin-right: 6px; }

.cal-field-inline { flex-direction: row; align-items: center; }
.cal-field-inline label { width: 100px; flex-shrink: 0; }

.cal-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

.cal-postpone-row {
  display: flex;
  gap: 8px;
  margin: 8px 0;
}

/* Weekdays checkbox row (new event recurrence) */
.cal-weekdays-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.cal-weekdays-row label {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 13px;
  cursor: pointer;
}

/* Category list */
.cat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #1e293b;
}
.cat-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cat-name { flex: 1; font-size: 14px; }
.cat-color-edit { width: 32px; height: 24px; padding: 1px; border: none; cursor: pointer; border-radius: 4px; }

/* Recurring notice badge */
.cal-recur-notice {
  background: #172554;
  color: #93c5fd;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  margin: 6px 0;
}

/* ── Phase 5e: Calendar tab in detail panel ───────────────────────────────── */

#detail-pane-calendar { padding: 0 2px; }

.cal-tab-wrap { padding: 4px 0; }

.cal-tab-header {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.cal-tab-section-title {
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 8px;
}

.cal-tab-form { padding: 4px 0; }

.cal-tab-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.cal-tab-label {
  font-size: 12px;
  color: #94a3b8;
  width: 36px;
  flex-shrink: 0;
}

.cal-tab-input {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 4px;
  color: #e2e8f0;
  padding: 4px 8px;
  font-size: 13px;
  flex: 1;
  min-width: 0;
}

.cal-tab-card {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

.cal-tab-card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
}

.cal-tab-card-meta {
  font-size: 12px;
  color: #94a3b8;
  margin-bottom: 8px;
}

.cal-tab-edit-wrap { margin-top: 8px; }

.cal-tab-btn-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.cal-tab-loading { color: #94a3b8; font-size: 13px; padding: 4px 0; }
.cal-tab-err     { color: #f87171; font-size: 13px; }

/* ── Phase 4e: Named Relations (virtual children) ────────────────────────── */

/* Relations tab pane — same structural pattern as other panes */
#detail-pane-relations {
  padding: 0;
}

/* Virtual node: dashed purple border applied inline by loci-relations.js decorator.
   The me-tpc selector here provides a CSS fallback/reinforcement. */
me-tpc[data-nodeid^="mevirt_"] {
  border: 1px dashed #7c3aed !important;
  border-radius: 4px !important;
}

/* ── Phase 5f: Search modals (節點搜尋器 + 內容取代) ───────────────────────── */

.search-modal-box {
  width: 520px;
  max-width: 95vw;
}

.sr-scope-row {
  display: flex;
  gap: 20px;
  font-size: 13px;
  color: #64748b;
  margin-bottom: 14px;
}
.sr-scope-row label { display: flex; align-items: center; gap: 5px; cursor: pointer; }

.sr-label-row {
  margin-bottom: 0;
}
.sr-label {
  display: block;
  font-size: 12px;
  color: #94a3b8;
  margin-bottom: 4px;
}

.sr-preview-btn {
  width: 100%;
  margin-bottom: 10px;
}

.sr-result-list {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  margin-bottom: 10px;
}
.sr-result-list.hidden { display: none; }

.sr-hint {
  padding: 12px 14px;
  font-size: 13px;
  color: #94a3b8;
  text-align: center;
}
.sr-hint.sr-error { color: #ef4444; }

.sr-result-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 14px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background .12s;
}
.sr-result-item:last-child { border-bottom: none; }
.sr-result-item:hover { background: #f8fafc; }

.sr-result-check {
  cursor: default;
}
.sr-result-check:hover { background: #f8fafc; }

.sr-checkbox {
  margin-top: 3px;
  flex-shrink: 0;
  accent-color: #6366f1;
}

.sr-result-title {
  font-size: 13px;
  font-weight: 500;
  color: #1e293b;
  line-height: 1.4;
}

.sr-result-excerpt {
  font-size: 12px;
  color: #64748b;
  margin-top: 3px;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 420px;
}

/* ── Phase 5h: AI Collaboration Modal ─────────────────────────────────────── */

.ai-collab-box {
  width: 560px;
  max-width: 96vw;
  max-height: 80vh;
  overflow-y: auto;
}

.ai-collab-label {
  display: block;
  font-size: 13px;
  color: #94a3b8;
  margin-bottom: 4px;
}

.ai-collab-radios {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: #cbd5e1;
}

.ai-collab-radios label {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
}

.ai-token-loading,
.ai-token-empty {
  font-size: 13px;
  color: #64748b;
  padding: 10px 0;
}

.ai-token-item {
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 10px 12px;
  margin-top: 10px;
  background: #1e293b;
}

.ai-token-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 6px;
}

.ai-token-name {
  font-size: 13px;
  font-weight: 600;
  color: #e2e8f0;
}

.ai-token-date {
  font-size: 11px;
  color: #64748b;
}

.ai-token-perm {
  font-size: 11px;
  color: #94a3b8;
  margin-left: auto;
}

.ai-token-value {
  font-family: monospace;
  font-size: 12px;
  color: #a5b4fc;
  word-break: break-all;
  margin-bottom: 8px;
  padding: 4px 6px;
  background: #0f172a;
  border-radius: 4px;
}

.ai-token-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

/* Phase 5h+1: scope list inside each token card */
.ai-scope-list {
  margin: 6px 0 4px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ai-scope-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.ai-scope-lnum {
  font-family: monospace;
  color: #6366f1;
  min-width: 40px;
}

.ai-scope-title {
  color: #94a3b8;
  font-size: 12px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.ai-scope-perm {
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.ai-perm-read    { background: #dbeafe; color: #1d4ed8; }
.ai-perm-write   { background: #dcfce7; color: #15803d; }
.ai-perm-control { background: #fef3c7; color: #b45309; }

.ai-scope-del-btn {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  font-size: 11px;
  padding: 0 2px;
  line-height: 1;
}

.ai-scope-del-btn:hover { color: #ef4444; }

.ai-scope-add-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0;
  flex-wrap: wrap;
}

.ai-scope-add-row.hidden { display: none; }

.btn-danger {
  background: transparent;
  border: 1px solid #ef4444;
  color: #ef4444;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}

.btn-danger:hover {
  background: #ef444422;
}

/* ── Password field: type=text with hidden input ─────────────────────────── */
.password-field {
  -webkit-text-security: disc;
}
