:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --surface-2: #f0eee8;
  --border: #e3e0d8;
  --text: #1e1c18;
  --text-muted: #6b6558;
  --accent: #b5562f;
  --accent-hover: #9c4726;
  --accent-soft: #f3e2d6;
  --success: #3f7a4f;
  --success-soft: #e2efe3;
  --danger: #b0362f;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(30, 28, 24, 0.05), 0 8px 24px -12px rgba(30, 28, 24, 0.12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17150f;
    --surface: #201d17;
    --surface-2: #2a261d;
    --border: #3a352a;
    --text: #f2efe8;
    --text-muted: #a89f8c;
    --accent: #e08350;
    --accent-hover: #ec9968;
    --accent-soft: #3a291f;
    --success: #7fbf8e;
    --success-soft: #223324;
    --danger: #e0685f;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 16px 96px;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.25rem;
}

.brand .icon {
  font-size: 1.6rem;
}

.brand small {
  display: block;
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--text-muted);
}

button {
  font-family: inherit;
  cursor: pointer;
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.05s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
  border-color: var(--accent);
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.8rem;
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.card + .card {
  margin-top: 16px;
}

.progress-bar {
  height: 6px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 18px;
}

.progress-bar > div {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.3s ease;
}

.step-header {
  margin-bottom: 18px;
}

.step-header h2 {
  margin: 0 0 4px;
  font-size: 1.35rem;
}

.step-header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.field {
  margin-bottom: 18px;
}

.field label.field-label {
  display: block;
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 8px;
}

.select,
.text-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}

.select:focus,
.text-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 99px;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.chip.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.number-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.number-row button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 1.1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.number-row .value {
  min-width: 28px;
  text-align: center;
  font-weight: 700;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-row input {
  width: 20px;
  height: 20px;
}

details.advanced {
  margin-top: 6px;
}

details.advanced summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.step-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  gap: 10px;
}

.step-nav .spacer {
  flex: 1;
}

.quickstart-bar {
  text-align: center;
  margin: 12px 0 20px;
}

.quickstart-bar button {
  width: 100%;
}

.dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 14px;
}

.dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
}

.dots span.active {
  background: var(--accent);
  width: 18px;
  border-radius: 4px;
}

/* Checklist */
.checklist-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.search-input {
  flex: 1;
  min-width: 160px;
}

.progress-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.category-block {
  margin-bottom: 18px;
}

.category-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.category-title .count {
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

.item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
}

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

.item-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.item-row label {
  flex: 1;
  font-size: 0.95rem;
  cursor: pointer;
}

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

.item-qty {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-left: 4px;
}

.item-note {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.item-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 2px 6px;
  border-radius: 6px;
}

.item-remove:hover {
  color: var(--danger);
}

.provided-section summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  padding: 8px 0;
}

.add-item-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.add-item-row input {
  flex: 1;
}

.disclaimer-note {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Medication */
.med-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}

@media (max-width: 560px) {
  .med-row {
    grid-template-columns: 1fr 1fr;
  }
}

.med-row input {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.88rem;
}

/* Saves list */
.save-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.save-item .meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.save-actions {
  display: flex;
  gap: 6px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 14, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  padding: 0;
}

@media (min-width: 620px) {
  .modal-backdrop {
    align-items: center;
  }
}

.modal {
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 20px;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
}

@media (min-width: 620px) {
  .modal {
    border-radius: var(--radius);
  }
}

.modal h3 {
  margin-top: 0;
}

.modal-close {
  float: right;
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--text-muted);
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 99px;
  font-size: 0.85rem;
  z-index: 60;
  box-shadow: var(--shadow);
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 24px 0;
  font-size: 0.9rem;
}

.footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}

visually-hidden,
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

@media print {
  header.top, .quickstart-bar, .step-nav, .checklist-toolbar, .footer-actions, .btn, .provided-section summary ~ *:not(.item-row) {
    display: none !important;
  }
  body {
    background: #fff;
    color: #000;
  }
  .card {
    box-shadow: none;
    border: none;
  }
}
