:root {
  --bg: #ffffff;
  --bg-soft: #f3f5f1;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;
  --surface-muted: #f7f8f5;
  --text: #1b231d;
  --text-soft: #617064;
  --border: rgba(33, 53, 39, 0.09);
  --shadow: 0 24px 64px rgba(34, 52, 39, 0.11);
  --shadow-soft: 0 18px 36px rgba(34, 52, 39, 0.08);
  --accent: #94b59a;
  --accent-deep: #4e7455;
  --danger: #b85c5c;
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 18px;
  --ease: 300ms ease;
}

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

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: "Avenir Next", "SF Pro Display", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(148, 181, 154, 0.12), transparent 26%),
    radial-gradient(circle at top right, rgba(201, 214, 189, 0.24), transparent 22%),
    linear-gradient(180deg, #ffffff 0%, #f6f8f4 100%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  background: none;
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

.app-shell {
  min-height: 100vh;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 8px 0 22px;
  backdrop-filter: blur(18px);
}

.brand-lockup h1,
.modal-header h2,
.recipe-heading h2,
.recipe-section h3,
.empty-state p {
  margin: 0;
}

.brand-lockup h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 0.95;
  letter-spacing: -0.05em;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-deep);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.search-field {
  flex: 0 1 380px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-soft);
}

.search-field input {
  width: 100%;
  border: 0;
  outline: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
}

.search-field input::placeholder,
.gallery-hint,
.gallery-count,
.ingredient-list,
.step-list,
.recipe-form label span {
  color: var(--text-soft);
}

.search-icon {
  width: 18px;
  height: 18px;
  color: var(--text-soft);
}

.search-icon svg,
.nav-button svg,
.icon-button svg,
.delete-button svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.app-main {
  display: block;
}

.gallery-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.gallery-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 6px;
}

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

.gallery-count,
.gallery-hint {
  margin: 0;
  font-size: 0.95rem;
}

.gallery-window {
  position: relative;
  overflow: hidden;
  min-height: clamp(620px, 78vh, 880px);
  padding: 6px;
}

.cards-track {
  display: flex;
  gap: 24px;
  height: 100%;
  touch-action: pan-y;
  transition: transform var(--ease);
  will-change: transform;
}

.cards-track.is-dragging {
  transition: none;
  cursor: grabbing;
}

.recipe-card {
  position: relative;
  flex: 0 0 100%;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  overflow: hidden;
  border: 1px solid rgba(33, 53, 39, 0.07);
  border-radius: var(--radius-xl);
  background: var(--surface-solid);
  box-shadow: var(--shadow);
  transform: scale(0.96);
  opacity: 0.5;
  transition: transform var(--ease), opacity var(--ease), box-shadow var(--ease);
}

.recipe-card.is-active {
  transform: scale(1);
  opacity: 1;
}

.recipe-card.is-neighbor {
  opacity: 0.75;
  transform: scale(0.98);
}

.recipe-media {
  --media-height: clamp(384px, 60vh, 576px);
  position: relative;
  flex: 0 0 var(--media-height);
  height: var(--media-height);
  min-height: var(--media-height);
  overflow: hidden;
  background: linear-gradient(135deg, #eef2ec, #dce6d8);
}

.recipe-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.recipe-body {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 24px;
  padding: 28px;
  flex: 1;
}

.recipe-heading {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.recipe-heading h2 {
  font-size: clamp(1.9rem, 3vw, 2.8rem);
  line-height: 1;
  letter-spacing: -0.04em;
}

.recipe-meta {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.recipe-section {
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  background: var(--surface-muted);
}

.recipe-section h3 {
  margin-bottom: 14px;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.ingredient-list,
.step-list {
  margin: 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 10px;
  line-height: 1.5;
}

.step-list {
  padding-left: 1.35rem;
}

.delete-button,
.icon-button,
.nav-button,
.button,
.fab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform var(--ease), opacity var(--ease), background-color var(--ease), box-shadow var(--ease);
}

.delete-button:hover,
.icon-button:hover,
.nav-button:hover,
.button:hover,
.fab:hover {
  transform: translateY(-1px);
}

.delete-button {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 3;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  color: var(--danger);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 14px 28px rgba(34, 52, 39, 0.13);
  opacity: 0;
}

.recipe-card:hover .delete-button,
.recipe-card:focus-within .delete-button,
.recipe-card.show-actions .delete-button {
  opacity: 1;
}

.delete-button svg,
.nav-button svg,
.icon-button svg {
  width: 18px;
  height: 18px;
}

.nav-button {
  position: absolute;
  top: clamp(200px, 30vh, 300px);
  transform: translateY(-50%);
  z-index: 5;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow-soft);
}

.nav-button:hover {
  transform: translateY(calc(-50% - 1px));
}

.nav-button:disabled {
  opacity: 0.35;
  cursor: default;
  transform: translateY(-50%);
}

.nav-prev {
  left: 22px;
}

.nav-next {
  right: 22px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 220px;
  border: 1px dashed rgba(33, 53, 39, 0.16);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.55);
}

.fab {
  position: fixed;
  right: max(24px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 40;
  width: 64px;
  height: 64px;
  border-radius: 999px;
  background: linear-gradient(180deg, #a7c2ac, #86aa8d);
  color: #ffffff;
  box-shadow: 0 22px 44px rgba(92, 123, 98, 0.3);
  font-size: 2rem;
  line-height: 1;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(22, 33, 24, 0.22);
  backdrop-filter: blur(12px);
}

.modal {
  width: min(100%, 620px);
  max-height: min(88vh, 860px);
  overflow: auto;
  padding: 24px;
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.modal-header h2 {
  font-size: 1.8rem;
  letter-spacing: -0.04em;
}

.icon-button {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 999px;
  color: var(--text);
  background: var(--surface-muted);
}

.recipe-form {
  display: grid;
  gap: 16px;
}

.recipe-form label {
  display: grid;
  gap: 10px;
}

.recipe-form label span {
  font-size: 0.94rem;
  font-weight: 600;
}

.recipe-form input,
.recipe-form textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px 16px;
  outline: 0;
  resize: vertical;
  background: #fff;
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.recipe-form input:focus,
.recipe-form textarea:focus {
  border-color: rgba(78, 116, 85, 0.32);
  box-shadow: 0 0 0 4px rgba(148, 181, 154, 0.16);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.button {
  min-width: 120px;
  padding: 14px 18px;
  border-radius: 999px;
  font-weight: 700;
}

.browse-button {
  min-width: auto;
  padding: 10px 16px;
  font-size: 0.92rem;
}

.button-primary {
  color: #fff;
  background: linear-gradient(180deg, #89ad8f, #6d9675);
}

.button-secondary {
  background: var(--surface-muted);
}

.is-hidden {
  display: none;
}

body.modal-open {
  overflow: hidden;
}

.list-modal {
  width: min(100%, 760px);
}

.list-modal-copy {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  color: var(--text-soft);
}

.list-modal-copy p {
  margin: 0;
}

.recipe-list-grid {
  display: grid;
  gap: 12px;
  max-height: min(62vh, 720px);
  overflow: auto;
  padding-right: 4px;
}

.recipe-list-item {
  width: 100%;
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 12px;
  text-align: left;
  border: 1px solid rgba(33, 53, 39, 0.08);
  border-radius: 20px;
  background: var(--surface-muted);
  box-shadow: 0 8px 22px rgba(34, 52, 39, 0.04);
}

.recipe-list-item.is-active {
  border-color: rgba(78, 116, 85, 0.24);
  background: rgba(148, 181, 154, 0.12);
}

.recipe-list-thumb {
  width: 88px;
  height: 72px;
  overflow: hidden;
  border-radius: 16px;
  background: linear-gradient(135deg, #eef2ec, #dce6d8);
}

.recipe-list-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.recipe-list-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.recipe-list-copy strong,
.recipe-list-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recipe-list-copy strong {
  font-size: 1rem;
}

.recipe-list-copy span {
  color: var(--text-soft);
  font-size: 0.9rem;
}

@media (max-width: 980px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-field {
    flex-basis: auto;
  }

  .gallery-meta,
  .list-modal-copy {
    flex-direction: column;
    align-items: flex-start;
  }

  .recipe-body {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding-inline: 16px;
  }

  .gallery-window {
    min-height: auto;
  }

  .cards-track {
    gap: 16px;
  }

  .gallery-actions {
    width: 100%;
    justify-content: space-between;
  }

  .recipe-card {
    min-height: auto;
  }

  .recipe-body {
    padding: 20px;
    gap: 18px;
  }

  .nav-button {
    display: none;
  }

  .fab {
    width: 58px;
    height: 58px;
  }

  .recipe-list-item {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .recipe-list-thumb {
    width: 72px;
    height: 60px;
  }
}
