:root {
  --bg: #f4f1e9;
  --surface: #fffdf8;
  --surface-2: #ece8dc;
  --text: #1d241f;
  --muted: #687068;
  --border: #d9d4c7;
  --accent: #c95f2d;
  --accent-dark: #9f431c;
  --green: #243b2b;
  --green-2: #31523b;
  --danger: #a92b2b;
  --shadow: 0 12px 35px rgba(35, 41, 36, .08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.skip-link {
  position: fixed;
  left: 1rem;
  top: -5rem;
  z-index: 100;
  padding: .75rem 1rem;
  background: var(--text);
  color: white;
  border-radius: 10px;
}
.skip-link:focus { top: 1rem; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .75rem 1.25rem;
  background: rgba(255, 253, 248, .93);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  text-decoration: none;
  margin-right: auto;
}
.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--green);
  font-size: 1.7rem;
  box-shadow: var(--shadow);
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 1.08rem; }
.brand small { color: var(--muted); font-size: .78rem; }
.topbar-actions { display: flex; gap: .5rem; }

.button, .icon-button {
  border: 0;
  border-radius: 12px;
  font-weight: 700;
  transition: .18s ease;
}
.button { padding: .72rem 1rem; }
.button:hover, .icon-button:hover { transform: translateY(-1px); }
.button-primary { background: var(--accent); color: white; }
.button-primary:hover { background: var(--accent-dark); }
.button-ghost { background: var(--surface-2); color: var(--text); }
.button-danger { background: #f3dddd; color: var(--danger); }
.icon-button {
  width: 42px;
  height: 42px;
  background: transparent;
  font-size: 1.5rem;
}

.app-shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: calc(100vh - 76px); }
.sidebar {
  position: sticky;
  top: 76px;
  height: calc(100vh - 76px);
  padding: 1.25rem 1rem;
  background: var(--green);
  color: white;
  overflow-y: auto;
}
.nav-label {
  margin: 1.35rem .75rem .5rem;
  color: #b8c8bc;
  font-size: .73rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .1em;
}
.nav-item {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  padding: .72rem .8rem;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #eef4ef;
  text-align: left;
}
.nav-item:hover, .nav-item.active { background: var(--green-2); color: white; }
.count {
  min-width: 26px;
  padding: .05rem .4rem;
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  text-align: center;
  font-size: .78rem;
}
.sidebar-note {
  margin-top: 2rem;
  padding: 1rem;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 15px;
  color: #d7e3d9;
  font-size: .84rem;
}
.sidebar-note p { margin: .35rem 0 0; }

.content { width: min(1240px, 100%); margin: 0 auto; padding: 2rem clamp(1rem, 3vw, 3rem) 4rem; }
.hero {
  display: grid;
  grid-template-columns: 1fr minmax(320px, 480px);
  align-items: end;
  gap: 2rem;
  padding: 1.6rem 0 2rem;
}
.eyebrow {
  margin: 0 0 .35rem;
  color: var(--accent-dark);
  font-weight: 850;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .12em;
}
h1 { margin: 0; font-size: clamp(2rem, 4vw, 3.7rem); line-height: 1.05; letter-spacing: -.04em; }
.hero p:not(.eyebrow) { color: var(--muted); max-width: 700px; }
.search-wrap {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: .65rem;
  padding: .85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 15px;
  box-shadow: var(--shadow);
}
.search-wrap input { min-width: 0; border: 0; outline: 0; background: transparent; font-size: 1rem; }
kbd { padding: .1rem .42rem; border: 1px solid var(--border); border-radius: 6px; color: var(--muted); background: var(--bg); }

.filter-row, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.filter-row { margin-bottom: 1.5rem; }
.chips { display: flex; gap: .5rem; flex-wrap: wrap; }
.chip {
  padding: .5rem .78rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 750;
}
.chip.active { border-color: var(--green); background: var(--green); color: white; }
.select-wrap { display: flex; align-items: center; gap: .55rem; color: var(--muted); font-size: .85rem; }
.select-wrap select { padding: .5rem .7rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.section-heading h2 { margin: 0; font-size: 1.25rem; }
.muted { color: var(--muted); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 245px;
  padding: 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 5px 20px rgba(35, 41, 36, .045);
  transition: .18s ease;
  overflow: hidden;
}
.card-with-image { padding-top: 0; }
.card-image {
  width: calc(100% + 2.3rem);
  height: 155px;
  margin: 0 -1.15rem 1rem;
  object-fit: cover;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: #c9c2b2; }
.card::after {
  content: "";
  position: absolute;
  right: -25px;
  top: -25px;
  width: 85px;
  height: 85px;
  border-radius: 50%;
  background: rgba(201,95,45,.08);
}
.card-top { display: flex; justify-content: space-between; gap: .75rem; align-items: start; }
.type-badge {
  display: inline-flex;
  padding: .28rem .58rem;
  border-radius: 999px;
  background: #e8eee9;
  color: var(--green);
  font-size: .72rem;
  font-weight: 850;
}
.favorite-button { border: 0; background: transparent; color: #b1aa9b; font-size: 1.25rem; z-index: 1; }
.favorite-button.active { color: #d3901b; }
.card h3 { margin: .9rem 0 .3rem; font-size: 1.2rem; line-height: 1.2; }
.card .path { color: var(--accent-dark); font-size: .8rem; font-weight: 760; }
.card p { color: var(--muted); margin: .65rem 0 1rem; }
.card-footer { margin-top: auto; display: flex; justify-content: space-between; align-items: end; gap: .7rem; }
.meta { display: flex; flex-wrap: wrap; gap: .35rem .7rem; color: var(--muted); font-size: .8rem; }
.open-button { border: 0; background: transparent; color: var(--accent-dark); font-weight: 850; }

.empty-state { text-align: center; padding: 5rem 1rem; color: var(--muted); }
.empty-icon { font-size: 3rem; }
.hidden { display: none !important; }
.mobile-only { display: none; }

/* Dialogs */
dialog { border: 0; padding: 0; color: var(--text); background: var(--surface); box-shadow: 0 25px 80px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(18, 24, 20, .58); backdrop-filter: blur(3px); }
.detail-dialog { width: min(760px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); border-radius: 22px; }
.detail-dialog article { padding: clamp(1.2rem, 4vw, 2rem); }
.detail-image {
  width: 100%;
  max-height: 360px;
  margin: .8rem 0 1rem;
  border-radius: 16px;
  object-fit: cover;
  background: var(--surface-2);
}
.detail-header { display: flex; gap: 1rem; justify-content: space-between; align-items: start; }
.detail-header h2 { font-size: clamp(1.7rem, 4vw, 2.6rem); margin: .2rem 0; letter-spacing: -.03em; }
.detail-actions { display: flex; gap: .45rem; flex-wrap: wrap; margin: 1.2rem 0; }
.detail-summary { color: var(--muted); font-size: 1.05rem; }
.detail-meta { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0 1.4rem; }
.meta-pill { padding: .4rem .65rem; background: var(--surface-2); border-radius: 999px; font-size: .82rem; }
.steps { list-style: none; margin: 1rem 0; padding: 0; counter-reset: steps; }
.steps li { counter-increment: steps; display: grid; grid-template-columns: 38px 1fr; gap: .8rem; padding: .8rem 0; border-bottom: 1px solid var(--border); }
.steps li::before { content: counter(steps); width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--green); color: white; font-weight: 850; }
.tip-box { padding: 1rem; border-left: 4px solid var(--accent); background: #f7ece5; border-radius: 0 12px 12px 0; }
.tip-box ul { margin: .5rem 0 0; padding-left: 1.2rem; }
.ingredient-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: .45rem 1.25rem;
  margin: .8rem 0 1.5rem;
  padding: 0;
  list-style: none;
}
.ingredient-list li {
  position: relative;
  padding: .55rem .7rem .55rem 1.55rem;
  border-radius: 10px;
  background: var(--surface-2);
}
.ingredient-list li::before {
  content: "•";
  position: absolute;
  left: .65rem;
  color: var(--accent-dark);
  font-weight: 900;
}
.detail-dialog h3 small { color: var(--muted); font-size: .8rem; font-weight: 600; }
.related-list { display: flex; gap: .45rem; flex-wrap: wrap; }
.related-button { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: .45rem .7rem; }

.editor-dialog { width: min(820px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); border-radius: 22px; }
.editor-dialog form { padding: 1.5rem; overflow-y: auto; max-height: calc(100vh - 2rem); }
.dialog-header, .dialog-footer { display: flex; align-items: center; gap: .8rem; }
.dialog-header { justify-content: space-between; margin-bottom: 1rem; }
.dialog-header h2 { margin: 0; }
.dialog-footer { margin-top: 1rem; }
.spacer { flex: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.editor-dialog label { display: grid; gap: .35rem; margin-bottom: .8rem; font-weight: 750; }
.editor-dialog label small { color: var(--muted); font-weight: 500; }
.editor-dialog input, .editor-dialog textarea, .editor-dialog select {
  width: 100%;
  padding: .75rem .85rem;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: white;
}
.editor-dialog textarea { resize: vertical; }

.cook-dialog { width: 100vw; height: 100vh; max-width: none; max-height: none; background: var(--green); color: white; }
.cook-shell { height: 100%; display: grid; grid-template-rows: auto 1fr auto; padding: clamp(1rem, 4vw, 3rem); }
.cook-shell header, .cook-shell footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.cook-shell main { display: grid; place-content: center; text-align: center; width: min(900px, 100%); margin: auto; }
.cook-shell .eyebrow { color: #eab08f; }
.cook-step { font-size: clamp(2rem, 5vw, 4.7rem); font-weight: 780; line-height: 1.12; letter-spacing: -.035em; }
.cook-shell .button-ghost { background: rgba(255,255,255,.12); color: white; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.2rem;
  z-index: 100;
  transform: translate(-50%, 130%);
  padding: .8rem 1rem;
  border-radius: 12px;
  background: #161b17;
  color: white;
  opacity: 0;
  transition: .25s ease;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 900px) {
  .mobile-only { display: inline-grid; place-items: center; }
  .topbar-actions .admin-action.button-ghost { display: none; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 76px auto 0 0;
    z-index: 25;
    width: min(320px, 86vw);
    transform: translateX(-105%);
    transition: transform .22s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .hero { grid-template-columns: 1fr; gap: 1rem; }
}

@media (max-width: 620px) {
  .topbar { padding-inline: .7rem; }
  .brand small { display: none; }
  .topbar-actions .button-primary { padding: .65rem .75rem; font-size: .85rem; }
  .content { padding-inline: 1rem; }
  .filter-row { align-items: start; flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
  .detail-actions .button { flex: 1; }
  .cook-shell footer .button { flex: 1; }
}

/* Server-, login- en synchronisatiestatus */
.sync-status {
  display: inline-flex;
  align-items: center;
  gap: .42rem;
  padding: .45rem .65rem;
  color: var(--muted);
  font-size: .78rem;
  white-space: nowrap;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3d8b52;
  box-shadow: 0 0 0 3px rgba(61, 139, 82, .12);
}
.sync-status[data-mode="working"] .status-dot { background: #c98a20; box-shadow: 0 0 0 3px rgba(201, 138, 32, .15); }
.sync-status[data-mode="error"] .status-dot { background: var(--danger); box-shadow: 0 0 0 3px rgba(169, 43, 43, .13); }
.sync-status[data-mode="locked"] .status-dot { background: #7a807b; box-shadow: 0 0 0 3px rgba(122, 128, 123, .13); }

.security-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid #e0b7a6;
  border-radius: 15px;
  background: #fff0e9;
}
.security-banner p { margin: .2rem 0 0; color: var(--muted); }

.locked-state {
  max-width: 620px;
  margin: 2rem auto;
  padding: clamp(2rem, 6vw, 4rem);
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}
.locked-state h2 { margin-bottom: .3rem; }
.locked-state p { color: var(--muted); margin: 0 0 1.2rem; }

.auth-dialog {
  width: min(520px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  border-radius: 22px;
}
.auth-dialog form,
.account-shell {
  padding: 1.5rem;
}
.auth-dialog label {
  display: grid;
  gap: .35rem;
  margin-bottom: .85rem;
  font-weight: 750;
}
.auth-dialog input {
  width: 100%;
  padding: .75rem .85rem;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: white;
}
.account-section {
  padding: 1rem 0;
  border-top: 1px solid var(--border);
}
.account-section h3 { margin: 0 0 .75rem; }
.account-section p { color: var(--muted); }
.account-section form { padding: 0; }
.account-footer { padding-top: 1rem; border-top: 1px solid var(--border); }
.form-error {
  margin: .6rem 0;
  padding: .65rem .75rem;
  border-radius: 10px;
  background: #f7dddd;
  color: var(--danger);
  font-size: .88rem;
  font-weight: 700;
}
button:disabled {
  cursor: not-allowed;
  opacity: .55;
  transform: none !important;
}
.related-button:disabled { cursor: default; opacity: .62; }
.favorite-button:focus-visible,
.open-button:focus-visible,
.related-button:focus-visible,
.button:focus-visible,
.icon-button:focus-visible,
.nav-item:focus-visible,
.chip:focus-visible {
  outline: 3px solid rgba(201, 95, 45, .3);
  outline-offset: 2px;
}

@media (max-width: 1050px) {
  .sync-status span:last-child { display: none; }
  .sync-status { padding-inline: .25rem; }
}

@media (max-width: 620px) {
  .security-banner { align-items: stretch; flex-direction: column; }
  .topbar-actions { gap: .3rem; }
  .topbar-actions .button { padding: .63rem .7rem; font-size: .82rem; }
  .sync-status { display: none; }
}

/* Community en afbeeldingsbeheer (v0.4) */
.form-span-2 { grid-column: 1 / -1; }
.draft-badge {
  padding: .24rem .5rem;
  border-radius: 999px;
  background: #fff4d6;
  color: #7a4b00;
  font-size: .72rem;
  font-weight: 750;
}
.community-meta,
.byline {
  display: flex;
  align-items: center;
  gap: .55rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: .84rem;
}
.community-meta { margin-top: auto; padding-top: .65rem; }
.author-link,
.link-button {
  border: 0;
  padding: 0;
  background: none;
  color: var(--primary);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}
.author-link:hover,
.link-button:hover { text-decoration: underline; }
.danger-link { color: var(--danger); }

.image-editor {
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.image-editor legend { padding: 0 .4rem; font-weight: 750; }
.image-editor legend small { color: var(--muted); font-weight: 500; }
.image-editor-layout {
  display: grid;
  grid-template-columns: minmax(150px, 220px) 1fr;
  gap: 1rem;
  align-items: center;
}
.image-preview {
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px dashed var(--border-strong, var(--border));
  border-radius: calc(var(--radius) - 2px);
  background: var(--surface-soft, #f6f7f4);
  color: var(--muted);
}
.image-preview img { width: 100%; height: 100%; object-fit: cover; }
.file-button { display: inline-flex; margin-right: .5rem; margin-bottom: .5rem; }
.field-help { margin: .6rem 0 0; color: var(--muted); font-size: .82rem; line-height: 1.45; }

.comments-section { border-top: 1px solid var(--border); padding-top: 1.2rem; }
.comment {
  padding: .9rem 0;
  border-bottom: 1px solid var(--border);
}
.comment:last-child { border-bottom: 0; }
.comment-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: .82rem;
}
.comment p { margin: .55rem 0; line-height: 1.55; }
.comment-actions { display: flex; gap: .8rem; font-size: .82rem; }
.comment-form { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.comment-form > div { display: flex; justify-content: flex-end; }
.login-prompt { margin: 1rem 0 0; color: var(--muted); }

.profile-body { padding: 0 1.25rem 1.25rem; }
.profile-stats {
  display: flex;
  gap: 1rem;
  margin: 1rem 0 1.25rem;
}
.profile-stats span {
  padding: .65rem .85rem;
  border-radius: var(--radius);
  background: var(--surface-soft, #f6f7f4);
}
.profile-stats strong { display: block; font-size: 1.2rem; }
.profile-items { display: grid; gap: .5rem; }
.profile-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  width: 100%;
  padding: .75rem .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.profile-item:hover { border-color: var(--primary); }
.profile-item small { color: var(--muted); }
.wide-dialog { width: min(680px, calc(100vw - 1.5rem)); }
.auth-footer { flex-wrap: wrap; }

@media (max-width: 640px) {
  .image-editor-layout { grid-template-columns: 1fr; }
  .image-preview { max-width: 100%; }
  .comment-head { align-items: flex-start; flex-direction: column; gap: .2rem; }
  .profile-item { align-items: flex-start; flex-direction: column; gap: .2rem; }
}
