/* Burger Family Farm portal: design tokens + components.
   Restyle the whole portal by editing the tokens in the first two blocks. */

:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efeee8;
  --fg: #1f2420;
  --muted: #5f675f;
  --line: #dcdcd3;
  --accent: #2f6b46;
  --accent-fg: #ffffff;
  --accent-soft: #e1eee4;
  --danger: #b3261e;
  --danger-soft: #fbe6e4;
  --warn: #8a5a00;
  --warn-soft: #fbf0d9;
  --info-soft: #e4ecf6;
  --lead: #6b3fa0;
  --lead-soft: #efe6f8;
  --ins: #dff3e2;
  --del: #fbe2df;
  --focus: #2f6b46;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 8px;
  --sidebar-w: 248px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151916; --surface: #1d221e; --surface-2: #252b26; --fg: #e4e8e3; --muted: #9ba59c;
    --line: #313a33; --accent: #6cbf88; --accent-fg: #0f1a12; --accent-soft: #1f3326;
    --danger: #ff8a80; --danger-soft: #3a1f1d; --warn: #f0b45e; --warn-soft: #352916;
    --info-soft: #1c2735; --lead: #c39bef; --lead-soft: #2b2238; --ins: #1d3a24; --del: #3e2220;
    --focus: #6cbf88;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 15px/1.55 var(--font); }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0; text-wrap: balance; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }
.skip-link:focus { left: 8px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Layout */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--fg); text-decoration: none; padding: 4px 8px; }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-fg); font-weight: 800; }
.side-nav, .side-section { display: flex; flex-direction: column; gap: 2px; }
.side-nav a, .side-link { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; border-radius: 6px; color: var(--fg); text-decoration: none; }
.side-nav a:hover, .side-link:hover { background: var(--surface-2); }
.side-nav a[aria-current="page"] { background: var(--accent-soft); font-weight: 600; }
.side-heading { font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 0 10px 4px; }
.side-heading a { color: inherit; text-decoration: none; }
.side-empty { color: var(--muted); font-size: 0.85rem; padding: 2px 10px; }
.side-link { font-size: 0.92rem; }
.lock { color: var(--lead); font-size: 0.6rem; }
.count { background: var(--accent); color: var(--accent-fg); border-radius: 999px; font-size: 0.72rem; padding: 1px 7px; font-weight: 700; }
.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 24px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.search { flex: 1; max-width: 520px; }
.search input { width: 100%; }
.topbar .menu-toggle { display: none; }
.content { padding: 24px; max-width: 1180px; width: 100%; display: flex; flex-direction: column; gap: 20px; }
.env-banner { background: var(--warn-soft); color: var(--warn); text-align: center; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.06em; padding: 4px; }
.notice { background: var(--info-soft); padding: 8px 24px; font-size: 0.9rem; }
.flashes { padding: 12px 24px 0; display: grid; gap: 8px; }
@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(80vw, var(--sidebar-w)); transform: translateX(-100%); transition: transform .2s; z-index: 20; box-shadow: 0 0 0 100vmax transparent; }
  .sidebar.is-open { transform: none; box-shadow: 0 0 0 100vmax rgb(0 0 0 / 0.35); }
  .topbar .menu-toggle { display: inline-flex; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

/* Account menu */
.menu { position: relative; margin-left: auto; }
.menu summary { list-style: none; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 8px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; min-width: 220px; display: grid; gap: 2px; box-shadow: 0 8px 24px rgb(0 0 0 / 0.12); }
.menu-panel a, .menu-panel button { display: block; width: 100%; text-align: left; padding: 7px 10px; border-radius: 6px; color: var(--fg); text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer; }
.menu-panel a:hover, .menu-panel button:hover { background: var(--surface-2); }
.menu-who { padding: 6px 10px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }

/* Avatars, chips */
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 0.8rem; flex: none; }
.avatar-sm { width: 24px; height: 24px; font-size: 0.68rem; }
.chip { display: inline-block; font-size: 0.72rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip-lead { background: var(--lead-soft); color: var(--lead); }
.chip-active { background: var(--accent-soft); color: var(--accent); }
.chip-on_hold { background: var(--warn-soft); color: var(--warn); }
.chip-done { background: var(--info-soft); }
.chip-overdue { background: var(--danger-soft); color: var(--danger); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 6px; padding: 7px 14px; font: inherit; font-weight: 600; font-size: 0.92rem; border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn-primary { background: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--surface); color: var(--fg); border-color: var(--line); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--fg); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 0.82rem; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* Forms */
.form { display: grid; gap: 14px; }
.form.narrow { max-width: 560px; }
.field { display: grid; gap: 4px; }
.field label { font-weight: 600; font-size: 0.9rem; }
input[type="text"], input[type="email"], input[type="search"], input[type="date"], input[type="number"], input[type="url"], input:not([type]), select, textarea {
  width: 100%; font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px;
}
textarea { min-height: 120px; resize: vertical; }
textarea.editor { font-family: var(--mono); font-size: 0.9rem; min-height: 420px; line-height: 1.5; }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.help { color: var(--muted); font-size: 0.82rem; }
.error { color: var(--danger); font-size: 0.85rem; }
.has-error input, .has-error textarea, .has-error select { border-color: var(--danger); }
.form-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form select, .inline-form input { width: auto; flex: 1 1 180px; }
.code-input { font-family: var(--mono); font-size: 1.6rem; letter-spacing: 0.4em; text-align: center; }

/* Alerts */
.alert { border-radius: 6px; padding: 9px 12px; background: var(--info-soft); font-size: 0.92rem; }
.alert-success { background: var(--accent-soft); }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-warning { background: var(--warn-soft); color: var(--warn); }

/* Page structure */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head > div { display: grid; gap: 4px; min-width: 0; }
.eyebrow { font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.space-head { display: grid; gap: 12px; border-bottom: 1px solid var(--line); padding-bottom: 0; }
.space-title { display: grid; gap: 4px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: -1px; }
.tabs a { padding: 8px 12px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; font-weight: 600; font-size: 0.92rem; }
.tabs a:hover { color: var(--fg); }
.tabs a[aria-current="page"] { color: var(--fg); border-bottom-color: var(--accent); }
.breadcrumbs { display: flex; gap: 6px; flex-wrap: wrap; font-size: 0.85rem; color: var(--muted); }
.breadcrumbs a { color: var(--muted); }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.overview-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; align-items: start; }
.with-aside { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 24px; align-items: start; }
@media (max-width: 960px) { .with-aside { grid-template-columns: minmax(0, 1fr); } }

/* Panels, cards, lists */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.panel-head a { font-size: 0.85rem; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 6px; align-content: start; min-width: 0; }
.card-link { color: inherit; text-decoration: none; }
.card-link:hover { border-color: var(--accent); }
.card-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card-title { font-size: 1rem; margin-right: auto; }
.is-archived { opacity: 0.65; }
.list { list-style: none; margin: 0; padding: 0; display: grid; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 4px; border-bottom: 1px solid var(--line); min-width: 0; }
.list-row:last-child { border-bottom: 0; }
.list.compact .list-row { padding: 6px 2px; }
.list-main { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--fg); text-decoration: none; overflow-wrap: anywhere; }
a.list-main:hover { color: var(--accent); }
.is-unread .list-main { font-weight: 600; }
.empty { color: var(--muted); padding: 18px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }
.empty.small { padding: 10px; font-size: 0.9rem; text-align: left; border: 0; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
.table th, .table td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 0.75rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); }
.table tr:last-child td { border-bottom: 0; }

/* Page tree (docs) */
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { padding-left: 14px; border-left: 1px solid var(--line); margin-left: 6px; }
.tree a { display: block; padding: 3px 8px; border-radius: 5px; color: var(--fg); text-decoration: none; font-size: 0.92rem; }
.tree a:hover { background: var(--surface-2); }
.tree a[aria-current="page"] { background: var(--accent-soft); font-weight: 600; }

/* Rendered Markdown */
.prose { line-height: 1.65; overflow-wrap: anywhere; max-width: 76ch; }
.prose > * + * { margin-top: 0.8em; }
.prose h1 { font-size: 1.5rem; } .prose h2 { font-size: 1.25rem; margin-top: 1.4em; } .prose h3 { font-size: 1.05rem; margin-top: 1.2em; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose code { font-family: var(--mono); font-size: 0.88em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.prose pre { background: var(--surface-2); padding: 12px; border-radius: 6px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose blockquote { border-left: 3px solid var(--line); margin-left: 0; padding-left: 12px; color: var(--muted); }
.prose table { border-collapse: collapse; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 6px 10px; }
.prose img { max-width: 100%; }
.prose input[type="checkbox"] { margin-right: 6px; }

/* Diffs */
.diff { font-family: var(--mono); font-size: 0.85rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.diff div { padding: 1px 10px; white-space: pre-wrap; }
.diff .ins { background: var(--ins); }
.diff .del { background: var(--del); text-decoration: line-through; text-decoration-color: rgb(0 0 0 / 0.25); }
.diff .ctx { color: var(--muted); }

/* To-dos */
.todo { display: flex; gap: 10px; align-items: flex-start; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.todo:last-child { border-bottom: 0; }
.todo input[type="checkbox"] { margin-top: 4px; width: 17px; height: 17px; accent-color: var(--accent); }
.todo-body { display: grid; gap: 2px; min-width: 0; flex: 1; }
.todo.is-done .todo-title { text-decoration: line-through; color: var(--muted); }
.todo-meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 0.82rem; color: var(--muted); }

/* Sign-in pages */
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 28px 24px; display: grid; gap: 16px; }
.auth-brand { font-size: 1.05rem; padding: 0; }
.auth-card .btn { width: 100%; padding: 10px 14px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.82rem; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }

/* htmx */
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
