:root {
  --yellow: #f5c400;
  --ink: #141414;
  --cream: #e9e4d2;
  --gray: #b9bcc0;
  --gray-dark: #9aa0a6;
  --display: "Anton", system-ui, sans-serif;
  --display-alt: "Oswald", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--yellow);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-weight: 800;
  -webkit-font-smoothing: antialiased;
  padding: 24px clamp(20px, 5vw, 64px) 160px;
  position: relative;
  overflow-x: hidden;
}

/* Decorative cream shapes in the corners */
.decor {
  position: fixed;
  background: var(--cream);
  pointer-events: none;
  z-index: 0;
  opacity: 0.85;
}

.decor-tr {
  top: -28px;
  right: 64px;
  width: 150px;
  height: 96px;
  border-radius: 6px;
}

.decor-br {
  bottom: -60px;
  right: -40px;
  width: 320px;
  height: 90px;
  border-radius: 8px;
  transform: rotate(45deg);
  transform-origin: bottom right;
}

.page-header,
.list,
.empty,
.fab,
.modal-backdrop {
  position: relative;
  z-index: 1;
}

h1 {
  font-family: var(--display);
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  font-weight: 400;
  letter-spacing: 0.5px;
  margin: 0 0 28px;
}

/* ---------- List ---------- */
.list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 1100px;
}

.item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: clamp(16px, 4vw, 48px);
  cursor: pointer;
  border-radius: 6px;
  padding: 4px 2px;
}

.item-name {
  font-family: var(--display-alt);
  font-size: clamp(1.6rem, 4vw, 2.5rem);
  font-weight: 700;
  letter-spacing: 0.5px;
  line-height: 1.1;
  padding: 6px 14px;
  border: 3px solid transparent;
  border-radius: 4px;
  min-width: 180px;
  transition: border-color 0.12s, background 0.12s;
}

.item:hover .item-name,
.item:focus-within .item-name {
  border-color: var(--ink);
  background: rgba(255, 255, 255, 0.12);
}

.item-count {
  font-family: var(--display);
  font-size: clamp(1.7rem, 4.4vw, 2.8rem);
  font-weight: 400;
  letter-spacing: 0.5px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;

  /* Flowing, continuously moving multicolor gradient through the text. */
  background-image: linear-gradient(
    90deg,
    #c2185b,
    #6a1b9a,
    #1565c0,
    #00838f,
    #2e7d32,
    #c2185b
  );
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.18));
  animation: flow 6s linear infinite;
  will-change: background-position;
}

@keyframes flow {
  from {
    background-position: 0% 50%;
  }
  to {
    background-position: 300% 50%;
  }
}

.item.expired .item-count {
  background: none;
  -webkit-text-fill-color: #b3231a;
  color: #b3231a;
  filter: none;
  animation: none;
}

.empty {
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  font-weight: 700;
  opacity: 0.65;
  margin-top: 8px;
}

/* ---------- Floating add button ---------- */
.fab {
  position: fixed;
  left: 50%;
  bottom: 36px;
  transform: translateX(-50%);
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: none;
  background: var(--gray);
  color: var(--ink);
  font-size: 56px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  transition: background 0.12s, transform 0.08s;
}

.fab:hover {
  background: var(--gray-dark);
}

.fab:active {
  transform: translateX(-50%) scale(0.94);
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 20, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  background: #fff;
  color: var(--ink);
  width: 100%;
  max-width: 440px;
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
  font-weight: 600;
}

.modal h2 {
  margin: 0 0 18px;
  font-size: 1.4rem;
  font-weight: 900;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.field > span {
  font-size: 0.85rem;
  font-weight: 700;
  color: #555;
}

.field input {
  font: inherit;
  font-weight: 700;
  padding: 10px 12px;
  border: 2px solid #d4d4d4;
  border-radius: 8px;
}

.field input:focus-visible {
  outline: none;
  border-color: var(--ink);
}

.mode-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.mode-toggle button {
  flex: 1;
  font: inherit;
  font-weight: 800;
  padding: 9px;
  border: 2px solid #d4d4d4;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.mode-toggle button.active {
  background: var(--yellow);
  border-color: var(--ink);
}

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

.duration-grid .field {
  margin-bottom: 0;
}

.modal-error {
  color: #b3231a;
  font-weight: 700;
  font-size: 0.9rem;
  margin: 0 0 12px;
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.spacer {
  flex: 1;
}

.modal-actions button {
  font: inherit;
  font-weight: 800;
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent;
}

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

.btn-secondary {
  background: #fff;
  border-color: #d4d4d4;
}

.btn-delete {
  background: #fff;
  color: #b3231a;
  border-color: #e7c4bb;
}

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

@media (max-width: 560px) {
  .item {
    gap: 4px 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }

  /* Keep the colorful gradient but stop the motion. */
  .item-count {
    animation: none !important;
    background-position: 0% 50%;
  }
}
