:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --border: #e4e2dc;
  --text: #20201d;
  --muted: #6b6860;
  --accent: #2f5d50;
  --accent-contrast: #ffffff;
  --danger: #a13d3d;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171a;
    --surface: #1d2024;
    --border: #2a2d31;
    --text: #e9e7e1;
    --muted: #9b9890;
    --accent: #5fa98d;
    --accent-contrast: #0f1210;
    --danger: #d98a8a;
  }
}

:root[data-theme="dark"] {
  --bg: #15171a;
  --surface: #1d2024;
  --border: #2a2d31;
  --text: #e9e7e1;
  --muted: #9b9890;
  --accent: #5fa98d;
  --accent-contrast: #0f1210;
  --danger: #d98a8a;
}

* {
  box-sizing: border-box;
}

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  transition: background-color 0.15s ease, color 0.15s ease;
}

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

/* ---- top bar ---- */

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

header h1 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.01em;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.theme-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface);
}

.theme-toggle button {
  width: auto;
  margin: 0;
  padding: 0.35rem 0.6rem;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
}

.theme-toggle button:not(:last-child) {
  border-right: 1px solid var(--border);
}

.theme-toggle button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-contrast);
}

.logout-form button {
  width: auto;
  margin: 0;
  padding: 0.4rem 0.8rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}

.logout-form button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---- layout ---- */

main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  padding: 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
}

@media (max-width: 720px) {
  main {
    grid-template-columns: 1fr;
  }
}

section h2 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

/* ---- forms / inputs (shared) ---- */

input,
textarea,
button {
  font-size: 0.95rem;
  padding: 0.5rem 0.6rem;
  margin: 0.25rem 0;
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}

textarea {
  min-height: 4.5rem;
  resize: vertical;
}

input:focus,
textarea:focus,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

button {
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  font-weight: 500;
}

button:hover {
  opacity: 0.9;
}

/* ---- facts: catalogued index cards, monospace ---- */

#fact-list {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.fact-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.65rem 0.75rem;
  background: var(--surface);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.85rem;
  line-height: 1.4;
}

.fact-card .category-tag {
  position: absolute;
  top: -0.5rem;
  right: 0.5rem;
  background: var(--bg);
  padding: 0 0.35rem;
  font-size: 0.7rem;
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 3px;
}

/* ---- notes: flowing journal entries, serif ---- */

#note-list {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
}

.note-entry {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  font-family: "Source Serif 4", Georgia, serif;
}

.note-entry:first-child {
  padding-top: 0;
}

.note-entry .note-date {
  display: block;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.note-entry .note-title {
  font-weight: 600;
  margin-right: 0.4rem;
}

.note-entry .note-body {
  color: var(--text);
  line-height: 1.55;
}

.empty-state {
  color: var(--muted);
  font-size: 0.85rem;
  font-style: italic;
  font-family: "Inter", system-ui, sans-serif;
}

/* ---- login ---- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-form {
  max-width: 320px;
  width: 100%;
  margin: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 2rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.login-form h1 {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.login-form .brand-mark {
  width: 22px;
  height: 22px;
}
