:root {
  --paper: #f8f5ee;
  --paper-deep: #efe9dc;
  --ink: #33322f;
  --muted: #7a756b;
  --line: #d8d0c0;
  --sage: #5e745d;
  --sage-deep: #4d614c;
  --clay: #5c4841;
  --blush: #ecdcd5;
  --error: #9a3b2e;

  --display: "Cormorant Garamond", "Adobe Jenson Pro", Garamond, Georgia, serif;
  --body: "EB Garamond", Garamond, Georgia, serif;
  --label: "Outfit", "Helvetica Neue", Arial, sans-serif;

  --gutter: clamp(16px, 4vw, 56px);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 18px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--display); font-weight: 300; line-height: 1.08; text-wrap: balance; }
em { font-style: italic; }
a { color: inherit; }
img { display: block; max-width: 100%; }

.label {
  font-family: var(--label);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

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

:focus-visible { outline: 1px solid var(--ink); outline-offset: 3px; }

/* ---------- buttons & fields ---------- */

button { font: inherit; color: inherit; cursor: pointer; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 28px;
  border: 1px solid var(--sage);
  background: var(--sage);
  color: #fff;
  font-family: var(--label);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.btn:hover { background: var(--sage-deep); border-color: var(--sage-deep); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn--outline { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn--outline:hover { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn--block { width: 100%; }

.link {
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--label);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  padding-bottom: 2px;
}
.link:hover { color: var(--sage); }
.link--plain { border-bottom-color: transparent; }
.link--plain:hover, .link--plain[aria-current="true"] { border-bottom-color: currentColor; color: inherit; }

.field { display: block; margin-bottom: 22px; }
.field > span { display: block; margin-bottom: 4px; color: var(--muted); }
.field input, .field textarea {
  width: 100%;
  padding: 8px 0 10px;
  border: 0;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--body);
  font-size: 19px;
}
.field textarea { resize: vertical; min-height: 44px; }
.field input[type="search"] { appearance: none; -webkit-appearance: none; }
.field input[type="search"]::-webkit-search-cancel-button { display: none; }
.field input::placeholder, .field textarea::placeholder { color: #a9a294; font-style: italic; }
.field input:focus, .field textarea:focus { outline: 0; border-bottom-color: var(--sage); box-shadow: 0 1px 0 var(--sage); }

.error { color: var(--error); font-style: italic; min-height: 1.5em; }

/* ---------- sign in ---------- */

.gate {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.gate__art {
  background: var(--sage);
  color: var(--paper);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--gutter);
}
.gate__art h1 { font-size: clamp(48px, 7vw, 104px); font-style: italic; }
.gate__art p { max-width: 26ch; font-size: 21px; opacity: 0.9; }
.gate__form {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--gutter);
}
.gate__form form { width: 100%; max-width: 380px; margin: 0 auto; }
.gate__form h2 { font-size: 40px; margin: 10px 0 12px; }
.gate__form p { margin-bottom: 32px; }

@media (max-width: 760px) {
  .gate { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .gate__art { min-height: 38svh; gap: 40px; }
}

/* ---------- header ---------- */

.strip {
  background: var(--sage);
  color: #fff;
  text-align: center;
  padding: 9px var(--gutter);
}

.header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 22px var(--gutter);
  border-bottom: 1px solid var(--line);
}
.header nav { display: flex; flex-wrap: wrap; gap: 8px 26px; align-items: center; }
.header nav:last-child { justify-content: flex-end; }
.wordmark {
  font-family: var(--display);
  font-size: clamp(28px, 3.4vw, 40px);
  font-weight: 300;
  letter-spacing: 0.02em;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}
.wordmark em { font-weight: 300; }

@media (max-width: 760px) {
  .header { grid-template-columns: 1fr; justify-items: center; gap: 14px; padding-block: 18px; }
  .header nav, .header nav:last-child { justify-content: center; }
  .header .wordmark { order: -1; }
}

/* ---------- hero ---------- */

.hero { text-align: center; padding: clamp(48px, 8vw, 104px) var(--gutter) clamp(36px, 5vw, 64px); }
.hero h1 { font-size: clamp(46px, 7.5vw, 104px); font-style: italic; margin: 14px 0 18px; }
.hero p { max-width: 46ch; margin: 0 auto; font-size: 20px; }

.steps {
  display: flex;
  justify-content: center;
  gap: clamp(18px, 4vw, 48px);
  margin: 36px 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
}
.steps li { padding-bottom: 6px; border-bottom: 1px solid transparent; }
.steps li[aria-current="step"] { color: var(--ink); border-bottom-color: var(--ink); }

/* ---------- sections ---------- */

.section { padding: 0 var(--gutter) clamp(56px, 8vw, 104px); }
.section__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 18px 0;
  margin-bottom: 32px;
  border-top: 1px solid var(--line);
}
.section__head h2 { font-size: 30px; }

.empty { text-align: center; padding: 40px 0 8px; font-size: 22px; font-style: italic; color: var(--muted); }

/* ---------- book grid ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(36px, 5vw, 64px) clamp(14px, 2.4vw, 32px);
}
@media (max-width: 1100px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.card { display: flex; flex-direction: column; min-width: 0; }
.card__body { padding-top: 16px; display: flex; flex-direction: column; flex: 1; gap: 6px; }
.card h3 { font-size: 25px; font-weight: 400; overflow-wrap: anywhere; }
.card__note { font-style: italic; color: var(--clay); margin-top: 4px; overflow-wrap: anywhere; }
.card__by { color: var(--muted); font-size: 16px; }
.card__action { margin-top: auto; padding-top: 16px; }

.cover {
  position: relative;
  aspect-ratio: 2 / 3;
  background: var(--paper-deep);
  overflow: hidden;
}
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover--set {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12%;
  color: var(--paper);
  container-type: inline-size;
}
.cover--tagged { padding-top: max(22%, 52px); }
.cover--set::after {
  content: "";
  position: absolute;
  inset: 5%;
  border: 1px solid rgb(255 255 255 / 0.35);
  pointer-events: none;
}
.cover--set .cover__title {
  font-family: var(--display);
  font-style: italic;
  font-weight: 300;
  font-size: 13cqw;
  line-height: 1.05;
  overflow-wrap: anywhere;
}
.cover--set .cover__author { font-family: var(--label); font-size: 4.2cqw; letter-spacing: 0.16em; text-transform: uppercase; }

.tag {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1;
  padding: 5px 10px;
  background: var(--paper);
  color: var(--ink);
}

.tally { display: flex; align-items: center; gap: 12px; }
.tally__bar { flex: 1; height: 1px; background: var(--line); position: relative; }
.tally__bar i { position: absolute; left: 0; top: -1px; height: 3px; background: var(--sage); }
.tally__n { white-space: nowrap; }

/* ---------- suggest ---------- */

.panel {
  background: var(--paper-deep);
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: clamp(28px, 6vw, 88px);
  padding: clamp(28px, 5vw, 72px);
  margin-bottom: clamp(48px, 7vw, 88px);
}
.panel h2 { font-size: clamp(34px, 4.4vw, 56px); margin: 12px 0 16px; }
@media (max-width: 760px) { .panel { grid-template-columns: 1fr; } }

.results { list-style: none; margin: -12px 0 22px; padding: 0; border: 1px solid var(--line); background: var(--paper); }
.results li + li { border-top: 1px solid var(--line); }
.results button {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 14px;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  background: none;
  text-align: left;
}
.results button:hover { background: var(--blush); }
.results img, .results .thumb { width: 34px; height: 50px; object-fit: cover; background: var(--paper-deep); }
.results strong { display: block; font-weight: 500; line-height: 1.2; }
.results small { color: var(--muted); font-size: 15px; }

.chosen { display: grid; grid-template-columns: 72px 1fr; gap: 18px; align-items: center; margin-bottom: 26px; }
.chosen h3 { font-size: 26px; font-weight: 400; }

/* ---------- winner ---------- */

.winner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  background: var(--paper-deep);
  margin: 0 0 clamp(48px, 7vw, 88px);
}
.winner__cover { padding: clamp(28px, 6vw, 88px); display: flex; justify-content: center; background: var(--blush); }
.winner__cover .cover { width: min(100%, 360px); box-shadow: 0 24px 40px -24px rgb(51 50 47 / 0.45); }
.winner__text { padding: clamp(28px, 6vw, 88px); display: flex; flex-direction: column; justify-content: center; gap: 14px; }
.winner__text h2 { font-size: clamp(40px, 5.4vw, 76px); font-style: italic; overflow-wrap: anywhere; }
.winner__text .card__note { font-size: 21px; }
.winner__links { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 18px; }
@media (max-width: 760px) {
  .winner { grid-template-columns: 1fr; }
  .winner__links .btn { width: 100%; }
}

/* ---------- past reads ---------- */

.past { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 28px 18px; }
.past h3 { font-size: 19px; font-weight: 400; margin-top: 8px; overflow-wrap: anywhere; }

/* ---------- admin ---------- */

.admin { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: clamp(28px, 6vw, 88px); }
@media (max-width: 760px) { .admin { grid-template-columns: 1fr; } }
.admin h3 { font-size: 26px; font-weight: 400; margin-bottom: 10px; }
.admin p { margin-bottom: 18px; }

.members { width: 100%; border-collapse: collapse; margin-bottom: 26px; }
.members th { text-align: left; font-weight: 400; color: var(--muted); padding: 0 12px 8px 0; }
.members td { padding: 10px 12px 10px 0; border-top: 1px solid var(--line); vertical-align: baseline; overflow-wrap: anywhere; }
.members td:last-child, .members th:last-child { padding-right: 0; text-align: right; }
.members small { display: block; color: var(--muted); font-size: 15px; }
.table-wrap { overflow-x: auto; }

.row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 16px; align-items: end; }
.row .field { margin-bottom: 0; }
.row .btn { justify-self: start; }
@media (max-width: 1100px) { .row { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .row { grid-template-columns: 1fr; } }

/* ---------- dialog & footer ---------- */

dialog {
  width: min(92vw, 460px);
  padding: 36px;
  border: 0;
  background: var(--paper);
  color: var(--ink);
  text-align: center;
}
dialog::backdrop { background: rgb(51 50 47 / 0.45); }
dialog h2 { font-size: 36px; font-style: italic; margin: 10px 0 12px; }
dialog p { margin-bottom: 24px; }
dialog .actions { display: flex; flex-direction: column; gap: 10px; }

.footer {
  border-top: 1px solid var(--line);
  padding: 28px var(--gutter) 40px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

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

/* ---------- ballot: drag to rank ---------- */

.modes { display: flex; gap: 22px; }

.ballot { max-width: 860px; margin: 0 auto; }
.ballot__intro { text-align: center; max-width: 48ch; margin: 0 auto 28px; }
.ballot__submit { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 24px; margin-top: 32px; }

.rank { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.rank__row {
  display: grid;
  grid-template-columns: 56px 64px minmax(0, 1fr) auto auto 36px;
  align-items: center;
  gap: clamp(12px, 2.4vw, 24px);
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.rank__row.is-dragging { background: var(--paper-deep); box-shadow: 0 14px 28px -18px rgb(51 50 47 / 0.5); position: relative; z-index: 1; }
.is-sorting, .is-sorting * { cursor: grabbing !important; }
.rank__n { font-family: var(--display); font-size: 52px; font-weight: 300; font-style: italic; line-height: 1; text-align: center; }
.rank__text h3 { font-size: 25px; font-weight: 400; overflow-wrap: anywhere; }
.rank__text .card__note { font-size: 16px; margin-top: 2px; }
.rank__pts { white-space: nowrap; }
.rank__move { display: flex; flex-direction: column; gap: 4px; }
.rank__move button {
  width: 32px;
  height: 28px;
  border: 1px solid var(--line);
  background: transparent;
  font-family: var(--label);
  font-size: 14px;
  line-height: 1;
}
.rank__move button:hover:not(:disabled) { border-color: var(--ink); }
.rank__move button:disabled { opacity: 0.3; cursor: default; }
.rank__handle {
  width: 36px;
  height: 44px;
  touch-action: none;
  cursor: grab;
  background:
    linear-gradient(var(--muted), var(--muted)) center 16px / 18px 1px no-repeat,
    linear-gradient(var(--muted), var(--muted)) center 22px / 18px 1px no-repeat,
    linear-gradient(var(--muted), var(--muted)) center 28px / 18px 1px no-repeat;
}

@media (max-width: 760px) {
  .rank__row { grid-template-columns: 30px 48px minmax(0, 1fr) auto 32px; gap: 12px; }
  .rank__n { font-size: 36px; }
  .rank__text h3 { font-size: 20px; }
  .rank__text .card__note { display: none; }
  .rank__pts { display: none; }
}

/* ---------- ballot: bracket ---------- */

.match { text-align: center; }
.match__q { font-family: var(--display); font-style: italic; font-weight: 300; font-size: clamp(30px, 4.4vw, 48px); line-height: 1.1; margin-bottom: 10px; }
.match__pair {
  display: grid;
  grid-template-columns: minmax(0, 300px) auto minmax(0, 300px);
  justify-content: center;
  align-items: center;
  gap: clamp(12px, 4vw, 48px);
  margin-top: 32px;
}
.match__or { font-family: var(--display); font-style: italic; font-size: 28px; color: var(--muted); }
.match__side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
}
.match__side .cover { transition: transform 0.25s, box-shadow 0.25s; margin-bottom: 8px; }
.match__side:hover .cover { transform: translateY(-6px); box-shadow: 0 24px 36px -24px rgb(51 50 47 / 0.5); }
.match__side h3 { font-size: clamp(20px, 2.6vw, 28px); font-weight: 400; overflow-wrap: anywhere; }
.match__side .btn { margin-top: 8px; }
.match__side:hover .btn { background: var(--ink); color: var(--paper); }
@media (max-width: 560px) { .match__side .btn { padding: 0 10px; } }

.tag { border: 1px solid var(--line); }
.modes .link { white-space: nowrap; }
@media (max-width: 760px) { .modes { gap: 14px; } .section__head h2 { font-size: 24px; } }

/* ---------- summaries ---------- */

.card__note { font-style: normal; font-size: 16px; line-height: 1.45; }
.card .card__note, .match__side .card__note {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  line-clamp: 5;
  overflow: hidden;
}
.rank__text .card__note { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.winner__text .card__note { font-size: 19px; }
@media (max-width: 760px) {
  .rank__text .card__note { display: -webkit-box; font-size: 15px; }
  .match__side .card__note { -webkit-line-clamp: 7; line-clamp: 7; font-size: 15px; }
}
.card .card__note, .match__side .card__note { display: block; -webkit-line-clamp: none; line-clamp: none; overflow: visible; }
.rank__text .card__note { -webkit-line-clamp: 3; line-clamp: 3; }

/* ---------- edit book ---------- */

.card__links { display: flex; gap: 20px; }
dialog.dialog--form { width: min(92vw, 560px); text-align: left; }
dialog.dialog--form h2 { margin-bottom: 26px; }
dialog.dialog--form .error { text-align: center; margin-top: 10px; }
