:root {
  --bg: #ffe4ee;
  --paper: #fffafc;
  --ink: #2a1b2e;
  --muted: #7a5c74;
  --edge: #2a1b2e;
  --pink: #ffb8d2;
  --lilac: #d9b8ff;
  --peach: #ffd9b3;
  --mint: #c6f5e3;
  --border: 2px;
  --offset: 3px;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1220;
    --paper: #2a1e31;
    --ink: #fff1f6;
    --muted: #c4afc0;
    --edge: #fff1f6;
    --pink: #ff9ec5;
    --lilac: #c9a6ff;
    --peach: #ffc38a;
    --mint: #9fead0;
  }
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  font-size: 17px;
  -webkit-text-size-adjust: 100%;
}

@supports (font: -apple-system-body) {
  html {
    font: -apple-system-body;
  }
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 20px) 18px calc(env(safe-area-inset-bottom, 0px) + 28px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hero {
  padding: 0 2px;
}

h1 {
  margin: 0;
  font-size: 1.9em;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.sparkle {
  width: 0.8em;
  height: 0.8em;
  margin-left: 0.3em;
  vertical-align: -0.05em;
  fill: #ff5fa2;
}

h2 {
  margin: 0 0 8px;
  font-size: 1.05em;
  font-weight: 800;
}

.card {
  background: var(--paper);
  border: var(--border) solid var(--edge);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--offset) var(--offset) 0 var(--edge);
}

.card--yellow {
  background: var(--pink);
  color: #2a1b2e;
  --ink: #2a1b2e;
  --muted: #7a4560;
}

.field-label {
  display: block;
  font-size: 1.05em;
  font-weight: 800;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.section-head h2 {
  margin-bottom: 8px;
}

.kj-field {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.kj-field input {
  flex: 1;
  min-width: 0;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 2.8em;
  font-weight: 900;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  padding: 0;
  outline: none;
  caret-color: var(--ink);
}

.kj-field input::placeholder {
  color: var(--ink);
  opacity: 0.25;
}

.unit {
  font-size: 1.2em;
  font-weight: 800;
}

.text-button {
  background: none;
  border: none;
  padding: 0.5em 0.5em;
  margin: -0.5em -0.5em;
  min-height: 44px;
  font: inherit;
  font-size: 1.05em;
  font-weight: 800;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--lilac);
  text-decoration-thickness: var(--border);
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.comparisons {
  list-style: none;
  margin: 0;
  padding: 0;
}

.comparisons li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-top: 1px solid var(--muted);
}

.comparisons li:first-child {
  border-top: none;
  padding-top: 2px;
}

.comparisons li:last-child {
  padding-bottom: 2px;
}

.comparison-info {
  flex: 1;
  min-width: 0;
  font-size: 1.1em;
  overflow-wrap: anywhere;
}

.comparison-count {
  font-size: 1.15em;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #2a1b2e;
  background: var(--mint);
  border-radius: 0.35em;
  padding: 0 0.3em;
  margin-right: 0.15em;
}

.comparison-name {
  font-weight: 700;
}

.comparison-kj {
  color: var(--muted);
  white-space: nowrap;
}

.delete-button {
  display: none;
  width: 2.4em;
  height: 2.4em;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  border: var(--border) solid var(--edge);
  background: var(--pink);
  color: #2a1b2e;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}

.delete-button svg {
  display: block;
  width: 1em;
  height: 1em;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  fill: none;
}

.is-editing .delete-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.empty {
  margin: 0;
  color: var(--muted);
}

.add-form {
  display: none;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: var(--border) solid var(--edge);
}

.is-editing .add-form {
  display: flex;
}

.add-form h2 {
  margin: 0;
}

.add-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 1.05em;
  font-weight: 800;
  color: var(--muted);
}

.add-form input {
  font: inherit;
  font-size: 1em;
  font-weight: 500;
  color: #2a1b2e;
  background: #fff;
  border: var(--border) solid var(--edge);
  border-radius: var(--radius);
  padding: 10px 12px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.add-form input::placeholder {
  color: #2a1b2e;
  opacity: 0.35;
}

.add-form input:focus {
  box-shadow: var(--offset) var(--offset) 0 var(--edge);
}

.primary-button {
  margin-top: 2px;
  font: inherit;
  font-size: 1.05em;
  font-weight: 800;
  color: #2a1b2e;
  background: var(--pink);
  border: var(--border) solid var(--edge);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  box-shadow: var(--offset) var(--offset) 0 var(--edge);
}

.primary-button:active {
  transform: translate(var(--offset), var(--offset));
  box-shadow: none;
}

.install-dialog {
  width: min(90vw, 400px);
  margin: auto;
  padding: 18px 20px;
  background: var(--paper);
  color: var(--ink);
  border: var(--border) solid var(--edge);
  border-radius: var(--radius);
  box-shadow: var(--offset) var(--offset) 0 var(--edge);
}

.install-dialog::backdrop {
  background: rgba(42, 27, 46, 0.55);
}

.install-dialog form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.install-dialog h2,
.install-dialog p {
  margin: 0;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
}

.checkbox input {
  width: 1.3em;
  height: 1.3em;
  margin: 0;
  accent-color: #ff5fa2;
}

.share-icon {
  width: 1.1em;
  height: 1.1em;
  vertical-align: -0.15em;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.foot {
  text-align: center;
  font-size: 1em;
  color: var(--muted);
}

.foot p {
  margin: 0;
}

/* Dark mode: dark cards with coloured outlines. */
@media (prefers-color-scheme: dark) {
  .card {
    border-color: var(--lilac);
    box-shadow: var(--offset) var(--offset) 0 var(--lilac);
  }

  .card--yellow {
    background: var(--paper);
    color: var(--ink);
    --ink: #fff1f6;
    --muted: #c4afc0;
    border-color: var(--pink);
    box-shadow: var(--offset) var(--offset) 0 var(--pink);
  }

  .card--yellow .field-label {
    color: var(--pink);
  }

  .card--yellow .text-button {
    text-decoration-color: var(--pink);
  }

  .comparisons li {
    border-top-color: #4a3a52;
  }

  .comparison-count {
    background: transparent;
    color: var(--mint);
    padding: 0;
  }

  .delete-button {
    background: transparent;
    color: var(--pink);
    border-color: var(--pink);
  }

  .install-dialog {
    border-color: var(--lilac);
    box-shadow: var(--offset) var(--offset) 0 var(--lilac);
  }

  .install-dialog::backdrop {
    background: rgba(0, 0, 0, 0.6);
  }

  .add-form {
    border-top-color: #4a3a52;
  }

  .add-form label {
    color: var(--peach);
  }

  .add-form input {
    background: var(--bg);
    color: var(--ink);
    border-color: var(--lilac);
  }

  .add-form input::placeholder {
    color: var(--muted);
    opacity: 1;
  }

  .add-form input:focus {
    box-shadow: var(--offset) var(--offset) 0 var(--lilac);
  }

  .primary-button {
    background: var(--paper);
    color: var(--pink);
    border-color: var(--pink);
    box-shadow: var(--offset) var(--offset) 0 var(--pink);
  }
}
