/* Shared styles for all pages: colour tokens, base elements, buttons,
   inputs, messages and the app header. Page-specific CSS goes in its own file. */

:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --text: #1f1d1a;
  --muted: #6b665e;
  --border: #d9d4ca;
  --border-strong: #b9b2a5;
  --accent: #8a6a1f;
  --accent-text: #ffffff;
  --accent-hover: #73581a;
  --focus: #c89b2e;
  --error-bg: #fdecea;
  --error-text: #8c1d18;
  --ok-bg: #e7f4ea;
  --ok-text: #1d5e2c;
  --warn-bg: #fff4d6;
  --warn-text: #6b4e00;
  --dirty-bg: #fff8e1;
  --new-bg: #eef6ff;
  --archived-text: #8a857c;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141311;
    --card: #1e1c19;
    --text: #ece8e1;
    --muted: #a39d93;
    --border: #3a3631;
    --border-strong: #57514a;
    --accent: #d4a945;
    --accent-text: #1a1609;
    --accent-hover: #e2bb5e;
    --focus: #e2bb5e;
    --error-bg: #3a1714;
    --error-text: #ffb4ab;
    --ok-bg: #15301c;
    --ok-text: #9fe0ad;
    --warn-bg: #3a2f10;
    --warn-text: #f3d27a;
    --dirty-bg: #352c12;
    --new-bg: #13263a;
    --archived-text: #7d776e;
  }
}

* { box-sizing: border-box; }

/* `hidden` must win over any display rule below. */
[hidden] { display: none !important; }

html, body { min-height: 100%; }

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

h1, h2, h3 { margin: 0; line-height: 1.25; }

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

label { font-size: 0.9rem; font-weight: 500; }

input, select, textarea {
  width: 100%;
  min-width: 0;
  padding: 9px 11px;
  font: inherit;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

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

input:focus-visible, select:focus-visible, textarea:focus-visible,
button:focus-visible, a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

[aria-invalid="true"] { border-color: var(--error-text); }

button {
  font: inherit;
  border-radius: var(--radius);
  cursor: pointer;
}

button:disabled { cursor: not-allowed; opacity: 0.6; }

button.primary {
  padding: 9px 16px;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent);
  border: 0;
}

button.primary:hover:not(:disabled) { background: var(--accent-hover); }
button.primary:disabled { background: var(--border); color: var(--muted); opacity: 1; }

button.ghost, a.button {
  display: inline-block;
  padding: 8px 12px;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  text-decoration: none;
}

button.ghost:hover:not(:disabled), a.button:hover { border-color: var(--border-strong); }

button.danger { color: var(--error-text); }

button.small { padding: 4px 10px; font-size: 0.85rem; }

.message {
  margin: 0;
  padding: 10px 12px;
  font-size: 0.9rem;
  border-radius: var(--radius);
  color: var(--error-text);
  background: var(--error-bg);
}

.message.ok { color: var(--ok-text); background: var(--ok-bg); }
.message.warn { color: var(--warn-text); background: var(--warn-bg); }

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

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------------------------------------------------------------- app header */

.app-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.app-header .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}

.brand-mark { width: 24px; height: 24px; fill: var(--accent); }

.app-header nav { display: flex; gap: 4px; flex: 1; }

.app-header nav a {
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}

.app-header nav a[aria-current="page"] { background: var(--bg); font-weight: 600; }

.app-header .user { display: flex; align-items: center; gap: 8px; }

@media (max-width: 640px) {
  .app-header { flex-wrap: wrap; gap: 8px; }
  .app-header .user .user-name { display: none; }
}

main.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 16px 0;
}

.toolbar .spacer { flex: 1; }

.toolbar input[type="search"] { width: 16rem; max-width: 100%; }

.toolbar select { width: auto; }

.badge {
  display: inline-block;
  padding: 1px 8px;
  font-size: 0.8rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
}
