*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  background: #f0f4f8;
  color: #1a202c;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* ── Login / Error screens ── */
#login-section,
#error-section {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.login-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.10);
  padding: 2.5rem 2rem;
  max-width: 380px;
  width: 100%;
  text-align: center;
}

.login-card h1 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
  color: #2d3748;
}

.login-card h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: #c53030;
}

.login-card p {
  color: #718096;
  margin-bottom: 1.75rem;
  font-size: 0.95rem;
}

/* Center the Google button */
.g_id_signin {
  display: flex;
  justify-content: center;
}

/* ── Main app ── */
header {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #2d3748;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#user-email {
  font-size: 0.85rem;
  color: #718096;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* ── Add form ── */
#add-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

#item-input {
  flex: 1;
  padding: 0.65rem 0.9rem;
  font-size: 16px; /* >=16px prevents iOS auto-zoom on focus */
  border: 1.5px solid #cbd5e0;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s;
}

#item-input:focus {
  border-color: #4299e1;
}

#add-btn {
  padding: 0.65rem 1.25rem;
  background: #4299e1;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

#add-btn:hover:not(:disabled) {
  background: #3182ce;
}

#add-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ── Autocomplete suggestions ── */
.input-wrapper {
  position: relative;
  flex: 1;
}

#suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-top: none;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.10);
  list-style: none;
  z-index: 20;
  max-height: 260px;
  overflow-y: auto;
}

#suggestions li {
  padding: 0.65rem 0.9rem;
  min-height: 44px;
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 0.95rem;
  color: #2d3748;
  transition: background 0.1s;
}

#suggestions li:hover {
  background: #ebf8ff;
}

#suggestions li:not(:last-child) {
  border-bottom: 1px solid #f0f4f8;
}

/* ── Status message ── */
#list-status {
  font-size: 0.88rem;
  color: #718096;
  margin-bottom: 0.75rem;
  min-height: 1.2em;
}

#list-status.error {
  color: #c53030;
}

/* ── Shopping list ── */
#shopping-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.item-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.item-name {
  font-size: 1rem;
  color: #2d3748;
  font-weight: 500;
}

.item-meta {
  font-size: 0.78rem;
  color: #a0aec0;
}

.delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #fc8181;
  font-size: 1.25rem;
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.delete-btn:hover {
  color: #c53030;
  background: #fff5f5;
}

.empty-state {
  text-align: center;
  color: #a0aec0;
  padding: 3rem 1rem;
  font-size: 0.95rem;
}

/* ── Generic secondary button ── */
.btn-secondary {
  padding: 0.5rem 1rem;
  background: #edf2f7;
  color: #4a5568;
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-secondary:hover {
  background: #e2e8f0;
}

/* ── Mobile ── */
@media (max-width: 480px) {
  header {
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    text-align: center;
  }

  .user-info {
    justify-content: center;
  }

  #user-email {
    font-size: 0.78rem;
  }

  main {
    padding: 1rem 0.75rem;
  }

  .login-card {
    padding: 2rem 1.25rem;
  }

  #add-btn {
    padding: 0.65rem 1rem;
  }

  .list-item {
    padding: 0.65rem 0.75rem;
  }
}
