/* ============================================================
   2ndBrain — a private knowledge graph grown from your own
   documents. Design language: ink on paper meets bioluminescence.
   ============================================================ */

@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url("/fonts/fraunces-300.woff2") format("woff2");
}
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/fraunces-500.woff2") format("woff2");
}
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/fraunces-600.woff2") format("woff2");
}
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/fraunces-700.woff2") format("woff2");
}
@font-face {
  font-family: "Fraunces";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/fraunces-italic-400.woff2") format("woff2");
}
@font-face {
  font-family: "Plex Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/plexsans-400.woff2") format("woff2");
}
@font-face {
  font-family: "Plex Sans";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/plexsans-italic-400.woff2") format("woff2");
}
@font-face {
  font-family: "Plex Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/plexsans-500.woff2") format("woff2");
}
@font-face {
  font-family: "Plex Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/plexsans-600.woff2") format("woff2");
}
@font-face {
  font-family: "Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/plexmono-400.woff2") format("woff2");
}
@font-face {
  font-family: "Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/plexmono-500.woff2") format("woff2");
}

/* ---------------- Tokens ---------------- */

:root {
  --void: #f7f5f0;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --edge: #ded8ca;
  --edge-strong: #c9c0ac;
  --ink: #211d16;
  --ink-dim: #6f6a5c;
  --synapse: #0f8b7f;
  --synapse-glow: rgba(15, 139, 127, 0.18);
  --ember: #c9711a;
  --danger: #b3432f;
  --shadow-color: 30, 25, 15;

  --font-display: "Fraunces", ui-serif, Georgia, serif;
  --font-body: "Plex Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --radius-sm: 6px;
  --radius: 12px;
  --radius-lg: 20px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --void: #0b0d12;
    --surface: #12151d;
    --surface-raised: #191d27;
    --edge: #262b37;
    --edge-strong: #3a4152;
    --ink: #e9e7de;
    --ink-dim: #8891a3;
    --synapse: #5eead4;
    --synapse-glow: rgba(94, 234, 212, 0.16);
    --ember: #f5a623;
    --danger: #f28b74;
    --shadow-color: 0, 0, 0;
  }
}

:root[data-theme="dark"] {
  --void: #0b0d12;
  --surface: #12151d;
  --surface-raised: #191d27;
  --edge: #262b37;
  --edge-strong: #3a4152;
  --ink: #e9e7de;
  --ink-dim: #8891a3;
  --synapse: #5eead4;
  --synapse-glow: rgba(94, 234, 212, 0.16);
  --ember: #f5a623;
  --danger: #f28b74;
  --shadow-color: 0, 0, 0;
}

:root[data-theme="light"] {
  --void: #f7f5f0;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --edge: #ded8ca;
  --edge-strong: #c9c0ac;
  --ink: #211d16;
  --ink-dim: #6f6a5c;
  --synapse: #0f8b7f;
  --synapse-glow: rgba(15, 139, 127, 0.18);
  --ember: #c9711a;
  --danger: #b3432f;
  --shadow-color: 30, 25, 15;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--void);
  color: var(--ink);
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--synapse);
  color: var(--void);
}

a { color: var(--synapse); }

h1, h2, h3 {
  font-family: var(--font-display);
  text-wrap: balance;
  margin: 0;
}

/* ---------------- Sidebar ---------------- */

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--edge);
  display: flex;
  flex-direction: column;
  padding: 1.6rem 1.1rem;
  gap: 2.2rem;
  position: relative;
  z-index: 2;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0 0.3rem;
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}

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

.nav-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-dim);
  padding: 0 0.7rem;
  margin-bottom: 0.4rem;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius-sm);
  color: var(--ink-dim);
  text-decoration: none;
  font-size: 0.93rem;
  transition: background 0.15s ease, color 0.15s ease;
  position: relative;
}

.nav a:hover {
  background: var(--surface-raised);
  color: var(--ink);
}

.nav a.active {
  color: var(--ink);
  font-weight: 500;
}

.nav a.active::before {
  content: "";
  position: absolute;
  left: -1.1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  border-radius: 2px;
  background: var(--synapse);
  box-shadow: 0 0 8px var(--synapse-glow);
}

.nav-icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  flex-shrink: 0;
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.theme-toggle, .logout-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  color: var(--ink-dim);
  text-decoration: none;
  font-size: 0.85rem;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
}

.theme-toggle:hover { background: var(--surface-raised); color: var(--ink); }
.logout-link:hover { background: var(--surface-raised); color: var(--danger); }

/* ---------------- Main ---------------- */

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ---------------- Buttons & focus ---------------- */

button, input {
  font-family: var(--font-body);
}

button:focus-visible, input:focus-visible, .dropzone:focus-visible, a:focus-visible {
  outline: 2px solid var(--synapse);
  outline-offset: 2px;
}

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

/* ---------------- Responsive ---------------- */

@media (max-width: 760px) {
  body { flex-direction: column; }
  .sidebar {
    width: auto;
    flex-direction: row;
    align-items: center;
    border-right: none;
    border-bottom: 1px solid var(--edge);
    padding: 0.85rem 1rem;
    gap: 1rem;
  }
  .nav { flex-direction: row; }
  .nav-eyebrow { display: none; }
  .nav a.active::before { display: none; }
  .sidebar-footer { margin-top: 0; margin-left: auto; flex-direction: row; }
}
