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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  max-width: 600px;
  margin: 0 auto;
  padding: 20px 16px;
  color: #1a1a1a;
  background: #fdf8f3;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #f0e6d8;
  margin-bottom: 28px;
}

.tab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  padding: 10px 24px;
  font-size: 16px;
  font-weight: 500;
  color: #888;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.tab.active { color: #d97706; border-bottom-color: #d97706; }
.tab:hover:not(.active) { color: #444; }

/* ── Utility ── */
.hidden { display: none !important; }

/* ── Input row ── */
.input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.input-row input {
  flex: 1;
  padding: 10px 14px;
  font-size: 16px;
  border: 1px solid #d4d4d4;
  border-radius: 12px;
  outline: none;
  background: #fff;
  transition: border-color 0.15s;
}

.input-row input:focus { border-color: #d97706; }

/* ── Buttons ── */
button {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  background: #78350f;
  color: #fff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

button:hover { background: #92400e; }

.secondary-btn {
  background: #f5ede3;
  color: #78350f;
}

.secondary-btn:hover { background: #ecdcc8; }

/* ── Task list ── */
ul { list-style: none; }

ul li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 4px;
  border-bottom: 1px solid #f5ede3;
}

ul li span { flex: 1; font-size: 16px; line-height: 1.4; }

ul li.completed span {
  text-decoration: line-through;
  color: #aaa;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: #d97706;
}

.delete-btn {
  background: none;
  color: #ccc;
  border: none;
  font-size: 20px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 400;
  transition: background 0.1s, color 0.1s;
}

.delete-btn:hover { background: #fee2e2; color: #dc2626; }

/* ── Grocery item checked state ── */
#item-list li.checked span {
  text-decoration: line-through;
  color: #aaa;
}

/* ── Groceries ── */
#new-list-prompt p {
  font-size: 15px;
  color: #666;
  margin-bottom: 14px;
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
}

.list-header h2 { font-size: 20px; font-weight: 700; }

/* ── Archives ── */
.archives {
  margin-top: 36px;
  border-top: 1px solid #f0e6d8;
  padding-top: 14px;
}

.archives summary {
  font-size: 14px;
  color: #888;
  cursor: pointer;
  user-select: none;
  padding: 4px 0 8px;
  list-style: none;
}

.archives summary::before { content: '▸ '; }
details[open] .archives summary::before { content: '▾ '; }

.archived-list {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid #f5ede3;
  gap: 12px;
}

.archived-list .archive-meta { font-size: 14px; color: #333; }
.archived-list .archive-meta small { color: #aaa; margin-left: 8px; font-size: 12px; }

.reload-btn {
  font-size: 12px;
  padding: 5px 12px;
  background: #f5ede3;
  color: #78350f;
  flex-shrink: 0;
}

.reload-btn:hover { background: #ecdcc8; }

.empty { color: #aaa; font-size: 14px; padding: 10px 0; }

/* ── Completed section ── */
.completed-section {
  margin-top: 28px;
  border-top: 1px solid #f0e6d8;
  padding-top: 12px;
}

.completed-section summary {
  font-size: 13px;
  color: #a78b6f;
  cursor: pointer;
  user-select: none;
  padding: 4px 0 8px;
  list-style: none;
}

.completed-section summary::before { content: '▸ '; }
details[open].completed-section > summary::before { content: '▾ '; }

/* ── Demo badge ── */
#demo-badge {
  position: fixed;
  top: 12px;
  right: 12px;
  background: #d97706;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 20px;
  z-index: 999;
  pointer-events: none;
}

/* ── Auth gate ── */
#auth-overlay {
  position: fixed;
  inset: 0;
  background: #fdf8f3;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.auth-box {
  text-align: center;
  width: 100%;
  max-width: 320px;
  padding: 0 24px;
}

.auth-box h1 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 28px;
  color: #1a1a1a;
}

#auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#auth-input {
  padding: 12px 16px;
  font-size: 16px;
  border: 1px solid #d4d4d4;
  border-radius: 12px;
  outline: none;
  text-align: center;
  background: #fff;
  transition: border-color 0.15s;
}

#auth-input:focus { border-color: #d97706; }

#auth-input.shake {
  animation: shake 0.4s ease;
  border-color: #dc2626;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-8px); }
  40%       { transform: translateX(8px); }
  60%       { transform: translateX(-6px); }
  80%       { transform: translateX(6px); }
}

/* ── Print ── */
@media print {
  .tabs,
  #groceries-section,
  .input-row,
  .delete-btn,
  input[type="checkbox"],
  #completed-section,
  #auth-overlay {
    display: none !important;
  }

  #tasks-section { display: block !important; }

  body { max-width: 100%; padding: 12px; font-size: 14px; }

  ul li { padding: 6px 0; border-bottom: 1px solid #ddd; }
  ul li span { font-size: 14px; }
}
