* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --surface2: #0f3460;
  --primary: #4CAF50;
  --primary-dark: #388E3C;
  --secondary: #FF9800;
  --text: #e0e0e0;
  --text-dim: #9e9e9e;
  --error: #ef5350;
  --divider: rgba(255,255,255,0.08);
  --cat-groceries: #4CAF50;
  --cat-hardware: #FF9800;
  --cat-drugstore: #E91E63;
  --cat-household: #2196F3;
  --cat-other: #9E9E9E;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--divider);
  min-height: 56px;
}

.header h1 {
  font-size: 20px;
  font-weight: 600;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.back-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px 4px 0;
}

/* Content */
.content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(80px + var(--safe-bottom));
}

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

.screen.active {
  display: flex;
}

/* Empty state */
.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-dim);
  font-size: 16px;
  padding: 32px;
  text-align: center;
}

/* Category header */
.cat-header {
  padding: 12px 16px 6px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--primary);
}

/* Item rows */
.item-row {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
  gap: 12px;
}

.item-row .name {
  flex: 1;
  font-size: 16px;
}

.item-row .meta {
  font-size: 12px;
  color: var(--text-dim);
}

.item-row .check-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  background: none;
  color: var(--primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
}

.item-row .check-btn:active {
  background: var(--primary);
  color: white;
}

.item-row .delete-btn,
.item-row .add-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}

.item-row .delete-btn { color: var(--error); }
.item-row .add-btn { color: var(--primary); }

/* Log items */
.log-row {
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
}

.log-row .name {
  font-size: 16px;
}

.log-row .log-meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.log-row .log-cat {
  font-size: 11px;
  color: var(--primary);
  text-transform: uppercase;
}

/* FAB */
.fab {
  position: fixed;
  bottom: calc(24px + var(--safe-bottom));
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 28px;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 28px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.fab:active {
  background: var(--primary-dark);
}

/* Icon buttons */
.icon-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

.icon-btn:active {
  background: rgba(255,255,255,0.1);
}

/* List items (lists screen) */
.list-card {
  display: flex;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  gap: 12px;
}

.list-card:active {
  background: rgba(255,255,255,0.05);
}

.list-card .list-info {
  flex: 1;
}

.list-card .list-name {
  font-size: 17px;
  font-weight: 500;
}

.list-card .list-meta {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
}

.list-card .list-icon {
  font-size: 24px;
  color: var(--primary);
}

/* Dialog / Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.modal {
  background: var(--surface);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.modal h2 {
  font-size: 18px;
  margin-bottom: 16px;
}

.modal input, .modal select {
  width: 100%;
  padding: 12px;
  margin-bottom: 12px;
  border-radius: 8px;
  border: 1px solid var(--divider);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  outline: none;
}

.modal input:focus, .modal select:focus {
  border-color: var(--primary);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.btn {
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  font-size: 15px;
  cursor: pointer;
  font-weight: 500;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:active {
  background: var(--primary-dark);
}

.btn-secondary {
  background: transparent;
  color: var(--text-dim);
}

/* Settings */
.settings-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 16px;
  margin: 16px;
}

.settings-card h3 {
  font-size: 14px;
  color: var(--primary);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.settings-row {
  font-size: 15px;
  padding: 4px 0;
  color: var(--text-dim);
}

.settings-row strong {
  color: var(--text);
}

/* Invite code */
.invite-code {
  font-family: monospace;
  font-size: 13px;
  background: var(--bg);
  padding: 8px 12px;
  border-radius: 6px;
  word-break: break-all;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.invite-code .copy-btn {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
}

/* Snackbar */
.snackbar {
  position: fixed;
  bottom: calc(90px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  color: var(--text);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 200;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  animation: snackIn 0.3s ease;
}

@keyframes snackIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Loading spinner */
.spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.spinner::after {
  content: '';
  width: 32px;
  height: 32px;
  border: 3px solid var(--divider);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Bottom nav for items screen */
.bottom-nav {
  display: flex;
  justify-content: space-around;
  padding: 8px 0 calc(8px + var(--safe-bottom));
  background: var(--surface);
  border-top: 1px solid var(--divider);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px 16px;
  font-size: 11px;
}

.nav-item.active {
  color: var(--primary);
}

.nav-item .nav-icon {
  font-size: 22px;
}
