:root {
  --accent: #14b8a6;
  --accent-dark: #0f9488;
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1c1c1e;
  --muted: #8e8e93;
  --line: #e5e5ea;
  --danger: #ef4444;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.4;
}

.screen {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* ---------- Landing ---------- */
#landing {
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
}

.landing-card {
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.brand {
  font-size: 40px;
  margin: 0 0 4px;
}

.tagline {
  color: var(--muted);
  margin: 0 0 28px;
}

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

.divider {
  position: relative;
  text-align: center;
  margin: 20px 0;
  color: var(--muted);
  font-size: 14px;
}
.divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--line);
}
.divider span {
  position: relative;
  background: var(--bg);
  padding: 0 12px;
}

/* ---------- Fields & buttons ---------- */
.field {
  width: 100%;
  padding: 13px 14px;
  font-size: 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
.field:focus {
  outline: none;
  border-color: var(--accent);
}

.btn {
  padding: 13px 16px;
  font-size: 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn-primary:active {
  background: var(--accent-dark);
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.list-name {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.icon-btn {
  width: 40px;
  height: 40px;
  font-size: 20px;
  line-height: 1;
  border: none;
  border-radius: 10px;
  background: var(--bg);
  cursor: pointer;
}
.icon-btn:active {
  background: var(--line);
}

/* ---------- Add area ---------- */
.add-area {
  position: relative;
  padding: 12px 16px;
}
.suggestions {
  position: absolute;
  left: 16px;
  right: 16px;
  top: calc(100% - 4px);
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  max-height: 50vh;
  overflow-y: auto;
  z-index: 10;
}
.suggestion {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 10px;
  border-radius: 10px;
  cursor: pointer;
}
.suggestion.active,
.suggestion:active {
  background: var(--bg);
}
.suggestion .emoji {
  font-size: 22px;
}

/* ---------- Items ---------- */
.items {
  list-style: none;
  margin: 0;
  padding: 4px 0 140px;
  flex: 1;
}
.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  touch-action: pan-y;
  user-select: none;
  position: relative;
}
.item .emoji {
  font-size: 24px;
  flex-shrink: 0;
}
.item .label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item .qty {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.item.checked {
  opacity: 0.45;
}
.item.checked .label {
  text-decoration: line-through;
}

/* Brief slide feedback on swipe commit */
.item.bump-right {
  animation: bumpRight 0.18s ease;
}
.item.bump-left {
  animation: bumpLeft 0.18s ease;
}
@keyframes bumpRight {
  50% {
    transform: translateX(14px);
    background: #e7f8f5;
  }
}
@keyframes bumpLeft {
  50% {
    transform: translateX(-14px);
    background: #fdeaea;
  }
}

/* ---------- Clear prompt ---------- */
.clear-prompt {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 14px 16px calc(16px + var(--safe-bottom));
  background: linear-gradient(to top, var(--surface) 70%, transparent);
  text-align: center;
}
.clear-msg {
  color: var(--muted);
  font-size: 15px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%);
  background: #1c1c1e;
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 50;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

[hidden] {
  display: none !important;
}
