/* --- Brand --- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 26px; height: 26px; flex-shrink: 0; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: var(--tracking-tight); }
.brand--lg .brand-mark { width: 46px; height: 46px; }
.brand--lg .brand-name { font-size: 25px; }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; white-space: nowrap;
  transition: background 0.16s var(--ease), border-color 0.16s var(--ease), transform 0.08s var(--ease), box-shadow 0.16s var(--ease);
  border: 1px solid transparent;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border-strong); }
.btn-secondary:hover { background: var(--color-surface-alt); }
.btn-ghost { background: transparent; color: var(--color-text-muted); }
.btn-ghost:hover { background: var(--color-surface-alt); color: var(--color-text); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-spinner {
  display: inline-block; width: 13px; height: 13px;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.65s linear infinite;
  vertical-align: middle; flex-shrink: 0;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }
.icon-btn {
  width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); color: var(--color-text-muted); flex-shrink: 0;
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}
.icon-btn:hover { background: var(--color-surface-alt); color: var(--color-text); }

/* Mobile hamburger - hidden on desktop, shown via responsive.css */
.sidebar-toggle-btn { display: none; }

/* Quick light/dark toggle: shows the sun in light mode (click to go dark)
   and the moon in dark mode (click to go light), swapped via [data-theme]
   rather than JS re-rendering the icon. */
.theme-toggle-btn { position: relative; }
.theme-toggle-btn .icon-sun, .theme-toggle-btn .icon-moon {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  transition: opacity 0.16s var(--ease), transform 0.16s var(--ease);
}
.theme-toggle-btn .icon-moon { opacity: 0; transform: translate(-50%, -50%) scale(0.6) rotate(-30deg); }
[data-theme="dark"] .theme-toggle-btn .icon-sun { opacity: 0; transform: translate(-50%, -50%) scale(0.6) rotate(30deg); }
[data-theme="dark"] .theme-toggle-btn .icon-moon { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0); }

/* --- Inputs --- */
.text-input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm); background: var(--color-surface); color: var(--color-text);
  margin-bottom: 14px; font-size: 14px;
}
.text-input:focus { border-color: var(--color-primary); }
.field-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--color-text-muted); margin-bottom: 6px; }
.field-hint { font-size: 12.5px; color: var(--color-text-faint); margin: -8px 0 16px; line-height: 1.5; }
.field-hint code { background: var(--color-surface-alt); padding: 1px 5px; border-radius: 4px; }
.form-error {
  background: var(--color-danger-soft); color: var(--color-danger);
  padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px; margin-top: 10px;
}
.radio-row { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.radio-row--muted { color: var(--color-text-faint); }
.visibility-row { display: flex; gap: 24px; margin-bottom: 16px; }

/* --- Search --- */
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--color-text-faint); pointer-events: none; }
.search-input {
  width: 100%; padding: 9px 12px 9px 36px; border: 1px solid var(--color-border);
  border-radius: 999px; background: var(--color-surface-alt); color: var(--color-text); font-size: 14px;
}
.search-input:focus { border-color: var(--color-primary); background: var(--color-surface); }

/* --- User chip --- */
.user-chip { margin-left: auto; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--color-primary-soft);
  color: var(--color-primary); display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; text-transform: uppercase;
}

/* --- Sidebar nav --- */
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 12px;
  border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; color: var(--color-text-muted);
  text-align: left; transition: background 0.16s var(--ease), color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
.nav-item svg { flex-shrink: 0; }
.nav-item:hover { background: var(--color-surface-alt); color: var(--color-text); }
.nav-item.active { background: var(--color-primary-soft); color: var(--color-primary); font-weight: 600; box-shadow: inset 3px 0 0 var(--color-primary); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot--connected { background: var(--color-success); box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-success) 20%, transparent); }
.dot--offline { background: var(--color-text-faint); }

/* --- Connect / repo screens --- */
.connect-card {
  width: 100%; max-width: 400px; background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 36px 32px; text-align: center;
}
.connect-card--wide { max-width: 520px; text-align: left; }
.connect-card--wide .brand--lg, .connect-card--wide .connect-tagline { text-align: center; }
.connect-tagline { color: var(--color-text-muted); margin: 10px 0 28px; font-size: 15px; }
.connect-step { text-align: left; }
.connect-facts {
  margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--color-border);
  display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--color-text-muted); text-align: left;
}
.connect-facts li::before { content: "✓ "; color: var(--color-success); font-weight: 700; }

/* --- Step-by-step token guide (native <details>, no JS needed) --- */
.token-guide {
  text-align: left; border: 1px solid var(--color-border); border-radius: var(--radius-md);
  background: var(--color-surface-alt); margin-bottom: 22px; overflow: hidden;
}
.token-guide-summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 13px 16px; font-size: 13.5px; font-weight: 600; color: var(--color-primary);
  user-select: none;
}
.token-guide-summary::-webkit-details-marker { display: none; }
.token-guide-summary:hover { background: var(--color-primary-soft); }
.token-guide-chevron { flex-shrink: 0; transition: transform 0.18s var(--ease); color: var(--color-primary); }
.token-guide[open] .token-guide-chevron { transform: rotate(180deg); }
.token-steps { list-style: none; margin: 0; padding: 4px 16px 18px; display: flex; flex-direction: column; gap: 16px; }
.token-steps li { display: flex; gap: 12px; align-items: flex-start; }
.step-num {
  flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%; background: var(--color-primary); color: var(--color-surface);
  font-family: var(--font-mono); font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  margin-top: 1px;
}
.step-body p { margin: 0 0 8px; font-size: 13.5px; color: var(--color-text-muted); line-height: 1.55; }
.step-body p:last-child { margin-bottom: 0; }
.step-body code { background: var(--color-surface); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.step-body .btn { gap: 6px; }

/* A small, honest mockup of the exact GitHub scope row the person should
   see - not a pixel-perfect GitHub clone, just enough to say "does your
   screen look like this? then you're in the right place, don't touch it." */
.scope-preview {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; margin: 4px 0 8px;
  border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm); background: var(--color-surface);
}
.scope-preview-check {
  flex-shrink: 0; width: 18px; height: 18px; border-radius: 4px; background: var(--color-primary); color: var(--color-surface);
  font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; margin-top: 1px;
}
.scope-preview-text { display: flex; flex-direction: column; gap: 1px; font-size: 13px; }
.scope-preview-text strong { font-family: var(--font-mono); font-size: 13px; }
.scope-preview-text span { color: var(--color-text-faint); font-size: 12px; }
.step-note { font-size: 12.5px !important; color: var(--color-text-faint) !important; font-style: italic; }

.repo-actions-row { display: flex; gap: 12px; margin-bottom: 18px; }
.repo-actions-row .btn { flex: 1; }
.panel { border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 18px; background: var(--color-surface-alt); }
.repo-list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }
.repo-list-item {
  display: flex; align-items: center; justify-content: space-between; padding: 12px 14px;
  border-radius: var(--radius-sm); background: var(--color-surface); border: 1px solid var(--color-border);
}
.repo-list-item:hover { border-color: var(--color-primary); }
.repo-list-item-meta { font-size: 12px; color: var(--color-text-faint); }

/* --- Dashboard --- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin: 20px 0 32px; }
.stat-card {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md);
  padding: 18px 20px; box-shadow: var(--shadow-sm);
}
.stat-card .stat-value { font-family: var(--font-mono); font-size: 28px; font-weight: 600; letter-spacing: -0.01em; }
.stat-card .stat-label { color: var(--color-text-muted); font-size: 13px; margin-top: 4px; }

/* --- Page header / toolbar --- */
.page-title { font-family: var(--font-display); font-size: 23px; font-weight: 700; letter-spacing: var(--tracking-tight); margin-bottom: 4px; }
.breadcrumbs { display: flex; align-items: center; gap: 6px; color: var(--color-text-muted); font-size: 13.5px; margin-bottom: 18px; flex-wrap: wrap; }
.breadcrumbs button { color: var(--color-text-muted); font-weight: 500; }
.breadcrumbs button:hover { color: var(--color-primary); }
.breadcrumbs .crumb-sep { color: var(--color-text-faint); }
.breadcrumbs .crumb-current { color: var(--color-text); font-weight: 600; }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.toolbar-spacer { flex: 1; }
.view-toggle { display: flex; border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.view-toggle button { padding: 7px 10px; color: var(--color-text-muted); }
.view-toggle button.active { background: var(--color-primary-soft); color: var(--color-primary); }
.sort-select {
  padding: 7px 10px; border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm);
  background: var(--color-surface); color: var(--color-text); font-size: 13.5px;
}

/* --- File grid --- */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 16px; }
.file-card {
  height: 168px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md);
  overflow: hidden; cursor: pointer; transition: box-shadow 0.18s var(--ease), border-color 0.18s var(--ease), transform 0.18s var(--ease); position: relative;
  display: flex; flex-direction: column;
}
.file-card:hover { box-shadow: var(--shadow-md); border-color: var(--color-border-strong); transform: translateY(-2px); }
.file-card.selected { outline: 2px solid var(--color-primary); outline-offset: -2px; background: var(--color-primary-soft); }
.file-card-preview {
  height: 108px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  background: var(--color-surface-alt); color: var(--color-text-faint);
}
.file-card-preview img { width: 100%; height: 100%; object-fit: cover; }
.file-card-body { padding: 8px 12px; overflow: hidden; }
.file-card-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-card-meta { font-family: var(--font-mono); font-size: 11.5px; color: var(--color-text-faint); margin-top: 2px; }
.file-card-fav {
  position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%;
  background: rgba(24, 22, 16, 0.55); color: #fff; display: flex; align-items: center; justify-content: center; z-index: 2;
}
.file-card-fav.active { color: var(--color-warm); }
.file-card-check-wrap {
  position: absolute; top: 8px; left: 8px; z-index: 2; width: 24px; height: 24px; border-radius: 6px;
  background: rgba(24, 22, 16, 0.35); display: flex; align-items: center; justify-content: center;
}
.file-card-checkbox { width: 16px; height: 16px; cursor: pointer; accent-color: var(--color-primary); }

/* --- List view (virtualized, div-based to keep row height fixed & predictable) --- */
.file-list-columns { display: grid; grid-template-columns: 32px 1fr 110px 100px 130px 44px; align-items: center; gap: 8px; }
.file-list-header {
  display: grid; grid-template-columns: 32px 1fr 110px 100px 130px 44px; align-items: center; gap: 8px;
  padding: 0 12px; height: 38px; color: var(--color-text-muted); font-weight: 600; font-size: 12.5px;
  border-bottom: 1px solid var(--color-border); position: sticky; top: 0; background: var(--color-background); z-index: 3;
}
.file-list-virtual { display: block; }
.file-list-row {
  display: grid; grid-template-columns: 32px 1fr 110px 100px 130px 44px; align-items: center; gap: 8px;
  padding: 0 12px; height: 46px; font-size: 13.5px; border-bottom: 1px solid var(--color-border); box-sizing: border-box;
}
.file-list-row:hover { background: var(--color-surface-alt); }
.file-list-row.selected { background: var(--color-primary-soft); }
.file-list-row input[type="checkbox"], .file-list-header input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--color-primary); cursor: pointer; }
.file-row-name { display: flex; align-items: center; gap: 10px; cursor: pointer; overflow: hidden; }
.file-row-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono-cell { font-family: var(--font-mono); font-size: 12.5px; color: var(--color-text-muted); }
.file-list-row .file-row-actions, .file-list-row > div:last-child { display: flex; justify-content: flex-end; }

/* --- Selection bar --- */
.selection-bar {
  display: flex; align-items: center; gap: 8px; background: var(--color-primary-soft); border: 1px solid var(--color-primary);
  border-radius: var(--radius-sm); padding: 9px 12px; margin-bottom: 14px;
}
.selection-count { font-size: 13.5px; font-weight: 600; color: var(--color-primary); }


/* --- Icons per file kind --- */
.kind-icon { width: 34px; height: 34px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.kind-icon.icon-image { background: #e3ecea; color: #2b6e63; }
.kind-icon.icon-video { background: #f3e2dd; color: #a6503e; }
.kind-icon.icon-pdf { background: #efe1e7; color: #8a3b57; }
.kind-icon.icon-archive { background: #f4ead4; color: #8c5a1e; }
.kind-icon.icon-document { background: #e6efe3; color: #3b7a52; }
.kind-icon.icon-file { background: var(--color-surface-alt); color: var(--color-text-muted); }
.kind-icon.icon-folder { background: var(--color-warm-soft); color: var(--color-warm); }
[data-theme="dark"] .kind-icon.icon-image { background: #1c322d; color: #7fc2b3; }
[data-theme="dark"] .kind-icon.icon-video { background: #362621; color: #e0a190; }
[data-theme="dark"] .kind-icon.icon-pdf { background: #332129; color: #d896b0; }
[data-theme="dark"] .kind-icon.icon-archive { background: #362c1a; color: #dbb066; }
[data-theme="dark"] .kind-icon.icon-document { background: #1f2f24; color: #8fcaa2; }

/* --- Empty / skeleton states --- */
.empty-state { text-align: center; padding: 70px 20px; color: var(--color-text-muted); }
.empty-state h3 { font-family: var(--font-display); font-size: 16px; font-weight: 700; color: var(--color-text); margin-bottom: 6px; }
.empty-state p { font-size: 13.5px; margin-bottom: 18px; }

.skeleton-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 16px; }
.skeleton-card { height: 150px; border-radius: var(--radius-md); background: linear-gradient(90deg, var(--color-surface-alt) 25%, var(--color-border) 37%, var(--color-surface-alt) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* --- Modal --- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(24, 22, 16, 0.5); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal {
  background: var(--color-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 460px; padding: 22px 24px 24px; max-height: 90vh; overflow-y: auto;
}
.modal--wide { max-width: 700px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-title { font-family: var(--font-display); font-size: 16.5px; font-weight: 700; letter-spacing: var(--tracking-tight); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* Upload dropzone */
.dropzone {
  border: 2px dashed var(--color-border-strong); border-radius: var(--radius-md); padding: 40px 20px;
  text-align: center; color: var(--color-text-muted); transition: border-color 0.18s var(--ease), background 0.18s var(--ease);
}
.dropzone.drag-over { border-color: var(--color-primary); background: var(--color-primary-soft); }
.dropzone-hint { font-size: 12.5px; color: var(--color-text-faint); margin-top: 14px; }
.upload-list { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; max-height: 220px; overflow-y: auto; }
.upload-item { border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 10px 12px; }
.upload-item-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.upload-item-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.progress-track { height: 6px; border-radius: 999px; background: var(--color-surface-alt); overflow: hidden; }
.progress-fill { height: 100%; background: var(--color-primary); transition: width 0.15s ease; }
.upload-item.error .progress-fill { background: var(--color-danger); }
.upload-item-status { font-size: 12px; color: var(--color-text-faint); margin-top: 4px; }

/* Preview modal */
.preview-body { display: flex; align-items: center; justify-content: center; max-height: 70vh; overflow: auto; background: var(--color-surface-alt); border-radius: var(--radius-md); }
.preview-body img, .preview-body video { max-width: 100%; max-height: 70vh; display: block; }
.preview-body iframe { width: 100%; height: 70vh; border: none; }
.preview-unavailable { padding: 60px 20px; text-align: center; color: var(--color-text-muted); }

/* Context menu */
.context-menu { position: fixed; z-index: 200; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 6px; min-width: 170px; }
.context-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 6px; font-size: 13.5px; color: var(--color-text); text-align: left; }
.context-menu button:hover { background: var(--color-surface-alt); }
.context-menu button.danger { color: var(--color-danger); }
.context-menu hr { border: none; border-top: 1px solid var(--color-border); margin: 5px 0; }

/* Toasts */
.toast-host { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 300; }
.toast {
  background: var(--color-text); color: var(--color-background); padding: 11px 16px; border-radius: var(--radius-sm);
  font-size: 13.5px; box-shadow: var(--shadow-md); max-width: 340px; animation: toast-in 0.18s ease;
}
.toast.toast-error { background: var(--color-danger); color: #fff; }
.toast.toast-success { background: var(--color-success); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Settings */
.settings-section { max-width: 520px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--color-border); }
.settings-row-label { font-size: 14px; font-weight: 600; }
.settings-row-desc { font-size: 12.5px; color: var(--color-text-faint); margin-top: 2px; }
.theme-toggle { display: flex; border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.theme-toggle button { padding: 7px 14px; font-size: 13px; color: var(--color-text-muted); }
.theme-toggle button.active { background: var(--color-primary-soft); color: var(--color-primary); }

.offline-banner {
  background: var(--color-warning); color: #fff; padding: 8px 16px; font-size: 13px; text-align: center;
}
