:root {
  font-family: system-ui, -apple-system, sans-serif;
  color: #193a34;
  background: #f3f5ef;
  font-synthesis: none
}

[hidden] {
  display: none !important
}

* {
  box-sizing: border-box
}

body {
  margin: 0
}

main {
  max-width: 1280px;
  margin: auto;
  padding: 48px 28px
}

.eyebrow {
  font-size: 12px;
  letter-spacing: .22em;
  color: #577369
}

h1 {
  font-size: clamp(28px, 5vw, 46px);
  font-weight: 650;
  letter-spacing: .06em;
  margin: 14px 0
}

.intro {
  color: #64766b;
  line-height: 1.8
}

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 28px 0
}

select,
button {
  font: inherit;
  border-radius: 10px;
  padding: 12px 18px;
  border: 1px solid #becbbf;
  background: #fff;
  color: inherit
}

button {
  cursor: pointer
}

button.primary {
  background: #205b47;
  color: white;
  border-color: #205b47
}

button:disabled {
  opacity: .45;
  cursor: default
}

button:focus-visible,
select:focus-visible {
  outline: 3px solid #d49330;
  outline-offset: 3px
}

.animation-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer
}

.animation-option input {
  width: 18px;
  height: 18px;
  accent-color: #205b47
}

.animation-option input:focus-visible {
  outline: 3px solid #d49330;
  outline-offset: 3px
}

.summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-block: 1px solid #ccd7c8;
  padding: 24px 0;
  margin: 22px 0
}

.formula {
  font: 32px Georgia, serif
}

.count {
  max-width: 75%;
  overflow-wrap: anywhere;
  text-align: right;
  font-size: clamp(22px, 3vw, 38px);
  font-variant-numeric: tabular-nums
}

.count small {
  font-size: 15px;
  color: #65766c
}

.count .class-tag {
  margin-right: 16px;
  vertical-align: middle
}

#status {
  font-size: 14px;
  color: #586e62;
  margin-top: 6px
}

.hint {
  font-size: 12px;
  color: #62766a
}

.pager {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 24px 0
}

.pager input[type="range"] {
  flex: 1;
  min-width: 140px;
  accent-color: #205b47;
  cursor: pointer
}

.pager .range-label {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-variant-numeric: tabular-nums
}

.pager input:focus-visible {
  outline: 3px solid #d49330;
  outline-offset: 4px
}

.page-number {
  font: inherit;
  width: 12ch;
  max-width: 100%;
  padding: 8px;
  border: 1px solid #becbbf;
  border-radius: 8px;
  color: inherit;
  background: white
}

.page-total {
  overflow-wrap: anywhere;
  max-width: 100%
}

#gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px
}

.card {
  display: block;
  text-align: left;
  padding: 15px;
  background: #fff;
  border: 1px solid #dce3d7;
  border-radius: 16px;
  min-width: 0;
  box-shadow: 0 3px 12px #173b2910
}

.card.appear {
  animation: appear .45s cubic-bezier(.2, .7, .2, 1) both
}

.card:hover {
  border-color: #779c87;
  box-shadow: 0 6px 18px #173b2920
}

.card-top {
  overflow-wrap: anywhere;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #6f8074
}

.card svg {
  width: 100%;
  height: 175px;
  display: block
}

svg text {
  font-family: system-ui, sans-serif;
  font-size: 20px;
  fill: #254c3b
}

svg line {
  stroke: #829786;
  stroke-width: 2.4;
  stroke-linecap: round
}

dialog {
  width: min(820px, 94vw);
  border: 1px solid #d1dccd;
  border-radius: 20px;
  padding: 24px;
  color: inherit;
  background: #fbfcf8
}

.detail-navigation {
  display: grid;
  grid-template-columns: auto auto minmax(100px, 1fr) 180px;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 16px
}

.detail-navigation input[type="range"] {
  width: 100%;
  min-width: 0
}

.detail-jump {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-width: 0;
  max-width: 100%
}

.detail-jump input {
  flex: 1 1 0;
  width: 0;
  min-width: 0;
  max-width: 100%;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, monospace
}

#detailPrevious:focus,
#detailNext:focus {
  outline: none
}

#detailCard:focus-visible {
  outline: 2px solid #70977e;
  outline-offset: 8px;
  border-radius: 8px
}

dialog::backdrop {
  background: #102e24a0;
  backdrop-filter: blur(4px)
}

#drawing {
  height: min(60vh, 480px);
  overflow: hidden;
  position: relative;
  touch-action: none;
  user-select: none;
  overscroll-behavior: contain;
  border: 1px solid #e0e7da;
  border-radius: 12px;
  background: #fff
}

#drawing>svg {
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
  pointer-events: none
}

#drawing:focus-visible {
  outline: 3px solid #d49330;
  outline-offset: 3px
}

.viewer-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 14px
}

.viewer-toolbar button {
  display: grid;
  place-items: center;
  min-width: 44px;
  height: 44px;
  padding: 10px
}

.viewer-toolbar svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round
}

.viewer-toolbar button[aria-pressed="true"] {
  background: #e0ecdf;
  border-color: #749c7d
}

#zoomReadout {
  font-variant-numeric: tabular-nums;
  min-width: 60px;
  text-align: center
}

#detailTitle {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 20px
}

.detail-formula {
  white-space: nowrap
}

.detail-number {
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.4;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 10px;
  background: #e7effb;
  color: #27528a
}

.dialog-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0
}

.detail-chain {
  display: inline-block;
  font-size: 14px;
  line-height: 1.4;
  font-weight: 600;
  white-space: nowrap;
  padding: 8px 12px;
  border-radius: 10px;
  background: #f0e8f7;
  color: #674184
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px
}

#detailTitle {
  font-size: 18px
}

#finish {
  font-size: 20px;
  font-weight: 600;
  color: #226449;
  min-height: 30px;
  margin: 24px 0
}

.celebrate {
  animation: celebrate .65s ease
}

@keyframes appear {
  from {
    opacity: 0;
    transform: translateY(18px) scale(.93)
  }

  to {
    opacity: 1;
    transform: none
  }
}

@keyframes celebrate {
  50% {
    transform: scale(1.04);
    color: #c1801c
  }
}

@media(prefers-reduced-motion:reduce) {

  *,
  *::before,
  *::after {
    animation: none !important
  }
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
  margin-left: 8px
}

.class-tag,
.chain-tag {
  display: inline-block;
  border-radius: 6px;
  padding: 4px 7px;
  line-height: 1.5
}

.class-tag {
  background: #e1efe5;
  color: #245c3b;
  font-size: 14px;
  font-weight: 500
}

.chain-tag {
  background: #f0e8f7;
  color: #674184
}

.detail-chain {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  white-space: normal;
  background: none;
  padding: 0;
  max-width: 100%
}

.dialog-actions {
  flex-shrink: 1;
  min-width: 0
}

.card-top {
  align-items: flex-start
}

.card-top>span:first-child {
  white-space: nowrap
}

.dialog-head {
  flex-wrap: wrap
}

.compound-note {
  color: #586e62;
  line-height: 1.7
}

.compound-note em {
  font-style: normal;
  font-weight: 700
}

#compound {
  max-width: 100%
}

@media(max-width:560px) {
  .detail-navigation { grid-template-columns: auto auto minmax(0, 1fr); }
  .detail-navigation input[type="range"] { grid-row: 2; grid-column: 1 / -1; }
  .detail-jump { grid-row: 1; grid-column: 3; }
  .dialog-head {
    flex-wrap: wrap
  }

  .dialog-actions {
    margin-left: auto;
    gap: 8px
  }

  .detail-chain {
    padding: 8px;
    font-size: 14px
  }

  main {
    padding: 28px 16px
  }

  #gallery {
    grid-template-columns: 1fr;
    gap: 10px
  }

  .card {
    padding: 9px
  }

  .card svg {
    height: 220px
  }
}

#alcoholFilters{border:0;padding:0;margin:16px 0;display:flex;flex-wrap:wrap;gap:12px 24px}#alcoholFilters legend{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}#alcoholFilters label{display:inline-flex;align-items:center;gap:8px;cursor:pointer}#alcoholFilters input{width:18px;height:18px;accent-color:#205b47}

.alcohol-degree{display:inline-block;padding:4px 9px;border-radius:7px;font-size:13px;line-height:1.5;font-weight:600;white-space:nowrap}
.alcohol-degree-1{background:#fff0cf;color:#805000}
.alcohol-degree-2{background:#d9f2f1;color:#096563}
.alcohol-degree-3{background:#fbe1e8;color:#943853}

/* Separate native buttons: no interactive controls nested inside another button. */
.card{position:relative;padding-bottom:42px}
.card-open{display:block;width:100%;padding:0;border:0;background:transparent;color:inherit;text-align:inherit;font:inherit;box-shadow:none}
.card-open:hover{background:transparent}
.name-help{position:absolute;right:12px;bottom:10px;width:26px;height:26px;min-width:26px;padding:0;border:1.5px solid #698075;border-radius:50%;background:#f4f7f3;color:#254c3b;font-size:16px;font-weight:600;line-height:1}
#nameDialog{width:min(650px,94vw)}
#nameHeading{font-size:17px;overflow-wrap:anywhere}
#nameText{font-size:22px;line-height:1.6;overflow-wrap:anywhere;user-select:text}
#nameNote{font-size:13px;line-height:1.6;color:#607168}
