/* Grocery list — plain CSS, phone-first (Variant A) */
:root {
  --bg: #0f1115;
  --surface: #1a1d24;
  --surface2: #242833;
  --border: #333848;
  --text: #eef0f5;
  --muted: #9aa3b5;
  --accent: #5b8cff;
  --ok: #3ecf8e;
  --danger: #ff6b7a;
  --font: system-ui, -apple-system, 'Segoe UI', sans-serif;
  --tabbar-h: 56px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100%;
}

body {
  margin: 0;
}

/* Auth / setup pages (simple forms) */
body.auth {
  margin: 1rem;
  max-width: 28rem;
}

body.auth label {
  display: block;
  margin: 0.75rem 0;
}

body.auth input {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem;
  font-size: 16px;
}

body.auth button {
  margin-top: 0.75rem;
  padding: 0.6rem 1rem;
  font-size: 1rem;
}

/* App shell */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 32rem;
  margin: 0 auto;
}

.screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--tabbar-h);
}

.screen-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem 0.35rem;
}

.screen-header h1 {
  margin: 0;
  font-size: 1.25rem;
}

.screen-header .hint {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

.search {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.search input {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 999px;
  padding: 0.65rem 0.9rem;
  font-size: 16px;
  outline: none;
}

.search input:focus {
  border-color: var(--accent);
}

.chip-row {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.65rem 0.75rem;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
}

.chip-row::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  border-radius: 999px;
  padding: 0.5rem 0.9rem;
  font-size: 0.8125rem;
  cursor: pointer;
  white-space: nowrap;
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.list-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.25rem 0 1rem;
}

.row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  width: 100%;
  text-align: left;
  background: transparent;
  color: inherit;
  font: inherit;
  border-left: none;
  border-right: none;
  border-top: none;
}

.row:active {
  background: var(--surface2);
}

.row.on-list {
  background: rgba(62, 207, 142, 0.08);
}

.row .name {
  flex: 1;
  font-size: 1rem;
}

.row .meta {
  font-size: 0.75rem;
  color: var(--muted);
}

.row .mark {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 0.875rem;
  flex: 0 0 auto;
}

.row.on-list .mark {
  background: var(--ok);
  border-color: var(--ok);
  color: #062;
  font-weight: 700;
}

.empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.875rem;
}

.error {
  padding: 0.75rem 0.9rem;
  color: var(--danger);
  font-size: 0.875rem;
}

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--tabbar-h);
  max-width: 32rem;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  border-top: 1px solid var(--border);
  background: var(--surface);
  z-index: 10;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.tabbar button {
  background: none;
  border: none;
  color: var(--muted);
  padding: 0.5rem 0.25rem;
  font-size: 0.7rem;
  cursor: pointer;
}

.tabbar button.active {
  color: var(--accent);
  font-weight: 700;
}

.tabbar button .icon {
  display: block;
  font-size: 1.15rem;
  margin-bottom: 0.1rem;
}

.more-panel {
  padding: 0.5rem 0.9rem 1.5rem;
}

.more-panel .signed-in {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 0.75rem;
}

.manage-section {
  margin: 0 0 1.25rem;
  padding: 0.75rem 0 0;
  border-top: 1px solid var(--border);
}

.manage-section h2 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.manage-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.manage-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}

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

.manage-label {
  font-size: 0.95rem;
}

.manage-label-block {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.manage-label-block .meta {
  font-size: 0.75rem;
  color: var(--muted);
}

.manage-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.manage-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.65rem;
  align-items: center;
}

.manage-form.stack {
  flex-direction: column;
  align-items: stretch;
}

.manage-input,
.manage-select {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 0.5rem;
  padding: 0.55rem 0.7rem;
  font-size: 16px;
}

.manage-select {
  appearance: auto;
}

.empty-inline {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0.5rem 0;
}

.btn {
  border: 1px solid var(--border);
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn.small {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 500;
}

.btn.ghost {
  background: var(--surface2);
  color: var(--text);
}

.btn.danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.logout-form {
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.list-item-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.list-item-row.checked .name {
  text-decoration: line-through;
  color: var(--muted);
}

.list-item-row .name {
  font-size: 1rem;
}

.list-item-row .meta {
  font-size: 0.75rem;
  color: var(--muted);
}

.check-btn {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.check-btn .mark {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 0.875rem;
  font-weight: 700;
}

.list-item-row.checked .check-btn .mark {
  background: var(--ok);
  border-color: var(--ok);
  color: #062;
}

.list-item-main {
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 0.35rem 0;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.list-item-main:disabled,
.check-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.list-remove {
  flex: 0 0 auto;
}
