/* Fenja UI Kit — composed over colors_and_type.css */

.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100vh;
  background: var(--surface-container-low);
  color: var(--on-surface);
  font-family: var(--font-sans);
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--surface-container);
  padding: 28px 22px;
  display: flex; flex-direction: column;
  gap: 28px;
  overflow-y: auto;
}
.brand {
  display: flex; align-items: center;
  padding-bottom: 8px;
}
.brand .wordmark { height: 26px; width: auto; display: block; }

.nav-section { display: flex; flex-direction: column; gap: 4px; }
.nav-section .heading {
  font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--on-surface-muted); font-weight: 500;
  margin: 0 0 6px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--on-surface-variant);
  cursor: pointer;
  font-size: 14px;
  transition: background var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard);
}
.nav-item:hover { background: var(--surface-container-high); color: var(--on-surface); }
.nav-item.active { background: var(--surface-container-lowest); color: var(--on-surface); font-weight: 500; }
.nav-item svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.5; fill: none; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.nav-item .count { margin-left: auto; font-size: 11px; color: var(--on-surface-muted); letter-spacing: 0.04em; }

.sidebar-footer { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; background: var(--surface-container-high); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--pigment-indigo); color: #fffcf7; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }
.sidebar-footer .name { font-size: 13px; color: var(--on-surface); font-weight: 500; }
.sidebar-footer .email { font-size: 11px; color: var(--on-surface-muted); letter-spacing: 0.02em; }

/* ---------- Main ---------- */
.main {
  background: var(--surface);
  overflow-y: auto;
  position: relative;
}

.topbar {
  position: sticky; top: 0; z-index: 5;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(255, 252, 247, 0.82);
  padding: 18px 56px;
  display: flex; align-items: center; gap: 20px;
}
.crumb { font-family: var(--font-sans); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--on-surface-muted); }
.crumb .sep { margin: 0 10px; }
.topbar-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }

.page { padding: 56px 96px 96px; max-width: 1100px; }
.page-hero { margin-bottom: 64px; }
.eyebrow { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--on-surface-muted); font-weight: 500; margin-bottom: 18px; }
.page-hero h1 { font-family: var(--font-serif); font-size: clamp(44px, 5vw, 72px); letter-spacing: -0.02em; line-height: 1.05; font-weight: 400; margin: 0 0 18px; max-width: 20ch; }
.page-hero h1 em { font-style: italic; font-weight: 700; }
.page-hero .lead { font-family: var(--font-serif); font-style: italic; font-size: 19px; color: var(--on-surface-variant); line-height: 1.55; max-width: 54ch; margin: 0; }

/* ---------- Buttons ---------- */
.btn { font-family: var(--font-sans); font-size: 14px; font-weight: 500; border: 0; cursor: pointer; padding: 10px 20px; border-radius: 12px; letter-spacing: 0; transition: transform var(--duration-fast) var(--ease-standard), filter var(--duration-fast) var(--ease-standard), background var(--duration-fast) var(--ease-standard); }
.btn-primary { color: #fff; background: linear-gradient(180deg, #785f53, #6b5348); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: translateY(1px); }
.btn-secondary { background: var(--surface-container-highest); color: var(--on-surface); }
.btn-secondary:hover { background: #e0ddd2; }
.btn-tertiary { background: transparent; color: var(--primary); padding: 10px 8px; position: relative; }
.btn-tertiary::after { content: ""; position: absolute; left: 8px; right: 14px; bottom: 6px; height: 2px; background: var(--secondary); transform: scaleX(0); transform-origin: left; transition: transform 240ms var(--ease-standard); }
.btn-tertiary:hover::after { transform: scaleX(1); }

.btn-icon { background: transparent; border: 0; width: 34px; height: 34px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--on-surface-variant); transition: background var(--duration-fast) var(--ease-standard); }
.btn-icon:hover { background: var(--surface-container); color: var(--on-surface); }
.btn-icon svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.5; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Search bar ---------- */
.floating-search {
  background: var(--surface-container-lowest);
  border-radius: 14px;
  box-shadow: var(--shadow-float);
  padding: 14px 18px;
  display: flex; align-items: center; gap: 14px;
  margin: 0 0 64px;
}
.floating-search svg { width: 18px; height: 18px; stroke: var(--on-surface-muted); stroke-width: 1.5; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.floating-search input { flex: 1; border: 0; background: transparent; font: inherit; font-family: var(--font-sans); font-size: 16px; color: var(--on-surface); outline: none; }
.floating-search input::placeholder { color: var(--on-surface-muted); font-style: italic; font-family: var(--font-serif); }
.floating-search .shortcut { font-size: 11px; color: var(--on-surface-muted); letter-spacing: 0.06em; padding: 3px 8px; background: var(--surface-container); border-radius: 6px; font-family: var(--font-mono); }

/* ---------- Section headers ---------- */
.section-head { display: flex; align-items: baseline; margin: 0 0 24px; gap: 14px; }
.section-head h2 { font-family: var(--font-serif); font-size: 28px; letter-spacing: -0.01em; font-weight: 400; margin: 0; color: var(--on-surface); }
.section-head h2 em { font-style: italic; font-weight: 700; }
.section-head .count { font-family: var(--font-sans); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--on-surface-muted); }

/* ---------- Archive list ---------- */
.archive-list { display: grid; gap: 0; }
.archive-item {
  padding: 22px 22px;
  border-radius: 10px;
  display: grid;
  grid-template-columns: 1fr 120px 80px;
  column-gap: 20px;
  align-items: baseline;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-standard);
}
.archive-item:nth-child(odd) { background: var(--surface-container-low); }
.archive-item:hover { background: var(--surface-container); }
.archive-item .title { font-family: var(--font-serif); font-size: 19px; line-height: 1.3; color: var(--on-surface); font-weight: 400; }
.archive-item .meta { font-family: var(--font-sans); font-size: 12px; color: var(--on-surface-muted); letter-spacing: 0.04em; }
.archive-item .pigment { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--on-surface-variant); }
.archive-item .pigment .dot { width: 8px; height: 8px; border-radius: 50%; }
.archive-item .excerpt { grid-column: 1 / 2; margin-top: 8px; font-family: var(--font-sans); font-size: 14px; color: var(--on-surface-variant); line-height: 1.55; max-width: 72ch; }

/* ---------- Reader panel (chat) ---------- */
.reader {
  display: grid; grid-template-columns: 1fr 380px;
  gap: 48px;
}
.reader-main { min-width: 0; }
.reader-main .doc-title { font-family: var(--font-serif); font-size: 42px; letter-spacing: -0.015em; line-height: 1.1; margin: 0 0 12px; font-weight: 400; }
.reader-main .doc-meta { font-family: var(--font-sans); font-size: 12px; color: var(--on-surface-muted); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 36px; }
.reader-main p { font-size: 17px; line-height: 1.7; color: var(--on-surface); max-width: 62ch; }
.reader-main p .highlight { background: rgba(194, 157, 89, 0.22); padding: 0 2px; border-radius: 2px; }

.ask-pane { background: var(--surface-container-low); border-radius: var(--radius-lg); padding: 28px; align-self: start; position: sticky; top: 88px; }
.ask-pane .eyebrow { margin-bottom: 10px; }
.ask-pane h3 { font-family: var(--font-serif); font-size: 22px; font-weight: 400; margin: 0 0 18px; }
.ask-pane h3 em { font-style: italic; font-weight: 700; }
.thread { display: flex; flex-direction: column; gap: 20px; margin-bottom: 22px; }
.msg { font-size: 14px; line-height: 1.55; }
.msg .who { font-family: var(--font-sans); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--on-surface-muted); margin-bottom: 6px; font-weight: 500; }
.msg.user .body { color: var(--on-surface); font-family: var(--font-sans); }
.msg.fenja .body { color: var(--on-surface); font-family: var(--font-serif); font-style: italic; }
.msg .cite { display: inline-block; margin-top: 6px; font-family: var(--font-sans); font-style: normal; font-size: 11px; color: var(--secondary); letter-spacing: 0.04em; border-bottom: 1px solid rgba(120,95,83,0.3); padding-bottom: 1px; }

.composer { background: var(--surface-container-lowest); border-radius: 12px; padding: 12px 14px; display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow-ambient); }
.composer input { flex: 1; border: 0; background: transparent; font: inherit; font-family: var(--font-sans); font-size: 14px; color: var(--on-surface); outline: none; padding: 6px 0; }
.composer input::placeholder { font-family: var(--font-serif); font-style: italic; color: var(--on-surface-muted); }

/* ---------- Runic loader ---------- */
.rune-spinner { width: 20px; height: 20px; animation: fenja-spin 6s linear infinite; }
.rune-spinner svg { width: 100%; height: 100%; }
.rune-spinner path, .rune-spinner line, .rune-spinner polygon { stroke: var(--on-surface); stroke-width: 1.5; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.rune-spinner .accent { stroke: var(--pigment-terracotta); }
@keyframes fenja-spin { to { transform: rotate(360deg); } }

/* ---------- Tags ---------- */
.tag { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 6px; font-family: var(--font-sans); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; background: var(--surface-container-high); color: var(--on-surface-variant); font-weight: 500; }
