/* Limitless Brain — Night Studio Console
   Semantic component styles (not a Tailwind build). */

@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=Outfit:wght@400;500;600;700&display=swap");

:root {
  --font-sans: "Outfit", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --bg: #090b10;
  --bg-elevated: #0e1219;
  --surface: #131822;
  --surface-2: #1a2030;
  --surface-hover: #1f2738;
  --border: #252d3d;
  --border-strong: #343e55;
  --text: #eef1f6;
  --text-secondary: #9aa6bc;
  --text-muted: #6e7a91;
  --accent: #6eb6ff;
  --accent-dim: rgba(110, 182, 255, 0.12);
  --accent-border: rgba(110, 182, 255, 0.35);
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-text: #ffffff;
  --success-bg: rgba(16, 185, 129, 0.1);
  --success-border: rgba(16, 185, 129, 0.35);
  --success-text: #6ee7b7;
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.1);
  --danger-border: rgba(248, 113, 113, 0.35);
  --danger-text: #fecaca;
  --warning-bg: rgba(251, 191, 36, 0.1);
  --warning-border: rgba(251, 191, 36, 0.3);
  --warning-text: #fde68a;
  --focus: #6eb6ff;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --shadow-sm: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 8px 24px rgba(0, 0, 0, 0.28);
  --shadow-drawer: 12px 0 40px rgba(0, 0, 0, 0.5);
  --sidebar-w: 15.5rem;
  --touch: 2.75rem;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --content: 42rem;
  --content-wide: 52rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* subtle grid noise on canvas */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(59, 130, 246, 0.08), transparent 50%),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(110, 182, 255, 0.04), transparent 45%);
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

code,
.font-mono,
pre {
  font-family: var(--font-mono);
}

[x-cloak] {
  display: none !important;
}

/* ——— Focus ——— */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.nav-link:focus-visible,
.filter-chip:focus-visible,
.author-chip input:focus-visible + .chip-face {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ——— Layout shell ——— */
.skip-link {
  position: absolute;
  left: 1rem;
  top: 1rem;
  z-index: 100;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  transform: translateY(-160%);
  transition: transform 0.2s var(--ease);
}
.skip-link:focus {
  transform: translateY(0);
}

.shell {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100%;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.35rem 1rem 1.25rem;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg-elevated) 0%, var(--bg) 100%);
}

.sidebar-brand {
  padding: 0 0.5rem;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.brand-icon {
  width: 2rem;
  height: 2rem;
  border-radius: 9px;
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-icon svg {
  width: 1.15rem;
  height: 1.15rem;
}

.brand-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.2;
}

.brand-sub {
  margin: 0.15rem 0 0;
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.nav-label {
  padding: 0 0.65rem 0.4rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: var(--touch);
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.nav-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-link.is-active {
  background: var(--accent-dim);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent-border);
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.nav-sub {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  margin: 0.05rem 0 0.2rem 0.85rem;
  padding: 0.15rem 0 0.15rem 0.7rem;
  border-left: 1px solid var(--border);
}

.nav-sublink {
  display: flex;
  align-items: center;
  min-height: 2.1rem;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.nav-sublink:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-sublink.is-active {
  background: var(--accent-dim);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent-border);
}

.nav-ico {
  width: 1.1rem;
  height: 1.1rem;
  opacity: 0.85;
  flex-shrink: 0;
}

.sidebar-user {
  margin-top: auto;
  padding: 0.85rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}

.sidebar-user-name {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.sidebar-user-meta {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sidebar-user form {
  margin-top: 0.65rem;
}

.btn-signout {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 0.25rem 0;
}

.btn-signout:hover {
  color: var(--accent);
}

main#main {
  flex: 1 1 0%;
  min-width: 0;
  padding: 2rem 2.25rem 3rem;
}

/* Mobile */
.mobile-bar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 30;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(14, 18, 25, 0.92);
  backdrop-filter: blur(12px);
}

.mobile-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 0 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
}

.mobile-brand {
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
}

.nav-backdrop {
  display: none;
}

@media (max-width: 767px) {
  .mobile-bar {
    display: flex;
  }
  .shell {
    flex-direction: column;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 40;
    width: min(18.5rem, 88vw);
    transform: translateX(-105%);
    transition: transform 0.25s var(--ease);
    background: var(--bg-elevated);
  }
  .sidebar.is-open {
    transform: translateX(0);
    box-shadow: var(--shadow-drawer);
  }
  .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(5, 7, 12, 0.65);
    backdrop-filter: blur(2px);
  }
  main#main {
    padding: 1.25rem 1.1rem 2.5rem;
  }
}

@media (min-width: 768px) {
  .mobile-bar {
    display: none !important;
  }
  .nav-backdrop {
    display: none !important;
  }
  .sidebar {
    transform: none !important;
    position: relative !important;
    box-shadow: none !important;
  }
}

/* ——— Page chrome ——— */
.page {
  max-width: var(--content);
  position: relative;
}

.page-wide {
  max-width: var(--content-wide);
}

/* Fluid page: fill the remaining main-column width instead of clamping to a
   fixed content width. Lets forms, editors, and card lists go full width. */
.page-fluid {
  max-width: none;
  width: 100%;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.page-title {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--text);
}

.page-desc {
  margin: 0.4rem 0 0;
  font-size: 0.925rem;
  color: var(--text-secondary);
  max-width: 36rem;
  line-height: 1.5;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.section {
  margin-top: 2.25rem;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.section-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

/* ——— Stats ——— */
.stat-grid {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .stat-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.stat-card {
  position: relative;
  overflow: hidden;
  padding: 1.1rem 1.15rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.stat-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), transparent 70%);
  opacity: 0.7;
}

.stat-label {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat-value {
  margin: 0.45rem 0 0;
  font-size: 1.45rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.15;
}

.stat-note {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* ——— Cards / lists ——— */
.card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.card-pad {
  padding: 1.25rem 1.35rem;
}

.card-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}

.card-list > li + li {
  border-top: 1px solid var(--border);
}

.list-row {
  display: block;
  padding: 0.9rem 1.1rem;
  transition: background 0.12s var(--ease);
}

a.list-row:hover {
  background: var(--surface-hover);
}

.list-row-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.list-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  letter-spacing: -0.015em;
}

.list-meta {
  margin: 0.25rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.list-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Author cards */
.author-grid {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .author-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.author-card {
  display: block;
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color 0.15s var(--ease), transform 0.15s var(--ease), background 0.15s var(--ease);
  box-shadow: var(--shadow-sm);
}

.author-card:hover {
  border-color: var(--accent-border);
  background: var(--surface-2);
  transform: translateY(-1px);
}

.author-card h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.author-slug {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.author-bio {
  margin: 0.75rem 0 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.author-count {
  margin: 1rem 0 0;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent);
}

/* ——— Forms ——— */
.composer {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: linear-gradient(165deg, var(--surface-2) 0%, var(--surface) 55%);
  padding: 1.35rem 1.4rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

.field {
  margin: 0;
}

.field + .field,
.field + fieldset,
fieldset + .field {
  margin-top: 1rem;
}

.label,
legend.field-legend {
  display: block;
  margin: 0 0 0.4rem;
  padding: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-inline-size: 0;
}

.input,
.textarea,
.select {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  padding: 0.65rem 0.85rem;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.input {
  font-size: 0.95rem;
  min-height: var(--touch);
}

.input-lg {
  font-size: 1.05rem;
  font-weight: 500;
}

.textarea {
  font-size: 0.9rem;
  line-height: 1.6;
  resize: vertical;
  min-height: 10rem;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-muted);
}

.input:hover,
.textarea:hover,
.select:hover {
  border-color: #45506a;
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.select {
  min-height: var(--touch);
  padding-right: 2rem;
}

/* Chips */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.author-chip {
  cursor: pointer;
  display: inline-flex;
}

.author-chip .chip-face {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch);
  padding: 0 1rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s var(--ease);
}

.author-chip:hover .chip-face {
  border-color: var(--accent-border);
  color: var(--text);
}

.author-chip input:checked + .chip-face {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-border);
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1.75rem;
}

.filter-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-right: 0.25rem;
  font-weight: 500;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.1rem;
  padding: 0 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  background: transparent;
  transition: all 0.12s var(--ease);
}

.filter-chip:hover {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--surface);
}

.filter-chip-active {
  border-color: var(--accent-border);
  background: var(--accent-dim);
  color: var(--accent);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: var(--touch);
  padding: 0.55rem 1.15rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease),
    transform 0.12s var(--ease);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(180deg, #4f8ff7 0%, var(--primary) 100%);
  color: var(--primary-text);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset, 0 4px 12px rgba(59, 130, 246, 0.25);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #6aa0f8 0%, var(--primary-hover) 100%);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: #4a5570;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

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

.btn-block {
  width: 100%;
}

.composer-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.15rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0;
}

/* ——— Pieces ingest tabs + source badges ——— */
.ingest-tabs {
  display: flex;
  gap: 0.4rem;
  margin: 0 0 0.85rem;
  padding: 0.3rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  width: fit-content;
  max-width: 100%;
}

.ingest-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.35rem;
  padding: 0.4rem 0.95rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.15s var(--ease), color 0.15s var(--ease), border-color 0.15s var(--ease);
}

.ingest-tab:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.ingest-tab.is-active {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.ingest-tab-ico {
  display: grid;
  place-items: center;
  width: 1.15rem;
  height: 1.15rem;
}

.ingest-tab-ico svg {
  width: 1.15rem;
  height: 1.15rem;
  display: block;
}

.source-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.08rem 0.4rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  border: 1px solid var(--border-strong);
  background: rgba(110, 122, 145, 0.14);
  color: var(--text-secondary);
  vertical-align: middle;
}

.source-badge-manual {
  border-color: var(--border-strong);
  background: rgba(110, 122, 145, 0.14);
  color: var(--text-secondary);
}

.source-badge-docs {
  border-color: rgba(66, 133, 244, 0.4);
  background: rgba(66, 133, 244, 0.12);
  color: #8ab4f8;
}

.source-badge-youtube {
  border-color: rgba(255, 0, 51, 0.35);
  background: rgba(255, 0, 51, 0.1);
  color: #ff8a9b;
}

.source-badge-notion {
  border-color: rgba(238, 241, 246, 0.25);
  background: rgba(238, 241, 246, 0.08);
  color: var(--text);
}

.source-badge-other {
  border-color: var(--warning-border);
  background: var(--warning-bg);
  color: var(--warning-text);
}

.list-badge {
  flex: 0 0 auto;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
  background: rgba(110, 122, 145, 0.14);
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
}

.local-graph {
  min-height: 280px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: radial-gradient(ellipse at center, rgba(110, 122, 145, 0.06), transparent 70%);
  overflow: hidden;
}

.local-graph-empty {
  display: none !important;
}

@media (max-width: 767px) {
  .local-graph {
    display: none;
  }
}

.drive-doc-list {
  margin-top: 0.75rem;
  max-height: 22rem;
  overflow: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
}

.drive-doc-row {
  display: flex !important;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem !important;
  text-decoration: none !important;
  border-radius: 0 !important;
  background: transparent !important;
}

.drive-doc-row:hover {
  background: var(--surface-hover) !important;
}

.drive-doc-check {
  margin-top: 0.3rem;
  flex: 0 0 auto;
  width: 1rem;
  height: 1rem;
  accent-color: var(--primary);
}

.drive-doc-label {
  flex: 1;
  min-width: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.drive-doc-label .list-title {
  min-width: 0;
}

.drive-browse {
  margin: 0 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.drive-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.drive-crumb {
  font-weight: 600;
  color: var(--text);
}

.drive-search {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.drive-search .input {
  flex: 1 1 220px;
}

.drive-folder-row .drive-doc-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text);
}

.drive-folder-row:hover .list-title {
  text-decoration: underline;
}

/* ——— Drive file explorer (sidebar + main panel) ——— */
.drive-explorer {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr;
  gap: 1.25rem;
  align-items: start;
}

.drive-sidebar {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 0.6rem;
  max-height: 32rem;
  overflow: auto;
}

.drive-folder-tree {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.drive-folder-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.55rem;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  min-width: 0;
}

.drive-folder-item:hover {
  background: var(--surface-hover);
}

.drive-folder-item.is-current {
  background: var(--primary-dim, rgba(138, 180, 248, 0.14));
  color: var(--primary, #8ab4f8);
  font-weight: 600;
}

.drive-folder-list {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding-left: 0.35rem;
}

.drive-folder-ico {
  flex: 0 0 auto;
  font-size: 0.7rem;
  color: var(--text-secondary);
  transform: rotate(90deg);
}

.drive-folder-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drive-main {
  min-width: 0;
}

@media (max-width: 767px) {
  .drive-explorer {
    grid-template-columns: 1fr;
  }
  .drive-sidebar {
    max-height: 12rem;
  }
}

/* ——— Integrations (Settings) ——— */
.integration-grid {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: 1fr;
}

@media (min-width: 720px) {
  .integration-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.integration-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 100%;
  padding: 1.15rem 1.2rem 1.2rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: linear-gradient(165deg, var(--surface-2) 0%, var(--surface) 60%);
  box-shadow: var(--shadow-sm);
}

.integration-card-disabled {
  opacity: 0.55;
  filter: grayscale(0.35);
  background: var(--surface);
}

.integration-card-disabled .btn:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.integration-card-top {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
}

.integration-logo {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}

.integration-logo-muted {
  opacity: 0.9;
}

.integration-svg {
  width: 1.65rem;
  height: 1.65rem;
  display: block;
}

.integration-card-head {
  min-width: 0;
  flex: 1;
}

.integration-card-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.55rem;
  margin-bottom: 0.3rem;
}

.integration-name {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.integration-desc {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.integration-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  border: 1px solid var(--accent-border);
  background: var(--accent-dim);
  color: var(--accent);
}

.integration-badge-ok {
  border-color: var(--success-border);
  background: var(--success-bg);
  color: var(--success-text);
}

.integration-badge-muted {
  border-color: var(--border-strong);
  background: rgba(110, 122, 145, 0.12);
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.72rem;
}

.integration-card-body {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.integration-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin: 0;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
}

.integration-meta-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.integration-meta-value {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  word-break: break-all;
}

.integration-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.integration-actions form {
  display: inline;
  margin: 0;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  padding: 1rem 0 0.5rem;
  margin-top: 1.25rem;
  background: linear-gradient(to top, var(--bg) 65%, transparent);
}

/* Alerts */
.alert {
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  font-size: 0.875rem;
  border: 1px solid;
  margin: 0 0 1rem;
}

.alert-success {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-text);
}

.alert-error {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-text);
}

.alert-info {
  background: var(--accent-dim);
  border-color: var(--accent-border);
  color: #bfdbfe;
}

/* Empty */
.empty {
  text-align: center;
  padding: 2.5rem 1.5rem;
  border-radius: var(--radius-lg);
  border: 1px dashed var(--border-strong);
  background: rgba(19, 24, 34, 0.4);
}

.empty-title {
  margin: 0;
  font-weight: 600;
  color: var(--text);
  font-size: 1rem;
}

.empty-body {
  margin: 0.5rem auto 0;
  max-width: 24rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Breadcrumb */
.crumb {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.crumb a:hover {
  color: var(--accent);
}

/* Search form */
.search-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.search-form .grow {
  flex: 1 1 14rem;
}

/* Advanced disclosure */
.disclosure {
  margin-top: 1.15rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--bg-elevated);
}

.disclosure-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--touch);
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.disclosure-toggle:hover {
  background: var(--surface);
  color: var(--text);
}

.disclosure-body {
  border-top: 1px solid var(--border);
  padding: 1rem;
  background: rgba(9, 11, 16, 0.45);
}

.grid-3 {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Pre / code blocks */
.panel-code {
  margin: 0.75rem 0 0;
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--text-secondary);
  overflow-x: auto;
  white-space: pre-wrap;
}

/* Login */
.login-screen {
  position: relative;
  z-index: 1;
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
}

.login-card {
  width: 100%;
  max-width: 22rem;
}

.login-brand {
  text-align: center;
  margin-bottom: 1.75rem;
}

.login-brand .brand-icon {
  margin: 0 auto 0.85rem;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 12px;
}

.login-brand h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: -0.03em;
}

.login-brand p {
  margin: 0.35rem 0 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.login-panel {
  padding: 1.5rem;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.login-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  margin: 1.25rem 0 0;
}

.login-google-g {
  display: inline-flex;
  align-items: center;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.9rem 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Utils kept for residual classes */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.mt-1 {
  margin-top: 0.25rem;
}
.mt-2 {
  margin-top: 0.5rem;
}
.mt-3 {
  margin-top: 0.75rem;
}
.mt-4 {
  margin-top: 1rem;
}
.mt-6 {
  margin-top: 1.5rem;
}
.mt-8 {
  margin-top: 2rem;
}
.mt-10 {
  margin-top: 2.5rem;
}
.mb-1 {
  margin-bottom: 0.25rem;
}
.space-y-3 > * + * {
  margin-top: 0.75rem;
}
.space-y-4 > * + * {
  margin-top: 1rem;
}
.space-y-5 > * + * {
  margin-top: 1.25rem;
}
.flex {
  display: flex;
}
.flex-wrap {
  flex-wrap: wrap;
}
.gap-2 {
  gap: 0.5rem;
}
.gap-3 {
  gap: 0.75rem;
}
.items-center {
  align-items: center;
}
.justify-between {
  justify-content: space-between;
}
.w-full {
  width: 100%;
}
.text-sm {
  font-size: 0.875rem;
}
.text-xs {
  font-size: 0.75rem;
}
.text-danger {
  color: var(--danger);
}
.text-danger:hover {
  color: #fca5a5;
}
.link {
  color: var(--accent);
  font-weight: 500;
}
.link:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}
.break-all {
  word-break: break-all;
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.border-t {
  border-top: 1px solid var(--border);
}
.pt-6 {
  padding-top: 1.5rem;
}
.divide-y > * + * {
  border-top: 1px solid var(--border);
}

.search-snippet mark {
  background: var(--accent-dim);
  color: #dbeafe;
  padding: 0 0.15em;
  border-radius: 0.15em;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
