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

:root {
  --brand: #F5939D;
  --pink: #F26F7D;
  --green: #183029;
  --green-mid: #41695B;
  --grey-50: #fafafa;
  --grey-100: #f6f6f6;
  --grey-200: #ebebeb;
  --grey-400: #bbb;
  --grey-600: #777;
  --grey-700: #4d4d4d;
  --grey-900: #1a1a1a;

  --bg: #E3EAE6;
  --surface: #ffffff;
  --surface-2: var(--grey-100);
  --text: var(--grey-900);
  --text-secondary: var(--grey-700);
  --text-muted: var(--grey-600);
  --border: var(--grey-200);
  --border-soft: rgba(152,158,143,0.4);
  --input-bg: #ffffff;
  --modal-overlay: rgba(15,15,15,0.5);
  --ok: #2f8f5b;
  --ok-light: rgba(47,143,91,0.12);
  --danger: #c94b4b;
  --vote-gray: var(--grey-400);
}

:root[data-theme="dark"] {
  --bg: #0e1613;
  --surface: #17211d;
  --surface-2: rgba(255,255,255,0.06);
  --text: #eef2ef;
  --text-secondary: #b7c0ba;
  --text-muted: #8a948e;
  --border: rgba(255,255,255,0.14);
  --border-soft: rgba(255,255,255,0.14);
  --input-bg: #1c2622;
  --modal-overlay: rgba(0,0,0,0.65);
  --ok: #6fbf9c;
  --ok-light: rgba(111,191,156,0.16);
  --danger: #e08585;
  --vote-gray: rgba(255,255,255,0.2);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background 0.15s, color 0.15s;
}

.hidden { display: none !important; }

/* ── Header ─────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--green);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding: 0 32px 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-left { display: flex; align-items: center; gap: 12px; flex-shrink: 0; min-width: 0; }
.brand-icon { width: 24px; height: 24px; object-fit: contain; flex-shrink: 0; display: block; }
.header-title {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #fff;
  white-space: nowrap;
}

.header-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.admin-controls { display: flex; align-items: center; gap: 10px; }

.header-btn {
  font-size: 0.75rem;
  font-weight: 500;
  color: rgba(255,255,255,0.65);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.14);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: inherit;
}
.header-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }
.header-btn.active { color: var(--brand); background: rgba(245,147,157,0.14); border-color: rgba(245,147,157,0.35); }
.header-btn.accent { color: var(--brand); background: rgba(245,147,157,0.14); border-color: rgba(245,147,157,0.35); }

.mode-toggle { display: flex; gap: 6px; }

.theme-toggle-btn { padding: 6px 9px; display: flex; align-items: center; justify-content: center; }
.theme-toggle-btn .theme-icon { display: none; }
:root:not([data-theme="dark"]) .theme-toggle-btn .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle-btn .icon-sun { display: block; }

/* ── Main layout ─────────────────────────────── */
main { max-width: 640px; margin: 0 auto; padding: 32px 20px 60px; }

/* ── Items ─────────────────────────────────── */
.items { margin-bottom: 16px; }

.item-row {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  box-shadow: 0 2px 20px rgba(24,48,41,0.06);
  padding: 14px 18px 16px;
  margin-bottom: 10px;
}

/* Voter / preview view: no card chrome, just a plain divided list */
.item-row.plain {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  box-shadow: none;
  border-radius: 0;
  padding: 14px 2px;
}
.item-row.plain:last-child { border-bottom: none; }

.item-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.item-main { display: flex; align-items: flex-start; gap: 14px; }
.item-body { flex: 1; min-width: 0; }
.item-text {
  font-size: 1rem;
  line-height: 1.4;
  color: var(--text);
  outline: none;
}
.item-context {
  font-size: 14px;
  color: var(--text);
  margin-top: 3px;
  line-height: 1.4;
  outline: none;
}
.item-context:empty::before,
.item-context[data-placeholder]:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  opacity: 0.6;
}
[contenteditable="true"] { cursor: text; }
[contenteditable="true"]:hover { background: var(--surface-2); border-radius: 4px; }
[contenteditable="true"]:focus {
  box-shadow: 0 0 0 2px var(--brand);
  border-radius: 4px;
  background: var(--surface-2);
}

.item-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; padding-top: 0.1rem; }
.vote-count { font-size: 0.85rem; color: var(--text-muted); min-width: 1.1rem; text-align: right; }

.vote-btn {
  --t: 0;
  border: none;
  background: none;
  padding: 0.2rem;
  cursor: pointer;
  line-height: 1;
  color: color-mix(in srgb, var(--ok) calc(var(--t) * 100%), var(--vote-gray));
  border-radius: 50%;
}
.vote-btn.mine { box-shadow: 0 0 0 2px var(--brand) inset; border-radius: 8px; }
.vote-btn:disabled { cursor: default; opacity: 0.55; }
.vote-btn svg { display: block; }

.empty-state { color: var(--text-muted); text-align: center; padding: 2.5rem 1rem; font-size: 0.95rem; }

/* ── Admin add / clear controls ─────────────────── */
.admin-actions { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 6px; }

.add-btn {
  border: 1.5px dashed var(--border-soft);
  background: var(--surface-2);
  color: var(--pink);
  border-radius: 12px;
  width: 100%;
  padding: 0.9rem;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.add-btn.centered { min-height: 4rem; font-size: 1.75rem; }

.add-form { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.add-form input {
  font-size: 16px;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  font-family: inherit;
}
.add-form-row { display: flex; gap: 8px; }
.add-form-row input { flex: 1; }
.add-form button {
  padding: 0 1rem;
  border: none;
  border-radius: 8px;
  background: var(--pink);
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
}

.max-note { color: var(--text-muted); font-size: 0.8rem; margin: 0; }

.clear-btn {
  border: 1px solid var(--danger);
  background: none;
  color: var(--danger);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  cursor: pointer;
  margin-top: 0.5rem;
  font-family: inherit;
}

/* ── Login popover ─────────────────────────────── */
.login-popover {
  position: fixed;
  inset: 0;
  background: var(--modal-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 30;
}
.login-popover form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: 100%;
  max-width: 260px;
}
.login-popover input {
  font-size: 16px;
  padding: 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  text-align: center;
  font-family: inherit;
}
.login-popover button {
  padding: 0.65rem;
  border: none;
  border-radius: 8px;
  background: var(--pink);
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
}
.error { color: var(--danger); font-size: 0.8rem; text-align: center; margin: 0; min-height: 1.1em; }
