/* Schnibbel — hand-written styles. */
:root {
  --bg: #f6f5f2;
  --fg: #1d1f1e;
  --muted: #5f6763;
  --card: #ffffff;
  --border: #d9dcd7;
  --accent: #2f6f5e;
  --accent-fg: #ffffff;
  --error: #a3262a;
  --selected: #e2efe9;
  --hover: rgba(0, 0, 0, 0.045);
  --radius: 10px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161817;
    --fg: #e7e9e6;
    --muted: #9aa39e;
    --card: #202321;
    --border: #353a37;
    --accent: #5fb39b;
    --accent-fg: #0d1a16;
    --error: #ff8a8a;
    --selected: #1f3a31;
    --hover: rgba(255, 255, 255, 0.06);
  }
}

*, *::before, *::after { box-sizing: border-box; }

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

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

.brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--fg);
  text-decoration: none;
}

main {
  max-width: 60rem;
  margin: 0 auto;
  padding: 1rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.narrow {
  max-width: 24rem;
  margin: 2rem auto;
}

h1 { font-size: 1.5rem; margin: 0 0 0.75rem; }

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

input[type="text"], input[type="password"], input[type="search"], input:not([type]) {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.55rem 0.7rem;
  font: inherit;
  font-weight: 400;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

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

button {
  font: inherit;
  padding: 0.55rem 1.1rem;
  color: var(--accent-fg);
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

button.linklike {
  padding: 0;
  color: var(--accent);
  background: none;
  text-decoration: underline;
}

form.inline { display: inline; margin: 0; }

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

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

/* Secondary buttons and button-like links. */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.7rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--fg);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:disabled:hover { border-color: var(--border); }
.btn.primary { color: var(--accent-fg); background: var(--accent); border-color: var(--accent); }
.btn.small { padding: 0.1rem 0.5rem; font-size: 0.8rem; }

/* Feed layout: sidebar filters next to search, composer and cards. */
.feed-layout {
  display: grid;
  grid-template-columns: 10.5rem minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.menu-btn { display: none; }

.sidebar { position: sticky; top: 1rem; font-size: 0.925rem; }
.nav { list-style: none; margin: 0 0 1rem; padding: 0; }
.nav a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.55rem;
  border-radius: 6px;
  color: var(--fg);
  text-decoration: none;
}
.nav a:hover { background: var(--hover); }
.nav a.on { background: var(--selected); color: var(--accent); font-weight: 600; }
.nav .icon { width: 1.25em; text-align: center; }
.nav .count { margin-left: auto; color: var(--muted); font-size: 0.8rem; font-weight: 400; }
.nav-head {
  margin: 0 0 0.3rem;
  padding: 0 0.55rem;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.feed-main { display: flex; flex-direction: column; gap: 0.75rem; min-width: 0; }
.search { margin: 0; }
.search input { margin-top: 0; }

.composer {
  padding: 0.6rem 0.75rem;
  background: var(--card);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
}
.composer:focus-within, body.dragging .composer { border-color: var(--accent); }
body.dragging .composer { background: var(--selected); }
.composer label { margin: 0; }
.composer textarea {
  display: block;
  width: 100%;
  min-height: 2.6rem;
  padding: 0.2rem 0;
  font: inherit;
  color: var(--fg);
  background: transparent;
  border: 0;
  resize: vertical;
}
.composer textarea:focus-visible { outline: none; }
.composer-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.9rem;
  margin-top: 0.4rem;
}
.composer-bar button[type="submit"] { margin-left: auto; padding: 0.35rem 1rem; }
.attach:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.switches { display: flex; gap: 0.9rem; }
.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}
.switch input[type="checkbox"] {
  appearance: none;
  position: relative;
  width: 2.1rem;
  height: 1.2rem;
  margin: 0;
  border-radius: 1rem;
  background: var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
.switch input[type="checkbox"]::before {
  content: "";
  position: absolute;
  top: 0.15rem;
  left: 0.15rem;
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}
.switch input[type="checkbox"]:checked { background: var(--accent); }
.switch input[type="checkbox"]:checked::before { transform: translateX(0.9rem); }
.switch input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled, .switch input:disabled + span { opacity: 0.5; cursor: not-allowed; }
.hint { margin: 0.4rem 0 0; font-size: 0.85rem; color: var(--muted); }
.post-status { margin: 0.3rem 0 0; font-size: 0.875rem; color: var(--muted); }
.post-status:empty { display: none; }

/* Cards */
.cards { display: flex; flex-direction: column; gap: 0.6rem; }
.item {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  padding: 0.75rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.thumb {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 96px;
  height: 54px;
  overflow: hidden;
  border-radius: 6px;
  background: var(--bg);
  font-size: 1.4rem;
  text-decoration: none;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.item-main { flex: 1; min-width: 0; }
.item-title { margin: 0; font-size: 1rem; line-height: 1.35; overflow-wrap: anywhere; }
.item-title a { color: var(--fg); text-decoration: none; }
.item-title a:hover { text-decoration: underline; }
.excerpt, .textbody {
  display: -webkit-box;
  margin: 0.15rem 0 0;
  overflow: hidden;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
}
.excerpt { font-size: 0.9rem; color: var(--muted); }
.textbody {
  margin: 0;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.875rem;
  -webkit-line-clamp: 6;
  line-clamp: 6;
}
.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  margin: 0.3rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}
.meta > * + *::before { content: "·"; display: inline-block; margin: 0 0.4rem; color: var(--muted); }
.meta a { color: var(--muted); }
.marker { color: var(--fg); font-weight: 500; }
.marker.busy { color: var(--accent); }
.tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.4rem 0 0; padding: 0; list-style: none; }
.tag {
  display: inline-block;
  padding: 0.05rem 0.55rem;
  font-size: 0.78rem;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 1rem;
  text-decoration: none;
}
.ai-mark { margin-right: 0.25rem; color: var(--accent); }
.problem {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.4rem;
  font-size: 0.85rem;
  color: var(--error);
}
.item-actions {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
}
.overflow { position: relative; }
.overflow summary { list-style: none; }
.overflow summary::-webkit-details-marker { display: none; }
.overflow .menu {
  position: absolute;
  top: calc(100% + 0.25rem);
  right: 0;
  z-index: 10;
  min-width: 10rem;
  padding: 0.3rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}
.menu form { margin: 0; }
.menu a, .menu button {
  display: block;
  width: 100%;
  padding: 0.4rem 0.6rem;
  font-size: 0.875rem;
  text-align: left;
  color: var(--fg);
  background: none;
  border-radius: 5px;
  text-decoration: none;
}
.menu a:hover, .menu button:hover { background: var(--hover); }
.menu .danger { color: var(--error); }
.more { display: flex; justify-content: center; padding: 0.5rem; }
.empty { padding: 2rem 0; text-align: center; color: var(--muted); }
.item ~ .empty { display: none; } /* a card arrived after the empty list was shown */

@media (max-width: 700px) {
  main { padding: 0.75rem; }
  .feed-layout { grid-template-columns: minmax(0, 1fr); gap: 0.75rem; }
  .menu-btn { display: inline-flex; justify-self: start; margin: 0; }
  .sidebar { display: none; position: static; }
  #menu-toggle:checked ~ .sidebar { display: block; }
  #menu-toggle:focus-visible + .menu-btn { outline: 2px solid var(--accent); outline-offset: 2px; }
  .item { flex-wrap: wrap; }
  .thumb { width: 64px; height: 48px; }
  .item-actions { width: 100%; justify-content: flex-start; }
}

/* settings */
ul.plain { list-style: none; padding: 0; }
ul.plain li { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 0.4rem 0; }
.notice { padding: 0.75rem 1rem; border: 1px solid var(--accent); border-radius: 6px; }
code.token { word-break: break-all; user-select: all; }

/* recipe page (mockup B: two tabs) */
.recipe-head { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 0.5rem; }
.recipe-title { min-width: 0; }
.recipe-title h1 { font-size: 1.2rem; line-height: 1.25; margin: 0 0 0.2rem; }
.media-viewer > summary { list-style: none; cursor: pointer; position: relative; display: block; }
.media-viewer > summary::-webkit-details-marker { display: none; }
.media-viewer .hero { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; background: var(--border); display: block; }
.media-viewer .play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 1.1rem; text-shadow: 0 0 4px rgba(0, 0, 0, 0.6); }
.recipe-head:has(.media-viewer[open]) { flex-wrap: wrap; }
.media-viewer[open] { flex-basis: 100%; }
.media-viewer .gallery { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.5rem; }
.gallery-item img, .gallery-item video { width: 100%; max-height: 70vh; object-fit: contain; border-radius: 8px; background: var(--card); }
.recipe-banner { padding: 0.5rem 0.75rem; border: 1px solid var(--accent); border-radius: 6px; font-size: 0.9rem; }
.tab-input { position: absolute; opacity: 0; pointer-events: none; }
.tabbar { display: flex; position: sticky; top: 0; z-index: 5; background: var(--card); border-bottom: 1px solid var(--border); }
.tabbar label { flex: 1; text-align: center; padding: 0.6rem 0; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; }
#tab-ing:checked ~ .tabbar label[for="tab-ing"],
#tab-steps:checked ~ .tabbar label[for="tab-steps"] { color: var(--accent); border-bottom-color: var(--accent); }
#tab-ing:focus-visible ~ .tabbar label[for="tab-ing"],
#tab-steps:focus-visible ~ .tabbar label[for="tab-steps"] { outline: 2px solid var(--accent); outline-offset: -2px; }
.panel { display: none; padding: 0.6rem 0; }
#tab-ing:checked ~ .panels .panel-ing,
#tab-steps:checked ~ .panels .panel-steps { display: block; }
.stepper { display: inline-flex; align-items: center; margin: 0.2rem 0 0.5rem; border: 1px solid var(--border); border-radius: 8px; background: var(--card); }
.stepper button { padding: 0.15rem 0.7rem; font-size: 1.1rem; color: var(--accent); background: none; border: 0; cursor: pointer; }
.stepper span { padding: 0 0.4rem; font-weight: 600; }
.ing-group { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0.9rem 0 0.2rem; }
ul.ingredients { list-style: none; margin: 0; padding: 0; }
ul.ingredients li { display: flex; gap: 0.6rem; padding: 0.45rem 0; border-bottom: 1px solid var(--border); cursor: pointer; }
ul.ingredients .box { flex: none; width: 18px; height: 18px; margin-top: 0.1rem; border: 2px solid var(--muted); border-radius: 4px; }
ul.ingredients .q { font-weight: 600; }
ul.ingredients li.done { color: var(--muted); text-decoration: line-through; }
ul.ingredients li.done .box { background: var(--accent); border-color: var(--accent); }
ol.steps { margin: 0; padding-left: 1.3rem; }
ol.steps li { margin-bottom: 0.6rem; }
.recipe-notes { white-space: pre-line; color: var(--muted); }
@media (min-width: 900px) {
  .tabbar { display: none; }
  .panels { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 2rem; }
  .panel, #tab-ing:checked ~ .panels .panel-ing, #tab-steps:checked ~ .panels .panel-steps { display: block; }
}

/* Recipes section: a grid of picture cards */
.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 0.75rem; }
.recipe-grid .more, .recipe-grid .empty { grid-column: 1 / -1; }
.recipe-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.5rem;
  color: var(--fg);
  text-decoration: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.recipe-card:hover { border-color: var(--accent); }
.recipe-pic {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 6px;
  background: var(--bg);
  font-size: 2rem;
}
.recipe-pic img { width: 100%; height: 100%; object-fit: cover; }
.recipe-card-title { font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.recipe-card-time { font-size: 0.85rem; color: var(--muted); }
@media (max-width: 700px) {
  .recipe-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.recipe-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 0.5rem 0; }

/* Recipe edit page */
.editform textarea, .editform input[type="number"] {
  display: block; width: 100%; margin-top: 0.3rem; padding: 0.55rem 0.7rem; font: inherit; font-weight: 400;
  color: var(--fg); background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
}
.editform .metarow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
.editform .ing-row { display: grid; grid-template-columns: 4.5rem 4.5rem 1fr auto; gap: 0.4rem; align-items: start; margin-bottom: 0.5rem; }
.editform .ing-row input { margin-top: 0; min-width: 0; }
.editform .ing-row input[name="ing_name"] { grid-column: 3; }
.editform .ing-row input[name="ing_group"] { grid-column: 1 / 4; grid-row: 2; }
.editform .ing-row .rm { grid-column: 4; grid-row: 1; }
.editform .step-row { display: flex; gap: 0.4rem; align-items: start; margin-bottom: 0.5rem; }
.editform .step-row textarea { margin-top: 0; }
.editform .rm { padding: 0.5rem 0.7rem; background: none; color: var(--error); border: 1px solid var(--border); }
.editform > button[type="submit"] { margin-top: 1rem; }
.media-list { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1.5rem; }
.media-item { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.media-item img { width: 96px; height: 72px; object-fit: cover; border-radius: 6px; background: var(--border); }
.media-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.hero-badge { font-size: 0.85rem; color: var(--accent); font-weight: 600; }
