:root {
  --accent: #3b82f6;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e3e7ef;
  --shadow: 0 4px 18px rgba(0,0,0,.07);
  --radius: 14px;
}

[data-theme="dark"] {
  --bg: #0e0f14;
  --card: #191b23;
  --text: #eef0f5;
  --muted: #9aa1b2;
  --border: #2a2d39;
  --shadow: 0 4px 18px rgba(0,0,0,.45);
}

[data-accent="red"]    { --accent: #ef4444; }
[data-accent="yellow"] { --accent: #eab308; }
[data-accent="blue"]   { --accent: #3b82f6; }
[data-accent="orange"] { --accent: #f97316; }
[data-accent="green"]  { --accent: #22c55e; }
[data-accent="pink"]   { --accent: #ec4899; }
[data-accent="violet"] { --accent: #8b5cf6; }

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

body {
  font-family: "Segoe UI", Roboto, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background .35s ease, color .35s ease;
}

/* выключенные анимации */
[data-animations="off"] *,
[data-animations="off"] *::before,
[data-animations="off"] *::after {
  animation-duration: .001s !important;
  transition-duration: .001s !important;
}

.hidden { display: none !important; }

.screen { min-height: 100vh; }

/* ====== авторизация ====== */
#screen-auth {
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px 30px;
  width: 100%; max-width: 420px;
  animation: pop .4s ease;
}
.logo { font-size: 1.7rem; color: var(--accent); text-align: center; }
.auth-sub { text-align: center; color: var(--muted); margin: 8px 0 22px; font-size: .93rem; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.tab {
  flex: 1; padding: 10px; border: 1px solid var(--border); background: var(--bg);
  color: var(--text); border-radius: 10px; cursor: pointer; font-size: .95rem;
  transition: all .2s ease;
}
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.tab:hover:not(.active) { border-color: var(--accent); }

form label { display: block; font-size: .88rem; color: var(--muted); margin-bottom: 14px; }
input, textarea {
  width: 100%; margin-top: 6px; padding: 11px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--text); font-size: 1rem;
  font-family: inherit; resize: vertical;
  transition: border-color .2s ease;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }

.error { color: #ef4444; font-size: .87rem; margin-bottom: 10px; }
.saved { color: var(--accent); font-size: .88rem; margin-top: 12px; }

/* ====== кнопки ====== */
.btn {
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  padding: 10px 16px; border-radius: 10px; cursor: pointer; font-size: .95rem;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(0,0,0,.13); }
.btn:active { transform: translateY(0); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.btn.big { width: 100%; padding: 13px; font-size: 1.02rem; }
.btn.small { padding: 6px 12px; font-size: .85rem; }
.btn.ghost { background: transparent; }
.btn.danger { border-color: #ef4444; color: #ef4444; }

/* ====== шапка ====== */
.topbar {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 14px 24px;
  background: var(--card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.brand { font-weight: 700; color: var(--accent); font-size: 1.1rem; }
.nav { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.nav-btn {
  padding: 8px 14px; border: none; background: transparent; color: var(--muted);
  cursor: pointer; border-radius: 9px; font-size: .93rem; transition: all .2s ease;
}
.nav-btn:hover { background: var(--bg); color: var(--text); }
.nav-btn.active { background: var(--accent); color: #fff; }
.user-box { display: flex; align-items: center; gap: 10px; }
.user-name { font-weight: 600; color: var(--accent); }

.content { max-width: 900px; margin: 0 auto; padding: 26px 18px 60px; }
.view h2 { margin-bottom: 18px; }

/* ====== карточки ====== */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
}
.form { max-width: 560px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 1.05rem; }

.polls-list { display: flex; flex-direction: column; gap: 14px; }
.poll-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
  cursor: pointer; transition: transform .2s ease, border-color .2s ease;
  animation: pop .35s ease;
}
.poll-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.poll-card h3 { margin-bottom: 6px; }
.poll-meta { color: var(--muted); font-size: .83rem; display: flex; gap: 14px; flex-wrap: wrap; }

/* ====== детали голосования ====== */
.detail-head { margin: 14px 0 18px; }
.detail-head h2 { color: var(--accent); }
.detail-meta { color: var(--muted); font-size: .86rem; margin-top: 6px; }

.option-row { margin-bottom: 12px; position: relative; }
.option-btn {
  width: 100%; text-align: left; padding: 13px 16px;
  border: 2px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 11px; cursor: pointer; font-size: .98rem; position: relative;
  overflow: hidden; transition: border-color .2s ease;
}
.option-btn:hover { border-color: var(--accent); }
.option-btn.voted { border-color: var(--accent); font-weight: 600; }
.option-btn .bar {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--accent); opacity: .18; width: 0;
  transition: width .7s cubic-bezier(.2,.8,.2,1);
  z-index: 0;
}
.option-btn .label { position: relative; z-index: 1; display: flex; justify-content: space-between; gap: 10px; }
.option-btn .pct { color: var(--accent); font-weight: 700; }
.voted-badge { font-size: .78rem; color: var(--accent); }

.stats-line { display: flex; justify-content: space-between; align-items: center; margin: 14px 0 6px; color: var(--muted); font-size: .88rem; }

/* ====== комментарии ====== */
.comments { margin-top: 26px; }
.comments h3 { margin-bottom: 14px; }
.comment-form { display: flex; gap: 10px; margin-bottom: 18px; }
.comment-form input { margin-top: 0; flex: 1; }
.comment-list { display: flex; flex-direction: column; gap: 12px; }
.comment {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 13px 15px; animation: pop .3s ease;
}
.comment-top { display: flex; justify-content: space-between; margin-bottom: 6px; }
.comment-author { font-weight: 600; color: var(--accent); font-size: .9rem; }
.comment-date { color: var(--muted); font-size: .78rem; }
.comment-text { font-size: .95rem; line-height: 1.45; }
.reactions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.react-btn {
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 20px; padding: 4px 10px; cursor: pointer; font-size: .88rem;
  transition: transform .15s ease, border-color .2s ease;
}
.react-btn:hover { transform: scale(1.12); border-color: var(--accent); }
.react-btn.mine { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 15%, var(--bg)); }
.react-count { font-size: .8rem; color: var(--muted); margin-left: 2px; }
.react-add { font-size: .85rem; opacity: .7; }
.react-picker {
  display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap;
  padding: 8px; background: var(--bg); border-radius: 10px;
  animation: pop .25s ease;
}
.react-picker button {
  border: none; background: transparent; font-size: 1.25rem; cursor: pointer;
  transition: transform .15s ease;
}
.react-picker button:hover { transform: scale(1.3); }

/* ====== настройки ====== */
.settings-card h3 { margin: 20px 0 10px; color: var(--accent); }
.settings-card h3:first-child { margin-top: 0; }
.theme-toggle { display: flex; gap: 10px; }
.theme-btn {
  flex: 1; padding: 12px; border-radius: 10px; cursor: pointer;
  border: 2px solid var(--border); background: var(--bg); color: var(--text);
  font-size: .95rem; transition: all .2s ease;
}
.theme-btn.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--bg)); font-weight: 600; }

.text-colors { display: flex; gap: 12px; flex-wrap: wrap; }
.color-dot {
  width: 42px; height: 42px; border-radius: 50%; border: 3px solid transparent;
  background: var(--c); cursor: pointer; transition: transform .2s ease, border-color .2s ease;
}
.color-dot:hover { transform: scale(1.14); }
.color-dot.active { border-color: var(--text); transform: scale(1.14); }

.switch-row { display: flex; align-items: center; gap: 14px; cursor: pointer; font-size: .95rem; color: var(--text); }
.switch-row input { display: none; }
.switch {
  width: 52px; height: 28px; border-radius: 20px; background: var(--border);
  position: relative; transition: background .25s ease; flex-shrink: 0;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; transition: transform .25s ease;
}
.switch-row input:checked + .switch { background: var(--accent); }
.switch-row input:checked + .switch::after { transform: translateX(24px); }

/* ====== анимации ====== */
@keyframes pop {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 640px) {
  .topbar { padding: 12px 14px; }
  .content { padding: 18px 12px 50px; }
}
