/* True Roots — shared design system. Plain CSS, no build step.
   Custom properties keep the palette/spacing in one place; everything
   else is hand-written per page. Light/dark aware via prefers-color-scheme. */

:root {
  --color-bg: #faf7f2;
  --color-surface: #ffffff;
  --color-surface-alt: #f1ece2;
  --color-border: #e1d9c9;
  --color-text: #2b2620;
  --color-text-muted: #6b6255;
  --color-primary: #7a5230;
  --color-primary-hover: #603e22;
  --color-primary-contrast: #fffaf3;
  --color-accent: #4f6b4a;
  --color-danger: #a33d3d;
  --color-danger-bg: #fbeceb;
  --color-warning-bg: #fdf3dd;
  --color-warning-text: #6b4f0e;
  --color-public: #4f6b4a;
  --color-private: #8a6a3f;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(43, 38, 32, 0.06), 0 4px 14px rgba(43, 38, 32, 0.06);
  --font-sans: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  --max-width: 1100px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #201c17;
    --color-surface: #2a251f;
    --color-surface-alt: #332c23;
    --color-border: #453c30;
    --color-text: #f1ece2;
    --color-text-muted: #b9ae9b;
    --color-primary: #c99a5b;
    --color-primary-hover: #dfb376;
    --color-primary-contrast: #201c17;
    --color-accent: #86a67e;
    --color-danger: #e08383;
    --color-danger-bg: #3a2222;
    --color-warning-bg: #3a3018;
    --color-warning-text: #e3c878;
    --color-public: #86a67e;
    --color-private: #d9b072;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-serif); font-weight: 600; margin: 0 0 0.5em; line-height: 1.25; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
small, .muted { color: var(--color-text-muted); }

img { max-width: 100%; display: block; }

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  /* Horizontal only — a shorthand `padding: 0 20px` here would silently
     zero out vertical padding on anything using this class, which is
     exactly what happened to `main`'s top/bottom spacing on every page. */
  padding-left: 20px;
  padding-right: 20px;
}

/* --- Top nav --- */
.site-nav {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  flex-wrap: wrap;
}
.site-nav .brand {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--color-text);
  margin-right: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.site-nav .brand:hover { text-decoration: none; }
.site-nav nav { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.site-nav nav a { color: var(--color-text-muted); font-weight: 500; }
.site-nav nav a.active, .site-nav nav a:hover { color: var(--color-primary); }
.site-nav .user-chip {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.9rem; color: var(--color-text-muted); text-decoration: none;
}
.site-nav .user-chip:hover { color: var(--color-primary); text-decoration: none; }
.role-badge {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 2px 7px; border-radius: 99px; background: var(--color-surface-alt);
  color: var(--color-text-muted); font-weight: 600;
}

main { padding: 32px 0 64px; }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: 0.95rem; font-weight: 600; cursor: pointer; font-family: inherit;
  background: var(--color-surface-alt); color: var(--color-text);
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn:hover { text-decoration: none; background: var(--color-border); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--color-primary); color: var(--color-primary-contrast); }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-danger { background: transparent; color: var(--color-danger); border-color: var(--color-danger); }
.btn-danger:hover { background: var(--color-danger-bg); }
.btn-ghost { background: transparent; border-color: var(--color-border); }
.btn-sm { padding: 5px 10px; font-size: 0.83rem; }

/* --- Cards / surfaces --- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card + .card { margin-top: 16px; }

/* --- Forms --- */
label { display: block; font-weight: 600; font-size: 0.88rem; margin-bottom: 4px; }
.field { margin-bottom: 16px; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row > .field { flex: 1; min-width: 160px; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="search"], input[type="file"], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); background: var(--color-surface); color: var(--color-text);
  font-size: 0.95rem; font-family: inherit;
}
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--color-primary); outline-offset: 1px;
}
.field .hint { font-size: 0.8rem; color: var(--color-text-muted); margin-top: 4px; }
.checkbox-field { display: flex; align-items: flex-start; gap: 8px; }
.checkbox-field input { width: auto; margin-top: 3px; }
.checkbox-field label { font-weight: 500; margin: 0; }

/* --- Badges / tags --- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.75rem; font-weight: 600; padding: 3px 9px; border-radius: 99px;
}
.badge-public { background: color-mix(in srgb, var(--color-public) 18%, transparent); color: var(--color-public); }
.badge-private { background: color-mix(in srgb, var(--color-private) 18%, transparent); color: var(--color-private); }

/* --- Alerts --- */
.alert { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 0.9rem; margin-bottom: 16px; }
.alert-error { background: var(--color-danger-bg); color: var(--color-danger); }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning-text); }

/* --- Empty states --- */
.empty-state {
  text-align: center; padding: 48px 20px; color: var(--color-text-muted);
}
.empty-state h3 { color: var(--color-text); }

/* --- Avatar / person thumb --- */
.avatar {
  border-radius: 50%; object-fit: cover; background: var(--color-surface-alt);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-muted); font-weight: 700; font-family: var(--font-serif);
  flex-shrink: 0;
}

/* --- Utility --- */
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wrap { flex-wrap: wrap; }
.mt-0 { margin-top: 0; }
.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--color-border); border-top-color: var(--color-primary);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

footer.site-footer {
  text-align: center; color: var(--color-text-muted); font-size: 0.82rem;
  padding: 24px 0 40px;
}
