
:root {
  color-scheme: dark;
  --bg: #09203b;
  --surface: #102c50;
  --surface2: #18395f;
  --pink: #e75c91;
  --pink2: #d94e83;
  --text: #f6f8ff;
  --muted: #a8bfd9;
  --line: #29496d;
  --green: #62d8a0;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: #061426;
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button, input, select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid #ffd1e2;
  outline-offset: 2px;
}

.app {
  width: 100%;
  max-width: 460px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding-bottom: 12px;
  background: var(--bg);
  overflow: hidden;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 17px;
  background: #147ed8;
  border-radius: 0 0 18px 18px;
}

.brand-icon {
  flex: 0 0 43px;
  width: 43px;
  height: 43px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(255,255,255,.14);
}

.brand-icon svg {
  width: 31px;
  color: white;
}

.app-header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.app-header p {
  margin: 4px 0 0;
  color: #e1f0ff;
  font-size: 12px;
}

#mainContent {
  padding: 17px 11px 22px;
}

.loading {
  padding: 25px 0;
  text-align: center;
  color: var(--muted);
}

.page-heading {
  margin: 3px 4px 16px;
}

.page-heading h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.3;
}

.page-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

/* Cercle de progression */

.progress-card {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px;
  margin-bottom: 21px;
  border-radius: 15px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.progress-ring {
  --progress: 0%;
  position: relative;
  flex: 0 0 66px;
  width: 66px;
  height: 66px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(
    var(--green) var(--progress),
    #345273 var(--progress)
  );
}

.progress-ring::before {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: var(--surface);
}

.progress-ring strong {
  position: relative;
  font-size: 15px;
}

.progress-info {
  flex: 1;
  min-width: 0;
}

.progress-info h3 {
  margin: 0 0 5px;
  font-size: 15px;
}

.progress-info p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.progress-track {
  height: 5px;
  margin-top: 9px;
  border-radius: 10px;
  overflow: hidden;
  background: #345273;
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: 10px;
  background: var(--green);
  transition: width .2s;
}

/* Grille de carrés, comme sur la photo */

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin: 0 3px 12px;
}

.section-title h3 {
  margin: 0;
  font-size: 16px;
}

.section-title small {
  color: var(--muted);
  font-size: 10px;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  align-items: stretch;
}

.category-card {
  aspect-ratio: .88;
  min-width: 0;
  padding: 9px 3px;
  border: 0;
  border-radius: 5px;
  background: var(--pink);
  color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  transition: filter .12s, transform .12s;
}

.category-card:nth-child(3n + 2) {
  background: var(--pink2);
}

.category-card:active {
  transform: scale(.97);
  filter: brightness(1.12);
}

.category-art {
  display: grid;
  place-items: center;
  width: 72%;
  max-width: 83px;
  aspect-ratio: 1;
  margin-bottom: 5px;
}

.category-art svg {
  display: block;
  width: 100%;
  height: 100%;
  color: white;
}

.category-card strong {
  display: block;
  max-width: 100%;
  font-size: clamp(10px, 3.1vw, 13px);
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.category-card small {
  margin-top: 4px;
  font-size: 9px;
  line-height: 1.25;
  color: #ffe7f0;
}

.category-card .mini-progress {
  width: 75%;
  height: 3px;
  margin-top: 6px;
  border-radius: 5px;
  overflow: hidden;
  background: rgba(255,255,255,.3);
}

.mini-progress span {
  display: block;
  height: 100%;
  background: white;
}

/* Pages secondaires */

.back-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 39px;
  margin: 0 0 17px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface2);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.back-arrow {
  font-size: 22px;
  line-height: 1;
}

.add-card,
.setting-card,
.list-card,
.empty-card {
  padding: 13px;
  margin-bottom: 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
}

.settings-title {
  margin: 0 0 12px;
  font-size: 15px;
}

.form-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.field {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 43px;
  padding: 10px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg);
  color: var(--text);
}

.field option {
  background: var(--surface);
  color: var(--text);
}

.field::placeholder {
  color: #829bb6;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.primary-button,
.secondary-button,
.danger-button {
  width: 100%;
  min-height: 43px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
}

.primary-button {
  border: 0;
  background: var(--pink);
  color: white;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--text);
}

.danger-button {
  border: 1px solid #814057;
  background: #54293b;
  color: #ffb7c7;
}

.list-card {
  padding: 8px 12px;
}

.food-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.food-item:last-child {
  border-bottom: 0;
}

.food-check {
  flex: 0 0 21px;
  width: 21px;
  height: 21px;
  margin: 2px 0 0;
  accent-color: var(--green);
}

.food-info {
  flex: 1;
  min-width: 0;
}

.food-name {
  display: block;
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.food-details {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.food-item.is-checked .food-name {
  color: var(--muted);
  text-decoration: line-through;
}

.delete-item {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: #45253a;
  color: #ffb3c2;
  font-size: 20px;
}

.empty-card {
  padding: 23px 13px;
  text-align: center;
}

.empty-card h3 {
  margin: 0 0 7px;
  font-size: 15px;
}

.empty-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 13px;
}

.filter-button {
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
}

.filter-button.active {
  border-color: var(--pink);
  background: var(--pink);
  color: white;
}

.setting-card p,
.setting-card li {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.setting-card ul {
  padding-left: 19px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.setting-row strong {
  font-size: 13px;
}

.setting-row p {
  margin: 4px 0 0;
}

.switch {
  position: relative;
  flex: 0 0 45px;
  width: 45px;
  height: 27px;
}

.switch input {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  background: #49617c;
  pointer-events: none;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: white;
  transition: transform .2s;
}

.switch input:checked + .switch-track {
  background: var(--pink);
}

.switch input:checked + .switch-track::after {
  transform: translateX(18px);
}

.app-footer {
  padding: 10px;
  text-align: center;
  color: var(--muted);
  font-size: 10px;
}

.toast {
  position: fixed;
  z-index: 20;
  bottom: 18px;
  left: 50%;
  width: max-content;
  max-width: calc(100% - 24px);
  padding: 11px 15px;
  border-radius: 10px;
  background: #244d6b;
  color: white;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity .2s, transform .2s;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

body.light-mode {
  color-scheme: light;
  --bg: #f1f5fb;
  --surface: #ffffff;
  --surface2: #e5edf7;
  --text: #19334e;
  --muted: #607890;
  --line: #d5e0ed;
}

body.light-mode {
  background: #e6edf7;
}

body.light-mode .progress-ring::before {
  background: var(--surface);
}

body.light-mode .danger-button {
  background: #fff0f3;
  color: #a5224c;
}

@media (min-width: 600px) {
  body {
    padding: 18px 0;
  }

  .app {
    min-height: calc(100dvh - 36px);
    border: 1px solid var(--line);
    border-radius: 18px;
  }

  .category-card strong {
    font-size: 13px;
  }
}

@media (max-width: 330px) {
  #mainContent {
    padding-right: 7px;
    padding-left: 7px;
  }

  .category-grid {
    gap: 4px;
  }

  .category-card {
    padding: 7px 2px;
  }

  .category-card strong {
    font-size: 10px;
  }

  .category-art {
    width: 70%;
  }
}
