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

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

[hidden] {
  display: none !important;
}

body {
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

a:hover {
  text-decoration: underline;
}

button {
  font: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
}

/* Layout */
.container {
  width: calc(100% - var(--s-6));
  max-width: var(--container);
  margin-inline: auto;
}

.page {
  padding-block: var(--s-6);
}

/* Navbar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.navbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding-block: var(--s-3);
}

.wordmark {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--brand-600);
  letter-spacing: -0.01em;
}

.wordmark:hover {
  text-decoration: none;
}

.navbar__actions {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.navbar__user {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-muted);
}

.navbar__logout {
  display: inline-flex;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-4);
  border: 1px solid transparent;
  border-radius: var(--r-full);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1;
}

.btn:hover {
  text-decoration: none;
}

.btn--primary {
  background: var(--brand-600);
  color: var(--text-invert);
}

.btn--primary:hover {
  background: var(--brand-700);
}

.btn--ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}

.btn--ghost:hover {
  border-color: var(--brand-500);
  background: var(--brand-50);
}

.btn--block {
  width: 100%;
  padding-block: var(--s-3);
  font-size: var(--fs-base);
}

.btn--sm {
  padding: var(--s-2) var(--s-3);
  font-size: var(--fs-xs);
}

.btn--danger {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--danger);
}

.btn--danger:hover {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
}

/* Auth card */
.auth-card {
  max-width: 420px;
  margin-inline: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  box-shadow: var(--shadow-sm);
}

.auth-card__title {
  font-size: var(--fs-xl);
  font-weight: 700;
}

.auth-card__subtitle {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  margin-bottom: var(--s-5);
}

.auth-card__alt {
  margin-top: var(--s-5);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  text-align: center;
}

/* Forms */
.field {
  margin-bottom: var(--s-4);
}

.field__label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  margin-bottom: var(--s-2);
}

.field input {
  width: 100%;
  padding: var(--s-3);
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
}

.field input:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--brand-50);
}

.field__help {
  margin-top: var(--s-2);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.field__error {
  margin-top: var(--s-2);
  font-size: var(--fs-xs);
  color: var(--danger);
}

.field--error input {
  border-color: var(--danger);
}

.form-alert {
  margin-bottom: var(--s-4);
  padding: var(--s-3);
  border: 1px solid var(--danger);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
  color: var(--danger);
  font-size: var(--fs-sm);
}

.field__check {
  display: flex;
  gap: var(--s-2);
  align-items: flex-start;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.field__check input {
  margin-top: 0.15em;
}

/* Feed header + tabs */
.feed-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-5);
  flex-wrap: wrap;
}

.feed-head__title {
  font-size: var(--fs-xl);
  font-weight: 700;
}

.tabs {
  display: inline-flex;
  gap: var(--s-1);
  background: var(--surface-alt);
  padding: var(--s-1);
  border-radius: var(--r-full);
}

.tab {
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-full);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-muted);
}

.tab:hover {
  text-decoration: none;
  color: var(--text);
}

.tab--active {
  background: var(--surface);
  color: var(--brand-600);
  box-shadow: var(--shadow-sm);
}

/* Poll list + card */
.poll-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.poll-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  transition: box-shadow 0.2s ease;
}

.poll-card:hover {
  box-shadow: var(--shadow-md);
}

.poll-card--detail:hover {
  box-shadow: none;
}

.poll-card__meta {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-bottom: var(--s-3);
}

.poll-card__author {
  font-weight: 600;
  color: var(--text-muted);
}

.poll-card__question {
  display: block;
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--s-4);
}

a.poll-card__question:hover {
  text-decoration: none;
  color: var(--brand-700);
}

.poll-card__question--detail {
  font-size: var(--fs-xl);
}

.poll-options {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.option {
  width: 100%;
  text-align: left;
  padding: var(--s-3) var(--s-4);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text);
  font-weight: 500;
}

.option:not([disabled]):hover {
  border-color: var(--brand-500);
  background: var(--brand-50);
}

.option[disabled] {
  cursor: progress;
  opacity: 0.6;
}

/* Result bars */
.result {
  position: relative;
  overflow: hidden;
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
}

.result__bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--brand-100);
  transition: width 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.result--chosen {
  border-color: var(--brand-600);
}

.result--chosen .result__bar {
  background: color-mix(in srgb, var(--brand-500) 18%, transparent);
  border-left: 3px solid var(--brand-600);
}

.result__row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  font-weight: 500;
}

.result__pct {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-weight: 600;
}

.result--chosen .result__pct {
  color: var(--brand-700);
}

.poll-error {
  margin-top: var(--s-3);
  font-size: var(--fs-sm);
  color: var(--danger);
}

.poll-card__footer {
  margin-top: var(--s-4);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}

.poll-card__hint {
  color: var(--text-muted);
}

@media (prefers-reduced-motion: reduce) {
  .result__bar {
    transition: none;
  }
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-4);
  margin-top: var(--s-6);
  font-size: var(--fs-sm);
}

.pagination__link {
  font-weight: 600;
}

.pagination__link--muted {
  color: var(--text-muted);
}

.pagination__status {
  color: var(--text-muted);
}

/* Profile */
.profile-head {
  margin-bottom: var(--s-5);
}

.profile-head__name {
  font-size: var(--fs-xl);
  font-weight: 700;
}

.profile-head__count {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.back-link {
  margin-bottom: var(--s-4);
  font-size: var(--fs-sm);
}

.account-danger {
  margin-top: var(--s-6);
  padding-top: var(--s-5);
  border-top: 1px solid var(--border);
}

.account-danger__link {
  font-size: var(--fs-sm);
  color: var(--danger);
}

/* Create form */
.auth-card--wide {
  max-width: 560px;
}

.option-set {
  border: none;
  margin-block: var(--s-4);
}

.option-set legend {
  font-size: var(--fs-sm);
  font-weight: 600;
  margin-bottom: var(--s-3);
}

/* Messages */
.messages {
  list-style: none;
  margin-bottom: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.messages__item {
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  border: 1px solid var(--border);
  background: var(--surface);
}

.messages__item--success {
  border-color: var(--success);
  color: var(--success);
  background: color-mix(in srgb, var(--success) 8%, var(--surface));
}

.messages__item--error {
  border-color: var(--danger);
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
}

/* Poll actions (detail) */
.poll-actions {
  margin-top: var(--s-5);
  padding-top: var(--s-4);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.poll-actions__delete {
  margin-left: auto;
}

/* Skeleton loading */
#skeleton-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  margin-top: var(--s-4);
}

.skeleton-card {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.skeleton {
  border-radius: var(--r-sm);
  background: linear-gradient(
    90deg,
    var(--surface-alt) 25%,
    var(--border) 37%,
    var(--surface-alt) 63%
  );
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
}

.skeleton--meta { width: 40%; height: 14px; }
.skeleton--title { width: 100%; height: 20px; }
.skeleton--short { width: 55%; }
.skeleton--option { width: 100%; height: 44px; border-radius: var(--r-md); }

@keyframes skeleton-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.feed-sentinel {
  height: 1px;
}

@media (prefers-reduced-motion: reduce) {
  .skeleton {
    animation: none;
  }
}

/* Error pages */
.errorpage {
  text-align: center;
  padding-block: var(--s-8);
}

.errorpage__code {
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--brand-600);
}

.errorpage__title {
  font-size: var(--fs-lg);
  font-weight: 600;
  margin-block: var(--s-2) var(--s-3);
}

.errorpage__text {
  color: var(--text-muted);
  margin-bottom: var(--s-5);
}

/* Empty state */
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding-block: var(--s-8);
}

.empty-state__title {
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--s-2);
}

@media (min-width: 768px) {
  .container {
    width: 100%;
  }
}

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