:root {
  --ink: #171817;
  --paper: #f6f7f3;
  --surface: #ffffff;
  --muted: #62675f;
  --line: #d7dbd3;
  --acid: #c7f43d;
  --acid-dark: #9fc51d;
  --coral: #ff675d;
  --sky: #8ad6ff;
  --danger: #bb2d25;
  --shadow: 0 10px 30px rgba(23, 24, 23, 0.08);
}

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

html {
  color-scheme: light;
}

body {
  min-height: 100vh;
  background:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px),
    var(--paper);
  background-size: 40px 40px;
  color: var(--ink);
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
  line-height: 1.5;
  letter-spacing: 0;
}

button,
input,
fieldset {
  font: inherit;
  letter-spacing: 0;
}

a {
  color: inherit;
}

.app-header {
  min-height: 70px;
  padding: 0 5vw;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--ink);
  color: var(--surface);
  border-bottom: 4px solid var(--acid);
}

.brand {
  color: inherit;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
}

.brand span {
  color: var(--coral);
}

.header-actions,
.actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.current-user {
  max-width: 12rem;
  overflow: hidden;
  color: #d9ddd5;
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

main {
  width: min(900px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 3rem 0 5rem;
}

.form-page,
.detail-page {
  width: min(680px, calc(100% - 2rem));
}

.page-heading {
  margin-bottom: 1.5rem;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
}

.page-heading h1,
.login-main h1 {
  max-width: 18ch;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 3rem;
  line-height: 1.05;
  letter-spacing: 0;
}

.eyebrow {
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.summary,
.meta,
.vote-info,
.field-hint {
  color: var(--muted);
  font-size: 0.85rem;
}

.survey-row {
  min-height: 104px;
  margin-bottom: 0.75rem;
  padding: 1.25rem 1.35rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 6px solid var(--sky);
  border-radius: 6px;
  box-shadow: 0 2px 0 rgba(23, 24, 23, 0.05);
}

.survey-row:nth-child(3n + 2) {
  border-left-color: var(--acid);
}

.survey-row:nth-child(3n) {
  border-left-color: var(--coral);
}

.question {
  overflow-wrap: anywhere;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.16rem;
  line-height: 1.25;
}

.meta {
  margin-top: 0.35rem;
}

.page-heading .meta {
  overflow-wrap: anywhere;
}

.btn {
  min-height: 40px;
  padding: 0.55rem 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--acid);
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 5px;
  box-shadow: 2px 2px 0 var(--ink);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 700;
  text-decoration: none;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.btn:hover:not(:disabled) {
  background: #d7ff5d;
  box-shadow: 1px 1px 0 var(--ink);
  transform: translate(1px, 1px);
}

.btn:focus-visible,
input:focus-visible {
  outline: 3px solid var(--sky);
  outline-offset: 2px;
}

.btn:disabled {
  cursor: wait;
  opacity: 0.55;
}

.btn.secondary {
  background: var(--surface);
}

.btn.danger {
  background: var(--surface);
  color: var(--danger);
  border-color: var(--danger);
  box-shadow: 2px 2px 0 var(--danger);
}

.btn.danger:hover:not(:disabled) {
  background: #fff0ef;
  box-shadow: 1px 1px 0 var(--danger);
}

.app-header .btn.secondary {
  background: transparent;
  color: var(--surface);
  border-color: #6a6e68;
  box-shadow: none;
}

.app-header .btn.secondary:hover:not(:disabled) {
  background: #30322f;
}

.btn.small {
  min-height: 34px;
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
}

.full-width {
  width: 100%;
}

form,
#survey-content,
#results-content {
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

label {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.86rem;
  font-weight: 700;
}

input[type="text"],
input[type="email"] {
  width: 100%;
  min-height: 44px;
  margin-top: 0.35rem;
  padding: 0.65rem 0.75rem;
  background: #fbfcf9;
  color: var(--ink);
  border: 1px solid #aeb4aa;
  border-radius: 4px;
  outline: none;
}

input[type="text"]:focus,
input[type="email"]:focus {
  border-color: var(--ink);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 400;
  cursor: pointer;
}

.checkbox-label input {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--ink);
}

.field-hint {
  font-weight: 400;
}

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

.form-message {
  min-height: 1.25rem;
  margin: 0.4rem 0 0.75rem;
  color: #31640f;
  font-size: 0.82rem;
  font-weight: 700;
}

.mode-fieldset {
  margin: 1.1rem 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 5px;
}

.mode-fieldset legend {
  padding: 0 0.35rem;
  font-size: 0.86rem;
  font-weight: 700;
}

.ballot-heading {
  margin-top: 1.5rem;
  font-family: Georgia, "Times New Roman", serif;
}

.ballot-list {
  margin: 0.5rem 0 1.5rem 1.25rem;
  overflow-wrap: anywhere;
}

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

.option-row {
  margin-bottom: 0.5rem;
}

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

.remove-opt {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  background: transparent;
  color: var(--danger);
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1.2rem;
}

.remove-opt:hover {
  background: #fff0ef;
  border-color: #f3b7b2;
}

.empty,
.voted-message {
  min-height: 220px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--surface);
  color: var(--muted);
  border: 1px dashed #aeb4aa;
  border-radius: 6px;
  text-align: center;
}

.empty strong,
.voted-message strong {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
}

.empty span,
.voted-message span {
  margin-bottom: 0.75rem;
}

.error-state {
  border-color: var(--coral);
}

.options-list {
  margin: 1rem 0;
}

.option-item {
  min-height: 50px;
  margin-bottom: 0.5rem;
  padding: 0.7rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #fbfcf9;
  border: 1px solid var(--line);
  border-radius: 5px;
  cursor: pointer;
}

.option-item:hover,
.option-item:has(input:checked) {
  background: #f3ffd0;
  border-color: var(--acid-dark);
}

.option-item input {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--ink);
}

.custom-option {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.owner-actions {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.result-bar-group {
  margin: 1.2rem 0 1.5rem;
}

.result-row {
  margin-bottom: 1rem;
}

.result-label {
  margin-bottom: 0.35rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.88rem;
}

.result-label span:first-child {
  overflow-wrap: anywhere;
}

.result-label span:last-child {
  flex: 0 0 auto;
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-weight: 700;
}

.result-progress {
  width: 100%;
  height: 20px;
  display: block;
  overflow: hidden;
  appearance: none;
  background: #e5e8e1;
  border: 0;
  border-radius: 3px;
}

.result-progress::-webkit-progress-bar {
  background: #e5e8e1;
}

.result-progress::-webkit-progress-value {
  background: var(--acid);
}

.result-progress::-moz-progress-bar {
  background: var(--acid);
}

.login-page {
  display: grid;
  place-items: center;
  padding: 1rem;
  background: var(--ink);
}

.login-main {
  width: min(400px, 100%);
  padding: 0;
}

.login-brand {
  margin-bottom: 1.2rem;
  display: inline-block;
  color: var(--surface);
}

.login-main form {
  border-top: 6px solid var(--coral);
}

.login-main h1 {
  margin-bottom: 1.25rem;
}

.form-switch {
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.84rem;
  text-align: center;
}

.form-switch a {
  color: var(--ink);
  font-weight: 700;
}

@media (max-width: 640px) {
  .app-header {
    min-height: 64px;
    padding: 0 1rem;
  }

  .header-actions {
    gap: 0.4rem;
  }

  .current-user {
    display: none;
  }

  main {
    padding-top: 2rem;
  }

  .page-heading {
    align-items: start;
    flex-direction: column;
    gap: 0.4rem;
  }

  .page-heading h1,
  .login-main h1 {
    font-size: 2.25rem;
  }

  .survey-row {
    grid-template-columns: 1fr;
  }

  .survey-row .actions {
    width: 100%;
  }

  .survey-row .btn {
    flex: 1;
  }

  form,
  #survey-content,
  #results-content {
    padding: 1.1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
