:root {
  --ink: #1c1b1a;
  --paper: #fdfcfa;
  --accent: #a8442e;
  --muted: #6b6459;
  --border: #e4dfd6;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
}

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

a:hover {
  text-decoration: underline;
}

.site-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--ink);
}

.search-form {
  flex: 1;
  min-width: 180px;
}

.search-form input {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.whoami {
  color: var(--muted);
  font-size: 0.9rem;
}

.theme-form select {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.85rem;
}

.layout {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  display: flex;
  gap: 2.5rem;
  align-items: flex-start;
}

.sidebar {
  flex: 0 0 200px;
  position: sticky;
  top: 1.5rem;
}

.nav-section {
  margin-bottom: 1.5rem;
}

.nav-section h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.nav-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-section li {
  margin-bottom: 0.35rem;
}

.manage-nav-link {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--muted);
}

.content {
  flex: 1;
  min-width: 0;
}

@media (max-width: 680px) {
  .layout {
    flex-direction: column;
  }
  .sidebar {
    position: static;
    flex-basis: auto;
  }
}

.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 2rem 1.5rem;
}

.category {
  margin-bottom: 2rem;
}

.category h2 {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3rem;
}

.category-tag {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
}

.page-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.page-content h2,
.page-content h3 {
  margin-top: 1.5rem;
}

.page-footer {
  margin-top: 2.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

form label {
  display: block;
  margin-bottom: 1rem;
  font-weight: 600;
}

form input[type="text"],
form input[type="email"],
form input[type="search"],
form textarea {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}

form textarea {
  font-family: ui-monospace, Menlo, Consolas, monospace;
}

button,
input[type="submit"] {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.55rem 1.1rem;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
}

button.secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

button.link-button {
  background: none;
  color: var(--accent);
  padding: 0;
  font-size: inherit;
  text-decoration: underline;
}

.inline-form {
  display: inline;
}

.error {
  color: var(--accent);
  font-weight: 600;
}

.saved-message {
  color: var(--muted);
  font-weight: 600;
}

.pending-list {
  list-style: none;
  padding: 0;
}

.pending-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.admin-actions {
  display: flex;
  gap: 0.5rem;
}

.admin-actions button {
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
}

a[href^="/new?title="] {
  color: var(--accent);
  border-bottom: 1px dashed var(--accent);
  text-decoration: none;
}

a[href^="/new?title="]:hover {
  text-decoration: none;
}

.field-hint {
  display: block;
  margin-top: 0.35rem;
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--muted);
}

.field-hint code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
}

.admin-nav .nav-section-editor {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.nav-section-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.nav-section-editor-header form:first-child {
  display: flex;
  gap: 0.5rem;
  flex: 1;
  min-width: 200px;
}

.nav-section-editor-header input[type="text"] {
  margin: 0;
  width: auto;
  flex: 1;
}

.nav-link-list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.75rem;
}

.nav-link-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}

.add-link-form,
.new-section-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.add-link-form select,
.add-link-form input,
.new-section-form input {
  margin: 0;
  width: auto;
  flex: 1;
  min-width: 160px;
}
