:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-alt: #eef3ff;
  --border: #dfe7f5;
  --text: #1f2a37;
  --muted: #5c6b7d;
  --primary: #2d5bff;
  --primary-dark: #1f49d1;
  --danger: #c44f5a;
  --success: #1d9a6c;
  --shadow: 0 12px 30px rgba(34, 54, 82, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: linear-gradient(135deg, #f8f9ff 0%, #edf3ff 100%);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  border: none;
  border-radius: 10px;
  padding: 0.72rem 1rem;
  cursor: pointer;
  background: #eaf0ff;
  color: var(--text);
  transition: transform 0.15s ease, background 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
}

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

button.primary:hover {
  background: var(--primary-dark);
}

button.secondary {
  background: #edf3ff;
  color: var(--text);
}

button.danger {
  background: #fce7ea;
  color: var(--danger);
}

.sidebar-actions {
  display: grid;
  gap: 0.7rem;
  margin-top: 0.8rem;
}

.language-toggle {
  display: inline-flex;
  gap: 0.4rem;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f7f9ff;
}

.lang-btn {
  padding: 0.45rem 0.8rem;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}

.lang-btn.active {
  background: var(--primary);
  color: white;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 1.5rem;
  max-width: 1360px;
  margin: 0 auto;
  padding: 2rem;
}

.sidebar,
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.sidebar {
  padding: 1.25rem;
  min-height: 720px;
}

.panel-header {
  margin-bottom: 1rem;
}

.panel-header h2,
.ingredients-toolbar h2,
.results-header h2,
.page-header h1 {
  margin: 0;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.eyebrow {
  margin: 0 0 0.3rem;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary);
  font-weight: 700;
}

.field-label {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--muted);
  width: 100%;
}

.field-label > span {
  display: block;
  line-height: 1.3;
  overflow-wrap: anywhere;
  width: 100%;
}

.field-label input {
  width: 100%;
  min-width: 0;
  min-height: 48px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 1rem;
  align-items: start;
}

input,
select {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  background: #fafcff;
  color: var(--text);
}

input:focus,
select:focus {
  outline: 2px solid rgba(45, 91, 255, 0.15);
  border-color: var(--primary);
}

.form-card,
.results-card {
  padding: 1.25rem;
}

.ingredients-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 1.5rem 0 1rem;
}

.ingredient-list {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.ingredient-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.5fr) minmax(120px, 0.8fr) auto;
  gap: 0.75rem;
  align-items: end;
}

.ingredient-row .remove-row {
  background: #f7e8eb;
  color: var(--danger);
  padding-inline: 0.9rem;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.result-summary {
  display: inline-flex;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: var(--panel-alt);
  color: var(--primary-dark);
  font-size: 0.82rem;
  font-weight: 700;
}

.result-list {
  margin-top: 1rem;
  display: grid;
  gap: 0.85rem;
}

.result-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.8rem 1rem;
  background: #f9fbff;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.whole-meal-item {
  background: #edf3ff;
  border-color: rgba(45, 91, 255, 0.24);
}

.whole-meal-item .result-name {
  font-size: 1.02rem;
}

.result-name {
  font-weight: 700;
}

.result-amount {
  color: var(--primary-dark);
  font-weight: 700;
}

.empty-state {
  padding: 1rem;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--muted);
  background: #fafcff;
}

.recipe-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  display: grid;
  gap: 0.7rem;
}

.recipe-list button {
  width: 100%;
  text-align: left;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border);
  background: #f8faff;
}

.recipe-list button.is-active {
  background: #edf3ff;
  border-color: rgba(45, 91, 255, 0.25);
}

.recipe-name {
  font-weight: 700;
  display: block;
}

.recipe-meta {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.2rem;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(14, 24, 40, 0.5);
  padding: 1.5rem;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(100%, 480px);
  background: white;
  border-radius: 18px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.modal-card h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1.2rem;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .field-label {
    align-items: stretch;
  }

  .ingredient-row {
    grid-template-columns: 1fr;
  }

  .result-item {
    flex-direction: column;
    align-items: flex-start;
  }
}
