
:root {
  color-scheme: light;
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-soft: #f0f2f8;
  --text: #202338;
  --muted: #81869b;
  --border: #e7e9f1;
  --accent: #635bdf;
  --accent-soft: #eeecff;
  --success: #209b75;
  --danger: #d9485f;
  --shadow: 0 8px 24px rgba(32, 35, 56, .045);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 280px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

button:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.app {
  position: relative;
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 26px 20px 110px;
  background: var(--bg);
  overflow-wrap: anywhere;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 24px;
}

.eyebrow {
  display: block;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.7px;
  margin-bottom: 7px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(27px, 7vw, 33px);
  letter-spacing: -1.3px;
  line-height: 1.15;
}

.title-dot {
  color: var(--accent);
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.icon-button {
  flex: 0 0 auto;
  width: 43px;
  height: 43px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.icon-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.progress-card {
  padding: 20px;
  margin-bottom: 28px;
  color: #fff;
  border-radius: 22px;
  background: linear-gradient(135deg, #635bdf, #8176ed);
  box-shadow: 0 12px 28px rgba(99, 91, 223, .2);
}

.progress-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 21px;
}

.progress-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  opacity: .8;
}

.progress-card h2 {
  margin: 8px 0 5px;
  font-size: 18px;
  line-height: 1.3;
}

.progress-card p {
  margin: 0;
  color: rgba(255, 255, 255, .78);
  font-size: 12px;
}

.progress-number {
  display: grid;
  place-items: center;
  flex: 0 0 60px;
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255, 255, 255, .3);
  border-radius: 50%;
  font-size: 16px;
  font-weight: 800;
}

.progress-track {
  height: 7px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255, 255, 255, .23);
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: #fff;
  transition: width .25s ease;
}

.progress-bottom {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  color: rgba(255, 255, 255, .85);
  font-size: 11px;
}

.add-section,
.list-section {
  margin-bottom: 30px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 17px;
}

.section-heading h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.4px;
}

.small-label,
.item-total {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

#addForm {
  padding: 19px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

#addForm > label,
.form-row label {
  display: block;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

#addForm > input,
#addForm > select,
.form-row input,
.form-row select {
  display: block;
  width: 100%;
  min-width: 0;
  height: 45px;
  padding: 0 12px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
}

#addForm input::placeholder {
  color: #a4a8b8;
}

.form-row {
  display: grid;
  grid-template-columns: .75fr 1.25fr;
  gap: 12px;
}

.form-row input,
.form-row select {
  margin-bottom: 16px;
}

.primary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: 48px;
  padding: 12px;
  border: 0;
  border-radius: 13px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 750;
  transition: filter .15s, transform .15s;
}

.primary-button:active {
  transform: scale(.98);
}

.primary-button:hover {
  filter: brightness(1.06);
}

.plus-symbol {
  font-size: 21px;
  line-height: 1;
  font-weight: 400;
}

.form-message {
  margin: 9px 0 0;
  font-size: 11px;
  color: var(--success);
}

.form-message:empty {
  display: none;
}

.filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 12px;
  margin-bottom: 7px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.filter-row::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  flex: 0 0 auto;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.filter-chip.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.list-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 15px;
}

.hide-checked {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 10px;
}

.hide-checked input {
  accent-color: var(--accent);
}

.text-button {
  padding: 5px 0;
  border: 0;
  background: transparent;
  color: var(--danger);
  font-size: 10px;
  font-weight: 750;
}

.category-group {
  margin-bottom: 19px;
}

.category-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px 10px;
}

.category-heading-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.category-dot {
  flex: 0 0 9px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--category-color, var(--accent));
}

.category-heading h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
}

.category-heading > span {
  color: var(--muted);
  font-size: 10px;
}

.food-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface);
  transition: opacity .2s, background .2s;
}

.food-card.checked {
  background: var(--surface-soft);
}

.food-checkbox {
  appearance: none;
  flex: 0 0 21px;
  width: 21px;
  height: 21px;
  margin: 0;
  border: 1.7px solid #c8cad8;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
}

.food-checkbox:checked {
  display: grid;
  place-content: center;
  border-color: var(--success);
  background: var(--success);
}

.food-checkbox:checked::after {
  content: "";
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}

.food-info {
  flex: 1;
  min-width: 0;
}

.food-name {
  display: block;
  overflow-wrap: anywhere;
  margin-bottom: 5px;
  font-size: 13px;
  font-weight: 750;
}

.checked .food-name {
  color: var(--muted);
  text-decoration: line-through;
}

.food-quantity {
  color: var(--muted);
  font-size: 11px;
}

.food-status {
  display: inline-block;
  margin-left: 5px;
  color: var(--success);
  font-size: 10px;
  font-weight: 750;
}

.delete-item {
  display: grid;
  place-items: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 19px;
}

.delete-item:hover {
  background: var(--surface-soft);
  color: var(--danger);
}

.empty-state {
  padding: 30px 15px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 19px;
  background: var(--surface);
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin: 0 auto 13px;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 28px;
}

.empty-state h3 {
  margin: 0 0 7px;
  font-size: 14px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.app-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 24px;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
}

.bottom-nav {
  position: fixed;
  z-index: 10;
  bottom: 0;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: space-around;
  width: min(100%, 480px);
  min-height: 76px;
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
  transform: translateX(-50%);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 90px;
  padding: 4px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.nav-item svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item.active {
  color: var(--accent);
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  background: rgba(16, 18, 34, .52);
  backdrop-filter: blur(5px);
}

.settings-panel {
  width: 100%;
  max-width: 448px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  border: 1px solid var(--border);
  border-radius: 25px;
  background: var(--surface);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .18);
}

.modal-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 23px;
}

.modal-heading h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -.7px;
}

.close-button {
  font-size: 25px;
  box-shadow: none;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.setting-copy {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setting-copy strong,
.setting-info strong {
  font-size: 13px;
}

.setting-copy span,
.setting-info p,
.danger-section p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.switch {
  position: relative;
  flex: 0 0 48px;
  width: 48px;
  height: 28px;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 99px;
  background: #d4d6e1;
  transition: background .2s;
  cursor: pointer;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .12);
  transition: transform .2s;
}

.switch input:checked + .switch-track {
  background: var(--accent);
}

.switch input:checked + .switch-track::after {
  transform: translateX(20px);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.setting-info {
  padding: 19px 0;
  border-bottom: 1px solid var(--border);
}

.setting-info p {
  margin-top: 7px;
}

.setting-info > span {
  display: block;
  margin-top: 9px;
  color: var(--success);
  font-size: 10px;
}

.danger-section {
  padding-top: 21px;
}

.danger-section h3 {
  margin: 0 0 8px;
  font-size: 13px;
}

.danger-button {
  width: 100%;
  min-height: 45px;
  margin-top: 15px;
  padding: 11px;
  border: 1px solid rgba(217, 72, 95, .3);
  border-radius: 12px;
  background: rgba(217, 72, 95, .08);
  color: var(--danger);
  font-size: 12px;
  font-weight: 750;
}

.toast {
  position: fixed;
  z-index: 50;
  bottom: 92px;
  left: 50%;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .13);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity .2s, transform .2s;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

body.dark-mode {
  color-scheme: dark;
  --bg: #11121a;
  --surface: #1b1d29;
  --surface-soft: #252736;
  --text: #f0f1fa;
  --muted: #a0a4b9;
  --border: #303344;
  --accent: #9188ff;
  --accent-soft: #302e50;
  --success: #4dcc9b;
  --danger: #ff7085;
  --shadow: 0 8px 24px rgba(0, 0, 0, .12);
}

body.dark-mode .progress-card {
  background: linear-gradient(135deg, #5147c6, #6d61db);
}

body.dark-mode .primary-button {
  background: #7168e9;
}

body.dark-mode .icon-button {
  box-shadow: none;
}

body.dark-mode .empty-icon {
  background: #302e50;
}

body.dark-mode .switch-track {
  background: #44475a;
}

@media (min-width: 600px) {
  body {
    padding: 22px 0;
  }

  .app {
    min-height: calc(100vh - 44px);
    border: 1px solid var(--border);
    border-radius: 28px;
    box-shadow: 0 16px 55px rgba(24, 27, 48, .09);
    padding-top: 30px;
  }

  .bottom-nav {
    bottom: 22px;
    border: 1px solid var(--border);
    border-radius: 0 0 28px 28px;
  }

  .modal-backdrop {
    align-items: center;
  }

  .settings-panel {
    border-radius: 25px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
