:root {
  --paper: #FBF7F0;
  --surface: #FFFFFF;
  --ink: #2A2420;
  --muted: #8A7F72;
  --line: #E8DFD3;
  --copper: #C2683B;
  --copper-d: #9E4F2A;
  --sage: #6E7B5A;
  --danger: #B23A2E;
  --radius: 16px;
  --tap: 52px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 18px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
}

a { color: var(--copper-d); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--ink);
  color: var(--paper);
  flex-wrap: wrap;
}
.brand {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--paper);
  letter-spacing: -0.02em;
}
.brand span { color: var(--copper); }
.brand:hover { text-decoration: none; }
.brand-big { font-size: 2.2rem; }
.nav { display: flex; align-items: center; gap: 0.5rem 1rem; flex-wrap: wrap; }
.nav a { color: var(--paper); font-weight: 600; }
.logout-form { margin: 0; }
.link-btn {
  background: none; border: none; color: var(--paper);
  font: inherit; font-weight: 600; cursor: pointer; padding: 0;
}

/* Layout */
.container { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1rem 4rem; }

h1 { font-size: 1.8rem; margin: 0.2em 0 0.6em; }
h2 { font-size: 1.3rem; }
.muted { color: var(--muted); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); padding: 0 1.25rem;
  border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 700; cursor: pointer;
  text-decoration: none;
}
.btn:hover { text-decoration: none; border-color: var(--copper); }
.btn-primary { background: var(--copper); border-color: var(--copper); color: #fff; }
.btn-primary:hover { background: var(--copper-d); border-color: var(--copper-d); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-big { min-height: 60px; font-size: 1.15rem; width: 100%; }
.btn-small { min-height: 40px; padding: 0 0.8rem; font-size: 0.9rem; }

/* Cards / forms */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.stack { display: flex; flex-direction: column; gap: 1rem; }
.stack label { display: flex; flex-direction: column; gap: 0.35rem; font-weight: 600; }
input[type=text], input[type=password], input[type=search], input[type=file],
textarea, select {
  font: inherit; padding: 0.7rem 0.9rem;
  border: 2px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink);
  min-height: var(--tap);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--copper); border-color: var(--copper); }

.alert { padding: 0.8rem 1rem; border-radius: 12px; margin-bottom: 1rem; }
.alert-danger { background: #f7e3e0; color: var(--danger); border: 1px solid var(--danger); }

/* Login */
.login-wrap { display: flex; justify-content: center; padding-top: 3rem; }
.login-card { max-width: 420px; width: 100%; text-align: center; }
.login-card .brand-big { display: inline-block; margin: 0 0 0.2em; }
.login-card form { margin-top: 1.25rem; text-align: left; }

/* Search + chips */
.searchbar { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.searchbar input { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.25rem; }
.chip {
  display: inline-flex; align-items: center;
  padding: 0.45rem 0.9rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--ink); font-weight: 600; font-size: 0.95rem;
}
.chip:hover { text-decoration: none; border-color: var(--sage); }
.chip-active { background: var(--sage); border-color: var(--sage); color: #fff; }

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}
.tile {
  display: block; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; color: var(--ink);
}
.tile:hover { text-decoration: none; border-color: var(--copper); }
.tile-thumb { position: relative; aspect-ratio: 3 / 4; background: var(--paper); }
.tile-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-placeholder { display: flex; align-items: center; justify-content: center; height: 100%; font-size: 3rem; }
.badge {
  position: absolute; left: 0.5rem; bottom: 0.5rem;
  background: rgba(42,36,32,0.85); color: #fff;
  font-size: 0.75rem; padding: 0.2rem 0.5rem; border-radius: 8px;
}
.tile-title { padding: 0.7rem 0.8rem; font-weight: 700; }

.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-icon { font-size: 3rem; margin: 0; }

/* Detail */
.back-link { display: inline-block; margin-bottom: 0.5rem; font-weight: 600; }
.recipe-title { margin-top: 0.2rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0; }
.viewer { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.viewer iframe { width: 100%; height: 80vh; border: 0; display: block; }
.viewer img { width: 100%; height: auto; display: block; }
.note { margin-top: 1.25rem; }
.edit-block { margin-top: 1.5rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; }
.edit-block summary { font-weight: 700; cursor: pointer; min-height: var(--tap); display: flex; align-items: center; }
.edit-block form { margin-top: 1rem; }
.delete-form { margin-top: 1rem; }

.tag-grid { border: 1px solid var(--line); border-radius: 12px; padding: 0.8rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.4rem; }
.tag-grid legend { font-weight: 700; padding: 0 0.4rem; }
.check { display: flex; flex-direction: row; align-items: center; gap: 0.5rem; font-weight: 500; }
.check input { min-height: auto; width: 1.2rem; height: 1.2rem; }

/* Users */
.credentials { border: 2px solid var(--sage); }
.cred-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin: 0.5rem 0; }
.cred-label { font-weight: 700; min-width: 120px; }
.cred-row code { background: var(--paper); padding: 0.4rem 0.6rem; border-radius: 8px; font-size: 1.05rem; }
.user-table { width: 100%; border-collapse: collapse; }
.user-table th, .user-table td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--line); }
.row-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.inline-form { margin: 0; }
