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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100dvh;
}

body.modal-open {
  overflow: hidden;
}

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

button {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4, p {
  margin: 0;
}

/* Cabeçalho fixo com vidro fosco */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  background: var(--bg-glass-strong);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}

.app-header-inner {
  max-width: var(--max-w);
  height: 100%;
  margin: 0 auto;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--success));
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.brand-title {
  display: block;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.brand-sub {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Área central das telas */
.app-main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 18px 16px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom, 0px));
}

.view {
  display: none;
  animation: viewFade 0.22s ease;
}

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

@keyframes viewFade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Blocos e cabeçalhos de seção */
.stack-lg {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.stack-md {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.page-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Grades responsivas */
.grid-recipes {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.grid-quick {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

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

.horizontal-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 2px 2px 10px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.horizontal-scroll::-webkit-scrollbar {
  display: none;
}

.horizontal-scroll > * {
  scroll-snap-align: start;
}

/* Barra inferior estilo iOS */
.tab-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding: 6px 8px env(safe-area-inset-bottom, 6px);
  background: var(--bg-glass);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  transition: color 0.18s ease, transform 0.15s ease;
}

.tab-item svg {
  width: 22px;
  height: 22px;
}

.tab-item.is-active {
  color: var(--accent);
  font-weight: 600;
}

.tab-item:active {
  transform: scale(0.94);
}

/* Janelas sobrepostas (Sheet estilo iOS) */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-sheet {
  width: 100%;
  max-width: 640px;
  max-height: 92dvh;
  background: var(--bg-card);
  border-radius: 24px 24px 0 0;
  box-shadow: var(--shadow-sheet);
  overflow-y: auto;
  padding: 10px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  animation: sheetUp 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-sheet--compact {
  max-width: 500px;
  max-height: 82dvh;
}

.sheet-handle {
  width: 38px;
  height: 5px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.14);
  margin: 2px auto 14px;
}

@keyframes sheetUp {
  from {
    opacity: 0;
    transform: translateY(28px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Aviso rápido flutuante (Toast) */
.app-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 14px);
  z-index: 100;
  background: rgba(29, 29, 31, 0.92);
  color: var(--text-inverse);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: calc(100vw - 32px);
  text-align: center;
}

.app-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Ajustes para tablet e computador */
@media (min-width: 640px) {
  .app-main {
    padding: 24px 24px 110px;
  }

  .grid-recipes {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  .grid-two {
    grid-template-columns: repeat(2, 1fr);
  }

  .modal-overlay {
    align-items: center;
    padding: 20px;
  }

  .modal-sheet {
    border-radius: 24px;
    max-height: 88dvh;
    padding: 14px 24px 26px;
  }
}

@media (min-width: 880px) {
  .grid-recipes {
    grid-template-columns: repeat(3, 1fr);
  }

  .tab-bar {
    left: 50%;
    right: auto;
    bottom: 16px;
    transform: translateX(-50%);
    width: min(560px, calc(100vw - 32px));
    height: 64px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-md);
  }

  .app-toast {
    bottom: 94px;
  }
}
