/* VoteMeter 2.0 — mobile-first, one-thumb voting UI */

:root {
  --bg: #f4f4f8;
  --surface: #ffffff;
  --surface-2: #eef0f6;
  --ink: #17181d;
  --ink-soft: #5c6070;
  --line: rgba(23, 24, 29, 0.08);
  --brand: #6d4df6;
  --brand-2: #ee5aa0;
  --up: #16a34a;
  --up-soft: #e5f6ec;
  --down: #dc2626;
  --down-soft: #fdecec;
  --duel-a: #6366f1;
  --duel-a-soft: #eceeff;
  --duel-b: #ec4899;
  --duel-b-soft: #fdeaf4;
  --rising: #16a34a;
  --falling: #dc2626;
  --radius: 20px;
  --shadow: 0 1px 2px rgba(23, 24, 29, 0.05), 0 8px 24px -12px rgba(23, 24, 29, 0.12);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101014;
    --surface: #1a1b21;
    --surface-2: #24252d;
    --ink: #f2f2f6;
    --ink-soft: #a2a5b3;
    --line: rgba(242, 242, 246, 0.09);
    --up-soft: rgba(22, 163, 74, 0.16);
    --down-soft: rgba(220, 38, 38, 0.16);
    --duel-a-soft: rgba(99, 102, 241, 0.18);
    --duel-b-soft: rgba(236, 72, 153, 0.18);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}

a { color: var(--brand); text-decoration: none; }

button { font: inherit; color: inherit; }

/* ---------- App bar ---------- */

.vm-appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.vm-appbar-inner {
  max-width: 620px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
}

.vm-appbar-back {
  font-size: 28px;
  line-height: 1;
  color: var(--ink);
  padding: 2px 10px 6px 2px;
}

.vm-logo { display: flex; align-items: center; gap: 8px; margin-right: auto; }

.vm-logo-mark {
  display: block;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  box-shadow: 0 2px 8px -2px rgba(109, 77, 246, 0.5);
}

.vm-logo-name {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.vm-streak {
  font-size: 13px;
  font-weight: 700;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  box-shadow: var(--shadow);
}

.vm-auth { display: flex; }

.vm-auth-btn {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
}

/* ---------- Login ---------- */

.vm-login-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 18px 0;
  padding: 28px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

/* The Google Identity button renders inside an iframe at its own size;
   keep our wrapper snug and centred so it doesn't float in dead space. */
.vm-login-box > div { display: flex; justify-content: center; }

.vm-notice {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 14px;
}

.vm-link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--brand);
  font-size: inherit;
  font-weight: 650;
  cursor: pointer;
  text-decoration: underline;
}

/* ---------- Shell / hero ---------- */

.vm-shell {
  max-width: 620px;
  margin: 0 auto;
  padding: 0 16px calc(96px + env(safe-area-inset-bottom));
}

.vm-hero { padding: 22px 2px 6px; }

.vm-hero-title {
  margin: 0;
  font-size: clamp(26px, 6.5vw, 34px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.12;
}

.vm-hero-title em {
  font-style: normal;
  color: var(--brand);
}

.vm-hero-sub {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 15px;
}

.vm-hero-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

/* ---------- Chips + toolbar ---------- */

.vm-chips {
  position: sticky;
  top: calc(49px + env(safe-area-inset-top));
  z-index: 15;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 12px 2px 10px;
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.vm-chips::-webkit-scrollbar { display: none; }

.vm-chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 9px 15px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.12s ease, background 0.15s ease, color 0.15s ease;
}

.vm-chip:active { transform: scale(0.95); }

.vm-chip[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.vm-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 0 14px;
}

.vm-sort {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 3px;
}

.vm-sort-tab {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  cursor: pointer;
}

.vm-sort-tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.vm-search {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 14px;
  color: var(--ink);
}

.vm-search:focus { outline: 2px solid var(--brand); outline-offset: -1px; }

/* ---------- Cards ---------- */

.vm-feed { display: flex; flex-direction: column; gap: 14px; }

.vm-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 14px 12px;
}

.vm-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  min-height: 48px;
}

.vm-avatar {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  object-fit: cover;
  flex: 0 0 auto;
  background: var(--surface-2);
}

.vm-avatar-emoji {
  display: grid;
  place-items: center;
  font-size: 26px;
}

.vm-card-person .vm-avatar-emoji { background: #efeaff; }
.vm-card-org .vm-avatar-emoji { background: #e3f2fd; }
.vm-card-product .vm-avatar-emoji { background: #e2f7ef; }
.vm-card-duel .vm-avatar-emoji { background: #fff0e0; }

@media (prefers-color-scheme: dark) {
  .vm-card-person .vm-avatar-emoji { background: rgba(124, 92, 252, 0.2); }
  .vm-card-org .vm-avatar-emoji { background: rgba(14, 165, 233, 0.2); }
  .vm-card-product .vm-avatar-emoji { background: rgba(16, 185, 129, 0.2); }
  .vm-card-duel .vm-avatar-emoji { background: rgba(249, 115, 22, 0.2); }
}

.vm-card-id { display: flex; flex-direction: column; min-width: 0; flex: 1; }

.vm-card-title {
  font-weight: 750;
  font-size: 16.5px;
  letter-spacing: -0.015em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vm-card-sub {
  font-size: 13px;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vm-trend {
  flex: 0 0 auto;
  font-size: 12.5px;
  font-weight: 700;
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--surface-2);
  color: var(--ink-soft);
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.vm-trend-rising { color: var(--rising); background: var(--up-soft); }
.vm-trend-falling { color: var(--falling); background: var(--down-soft); }

/* ---------- Vote widget ---------- */

.vm-vote { margin-top: 12px; }

.vm-vote-actions { display: flex; gap: 10px; }

.vm-vote-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  border-radius: 15px;
  border: 1.5px solid var(--line);
  background: var(--surface-2);
  font-size: 15.5px;
  font-weight: 750;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.vm-vote-btn:active { transform: scale(0.96); }

.vm-vote-btn-emoji { font-size: 20px; }

.vm-vote-up:hover, .vm-vote-up:focus-visible { background: var(--up-soft); border-color: var(--up); }
.vm-vote-down:hover, .vm-vote-down:focus-visible { background: var(--down-soft); border-color: var(--down); }

.vm-vote-actions-duel { align-items: stretch; }

.vm-duel-a:hover, .vm-duel-a:focus-visible { background: var(--duel-a-soft); border-color: var(--duel-a); }
.vm-duel-b:hover, .vm-duel-b:focus-visible { background: var(--duel-b-soft); border-color: var(--duel-b); }

.vm-duel-vs {
  align-self: center;
  font-size: 11px;
  font-weight: 800;
  color: var(--ink-soft);
  flex: 0 0 auto;
}

.vm-duel-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 16ch;
}

.vm-vote-hint {
  margin: 9px 2px 0;
  font-size: 12.5px;
  color: var(--ink-soft);
}

/* ---------- Result reveal ---------- */

.vm-result { animation: vm-pop 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2); }

@keyframes vm-pop {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.vm-bar {
  position: relative;
  height: 40px;
  border-radius: 12px;
  background: var(--down-soft);
  overflow: hidden;
  display: flex;
  align-items: center;
}

.vm-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--up);
  border-radius: 12px 0 0 12px;
  transition: width 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.vm-bar-score {
  position: relative;
  margin-left: 12px;
  font-weight: 800;
  font-size: 15px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

/* At very low scores the label sits on the unfilled track, not the fill. */
.vm-bar-score-low { color: var(--ink); text-shadow: none; }

.vm-bar-duel { background: var(--duel-b-soft); }

.vm-bar-duel .vm-bar-fill { background: var(--duel-a); }

.vm-bar-a, .vm-bar-b {
  position: relative;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.vm-bar-a { margin-left: 12px; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); }
.vm-bar-b { margin-left: auto; margin-right: 12px; color: var(--duel-b); }

.vm-result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 9px;
}

.vm-result-meta { font-size: 13px; color: var(--ink-soft); }

.vm-result-meta b { color: var(--ink); }

.vm-share-btn {
  border: 0;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 13.5px;
  font-weight: 750;
  padding: 9px 16px;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.vm-share-btn:active { transform: scale(0.95); }

.vm-voted-flash { animation: vm-flash 0.5s ease; }

@keyframes vm-flash {
  0% { box-shadow: 0 0 0 0 rgba(109, 77, 246, 0.45); }
  100% { box-shadow: 0 0 0 14px rgba(109, 77, 246, 0); }
}

/* ---------- Feed empty ---------- */

.vm-feed-empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--ink-soft);
}

/* ---------- FAB ---------- */

.vm-fab {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 30;
  display: inline-flex;
  align-items: center;
  min-height: 52px;
  padding: 0 22px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 15.5px;
  font-weight: 800;
  box-shadow: 0 8px 20px -8px rgba(109, 77, 246, 0.45);
  transition: transform 0.12s ease;
}

.vm-fab:active { transform: scale(0.95); }

/* ---------- Buttons ---------- */

.vm-btn-primary, .vm-btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 14px;
  font-weight: 750;
  font-size: 15px;
  border: 0;
  cursor: pointer;
}

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

.vm-btn-secondary {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
}

.vm-btn-chip {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 13.5px;
  font-weight: 650;
  cursor: pointer;
}

.vm-btn-chip-primary {
  background: var(--brand);
  border: 0;
  color: #fff;
}

/* ---------- Topic page ---------- */

.vm-topic-hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
  margin-top: 16px;
}

.vm-topic-hero-head { display: flex; gap: 14px; align-items: center; }

.vm-avatar-lg { width: 64px; height: 64px; border-radius: 18px; }

.vm-avatar-lg.vm-avatar-emoji { font-size: 36px; }

.vm-topic-type {
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.vm-topic-title {
  margin: 2px 0;
  font-size: clamp(22px, 6vw, 28px);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.vm-topic-desc { color: var(--ink-soft); font-size: 14.5px; margin: 12px 0 0; }

.vm-topic-score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0 4px;
  padding: 14px;
  border-radius: 16px;
  background: var(--surface-2);
}

.vm-topic-score-value {
  font-size: 40px;
  font-weight: 850;
  letter-spacing: -0.03em;
  line-height: 1;
  display: block;
}

.vm-topic-score-caption { font-size: 13px; color: var(--ink-soft); }

.vm-topic-score-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  color: var(--brand);
}

.vm-sparkline { width: 130px; height: 40px; opacity: 0.9; }

.vm-duel-links { font-size: 13.5px; color: var(--ink-soft); margin: 12px 2px 0; }

.vm-share-row {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.vm-share-row-label {
  display: block;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin-bottom: 9px;
}

.vm-share-row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.vm-fineprint {
  font-size: 12.5px;
  color: var(--ink-soft);
  text-align: center;
  margin: 18px 8px;
}

/* ---------- Add form ---------- */

.vm-add { padding-top: 20px; }

.vm-add-title {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.vm-add-sub { color: var(--ink-soft); margin: 6px 0 18px; }

.vm-add-form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.vm-typegrid {
  border: 0;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.vm-typegrid legend { margin-bottom: 8px; }

.vm-typecard {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 4px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  background: var(--surface-2);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.vm-typecard:has(input:checked) {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 10%, var(--surface));
}

.vm-typecard input { position: absolute; opacity: 0; pointer-events: none; }

.vm-typecard-emoji { font-size: 24px; }

.vm-typecard-label { font-size: 12px; font-weight: 700; }

.vm-field { display: flex; flex-direction: column; gap: 6px; }

.vm-label { font-size: 13.5px; font-weight: 750; }

.vm-label em { font-weight: 500; color: var(--ink-soft); font-style: normal; }

.vm-input {
  border: 1.5px solid var(--line);
  background: var(--surface-2);
  border-radius: 12px;
  min-height: 48px;
  padding: 10px 14px;
  font-size: 16px;
  color: var(--ink);
  width: 100%;
}

.vm-input:focus { outline: 2px solid var(--brand); outline-offset: -1px; }

.vm-textarea { resize: vertical; }


.vm-duel-selects { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.vm-btn-submit { margin-top: 4px; }

.vm-field-hint { font-size: 12.5px; color: var(--ink-soft); margin: 0; }

.vm-field-error, .vm-form-error { color: var(--falling); font-size: 13.5px; font-weight: 650; }

.vm-form-error {
  background: var(--down-soft);
  border-radius: 12px;
  padding: 12px 14px;
}

/* ---------- Trust pages / footer ---------- */

.vm-trust { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }

.vm-trust-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.vm-trust-title { margin: 0 0 8px; font-size: 17px; font-weight: 800; letter-spacing: -0.02em; }

.vm-trust-body, .vm-trust-list li { color: var(--ink-soft); font-size: 14.5px; }

.vm-trust-body { margin: 0 0 8px; }

.vm-footer {
  margin-top: 40px;
  padding: 20px 4px 8px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.vm-footer-tag { font-size: 13px; color: var(--ink-soft); margin: 0; }

.vm-footer-nav { display: flex; gap: 14px; font-size: 13px; }

.vm-footer-nav a { color: var(--ink-soft); }

/* ---------- Desktop niceties ---------- */

@media (min-width: 700px) {
  .vm-shell { padding-bottom: 40px; }
  .vm-hero { padding-top: 34px; }
  .vm-feed { gap: 16px; }
  .vm-card { padding: 18px 18px 16px; }
}

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