/* ========== CSS Variables ========== */
:root {
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-danger: #dc2626;
  --color-danger-hover: #b91c1c;
  --color-success: #16a34a;
  --color-bg: #f1f5f9;
  --color-surface: #ffffff;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-border: #e2e8f0;
  --color-bought: #94a3b8;
  --radius: 10px;
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

/* ========== Base ========== */
body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  padding: 0 16px 40px;
}

/* ========== Container ========== */
.container {
  max-width: 560px;
  margin: 0 auto;
}

/* ========== Header ========== */
.app-header {
  padding: 24px 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
  flex: 1;
}

.back-link {
  color: var(--color-primary);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  white-space: nowrap;
}
.back-link:hover { text-decoration: underline; }

/* ========== List name heading (editable) ========== */
.list-name-wrap {
  flex: 1;
  min-width: 0;
}
.list-name {
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 6px;
  padding: 2px 6px;
  background: transparent;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: border-color 0.15s;
}
.list-name:hover { border-color: var(--color-border); }
.list-name:focus {
  outline: none;
  border-color: var(--color-primary);
  background: var(--color-surface);
  white-space: normal;
  overflow: visible;
}

/* ========== Card ========== */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

/* ========== Hero (landing page) ========== */
.hero {
  text-align: center;
  padding: 60px 0 32px;
}
.hero h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 8px;
}
.hero p {
  color: var(--color-text-muted);
  font-size: 1rem;
  margin-bottom: 32px;
}

/* ========== Forms ========== */
.input-row {
  display: flex;
  gap: 8px;
}

input[type="text"] {
  flex: 1;
  padding: 12px 14px;
  font-size: 16px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  color: var(--color-text);
  transition: border-color 0.15s;
  min-height: 48px;
}
input[type="text"]:focus {
  outline: none;
  border-color: var(--color-primary);
  background: var(--color-surface);
}
input[type="text"]::placeholder { color: var(--color-text-muted); }

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  min-height: 48px;
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); }

.btn-danger {
  background: var(--color-danger);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { background: var(--color-danger-hover); }

.btn-secondary {
  background: var(--color-border);
  color: var(--color-text);
}
.btn-secondary:hover:not(:disabled) { background: #cbd5e1; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 6px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
  min-width: 36px;
  min-height: 36px;
}
.btn-icon:hover { color: var(--color-danger); background: #fee2e2; }

/* ========== Item list ========== */
#items-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--color-border);
  transition: opacity 0.15s;
}
.item-row:last-child { border-bottom: none; }

.item-checkbox {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid var(--color-border);
  cursor: pointer;
  flex-shrink: 0;
  appearance: none;
  -webkit-appearance: none;
  background: var(--color-surface);
  transition: background 0.15s, border-color 0.15s;
  position: relative;
}
.item-checkbox:checked {
  background: var(--color-success);
  border-color: var(--color-success);
}
.item-checkbox:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 8px;
  height: 12px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(40deg);
}

.item-name {
  flex: 1;
  font-size: 1rem;
  word-break: break-word;
}
.item-name.bought {
  text-decoration: line-through;
  color: var(--color-bought);
}

/* ========== Empty state ========== */
.empty-state {
  text-align: center;
  padding: 32px 0;
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

/* ========== Action footer ========== */
.action-footer {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.action-footer .btn { flex: 1; min-width: 140px; }

/* ========== Toast ========== */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: #1e293b;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.9rem;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: auto;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--color-danger); }

/* ========== Loading ========== */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--color-text-muted);
}

/* ========== Responsive ========== */
@media (min-width: 600px) {
  body { padding: 0 24px 60px; }
  .hero { padding: 80px 0 40px; }
  .hero h1 { font-size: 2.4rem; }
  .card { padding: 28px; }
}

@media (min-width: 900px) {
  .hero { padding: 100px 0 48px; }
}
