:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1f2430;
  --muted: #6b7280;
  --line: #e3e6ea;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --danger: #dc2626;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 700; color: var(--ink); font-size: 16px; }
.topbar nav { display: flex; gap: 16px; }
.topbar nav a { color: var(--muted); font-weight: 500; }
.topbar nav a.active, .topbar nav a:hover { color: var(--ink); text-decoration: none; }
.topbar .search { margin-left: auto; }
.topbar .search input {
  padding: 7px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  min-width: 220px; background: var(--bg);
}
.topbar .logout button {
  background: none; border: 1px solid var(--line); color: var(--muted);
  padding: 7px 12px; border-radius: var(--radius); cursor: pointer;
}
.topbar .logout button:hover { color: var(--ink); }

main { max-width: 900px; margin: 24px auto; padding: 0 20px; }
main.authless { display: flex; justify-content: center; padding-top: 8vh; }

.page-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 12px;
}
.page-head h1 { font-size: 22px; margin: 0; }

h2 { font-size: 16px; margin: 0 0 12px; }

/* Cards & panels */
.card, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 18px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; }

/* Buttons */
.button, button {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
}
.button:hover, button:hover { text-decoration: none; border-color: var(--muted); }
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.primary:hover { background: #1d4ed8; color: #fff; }
.danger { color: var(--danger); border-color: #f0c7c7; }
.danger:hover { background: #fef2f2; border-color: var(--danger); }
.button.small, button.small { padding: 5px 10px; font-size: 13px; }
.link {
  background: none; border: none; color: var(--accent); padding: 0; cursor: pointer;
  font-size: 13px;
}
.link.danger { color: var(--danger); border: none; }
.link.danger:hover { background: none; text-decoration: underline; }

.actions { display: flex; gap: 8px; align-items: center; }
.actions form { margin: 0; }

/* Tables */
table.list { width: 100%; border-collapse: collapse; }
table.list th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line);
}
table.list th a.sort { color: inherit; text-decoration: none; white-space: nowrap; }
table.list th a.sort:hover { color: var(--ink); text-decoration: underline; }
table.list td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr:last-child td { border-bottom: none; }

/* Forms */
form.form { display: flex; flex-direction: column; gap: 14px; max-width: 560px; }
label { display: flex; flex-direction: column; gap: 5px; font-weight: 500; font-size: 14px; }
input, textarea, select {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: var(--radius); background: #fff; color: var(--ink); width: 100%;
}
textarea { resize: vertical; }
.inline-form { display: flex; gap: 8px; margin-bottom: 14px; align-items: flex-start; }
.inline-form textarea { flex: 1; }
.inline-form input[type=file] { flex: 1; border: none; padding-left: 0; }
.inline-form button { white-space: nowrap; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 18px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* Add-note form (textarea + attachments + submit) */
.note-add { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.note-add-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.note-add-actions input[type=file] { font-size: 13px; }

/* Timeline / notes */
.timeline .note {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 10px; background: var(--bg);
}
.note-body { white-space: normal; }

/* Attachments on a note */
.attachments { list-style: none; margin: 8px 0 0; padding: 8px 0 0; border-top: 1px dashed var(--line); }
.attachments li { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.attachments li form { margin: 0; }
.attachments .link.danger { font-size: 15px; line-height: 1; }

.row-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; gap: 8px; }
.row-meta time { color: var(--muted); font-size: 12px; }
.row-meta form { margin: 0; }
.note-actions { display: flex; align-items: center; gap: 12px; }
.note-actions .attach { display: flex; align-items: center; gap: 4px; }
.note-actions .attach input[type=file] { font-size: 12px; max-width: 170px; }

/* Files */
.filelist .file-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.filelist .file-row:last-child { border-bottom: none; }
.filelist .file-row form { margin: 0 0 0 auto; }

.note-date {
  color: var(--muted); font-size: 12px; margin-right: 6px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* Search results */
ul.results { list-style: none; margin: 0; padding: 0; }
ul.results li { padding: 6px 0; border-bottom: 1px solid var(--line); }
ul.results li:last-child { border-bottom: none; }

/* Login */
.login-card { width: 340px; }
.login-card h1 { font-size: 20px; margin-top: 0; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }

/* Notices & helpers */
.muted { color: var(--muted); }
.small { font-size: 12px; }
.empty { color: var(--muted); padding: 20px 0; }
.notice { padding: 10px 12px; border-radius: var(--radius); font-size: 14px; }
.notice.error { background: #fef2f2; color: var(--danger); border: 1px solid #f0c7c7; }
.notice.warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 13px; }

/* MCP setup page */
pre {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  overflow-x: auto;          /* long tokens and URLs must not stretch the page */
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
}
pre code { background: none; padding: 0; font-size: inherit; }

.mcp-facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.mcp-facts dt { color: var(--muted); }
.mcp-facts dd { margin: 0; }

/* The token is a long unbroken string; let it wrap rather than overflow. */
.mcp-token { word-break: break-all; }

.warn {
  border-left: 3px solid var(--danger);
  padding-left: 12px;
  color: var(--ink);
}
