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

:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-muted: #888;
  --accent: #2ecc71;
  --danger: #e74c3c;
  --checked: #bbb;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a2e;
    --surface: #16213e;
    --text: #eee;
    --text-muted: #666;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 500px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 80px;
}

/* Header */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

header h1 {
  font-size: 24px;
  font-weight: 700;
}

.btn-suggestions {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-suggestions.has-suggestions {
  background: var(--accent);
  color: white;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* Tilføj form */
#add-form {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

#add-form input {
  height: 44px;
  border: 2px solid var(--text-muted);
  border-radius: var(--radius);
  padding: 0 10px;
  font-size: 15px;
  min-width: 0;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

#add-form input:focus {
  border-color: var(--accent);
}

#item-name {
  flex: 1;
}

#item-qty {
  width: 60px;
}

.btn-add {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: white;
  font-size: 28px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-add:active {
  transform: scale(0.95);
}

/* Forslag panel */
#suggestions-panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

#suggestions-panel h2 {
  font-size: 16px;
  margin-bottom: 12px;
  color: var(--accent);
}

.suggestion-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--bg);
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-name {
  font-size: 16px;
}

.suggestion-info {
  font-size: 12px;
  color: var(--text-muted);
}

.btn-suggest-add {
  min-width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: white;
  font-size: 20px;
  cursor: pointer;
}

/* Kategori-overskrifter i listen */
.category-header {
  padding-top: 16px;
  padding-bottom: 4px;
  padding-left: 4px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  list-style: none;
}

/* Fjern ekstra padding over første kategori-overskrift */
.category-header:first-child {
  padding-top: 4px;
}

/* Indkøbsliste */
#item-list {
  list-style: none;
}

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  transition: opacity 0.3s, transform 0.3s;
}

.item.checked {
  opacity: 0.5;
}

.item.removing {
  transform: translateX(100%);
  opacity: 0;
}

.item-check {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: transparent;
  transition: all 0.2s;
}

.item.checked .item-check {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.item-info {
  flex: 1;
  min-width: 0;
}

.item-name {
  font-size: 16px;
  font-weight: 500;
}

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

.item-qty {
  font-size: 13px;
  color: var(--text-muted);
}

.item-delete {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--danger);
  font-size: 20px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.item-delete:active {
  background: var(--danger);
  color: white;
}

/* Inline redigering */
.item-info {
  cursor: pointer;
}

.item.editing .item-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.edit-name, .edit-qty {
  width: 100%;
  height: 36px;
  border: 2px solid var(--accent);
  border-radius: 8px;
  padding: 0 8px;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  outline: none;
}

.edit-qty {
  height: 30px;
  font-size: 13px;
}

.edit-save {
  width: 100%;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.edit-category {
  width: 100%;
  height: 30px;
  border: 2px solid var(--accent);
  border-radius: 8px;
  padding: 0 8px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  outline: none;
}

/* Tom liste */
#empty-msg {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 18px;
}

.hidden {
  display: none !important;
}

/* Toast besked */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface);
  color: var(--danger);
  padding: 12px 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 100;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
