:root {
  --paper:      #EBEDE6;
  --surface:    #F8F9F4;
  --ink:        #182019;
  --muted:      #6C7A6E;
  --accent:     #2F6B4B;
  --accent-dim: #C9DCC9;
  --crown:      #C9931A;
  --line:       #D5DACE;

  --radius: 4px;
  --shadow: 0 1px 0 var(--line), 0 12px 28px -22px rgba(24, 32, 25, .5);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  padding: 0 20px 140px;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.55 "Instrument Sans", system-ui, sans-serif;
}

h1, h2 { margin: 0; font-family: "Fraunces", Georgia, serif; font-weight: 700; }

.shell { max-width: 1040px; margin: 0 auto; }

.masthead { padding: 56px 0 32px; max-width: 34ch; }

.eyebrow {
  margin: 0 0 14px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--accent);
}
.eyebrow::before {
  content: "";
  display: inline-block;
  width: 7px; height: 7px;
  margin-right: 9px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 1px;
}

h1 { font-size: clamp(38px, 7vw, 62px); line-height: .98; letter-spacing: -.02em; }

.lede { margin: 16px 0 0; color: var(--muted); max-width: 44ch; }

.identity {
  padding: 22px 0 30px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 30px;
}

.identity label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .01em;
  margin-bottom: 8px;
}

#name {
  width: 100%;
  max-width: 340px;
  padding: 11px 14px;
  font: 500 17px "Instrument Sans", sans-serif;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
#name:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.identity-note { margin: 9px 0 0; font-size: 13px; color: var(--muted); }

.columns {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, .9fr);
  gap: 26px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.month-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.month-bar h2 { font-size: 22px; letter-spacing: -.01em; }

.month-nav {
  width: 36px; height: 36px;
  font-size: 20px; line-height: 1;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}
.month-nav:hover:not(:disabled) { background: var(--accent-dim); border-color: var(--accent); }
.month-nav:disabled { opacity: .3; cursor: default; }

.weekdays, .grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}

.weekdays {
  margin-bottom: 6px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
}

.day {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0;
  overflow: hidden;
  font: 400 15px "JetBrains Mono", monospace;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.day .fill {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 0;
  background: var(--accent-dim);
  transition: height .3s cubic-bezier(.2, .7, .3, 1);
}
.day .num, .day .count { position: relative; }

.day .count {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
}

.day:hover:not(:disabled) { border-color: var(--accent); }
.day:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.day.past, .day.blank { border-color: transparent; cursor: default; }
.day.past { color: color-mix(in srgb, var(--muted) 45%, transparent); }
.day.blank { pointer-events: none; }

.day.selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
  font-weight: 600;
}

.day.leader { border-top: 3px solid var(--crown); }
.day.leader .fill { background: color-mix(in srgb, var(--crown) 28%, var(--accent-dim)); }

.legend {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 0 0;
  font-size: 12px;
  color: var(--muted);
}
.legend-swatch {
  width: 18px; height: 10px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: linear-gradient(to top, var(--accent-dim) 60%, transparent 60%);
}

.results-head { margin-bottom: 16px; }
.results-head h2 { font-size: 20px; }
.total { margin: 4px 0 0; font-size: 13px; color: var(--muted); }

.results { list-style: none; margin: 0; padding: 0; }

.results li { border-top: 1px solid var(--line); }
.results li:first-child { border-top: none; }

.row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  padding: 13px 0;
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.row .rank {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  min-width: 20px;
}
.row .date { flex: 1; font-weight: 500; letter-spacing: -.01em; }
.row .votes {
  font-family: "JetBrains Mono", monospace;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}
.row .chev { color: var(--muted); font-size: 12px; transition: transform .2s; }
.results li.open .chev { transform: rotate(90deg); }
.results li.top .date { color: var(--crown); font-weight: 600; }

.voters { display: none; padding: 0 0 15px 30px; }
.results li.open .voters { display: flex; flex-wrap: wrap; gap: 6px; }

.voter {
  padding: 3px 9px;
  font-size: 13px;
  background: var(--accent-dim);
  border-radius: 100px;
}

.empty { margin: 6px 0 0; font-size: 14px; color: var(--muted); }

.dock {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
.dock > * { max-width: 1040px; }

.dock-status { margin: 0; font-size: 14px; color: var(--muted); }
.dock-status strong { color: var(--ink); font-weight: 600; }
.dock-actions { display: flex; gap: 10px; margin-left: auto; }

.btn {
  padding: 11px 20px;
  font: 600 15px "Instrument Sans", sans-serif;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #245539; }
.btn-primary:disabled { background: var(--line); color: var(--muted); cursor: default; }

.btn-quiet { background: transparent; color: var(--muted); border-color: var(--line); }
.btn-quiet:hover { color: var(--ink); border-color: var(--muted); }

.toast {
  position: fixed;
  left: 50%; bottom: 88px;
  transform: translate(-50%, 12px);
  margin: 0;
  padding: 10px 18px;
  font-size: 14px;
  color: var(--surface);
  background: var(--ink);
  border-radius: 100px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #8C2F2F; }

@media (max-width: 820px) {
  .columns { grid-template-columns: 1fr; }
  .masthead { padding: 36px 0 24px; }
  .day { font-size: 13px; }
  .dock-actions { width: 100%; }
  .dock-actions .btn { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
