:root {
  --red: #e0112b;
  --red-deep: #b50a20;
  --red-dark: #7d0615;
  --ink: #16040a;
  --cream: #fff3ef;
  --cream-dim: rgba(255, 243, 239, 0.72);
  --cream-faint: rgba(255, 243, 239, 0.16);
  --radius: 18px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--red);
  color: var(--cream);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100%;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(22px + env(safe-area-inset-top)) 18px calc(40px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100vh;
}

/* ---------- judge ---------- */
.judge-row { display: flex; align-items: flex-start; gap: 12px; }

.avatar {
  flex: none;
  width: 54px; height: 54px;
  display: grid; place-items: center;
  font-size: 30px;
  background: var(--ink);
  border-radius: 50%;
  transition: transform .25s cubic-bezier(.3, 1.6, .5, 1);
}
.avatar.react { animation: bop .5s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes bop {
  0% { transform: scale(1) rotate(0); }
  40% { transform: scale(1.18) rotate(-10deg); }
  100% { transform: scale(1) rotate(0); }
}

.bubble {
  position: relative;
  flex: 1;
  background: var(--cream);
  color: var(--ink);
  padding: 13px 15px;
  border-radius: 4px var(--radius) var(--radius) var(--radius);
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
  min-height: 54px;
}
.bubble.pop { animation: pop .35s ease-out; }
@keyframes pop {
  from { opacity: 0; transform: translateY(6px) scale(.97); }
  to { opacity: 1; transform: none; }
}

.meter { margin-top: 16px; }
.meter-top { display: flex; justify-content: space-between; align-items: baseline; }
.meter-label {
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .14em;
  color: var(--cream-dim);
}
.meter-value { font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }
.meter-track {
  margin-top: 7px;
  height: 8px;
  background: var(--red-dark);
  border-radius: 99px;
  overflow: hidden;
}
.meter-fill {
  height: 100%; width: 0%;
  background: var(--cream);
  border-radius: 99px;
  transition: width .6s cubic-bezier(.2, .9, .3, 1);
}
.verdict {
  margin-top: 8px;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: -0.035em;
  line-height: 1.02;
  text-transform: lowercase;
}

/* ---------- add ---------- */
.add { display: flex; gap: 8px; }
.add input {
  flex: 1;
  min-width: 0;
  background: var(--red-deep);
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 15px 16px;
  font-size: 16px;
  font-weight: 600;
  outline: none;
  transition: border-color .2s, background .2s;
}
.add input::placeholder { color: var(--cream-dim); font-weight: 500; }
.add input:focus { border-color: var(--cream); background: var(--red-dark); }
.add button {
  flex: none;
  width: 54px;
  background: var(--ink);
  color: var(--cream);
  border-radius: 14px;
  font-size: 28px;
  font-weight: 400;
  line-height: 1;
  transition: transform .15s;
}
.add button:active { transform: scale(.92); }
.add.shake { animation: shake .4s; }
@keyframes shake {
  0%, 100% { transform: none; }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 6px; }
.tabs button {
  padding: 8px 14px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 700;
  color: var(--cream-dim);
  transition: background .2s, color .2s;
}
.tabs button span { opacity: .6; margin-left: 2px; font-variant-numeric: tabular-nums; }
.tabs button.active { background: var(--cream); color: var(--ink); }

/* ---------- list ---------- */
.list { list-style: none; display: flex; flex-direction: column; gap: 8px; }

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--red-deep);
  border-radius: 14px;
  padding: 12px 10px 12px 12px;
  animation: slideIn .35s cubic-bezier(.2, .9, .3, 1);
  transition: opacity .3s, transform .3s;
}
.item.leaving { opacity: 0; transform: translateX(30px) scale(.96); }
@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

.check {
  flex: none;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2.5px solid var(--cream);
  display: grid; place-items: center;
  transition: background .2s, transform .15s;
}
.check:active { transform: scale(.85); }
.check svg { width: 14px; height: 14px; opacity: 0; transition: opacity .2s; }
.item.done .check { background: var(--cream); }
.item.done .check svg { opacity: 1; }

.body { flex: 1; min-width: 0; }
.text {
  font-size: 15.5px;
  font-weight: 650;
  line-height: 1.3;
  word-wrap: break-word;
}
.item.done .text { text-decoration: line-through; text-decoration-thickness: 2px; opacity: .6; }
.meta {
  margin-top: 3px;
  font-size: 12px;
  font-weight: 500;
  color: var(--cream-dim);
  font-style: italic;
}
.item.stale .meta { color: var(--cream); font-weight: 700; font-style: normal; }
.item.stale .meta::before { content: "⚠ "; }

.del {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 10px;
  display: grid; place-items: center;
  color: var(--cream-dim);
  font-size: 20px;
  transition: background .2s, color .2s;
}
.del:hover, .del:active { background: var(--red-dark); color: var(--cream); }

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--cream-dim);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
}
.empty b { display: block; font-size: 42px; margin-bottom: 8px; }
.empty:empty { display: none; }

.foot { margin-top: auto; display: flex; justify-content: center; padding-top: 10px; }
.ghost {
  font-size: 13px; font-weight: 700;
  color: var(--cream-dim);
  padding: 10px 16px;
  border-radius: 99px;
  transition: background .2s, color .2s;
}
.ghost:hover { background: var(--red-deep); color: var(--cream); }
.ghost[hidden] { display: none; }

.toast {
  position: fixed;
  left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: var(--cream);
  padding: 12px 18px;
  border-radius: 99px;
  font-size: 14px; font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  overflow: hidden; text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { margin-left: 10px; text-decoration: underline; font-weight: 800; }

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