:root {
  --bg: #fff8f1;
  --card: #ffffff;
  --ink: #2b2420;
  --muted: #6f625a;
  --accent: #ff7a59;
  --accent-ink: #ffffff;
  --accent-dark: #e85d3b;
  --heart: #e8335a;
  --line: #f1e3d6;
  --ok: #1f7a4d;
  --err: #b42318;
  --shadow: 0 2px 10px rgba(80, 40, 10, 0.08);
  --radius: 18px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1a18;
    --card: #2a2623;
    --ink: #f6efe9;
    --muted: #bfb2a8;
    --line: #3a3430;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
    --heart: #ff5c7c;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 18px;
  line-height: 1.45;
}

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           max(40px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.top { text-align: center; margin: 8px 0 20px; }

h1 {
  font-size: clamp(1.7rem, 6.5vw, 2.4rem);
  line-height: 1.15;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.lead { margin: 0; color: var(--muted); font-size: 1.1rem; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- add form ---------- */
.add {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 20px;
  position: sticky;
  top: 8px;
  z-index: 5;
}

.add-row { display: flex; gap: 10px; }

.add input {
  flex: 1;
  min-width: 0;
  min-height: 56px;
  padding: 12px 16px;
  font: inherit;
  font-size: 1.1rem; /* >=16px stops iOS zoom */
  color: var(--ink);
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: 14px;
  outline: none;
}
.add input:focus { border-color: var(--accent); }
.add input[aria-invalid="true"] { border-color: var(--err); }

.btn-add {
  min-height: 56px;
  min-width: 88px;
  padding: 0 22px;
  font: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent);
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  touch-action: manipulation;
}
.btn-add:hover { background: var(--accent-dark); }
.btn-add:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-add:focus-visible, .heart:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.counter { margin: 8px 4px 0; text-align: right; font-size: 0.9rem; color: var(--muted); }
.counter.near { color: #b26a00; }
.counter.over { color: var(--err); font-weight: 700; }

/* ---------- list ---------- */
.status { text-align: center; color: var(--muted); }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }

.card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 10px 10px 18px;
  min-height: 72px;
}

.card.flash { animation: flash 1.4s ease-out; }
@keyframes flash {
  0% { box-shadow: 0 0 0 4px var(--accent); }
  100% { box-shadow: var(--shadow); }
}

.idea-text {
  flex: 1;
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.heart {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 76px;
  min-height: 56px;
  padding: 0 14px;
  font: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
  background: transparent;
  border: 2px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.heart:disabled { cursor: progress; }
.heart-icon { width: 26px; height: 26px; }
.heart-icon path { fill: none; stroke: var(--heart); stroke-width: 2; stroke-linejoin: round; }
.heart.on { border-color: var(--heart); color: var(--heart); }
.heart.on .heart-icon path { fill: var(--heart); }
.heart:active .heart-icon { transform: scale(1.2); }
.heart-icon { transition: transform 0.12s ease; }

.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.empty-big { font-size: 1.4rem; color: var(--ink); margin: 0 0 6px; font-weight: 700; }

.foot { text-align: center; color: var(--muted); font-size: 0.95rem; margin-top: 28px; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: min(92vw, 520px);
  padding: 14px 20px;
  border-radius: 14px;
  background: #2b2420;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
  z-index: 20;
}
.toast-error { background: var(--err); }
.toast-ok { background: var(--ok); }

.noscript { text-align: center; padding: 20px; }

/* ---------- admin page ---------- */
.admin-box { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.admin-box input { width: 100%; min-height: 52px; padding: 10px 14px; font: inherit; color: var(--ink); background: var(--bg); border: 2px solid var(--line); border-radius: 12px; margin: 6px 0 12px; }
.admin-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-plain { min-height: 52px; padding: 0 18px; font: inherit; font-weight: 600; color: var(--ink); background: transparent; border: 2px solid var(--line); border-radius: 12px; cursor: pointer; }
.btn-danger { min-height: 52px; padding: 0 16px; font: inherit; font-weight: 700; color: #fff; background: var(--err); border: 0; border-radius: 12px; cursor: pointer; flex: none; }
.admin-votes { color: var(--muted); font-size: 0.95rem; flex: none; }
