@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,600;9..144,700&family=Inter:wght@400;500;600;700&display=swap");

:root {
  --oven-bruin: #7a3f24;
  --oven-donker: #4b281b;
  --meel: #f6efe2;
  --rogge: #e4d0b2;
  --gist-groen: #6f7f4d;
  --steen-grijs: #514d46;
  --zout-wit: #fffaf1;
  --lijn: rgba(81, 77, 70, 0.18);
  --schaduw: 0 18px 45px rgba(75, 40, 27, 0.12);
  --radius: 8px;
  color: var(--steen-grijs);
  background: var(--meel);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100vh; max-width: 100vw; overflow-x: hidden; }
body {
  background:
    linear-gradient(90deg, rgba(122,63,36,0.05) 1px, transparent 1px),
    linear-gradient(180deg, rgba(122,63,36,0.05) 1px, transparent 1px),
    var(--meel);
  background-size: 28px 28px;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; color: var(--oven-donker); font-family: Fraunces, Georgia, serif; line-height: 1.1; }
h1 { font-size: clamp(1.6rem, 5vw, 3.2rem); }
h2 { font-size: clamp(1.1rem, 3vw, 1.8rem); }

.app-shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 40px;
  display: grid;
  gap: 16px;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; padding: 16px 20px;
  background: var(--zout-wit); border: 1px solid var(--lijn);
  border-radius: var(--radius); box-shadow: var(--schaduw);
}

.brand-lockup { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  display: grid; place-items: center;
  width: clamp(44px, 7vw, 72px); aspect-ratio: 1;
  border: 2px solid rgba(111,127,77,0.22); border-radius: var(--radius);
  background: #fbf4e8; color: var(--gist-groen); flex-shrink: 0;
}
.brand-mark svg { width: 60%; height: 60%; }
.brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: calc(var(--radius) - 2px); }

.tool-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 7px 12px;
  border: 1px solid var(--lijn); border-radius: 6px;
  background: #fbf4e8; color: var(--oven-donker);
  font-size: 0.82rem; font-weight: 800; white-space: nowrap;
}
.tool-button svg { width: 16px; height: 16px; flex-shrink: 0; }
.tool-button.primary { border-color: rgba(122,63,36,0.45); background: var(--oven-bruin); color: var(--zout-wit); }
.tool-button.danger { border-color: rgba(122,63,36,0.3); background: #f4e1d6; }
.tool-button.wide { width: 100%; }
.tool-button:disabled { opacity: 0.6; cursor: not-allowed; }

.file-tool { cursor: pointer; }
.file-tool input { display: none; }

.icon-action {
  display: grid; place-items: center;
  width: 34px; height: 34px; padding: 0;
  border: 1px solid var(--lijn); border-radius: 999px;
  background: var(--zout-wit); color: var(--steen-grijs); flex-shrink: 0;
}
.icon-action svg { width: 16px; height: 16px; }
.icon-action.danger { border-color: rgba(122,63,36,0.24); color: var(--oven-bruin); }

.metric-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.metric-row > div {
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px 14px; border: 1px solid var(--lijn);
  border-radius: var(--radius); background: var(--meel);
}
.metric-row svg { width: 18px; height: 18px; color: var(--gist-groen); }
.metric-row span { font-size: 0.72rem; font-weight: 700; color: var(--gist-groen); text-transform: uppercase; }
.metric-row strong { font-size: 1.2rem; font-weight: 800; color: var(--oven-donker); font-variant-numeric: tabular-nums; }

.tabbar { display: flex; border-bottom: 2px solid var(--lijn); margin-bottom: 16px; }
.tabbar button {
  padding: 10px 16px; border: 0; border-bottom: 2px solid transparent;
  border-radius: 0; background: transparent; color: var(--steen-grijs);
  font-size: 0.9rem; font-weight: 700; margin-bottom: -2px;
}
.tabbar button.active { color: var(--oven-donker); border-bottom-color: var(--oven-bruin); }

.recipe-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 200px);
  gap: 20px; align-items: start; margin-bottom: 16px;
}

.recipe-name-field, .category-field, .description-field, .leavening-field { display: grid; gap: 6px; }
.recipe-name-field span, .category-field > span, .description-field > span, .leavening-field > span {
  color: var(--gist-groen); font-size: 0.76rem; font-weight: 900; text-transform: uppercase;
}
.recipe-name-field input {
  width: 100%; border: 0; border-bottom: 2px solid rgba(122,63,36,0.22);
  background: transparent; color: var(--oven-donker);
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(1.4rem, 4vw, 2rem); font-weight: 700;
}
.recipe-name-field input:focus { outline: 0; border-bottom-color: rgba(122,63,36,0.72); }

.category-field { margin-top: 10px; }
.category-field > div {
  display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center;
}
.category-field select, .category-field input {
  min-height: 36px; padding: 6px 8px;
  border: 1px solid rgba(122,63,36,0.18); border-radius: 6px;
  background: var(--zout-wit); color: var(--oven-donker);
  font-size: 0.86rem; font-weight: 700; width: 100%;
}

.description-field { margin-top: 10px; }
.description-field textarea {
  width: 100%; min-height: 56px; padding: 8px 10px;
  border: 1px solid rgba(122,63,36,0.18); border-radius: 6px;
  background: var(--zout-wit); color: var(--oven-donker);
  font-size: 0.9rem; line-height: 1.45; resize: vertical;
}

.flour-input { display: grid; gap: 6px; }
.flour-input > span { color: var(--gist-groen); font-size: 0.76rem; font-weight: 900; text-transform: uppercase; }
.flour-input > div {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border: 1px solid rgba(122,63,36,0.22); border-radius: var(--radius); background: var(--meel);
}
.flour-input input {
  flex: 1; min-width: 0; border: 0; background: transparent;
  color: var(--oven-donker); font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums;
}
.flour-input input:focus { outline: 0; }
.flour-input span:last-child { color: var(--gist-groen); font-size: 0.82rem; font-weight: 700; }

.leavening-field { margin-top: 10px; }
.leavening-options { display: flex; gap: 16px; flex-wrap: wrap; }
.leavening-option { display: flex; align-items: center; gap: 7px; cursor: pointer; font-size: 0.9rem; font-weight: 700; color: var(--oven-donker); }
.leavening-option input[type="radio"] { accent-color: var(--oven-bruin); width: 16px; height: 16px; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; background: var(--zout-wit); font-size: 0.88rem; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; border-top: 1px solid var(--lijn); text-align: left; vertical-align: middle; }
th { color: var(--gist-groen); font-size: 0.7rem; font-weight: 800; text-transform: uppercase; }

.material-input {
  width: 100%; min-height: 32px; padding: 5px 8px;
  border: 1px solid rgba(122,63,36,0.18); border-radius: 6px;
  background: #fbf4e8; color: var(--oven-donker); font-size: 0.86rem; font-weight: 700; min-width: 0;
}
.material-input:focus { outline: 0; border-color: rgba(122,63,36,0.68); box-shadow: 0 0 0 3px rgba(122,63,36,0.12); }

.number-cell {
  display: flex; align-items: center; gap: 5px; padding: 3px 7px;
  border: 1px solid rgba(122,63,36,0.22); border-radius: 6px;
  background: #fbf4e8; color: var(--oven-donker); min-width: 80px;
}
.number-cell input {
  flex: 1; min-width: 0; border: 0; background: transparent;
  color: inherit; font-size: 0.86rem; font-weight: 800; font-variant-numeric: tabular-nums; text-align: right;
}
.number-cell input:focus { outline: 0; }
.number-cell input[readonly] { color: var(--steen-grijs); cursor: default; }
.number-cell span { color: var(--gist-groen); font-size: 0.76rem; font-weight: 900; flex-shrink: 0; }
.number-cell:focus-within { border-color: rgba(122,63,36,0.68); box-shadow: 0 0 0 3px rgba(122,63,36,0.12); }

.logbook-workspace { display: grid; gap: 12px; }
.note-form {
  display: grid; gap: 8px; padding: 10px;
  border: 1px solid var(--lijn); border-radius: var(--radius); background: var(--meel);
}
.note-form-wide { grid-template-columns: minmax(110px, 150px) minmax(100px, 130px) minmax(80px, 105px) minmax(0, 1fr) auto; align-items: start; }
.note-form input, .note-form textarea, .note-form select {
  width: 100%; border: 1px solid rgba(122,63,36,0.18); border-radius: 6px;
  background: var(--zout-wit); color: var(--oven-donker); font-size: 0.9rem;
}
.note-form input { min-height: 36px; padding: 7px 9px; }
.note-temp-field { display: grid; gap: 5px; }
.note-temp-field span { color: var(--gist-groen); font-size: 0.7rem; font-weight: 900; text-transform: uppercase; }
.note-form textarea { min-height: 68px; padding: 8px 10px; resize: vertical; }
.note-form input:focus, .note-form textarea:focus { outline: 0; border-color: rgba(122,63,36,0.68); box-shadow: 0 0 0 3px rgba(122,63,36,0.12); }

.note-list-wide { max-height: 560px; overflow: auto; }
.note { border: 1px solid var(--lijn); border-radius: var(--radius); background: #fbf4e8; overflow: hidden; }
.note summary { display: grid; grid-template-columns: auto auto auto minmax(0,1fr); gap: 10px; align-items: center; padding: 10px 12px; cursor: pointer; }
.note summary span { grid-column: 4; overflow: hidden; color: var(--steen-grijs); font-size: 0.86rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.note time { color: var(--oven-bruin); font-size: 0.82rem; font-weight: 800; white-space: nowrap; }
.note-body { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px; align-items: start; padding: 0 12px 12px; }
.note-actions { display: grid; gap: 8px; justify-items: end; }
.note p { margin: 0; line-height: 1.5; }
.note:not([open]) .note-body { display: none; }

.rating-badge { padding: 3px 8px; border-radius: 999px; background: rgba(111,127,77,0.12); color: var(--gist-groen); font-size: 0.7rem; text-transform: uppercase; font-weight: 800; }
.rating-badge.mislukt { background: #f4e1d6; color: var(--oven-bruin); }
.rating-badge.favoriet { background: #fff0b8; color: #8a5d12; }
.temp-badge { padding: 3px 8px; border-radius: 999px; background: rgba(122,63,36,0.1); color: var(--oven-bruin); font-size: 0.7rem; font-weight: 900; white-space: nowrap; }
.note-meta { margin: 0 0 6px !important; color: var(--gist-groen); font-size: 0.82rem; font-weight: 800; }

.snapshot { margin-top: 10px; border-top: 1px solid var(--lijn); padding-top: 8px; }
.snapshot summary { display: block; padding: 0; color: var(--gist-groen); font-size: 0.8rem; font-weight: 900; }
.snapshot-grid { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 4px 14px; margin-top: 8px; font-size: 0.82rem; }
.snapshot-grid strong { color: var(--oven-donker); font-variant-numeric: tabular-nums; }

.method-panel label { display: grid; gap: 8px; }
.method-panel textarea {
  width: 100%; min-height: 200px; padding: 12px;
  border: 1px solid rgba(122,63,36,0.18); border-radius: 6px;
  background: var(--zout-wit); color: var(--oven-donker);
  font-size: 0.95rem; line-height: 1.55; resize: vertical;
}
.method-panel textarea:focus { outline: 0; border-color: rgba(122,63,36,0.68); box-shadow: 0 0 0 3px rgba(122,63,36,0.12); }

.field-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; color: var(--gist-groen); font-size: 0.76rem; font-weight: 900; text-transform: uppercase; }
.dictate-button {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border: 1px solid var(--lijn); border-radius: 999px;
  background: var(--meel); color: var(--steen-grijs); font-size: 0.78rem; font-weight: 700;
}
.dictate-button svg { width: 14px; height: 14px; }
.dictate-button.listening { border-color: var(--oven-bruin); background: var(--oven-bruin); color: var(--zout-wit); }
.dictation-field { display: grid; gap: 6px; }
.dictation-status { font-size: 0.78rem; color: var(--gist-groen); font-weight: 700; min-height: 1em; }

.empty-state { margin: 0; color: var(--steen-grijs); font-size: 0.86rem; line-height: 1.45; font-style: italic; }

.scale-panel { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; align-items: end; }
.scale-panel label { display: grid; gap: 6px; }
.scale-panel label span { color: var(--gist-groen); font-size: 0.76rem; font-weight: 900; text-transform: uppercase; }
.scale-panel input {
  min-height: 36px; padding: 7px 10px; width: 100%;
  border: 1px solid rgba(122,63,36,0.18); border-radius: 6px;
  background: var(--zout-wit); color: var(--oven-donker); font-size: 0.9rem; font-weight: 700;
}
.scale-panel p { font-size: 0.82rem; color: var(--steen-grijs); margin: 0; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .app-shell { width: 100%; padding: 8px 0 24px; }
  .topbar { padding: 10px 12px; border-radius: 0; border-left: none; border-right: none; }
  .recipe-header { grid-template-columns: 1fr !important; }
  .category-field > div { grid-template-columns: 1fr !important; }
  .metric-row { grid-template-columns: 1fr 1fr !important; }
  .note-form-wide { grid-template-columns: 1fr !important; }
  .scale-panel { grid-template-columns: 1fr 1fr !important; }
}

@media (max-width: 430px) {
  .category-field > div { grid-template-columns: 1fr !important; }
  .table-wrap { overflow-x: hidden; }
  table { min-width: 0 !important; }
  table, tbody { display: block; width: 100%; }
  thead { display: none; }
  tr {
    display: grid; grid-template-columns: 1fr auto auto;
    gap: 6px; align-items: center; padding: 10px 0;
    border-bottom: 1px solid var(--lijn);
  }
  tr td { display: block; padding: 0; border: none; }
  tr td:first-child { grid-column: 1 / -1; }
  tr td:nth-child(2) { grid-column: 1 / 2; }
  tr td:nth-child(3) { grid-column: 2 / 3; }
  tr td:last-child { grid-column: 3 / 4; }
  .number-cell { min-width: 0; max-width: 100%; }
  .scale-panel { grid-template-columns: 1fr !important; }
}
