:root {
  --paper: #f3efe4;
  --ink: #1d1a16;
  --muted: #5e584e;
  --line: #d9d0c0;
  --oxide: #8d3b2f;
  --moss: #2c4a3b;
  --card: #fbf8f2;
  --warn: #8a5a12;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(141, 59, 47, 0.08), transparent 28%),
    var(--paper);
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  line-height: 1.5;
}

.masthead, .tabs, main {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
}

.masthead { padding: 36px 0 8px; }

.eyebrow {
  margin: 0;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.74rem;
  color: var(--oxide);
}

h1, h2, h3 {
  font-family: Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-weight: 500;
}

h1 { margin: 6px 0 8px; font-size: 2.5rem; line-height: 1.1; }
h2 { margin: 0 0 8px; font-size: 1.55rem; }
.note-title { margin: 0 0 8px; font-weight: 600; }
h3 { margin: 22px 0 8px; font-size: 1.15rem; }

.lede { margin: 0; color: var(--muted); max-width: 68ch; }

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 22px 0 0;
}

.tab, button, select, input, textarea {
  font: inherit;
}

.tab, button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
}

.tab.is-active, button.primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

button.primary { border-radius: 10px; }
button:disabled { opacity: 0.55; cursor: wait; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  margin: 16px 0 48px;
}

label { display: block; margin: 12px 0 6px; color: var(--muted); font-size: 0.92rem; }

textarea, input, select {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--ink);
}

textarea { resize: vertical; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-top: 12px; }

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px 12px;
  align-items: end;
}

.filters button { height: 42px; }

.stack { display: flex; flex-direction: column; gap: 10px; }

.card, .path, .warning {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: white;
}

.card header, .meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.meta span, .chip {
  color: var(--muted);
  font-size: 0.86rem;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
}

.action-new { color: var(--oxide); }
.action-reuse { color: var(--moss); }
.action-update { color: #315f86; }

.rel-type {
  font-family: Palatino, Georgia, serif;
  letter-spacing: 0.04em;
}

.path {
  white-space: pre-wrap;
  font-family: Palatino, Georgia, serif;
  line-height: 1.45;
}

.warning { background: #fbf6ec; color: var(--warn); }
.error { color: var(--oxide); }
.ok { color: var(--moss); }
.hint { color: var(--muted); }
.empty { color: var(--muted); margin: 0; }

dl { display: grid; grid-template-columns: 220px 1fr; gap: 6px 12px; margin: 12px 0 0; }
dt { color: var(--muted); }
dd { margin: 0; }

pre {
  overflow: auto;
  padding: 12px;
  background: #f6f3ec;
  border-radius: 10px;
}

details { margin-top: 16px; }

dialog {
  width: min(560px, calc(100% - 24px));
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  padding: 18px;
}

dialog label, .filters label { display: block; margin: 10px 0; }
dialog input, dialog textarea, dialog select, .filters input, .filters select { width: 100%; }

#record-button.is-live {
  background: var(--oxide);
  color: white;
  border-color: var(--oxide);
}

@media (max-width: 640px) {
  h1 { font-size: 2rem; }
  dl { grid-template-columns: 1fr; }
}
