:root {
  --bg: #faf6f0;
  --card: #ffffff;
  --ink: #2f2a26;
  --muted: #8a7f74;
  --line: #e7ddd0;
  --accent: #b5533a;
  --accent-dark: #9a3f29;
  --chip: #f0e7da;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
       background: var(--bg); color: var(--ink); }
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar { display: flex; align-items: center; gap: 16px; padding: 12px 22px;
          background: var(--accent); color: #fff; position: sticky; top: 0; z-index: 10; }
.brand { color: #fff; font-size: 1.6rem; font-weight: 800; display: flex; align-items: center; gap: 11px; }
.brand:hover { text-decoration: none; }
.brandlogo { width: 52px; height: 52px; border-radius: 11px; display: block;
             box-shadow: 0 2px 5px rgba(0,0,0,.22); }
.search { flex: 1; display: flex; gap: 6px; max-width: 520px; }
.search input { flex: 1; padding: 8px 12px; border: none; border-radius: 6px; font-size: 1rem; }
.search button, .actions .btn { white-space: nowrap; }
.actions { display: flex; gap: 8px; }

.btn { display: inline-block; background: var(--accent-dark); color: #fff; border: none;
       padding: 8px 14px; border-radius: 6px; font-size: .95rem; cursor: pointer; }
.btn:hover { background: #7f3221; text-decoration: none; }
.btn.ghost { background: rgba(255,255,255,.18); }
.topbar .btn.ghost { color:#fff; }
.btn.ghost:not(.topbar *) { background: #fff; color: var(--accent-dark); border: 1px solid var(--line); }
.content .btn.ghost { background:#fff; color: var(--accent-dark); border:1px solid var(--line); }
.btn.danger { background: #fff; color: #b5533a; border: 1px solid #e3b4a8; }
.btn.danger:hover { background: #fbeae6; }
button.search, .search button { background: var(--accent-dark); color:#fff; border:none; border-radius:6px; padding:8px 14px; cursor:pointer; }

.flash { background: #fff6e8; border: 1px solid #f0d8a8; color: #7a5a1a;
         padding: 10px 18px; margin: 10px 22px; border-radius: 6px; }

.layout { display: grid; grid-template-columns: 240px 1fr; gap: 28px; padding: 22px 32px;
          max-width: 100%; margin: 0; }
.sidebar h3 { margin: 6px 0 10px; color: var(--muted); font-size: .8rem;
              text-transform: uppercase; letter-spacing: .05em; }
.catlist { list-style: none; margin: 0; padding: 0; }
.catlist li a { display: flex; justify-content: space-between; padding: 7px 10px;
                border-radius: 6px; color: var(--ink); }
.catlist li a:hover { background: var(--chip); text-decoration: none; }
.catlist li a.active { background: var(--accent); color: #fff; }
.count { color: var(--muted); font-size: .85rem; }
.catlist a.active .count { color: #ffdccf; }
.subcats { margin-top: 14px; }
.subcats summary { cursor: pointer; color: var(--muted); font-size: .8rem;
                   text-transform: uppercase; letter-spacing: .05em; padding: 6px 10px; }
.subcats summary:hover { color: var(--accent-dark); }
.subcats .catlist { max-height: 340px; overflow-y: auto; margin-top: 6px; }

.content-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.content-head h1 { margin: 0; }
.muted { color: var(--muted); font-size: .9rem; }
.sortform { margin-left: auto; font-size: .9rem; color: var(--muted); }
.sortform select { font: inherit; padding: 5px 8px; border: 1px solid var(--line);
                   border-radius: 6px; margin-left: 4px; background: #fff; }

.stars { white-space: nowrap; letter-spacing: 1px; line-height: 1; }
.stars .on { color: #e8a000; }
.stars .off { color: #d9cdbd; }
.card-body .stars { font-size: .95rem; display: inline-block; margin-bottom: 6px; }
.recipe-stars { margin: 2px 0 10px; font-size: 1.3rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px;
        overflow: hidden; display: flex; flex-direction: column; transition: box-shadow .15s, transform .15s; }
.card:hover { box-shadow: 0 6px 18px rgba(0,0,0,.08); transform: translateY(-2px); text-decoration: none; }
.thumb { aspect-ratio: 4/3; background: var(--chip); display: flex; align-items: center; justify-content: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.noimg { font-size: 2.4rem; opacity: .5; }
.card-body { padding: 12px 14px; }
.card-body h3 { margin: 0 0 6px; color: var(--ink); font-size: 1.05rem; }
.card-body p { margin: 0 0 8px; color: var(--muted); font-size: .88rem; }
.meta { display: flex; gap: 12px; color: var(--muted); font-size: .82rem; }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }

.pager { display: flex; align-items: center; justify-content: center; gap: 16px;
         margin: 28px 0 8px; }

/* recipe view */
.recipe { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 26px; max-width: 1150px; }
.recipe-head { display: flex; gap: 24px; justify-content: space-between; }
.recipe-head h1 { margin: 0 0 8px; }
.lead { color: #5c544b; font-size: 1.05rem; }
.hero { width: 300px; max-width: 40%; border-radius: 10px; object-fit: cover; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tag { background: var(--chip); padding: 3px 10px; border-radius: 20px; font-size: .8rem; }

.facts { display: flex; flex-wrap: wrap; gap: 10px 26px; margin: 18px 0; padding: 14px 0;
         border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.facts div { display: flex; flex-direction: column; }
.facts b { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

.toolbar { display: flex; align-items: center; gap: 10px; margin: 16px 0; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.scale input { width: 70px; padding: 6px; border: 1px solid var(--line); border-radius: 6px; }
.scale button { background: var(--accent-dark); color:#fff; border:none; padding:7px 12px; border-radius:6px; cursor:pointer; }

.recipe-body { display: grid; grid-template-columns: 1fr 1.4fr; gap: 34px; margin-top: 10px; }
.ingredients ul { list-style: none; padding: 0; }
.ingredients li { padding: 6px 0; border-bottom: 1px dashed var(--line); display: flex; gap: 8px; }
.ingredients .amt { font-weight: 600; min-width: 70px; }
.ing-head, .dir-head { font-weight: 700; color: var(--accent-dark); border-bottom: none !important;
                        margin-top: 10px; display: block !important; }
.directions ol { padding-left: 1.2em; }
.directions li { margin: 10px 0; line-height: 1.55; }
.note { background: var(--bg); border-left: 3px solid var(--accent); padding: 10px 14px;
        margin-top: 16px; border-radius: 0 6px 6px 0; }
.note h3 { margin: 0 0 4px; font-size: .95rem; }

/* forms */
.editform, .importbox { background: var(--card); border: 1px solid var(--line);
                        border-radius: 12px; padding: 26px; max-width: 900px; }
.editform label, .uploadform { display: block; margin: 14px 0; font-weight: 600; }
.editform input, .editform textarea { width: 100%; margin-top: 5px; padding: 9px 11px;
        border: 1px solid var(--line); border-radius: 7px; font: inherit; font-weight: 400; }
.editform textarea { resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.formbtns { display: flex; gap: 10px; margin-top: 20px; }
.editthumb { max-width: 240px; border-radius: 8px; margin-top: 8px; display: block; }

.addgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
           gap: 20px; max-width: 1100px; }
.addcard { background: var(--card); border: 1px solid var(--line); border-radius: 12px;
           padding: 22px; }
.addcard h2 { margin: 0 0 8px; font-size: 1.15rem; }
.addcard form { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.addcard input { padding: 10px 11px; border: 1px solid var(--line); border-radius: 7px; font: inherit; }
.addcard .btn { align-self: flex-start; }

.steps { line-height: 1.8; }
.uploadform { display: flex; gap: 12px; align-items: center; margin: 20px 0; font-weight: 400; }

/* login */
.loginwrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.loginbox { background: var(--card); border: 1px solid var(--line); border-radius: 12px;
            padding: 32px; width: 320px; box-shadow: 0 8px 30px rgba(0,0,0,.08); }
.loginbrand { font-size: 1.5rem; font-weight: 700; color: var(--accent); text-align: center; margin-bottom: 18px; }
.loginbrand img { border-radius: 12px; margin-bottom: 6px; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.loginbox label { display: block; margin: 12px 0; font-weight: 600; }
.loginbox input { width: 100%; margin-top: 5px; padding: 10px; border: 1px solid var(--line);
                  border-radius: 7px; font: inherit; }
.loginbox .btn { width: 100%; margin-top: 16px; text-align: center; }
.loginerr { background: #fbeae6; color: #9a3f29; padding: 9px 12px; border-radius: 6px; font-size: .9rem; }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .recipe-body { grid-template-columns: 1fr; }
  .recipe-head { flex-direction: column; }
  .hero { width: 100%; max-width: 100%; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
}
