:root {
  color-scheme: light;
  --paper: #fff8ef;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #65717c;
  --line: #ded6ca;
  --accent: #d94f3d;
  --accent-dark: #a9392b;
  --green: #2f6f5e;
  --shadow: 0 16px 42px rgba(31, 41, 51, 0.10);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
}

.pwa-body {
  display: flex;
  flex-direction: column;
}

.pwa-body .app-shell {
  flex: 1;
  min-height: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 88px;
  padding: max(18px, env(safe-area-inset-top)) clamp(18px, 4vw, 48px) 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 248, 239, 0.92);
  position: sticky;
  top: 0;
  z-index: 2;
  backdrop-filter: blur(12px);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.6rem, 3vw, 2.5rem);
  line-height: 1.05;
}

h2 {
  margin-bottom: 10px;
  font-size: clamp(1.45rem, 2vw, 2rem);
  line-height: 1.15;
}

h3 {
  margin-bottom: 12px;
  font-size: 1.05rem;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.app-shell,
.admin-shell {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 0;
  min-height: calc(100vh - 88px);
}

.recipe-list-panel,
.admin-list-panel {
  border-right: 1px solid var(--line);
  padding: 22px;
  background: #fbf2e7;
}

.recipe-detail,
.editor-panel {
  padding: clamp(22px, 4vw, 52px);
}

.search {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: var(--panel);
  color: var(--ink);
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

input:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(47, 111, 94, 0.25);
  outline-offset: 2px;
}

.primary-button,
.secondary-button,
.danger-button,
.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  min-height: 44px;
  padding: 0 18px;
  font-weight: 800;
  text-decoration: none;
}

.primary-button {
  background: var(--accent);
  color: white;
}

.secondary-button {
  background: var(--green);
  color: white;
}

.danger-button {
  background: #f3d5cf;
  color: var(--accent-dark);
}

.download-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--green);
}

.status-line,
.muted {
  color: var(--muted);
  font-size: 0.92rem;
}

.sync-status {
  padding: 14px 18px max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.recipe-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.recipe-row {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 70px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 12px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.recipe-row:hover,
.recipe-row.active {
  border-color: var(--line);
  background: var(--panel);
  box-shadow: 0 8px 20px rgba(31, 41, 51, 0.06);
}

.recipe-row span {
  font-weight: 800;
}

.recipe-row small {
  color: var(--muted);
  line-height: 1.3;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  gap: 10px;
  margin: 0 0 24px;
}

.meta-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel);
}

.meta-grid dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.meta-grid dd {
  margin: 4px 0 0;
  font-weight: 800;
}

.serving-meta {
  display: inline-grid;
  margin: -8px 0 28px;
}

.serving-meta div {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.serving-meta dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.serving-meta dd {
  margin: 4px 0 0;
  font-weight: 800;
}

.recipe-images {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.recipe-images figure {
  display: grid;
  gap: 10px;
  margin: 0;
}

.recipe-images img {
  width: 100%;
  max-height: 78vh;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.recipe-images figcaption {
  display: flex;
  justify-content: flex-end;
}

.recipe-text-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: clamp(18px, 3vw, 36px);
}

.recipe-text-grid section,
.notes {
  border-top: 1px solid var(--line);
  padding-top: 20px;
}

ul {
  margin: 0;
  padding-left: 1.2rem;
  line-height: 1.65;
}

li + li {
  margin-top: 8px;
}

.empty-state {
  display: grid;
  align-content: center;
  min-height: 50vh;
  max-width: 520px;
}

.admin-body {
  background: #f7f7f2;
}

.form-grid,
.upload-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

form {
  display: grid;
  gap: 18px;
  max-width: 980px;
}

.form-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.image-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.image-strip img {
  width: 150px;
  height: 190px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: var(--panel);
}

.login-body {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(100%, 420px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(24px, 5vw, 42px);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-form {
  margin-top: 24px;
}

@media (max-width: 820px) {
  .topbar {
    position: static;
  }

  .app-shell,
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .recipe-list-panel,
  .admin-list-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .recipe-list {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

  .meta-grid,
  .recipe-text-grid,
  .form-grid,
  .upload-grid {
    grid-template-columns: 1fr;
  }
}
