:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-alt: #f1f4fa;
  --text: #1a2138;
  --muted: #6b7488;
  --border: #e3e7ef;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --danger: #dc2626;
  --bar-grad-start: #6366f1;
  --bar-grad-end: #8b5cf6;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header {
  text-align: center;
  padding: 2.5rem 1rem 1.5rem;
}

.site-header h1 {
  margin: 0 0 0.25rem;
  font-size: 2.25rem;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0;
  color: var(--muted);
}

.container {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.card h2,
.polls-header h2 {
  margin: 0 0 1rem;
  font-size: 1.25rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.field-label {
  font-weight: 600;
  font-size: 0.9rem;
}

input[type="text"] {
  font: inherit;
  color: inherit;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.options-fieldset {
  border: none;
  padding: 0;
  margin: 0 0 1rem;
}

.options-fieldset legend {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  padding: 0;
}

#options-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.option-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.option-row .option-input {
  flex: 1;
}

.btn {
  font: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
  font-weight: 600;
}

.btn:active {
  transform: translateY(1px);
}

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

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

.btn-secondary {
  background: var(--primary-soft);
  color: var(--primary);
}

.btn-secondary:hover {
  background: #e0e7ff;
}

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

.btn-ghost:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.btn-small {
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
}

.btn-remove {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
  padding: 0.35rem 0.6rem;
  font-size: 1.1rem;
  line-height: 1;
}

.btn-remove:hover {
  color: var(--danger);
  border-color: var(--danger);
}

.form-actions {
  display: flex;
  gap: 0.5rem;
}

.form-error {
  color: var(--danger);
  margin: 0.75rem 0 0;
  min-height: 1.25rem;
  font-size: 0.9rem;
}

.polls-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.polls-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.polls-header h2 {
  margin: 0;
}

.polls-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.poll {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
}

.poll-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.poll-question {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.poll-meta {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.poll-delete {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
}

.poll-delete:hover {
  color: var(--danger);
  background: var(--surface-alt);
}

.poll-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.poll-option {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: center;
}

.option-info {
  min-width: 0;
}

.option-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  margin-bottom: 0.3rem;
  gap: 0.5rem;
}

.option-text {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.option-stats {
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.bar-track {
  background: var(--surface-alt);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--bar-grad-start), var(--bar-grad-end));
  border-radius: 999px;
  transition: width 0.35s ease;
  min-width: 0;
}

.vote-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s;
}

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

.poll-footer {
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: right;
}

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 1.5rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin: 0;
}

.empty-state.hidden,
.hidden {
  display: none;
}

.site-footer {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 480px) {
  .site-header h1 {
    font-size: 1.75rem;
  }
  .card,
  .poll {
    padding: 1rem;
  }
  .poll-option {
    grid-template-columns: 1fr;
  }
  .vote-btn {
    justify-self: start;
  }
}
