:root {
  /* 🎨 THE ONLY 3 YOU CHANGE */
  --bg: #fbe8ef;
  --ink: #2d0819;
  --accent: #f7b7d2;
  --font-main:
    "Poppins", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  --font-alt:
    "Quicksand", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;

  /* derived theme tokens (don’t edit) */
  --surface: color-mix(in srgb, white 92%, var(--bg));
  --surface-2: color-mix(in srgb, white 86%, var(--bg));
  --muted: color-mix(in srgb, var(--ink) 55%, var(--bg));
  --border: color-mix(in srgb, var(--ink) 18%, var(--bg));

  --accent-ink: color-mix(
    in srgb,
    var(--ink) 70%,
    #7a1f45
  ); /* richer headings/labels */
  --accent-soft: color-mix(in srgb, var(--accent) 18%, white);
  --accent-outline: color-mix(in srgb, var(--accent) 55%, transparent);

  --danger: #c43b58;

  --radius: 22px;

  --shadow: 0 10px 26px color-mix(in srgb, var(--accent) 16%, transparent);
  --shadow-soft: 0 4px 14px color-mix(in srgb, var(--accent) 12%, transparent);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-main);

  /* cute glow derived from accent */
  background:
    radial-gradient(
      1000px 500px at 20% 0%,
      color-mix(in srgb, var(--accent) 25%, transparent),
      transparent 55%
    ),
    radial-gradient(
      800px 400px at 80% 10%,
      color-mix(in srgb, var(--accent) 16%, transparent),
      transparent 55%
    ),
    var(--bg);

  color: var(--ink);
}

.noteInput {
  width: 100%;
  min-height: 120px;
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: 12px;
  font: inherit;
  resize: vertical;
  box-sizing: border-box;
}

.topbar {
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 14px 14px 10px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.slogan {
  margin: 0px 0 0px;
  color: var(--muted);
  font-family: var(--font-alt);
  font-size: 12px;
  /* font-style: italic; */
}

h1 {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.title h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0.2px;
  color: var(--accent-ink);
}

.subtitle {
  margin: 4px 0 10px;
  color: var(--muted);
  font-size: 18px;
}

.controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  width: 100%;
}

/* Center column */
.nav-stack {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.navigate {
  grid-column: 2;
  display: flex;
  gap: 8px;
}

.controls.secondary {
  display: none;
  margin-top: 3px;
}

#secondaryControls {
  display: none;
}

#secondaryControls.is-visible {
  display: flex;
  justify-content: center;
  margin-top: 6px;
}

.container {
  padding: 14px;
  max-width: 980px;
  margin: 0 auto;
}

.btn,
.select,
.search {
  font-family: var(--font-main);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  min-height: 30px; /* good touch target */
  padding: 0 14px; /* horizontal comfort */
  font-size: 14px;
  line-height: 1;
}

#backup {
  /* color: green; */
}

#settingsBtn {
  grid-column: 3;
  justify-self: end;
}

.icon-btn {
  padding: 0 14px;
  /* min-height: 44px; */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  color: var(--muted);
}

.icon-btn i {
  font-size: 16px;
  line-height: 1;
}

.btn {
  cursor: pointer;
}
.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
}

.btn-danger {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--border));
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
}

.fileBtn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.view {
  margin-top: 14px;
}
.hidden {
  display: none !important;
}

/* cards */
.card {
  font-family: var(--font-main);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.monthHeader {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.monthHeader h2 {
  margin: 0;
  font-size: 16px;
  color: var(--accent-ink);
}
.monthHeader .small {
  color: var(--muted);
  font-size: 12px;
}

.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0;
  padding: 10px 10px 0;
  color: var(--muted);
  font-size: 12px;
}
.weekdays div {
  text-align: center;
  padding: 6px 0;
}

.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  padding: 10px;
}

.day {
  font-family: var(--font-alt);
  font-weight: 400;
  min-height: 78px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: var(--surface);
  padding: 2px;
  position: relative;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease;
  overflow: hidden;
}
.day:active {
  transform: translateY(1px);
}
.day:hover {
  box-shadow: var(--shadow-soft);
}

.day .num {
  font-size: 12px;
  color: var(--muted);
}

.day.today {
  outline: 2px solid var(--accent-outline);
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent),
    var(--shadow-soft);
}

.day.outside {
  opacity: 0.45;
}

.stickerSlot {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 2px;
  min-height: 0; /* allows children to shrink */
}

.stickerSlot img {
  width: min(44px, 80%);
  height: min(44px, 80%);
  object-fit: contain;
  display: block;
}

/* Year view */
.yearGrid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 12px;
}
@media (min-width: 720px) {
  .yearGrid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.miniMonth {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.miniMonthTitle {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.miniCal {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.miniDay {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  line-height: 1;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  height: 48px;
  min-height: 48px;
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  cursor: pointer;
  align-content: end;
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease;
}
.miniDay:hover {
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}

.miniDay img {
  width: 90%;
  /* width: 18px;
  height: 18px; */
  object-fit: contain;
  /* padding-top: 5px; */
}

.miniDay.empty {
  opacity: 0.35;
  cursor: default;
}

.miniNum {
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  line-height: 1;
  pointer-events: none;
  z-index: 2;
}

/* Modal */
.overlay {
  position: fixed;
  inset: 0;
  background: color-mix(
    in srgb,
    black 55%,
    color-mix(in srgb, var(--accent) 18%, transparent)
  );
  display: grid;
  place-items: start center;
  padding: 14px;
  overflow-y: auto;
  z-index: 9999;
}

@media (min-width: 720px) {
  .overlay {
    place-items: center;
  }
}

.modal {
  width: min(980px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.18),
    var(--shadow);
}

.modalHeader {
  position: sticky;
  top: 0;
  z-index: 5;

  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px;

  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.modalHeader {
  backdrop-filter: blur(6px);
}

.modalHeaderActions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.modalDate {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-ink);
}

.modalHint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.modalTools {
  display: flex;
  gap: 8px;
  padding: 2px 2px;
  /* border-bottom: 1px solid var(--border); */
  flex-wrap: wrap;
  /* background: var(--surface); */
}

.search {
  display: none;
  flex: 1;
  min-width: 200px;
  border-radius: 999px;
}

.grid {
  padding: 12px 14px 16px;
  overflow: visible;
  display: block;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.stickerBtn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 16px;
  padding: 2px;
  cursor: pointer;
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 120px;
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease;
}
.stickerBtn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
}
.stickerBtn:active {
  transform: translateY(0px);
}

.stickerBtn img {
  width: 70%;
  /* width: 44px;
  height: 44px; */
  object-fit: contain;
}

.stickerLabel {
  display: none;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

/* Accessibility: focus ring */
.btn:focus-visible,
.select:focus-visible,
.search:focus-visible,
.day:focus-visible,
.miniDay:focus-visible,
.stickerBtn:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: 2px;
}

/* --- Mobile month grid fixes --- */

/* Prevent random horizontal cutoff */
html,
body {
  overflow-x: hidden;
}

.calendar {
  width: 100%;
}

/* Under ~550px: make day cells uniform + tighten spacing */
@media (max-width: 550px) {
  .container {
    padding: 10px;
  }

  .calendar {
    /* gap: 6px; */
    padding: 8px;
  }

  .day {
    min-height: 0; /* remove the old minimum */
    aspect-ratio: 1 / 1; /* keep all cells the same size */
    padding: 6px;
    border-radius: 16px;
  }

  .day .num {
    font-size: 11px;
  }

  .stickerSlot img {
    max-width: 36px;
    max-height: 36px;
  }

  .controls {
    justify-content: center;
  }
}

/* Under ~440px: tighten even more so nothing clips */
@media (max-width: 440px) {
  .calendar {
    gap: 4px;
    padding: 6px;
  }

  .day {
    padding: 5px;
    border-radius: 14px;
  }

  .stickerSlot img {
    width: 100%;
    /* max-width: 32px;
    max-height: 32px; */
  }
}

/* --- Tiny screens: keep stickers inside day boxes --- */
@media (max-width: 440px) {
  /* Let the day number float so it doesn't steal layout space */
  .day {
    position: relative;
  }

  .day .num {
    position: absolute;
    top: 6px;
    left: 8px;
    margin: 0;
    z-index: 2;
    font-size: 11px;
    line-height: 1;
    color: var(--muted);
    pointer-events: none;
  }

  /* Sticker gets the whole box, with a bit of top room for the number */
  .stickerSlot {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding-top: 10px;
    min-height: 0;
    min-width: 0;
  }

  .stickerSlot img {
    /* width: clamp(18px, 70%, 40px);
    height: clamp(18px, 70%, 40px); */
    /* max-width: 100%;
    max-height: 100%; */
    object-fit: contain;
    display: block;
    padding-bottom: 2px;
  }
}

/* Category-first sticker picker */
.catList {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 720px) {
  .catList {
    grid-template-columns: repeat(4, 1fr);
  }
}

.catTile {
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 18px;
  padding: 2px;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  display: grid;
  /* gap: 8px; */
  justify-items: center;
  min-height: 120px;
}

.catName {
  font-weight: 700;
  color: var(--accent-ink);
  font-size: 16px;
}

.catMeta {
  font-size: 14px;
  color: var(--muted);
  margin-top: -4px;
}

.catPreview {
  display: flex;
  gap: 6px;
  align-items: center;
}

.catPreview img {
  width: 100%;
  max-width: 56px;
  height: auto;
}

.catTopRow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.catTitle {
  font-weight: 800;
  color: var(--accent-ink);
}

.catGrid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

/* deleted */

.day .num.has-note,
.miniDay .miniNum.has-note {
  font-weight: 999;
  color: var(--accent-ink);
}

@media (min-width: 720px) {
  .catGrid {
    grid-template-columns: repeat(4, 1fr);
    aspect-ratio: 1;
  }
}

@media (max-width: 720px) {
  .catPreview img {
    max-width: 42px;
    height: auto;
  }
}

@media (max-width: 720px) {
  .modal {
    max-height: 92vh;
  }
}

@media (max-width: 440px) {
  .day .num.has-note {
    z-index: 2;
    background: transparent; /* ← key change */
    padding: 1px 1.5px;
    min-width: 1.4em;
    height: 1.3em;
    border-width: 1.5px;
  }

  .miniDay .miniNum.has-note {
    background: transparent; /* ← key change */
    z-index: 2;
    padding: 1px 2px;
    min-width: 1em;
    height: 1em;
    border-width: 1px;
  }
}
