:root {
  --paper: #f3efe7;
  --paper-2: #ebe5d8;
  --ink: #241c17;
  --ink-2: #5a5044;
  --muted: #8a7d68;
  --rule: #d3c8b0;
  --accent: #b2542f;
  --accent-soft: rgba(178, 84, 47, 0.12);
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --serif: Newsreader, Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

.bar {
  flex: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  height: 52px;
  padding: 0 16px;
  border-bottom: 1px solid var(--rule);
  font-family: var(--mono);
}
.heading { min-width: 0; display: flex; align-items: center; gap: 6px; }
.heading .title { font-family: var(--serif); font-size: 17px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.still { flex: none; display: inline-flex; color: var(--muted); }
.still[hidden] { display: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.pager { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.pager #count { min-width: 44px; text-align: center; }
.nav-btn { width: 32px; height: 32px; font-size: 20px; line-height: 1; color: var(--ink-2); border-radius: 50%; }
.nav-btn:hover { background: var(--paper-2); }
.who {
  justify-self: end;
  min-width: 34px;
  height: 30px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--rule);
  border-radius: 999px;
}
.who:hover { border-color: var(--muted); }

.stage {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 0;
  touch-action: pan-y;
}
.fit { position: relative; }
.device {
  position: absolute;
  top: 0;
  left: 0;
  width: 360px;
  height: 760px;
  transform-origin: 0 0;
}
.device > * {
  position: absolute;
  inset: 0;
  width: 360px;
  height: 760px;
  border: 0;
  display: block;
  transition: opacity 0.28s ease, transform 0.34s cubic-bezier(.2, .7, .2, 1);
}
.device > .off { opacity: 0; pointer-events: none; }
.device > .from-right { transform: translateX(40px); }
.device > .from-left { transform: translateX(-40px); }
.device img { object-fit: contain; border-radius: 40px; }

.side {
  position: absolute;
  top: 50%;
  translate: 0 -50%;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 26px;
  line-height: 1;
  color: var(--ink-2);
  background: rgba(243, 239, 231, 0.8);
  border: 1px solid var(--rule);
  z-index: 2;
}
.side:hover { border-color: var(--muted); color: var(--ink); }
.side.prev { left: max(12px, calc(50% - 300px)); }
.side.next { right: max(12px, calc(50% - 300px)); }
@media (max-width: 520px) { .side { display: none; } }

.panel {
  flex: none;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 8px 16px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rates { display: flex; align-items: center; justify-content: center; gap: 8px; }
.rate {
  width: 52px;
  height: 46px;
  font-size: 24px;
  line-height: 1;
  border: 1px solid var(--rule);
  border-radius: 12px;
  transition: background-color 0.15s, border-color 0.15s, transform 0.15s;
}
.rate:hover { border-color: var(--muted); }
.rate:active { transform: scale(0.94); }
.rate[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.note-btn {
  height: 46px;
  margin-left: 4px;
  padding: 0 12px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  border: 1px dashed var(--rule);
  border-radius: 12px;
  white-space: nowrap;
}
.note-btn:hover { color: var(--ink); border-color: var(--muted); }
.note-btn.has { color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent); font-weight: 600; }
.status { min-height: 16px; text-align: center; font-family: var(--mono); font-size: 11.5px; color: var(--muted); }

.link { font-family: var(--mono); font-size: 12px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--ink); }
.save {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  padding: 9px 20px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
}
.save:disabled { opacity: 0.5; }

.sheet {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(36, 28, 23, 0.35);
}
.sheet[hidden] { display: none; }
.sheet-card {
  width: 100%;
  max-width: 460px;
  padding: 18px 16px calc(16px + env(safe-area-inset-bottom));
  border-radius: 18px 18px 0 0;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
@media (min-width: 521px) {
  .sheet { align-items: center; padding: 16px; }
  .sheet-card { border-radius: 18px; }
}
.sheet-card { max-height: 88dvh; overflow-y: auto; }
.sheet-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet-h { font-size: 18px; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.x { width: 32px; height: 32px; border-radius: 50%; color: var(--muted); font-size: 15px; }
.x:hover { background: var(--paper-2); color: var(--ink); }

.aspects { display: flex; flex-direction: column; }
.aspect {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) 36px 36px;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  border-bottom: 1px solid var(--paper-2);
}
.aspect-name { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--ink); }
.hint { min-width: 0; font-size: 13.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hint b { font-weight: 500; font-size: 16px; color: var(--ink); }
.swatches { display: flex; }
.swatches i { flex: none; width: 15px; height: 15px; border-radius: 50%; margin-right: -3px; box-shadow: 0 0 0 1.5px var(--paper); }
.vote {
  width: 36px;
  height: 32px;
  border-radius: 9px;
  font-size: 16px;
  line-height: 1;
  filter: grayscale(1);
  opacity: 0.4;
  transition: opacity 0.12s, filter 0.12s, background-color 0.12s;
}
.vote:hover { opacity: 0.75; }
.vote[aria-pressed="true"] { filter: none; opacity: 1; }
.vote.keep[aria-pressed="true"] { background: rgba(74, 187, 143, 0.2); }
.vote.lose[aria-pressed="true"] { background: var(--accent-soft); }
.more { align-self: flex-start; }
.more[hidden] { display: none; }
.add-comment { align-self: flex-start; margin-top: 2px; }
.sheet-card textarea {
  width: 100%;
  resize: vertical;
  padding: 10px 12px;
  font: 16px/1.45 var(--serif);
  color: var(--ink);
  background: #fbf8f2;
  border: 1px solid var(--rule);
  border-radius: 10px;
}
.sheet-card textarea[hidden], .add-comment[hidden] { display: none; }
.sheet-card textarea:focus { outline: none; border-color: var(--muted); }
.sheet-row { display: flex; align-items: center; justify-content: space-between; }
.sheet-hint { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }

@media (max-width: 360px) {
  .aspect { grid-template-columns: minmax(0, 1fr) 36px 36px; row-gap: 0; padding: 4px 0; }
  .aspect-name { grid-column: 1; grid-row: 1; }
  .hint { grid-column: 1; grid-row: 2; font-size: 12.5px; }
  .aspect .vote { grid-row: 1 / span 2; }
}

.picker {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(36, 28, 23, 0.35);
}
.picker[hidden] { display: none; }
.picker-card {
  width: 100%;
  max-width: 340px;
  padding: 22px 20px 16px;
  border-radius: 18px;
  background: var(--paper);
  text-align: center;
}
.picker-h { font-size: 22px; font-weight: 500; margin-bottom: 14px; }
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.chips button {
  height: 48px;
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 600;
  border: 1px solid var(--rule);
  border-radius: 12px;
}
.chips button:hover, .chips button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.picker-note { margin: 14px 0 0; font-size: 13px; color: var(--muted); }
