:root {
  --bg: #eef7f6;
  --surface: #ffffff;
  --surface-soft: #f5fbfa;
  --text: #16201f;
  --muted: #64716f;
  --line: #cbdedb;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --primary-soft: #d9f3f0;
  --danger: #b91c1c;
  --shadow: 0 18px 50px rgba(8, 38, 36, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.phone-frame {
  width: min(100%, 430px);
  min-height: 720px;
  overflow: hidden;
  border: 1px solid rgba(15, 118, 110, 0.2);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.top-bar h1,
.screen h2 {
  margin: 0;
}

.top-bar h1 {
  font-size: 24px;
}

.screen h2 {
  font-size: 21px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-pill,
.tag,
.score-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  white-space: nowrap;
}

.status-pill {
  padding: 7px 10px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 700;
}

.screen {
  display: none;
  padding: 22px;
}

.screen.is-active {
  display: block;
}

.hero-panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, #e7f8f5, #f8fcfb);
}

.hero-panel p,
.field-help,
.loading-box p,
.result-text,
.notice-card p,
.error-card p {
  color: var(--muted);
  line-height: 1.6;
}

.hero-panel p {
  margin: 10px 0 0;
}

.setup-form,
.result-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.wide {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 11px 12px;
  outline-color: var(--primary);
}

textarea {
  min-height: 78px;
  resize: vertical;
}

fieldset {
  margin: 0;
  border: 0;
  padding: 0;
}

legend {
  font-size: 14px;
  font-weight: 700;
}

.field-help {
  margin: 6px 0 0;
  font-size: 12px;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.chip {
  position: relative;
}

.chip input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.chip span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 11px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.chip input:checked + span {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.primary-button,
.secondary-button,
.ghost-button {
  border: 0;
  border-radius: 8px;
  font-weight: 700;
}

.primary-button {
  background: var(--primary);
  color: #ffffff;
  padding: 12px 16px;
}

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

.secondary-button,
.ghost-button {
  background: var(--primary-soft);
  color: var(--primary-dark);
  padding: 12px 14px;
}

.full-button {
  width: 100%;
}

.loading-box {
  display: grid;
  min-height: 520px;
  place-items: center;
  align-content: center;
  gap: 12px;
  text-align: center;
}

.spinner {
  width: 54px;
  height: 54px;
  border: 5px solid var(--primary-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.screen-heading,
.action-row,
.result-card-header,
.meta-row,
.summary-strip {
  display: flex;
  align-items: center;
  gap: 10px;
}

.screen-heading,
.result-card-header {
  justify-content: space-between;
}

.screen-heading {
  margin-bottom: 16px;
}

.summary-strip {
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.summary-item,
.result-card,
.notice-card,
.error-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.summary-item {
  flex: 1 1 120px;
  padding: 12px;
}

.summary-label {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
}

.summary-value {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
}

.summary-value.small {
  font-size: 15px;
  line-height: 1.35;
}

.result-card,
.notice-card,
.error-card {
  padding: 16px;
}

.result-card h3 {
  margin: 0;
  font-size: 17px;
}

.rank {
  color: var(--primary-dark);
  font-weight: 800;
}

.score-pill {
  padding: 7px 10px;
  background: var(--primary);
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
}

.meta-row {
  flex-wrap: wrap;
  margin: 12px 0;
}

.tag {
  padding: 6px 9px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 700;
}

.result-text,
.notice-card p,
.error-card p {
  margin: 10px 0 0;
}

.allergy-card {
  background: #fff7ed;
  border-color: #fed7aa;
}

.budget-card {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.error-card {
  background: #fef2f2;
  border-color: #fecaca;
}

.error-card strong {
  color: var(--danger);
}

.action-row {
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 18px;
}

@media (max-width: 520px) {
  .app-shell {
    display: block;
    padding: 0;
  }

  .phone-frame {
    width: 100%;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

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

  .action-row {
    align-items: stretch;
    flex-direction: column;
  }

  .action-row button {
    width: 100%;
  }
}
