.bottle-top { flex-wrap: wrap; padding-block: .48rem; }
.bottle-actions { display: flex; align-items: stretch; flex-wrap: wrap; gap: .46rem; }
.bottle-main { padding-block: clamp(1.3rem, 4vw, 2.6rem) 2.4rem; }
.bottle-intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: .85rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
}
.bottle-intro p { margin: .42rem 0 0; color: var(--ui-muted); }
.shelf-button, .shelf-primary, .template-buttons button, .category-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: .46rem .74rem;
  border: 1px solid var(--ui-stroke);
  border-radius: .66rem;
  background: var(--ui-raised);
  color: var(--ui-text);
  font-size: .875rem;
  font-weight: 640;
  white-space: nowrap;
}
.shelf-primary {
  border-color: var(--ui-accent);
  color: var(--ui-accent-ink);
  background: var(--ui-accent);
  font-weight: 730;
}
.shelf-button:hover:not(:disabled), .shelf-primary:hover:not(:disabled),
.template-buttons button:hover, .category-tab:hover { border-color: var(--ui-accent); }
.shelf-button:disabled, .shelf-primary:disabled, .shelf-button[aria-disabled="true"] { opacity: .48; }

.template-buttons {
  display: flex;
  gap: .2rem;
  padding: .2rem;
  border: 1px solid var(--ui-stroke);
  border-radius: .8rem;
  background: var(--ui-bg);
}
.template-buttons button { border-color: transparent; background: transparent; }
.template-buttons button[aria-pressed="true"] { border-color: var(--ui-stroke); background: var(--ui-raised); }
.shelf-tools {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  gap: .55rem;
  padding: .62rem;
  border: 1px solid var(--ui-stroke);
  border-radius: var(--ui-radius);
  background: var(--ui-surface);
}
#category-tabs { display: flex; flex-wrap: wrap; gap: .36rem; }
.category-tab { min-height: 38px; color: var(--ui-muted); font-weight: 560; }
.category-tab[aria-current="true"] { border-color: #a76159; background: #3d292b; color: var(--ui-text); }
.shelf-toolbar, .shelf-controls {
  display: flex;
  align-items: center;
  gap: .46rem;
  flex-wrap: wrap;
}
.shelf-toolbar { justify-content: space-between; }
.shelf-category-line { display: contents; }
#shelf-export { min-width: 44px; min-height: 44px; padding-inline: .55rem; }
#shelf-status { color: var(--ui-muted); margin: 0; font-variant-numeric: tabular-nums; font-size: .875rem; }
.category-control { display: none; gap: .38rem; align-items: center; font-size: .875rem; }
.category-control > span { flex: none; white-space: nowrap; }
.category-control select { min-width: 5.4rem; max-width: 100%; }
.fill-color {
  display: flex;
  align-items: center;
  gap: .4rem;
  min-height: 42px;
  padding: .2rem .52rem;
  border: 1px solid var(--ui-stroke);
  border-radius: .66rem;
  background: var(--ui-raised);
  font-size: .875rem;
}
input[type="color"] { padding: 0; width: 1.65rem; height: 1.58rem; border: 0; cursor: pointer; background: transparent; }
.bulk-tools { position: relative; }
.bulk-tools > summary {
  min-height: 42px;
  display: grid;
  place-items: center;
  padding-inline: .68rem;
  cursor: pointer;
  list-style: none;
  border: 1px solid var(--ui-stroke);
  border-radius: .66rem;
  background: var(--ui-raised);
  font-size: .875rem;
}
.bulk-tools > summary::-webkit-details-marker { display: none; }
.bulk-menu {
  position: absolute;
  right: 0;
  top: calc(100% + .38rem);
  z-index: 6;
  display: grid;
  gap: .4rem;
  padding: .47rem;
  border: 1px solid var(--ui-stroke);
  border-radius: .7rem;
  background: var(--ui-surface);
  box-shadow: 0 8px 25px #09080c9c;
}
.shelf-section { margin-top: 1.1rem; content-visibility: auto; contain-intrinsic-size: auto 420px; }
.shelf-head { display: flex; align-items: baseline; gap: .55rem; margin-bottom: .5rem; }
.shelf-head h2 { margin: 0; font-size: 1.12rem; }
.shelf-head span { font-variant-numeric: tabular-nums; color: var(--ui-muted); font-size: .875rem; }
.bottle-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(7.75rem, 100%), 1fr)); gap: .5rem; }
.bottle-tile {
  --detail-zone: 50px;
  position: relative;
  min-width: 0;
  border: 1px solid var(--ui-stroke);
  border-radius: .8rem;
  background: var(--ui-surface);
}
.bottle-tile:hover { border-color: #a76159; }
.bottle-tile[data-filled="true"] { border-color: #88564e; background: #312329; }
.bottle-trigger {
  display: grid;
  grid-template-rows: 3.75rem minmax(2.3em, 1fr) auto;
  justify-items: center;
  align-content: start;
  gap: .22rem;
  width: 100%;
  height: 100%;
  min-height: 8rem;
  padding: .62rem .3rem .46rem;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: var(--ui-text);
  overflow-wrap: anywhere;
  /* Reserve the 44px detail target and its surrounding gutter for pointer hits. */
  clip-path: polygon(0 0, calc(100% - var(--detail-zone)) 0,
    calc(100% - var(--detail-zone)) var(--detail-zone), 100% var(--detail-zone), 100% 100%, 0 100%);
}
.bottle-tile:has(.bottle-trigger:focus-visible) { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
.bottle-trigger:focus-visible { outline: none; }
.bottle-label { align-self: center; font-size: .875rem; line-height: 1.25; }
.bottle-value { color: var(--ui-muted); font-size: .8125rem; font-variant-numeric: tabular-nums; }
.bottle-tile[data-filled="true"] .bottle-value { color: var(--ui-accent); }
.bottle-detail {
  position: absolute;
  top: 2px;
  right: 2px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ui-muted);
}
.bottle-detail-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--ui-stroke);
  border-radius: .55rem;
  background: var(--ui-raised);
  font-size: .875rem;
  font-weight: 720;
}
.bottle-detail:hover .bottle-detail-mark { border-color: var(--ui-accent); color: var(--ui-accent); }

/* The cap, neck and rounded glass body follow the V4 bottle silhouette. */
.bottle-glyph { position: relative; display: block; width: 2.95rem; height: 3.75rem; }
.bottle-trigger .bottle-glyph {
  justify-self: start;
  margin-inline-start: clamp(0px, calc(100% - var(--detail-zone) - 2.95rem), calc(50% - 1.475rem));
}
.bottle-glyph::after {
  position: absolute;
  inset: auto 6% 0;
  height: 10%;
  border-radius: 50%;
  content: "";
  background: radial-gradient(ellipse, #09070ab5, #09070a00 72%);
}
.bottle-cap, .bottle-neck, .bottle-body, .bottle-liquid { position: absolute; display: block; }
.bottle-cap {
  z-index: 3;
  inset: 3% 29% auto;
  height: 15%;
  border: 1px solid #aa8fa2;
  border-radius: .2rem .2rem .12rem .12rem;
  background: repeating-linear-gradient(90deg,#fff4 0 1px,transparent 1px 3px),
    linear-gradient(180deg,#eee0e9,#a88f9e);
  box-shadow: inset 0 1px #fff8;
}
.bottle-neck {
  z-index: 1;
  inset: 16% 35% auto;
  height: 18%;
  border: 1px solid #bbaab9;
  background: linear-gradient(90deg,#dad0dc,#fff7ef,#d9ccd6);
}
.bottle-body {
  z-index: 2;
  inset: 27% 6% 5%;
  overflow: hidden;
  border: 1px solid #baabb9;
  border-radius: 33% 33% 23% 23% / 29% 29% 16% 16%;
  background: linear-gradient(90deg,#dacbd7,#fffaf5 24%,#f5edf2 65%,#d6c6d2);
  box-shadow: inset 0 1px #fff9, inset 0 -2px #65506b35;
}
.bottle-liquid {
  inset: auto 0 0;
  height: var(--bottle-fill, 0%);
  background: linear-gradient(90deg,#fff2,transparent 25% 73%,#35243b28), var(--bottle-color, #eb80a4);
  transition: height .18s ease;
}
.bottle-liquid::before {
  position: absolute;
  inset: 0 0 auto;
  height: min(30%, 4px);
  border-radius: 50%;
  content: "";
  background: linear-gradient(90deg,#fff4,#fffb 52%,#fff4);
}
.bottle-body::after {
  position: absolute;
  inset: 15% auto 18% 15%;
  width: 11%;
  content: "";
  border-radius: 100px;
  background: linear-gradient(180deg,#fff9,#fff3 78%,transparent);
}
#bottle-tooltip {
  position: fixed;
  z-index: 20;
  width: min(21rem, calc(100vw - 24px));
  padding: .65rem .76rem;
  border: 1px solid #9c675d;
  border-radius: .72rem;
  background: #2c2025;
  color: var(--ui-text);
  box-shadow: 0 8px 25px #100a0dc0;
  pointer-events: none;
  font-size: .875rem;
}
#bottle-tooltip strong { color: var(--ui-accent); }
#bottle-tooltip p { margin: .24rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.bottle-notice {
  position: fixed;
  bottom: max(1rem, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  width: max-content;
  max-width: calc(100vw - 2rem);
  margin: 0;
  padding: .58rem .88rem;
  border: 1px solid var(--ui-stroke);
  border-radius: .65rem;
  color: var(--ui-text);
  background: #352b39;
  font-size: .875rem;
}
.bottle-dialog {
  width: min(32rem, calc(100% - 1.2rem));
  max-height: 90dvh;
  padding: 0;
  overflow: auto;
  border: 1px solid var(--ui-stroke);
  border-radius: var(--ui-radius);
  background: var(--ui-surface);
  color: var(--ui-text);
}
.bottle-dialog::backdrop { background: #09080dd0; }
.dialog-body { padding: .9rem; display: grid; gap: .68rem; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: .55rem; }
.dialog-heading h2 { margin: 0; font-size: 1.15rem; overflow-wrap: anywhere; }
.close-button { min-width: 42px; padding: .12rem .28rem; font-size: 1.15rem; }
.term-type, .term-description, #export-page, #export-progress { margin: 0; }
.term-type { color: var(--ui-accent); font-size: .875rem; }
.term-description { white-space: pre-wrap; overflow-wrap: anywhere; }
.term-fill { display: grid; grid-template-columns: 1fr auto; gap: .3rem; }
#term-level { grid-column: 1 / -1; width: 100%; accent-color: var(--ui-accent); }
#term-level-label { color: var(--ui-accent); }
.export-dialog { width: min(47rem, calc(100% - 1.2rem)); }
.export-form { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .55rem; }
.export-form label { min-width: 0; display: grid; gap: .28rem; color: var(--ui-muted); font-size: .875rem; }
#export-summary { margin: 0; font-size: .9rem; overflow-wrap: anywhere; }
.export-form input, .export-form select, #category-select {
  min-height: 42px;
  width: 100%;
  padding: .45rem .62rem;
  border: 1px solid var(--ui-stroke);
  border-radius: .64rem;
  background-color: var(--ui-bg);
  color: var(--ui-text);
}
select {
  appearance: none;
  padding-inline-end: 2rem !important;
  background-image: linear-gradient(45deg, transparent 50%, var(--ui-muted) 50%), linear-gradient(135deg, var(--ui-muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
.export-pagination { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
#preview-zoom { margin-inline-start: auto; }
#export-page { text-align: center; font-size: .875rem; font-variant-numeric: tabular-nums; }
.export-canvas {
  min-width: 0;
  max-height: 45dvh;
  overflow: auto;
  padding: .48rem;
  border: 1px solid var(--ui-stroke);
  border-radius: .68rem;
  background: var(--ui-bg);
}
#export-preview { display: block; max-width: 100%; height: auto; margin: auto; cursor: zoom-in; }
.export-canvas.original-size { overscroll-behavior: contain; }
.export-canvas.original-size #export-preview { width: auto; max-width: none; margin: 0; cursor: auto; }
#export-progress { color: var(--ui-muted); font-size: .875rem; }

@media (max-width: 700px) {
  #category-tabs { display: none; }
  .shelf-category-line { display: flex; flex: 1 0 100%; align-items: center; gap: .46rem; }
  .category-control { display: flex; flex: 1 1 9rem; min-width: 7.5rem; }
  .category-control select { min-width: 0; }
}
@media (max-width: 510px) {
  .export-form { grid-template-columns: minmax(0,1fr); }
  .bottle-grid { grid-template-columns: repeat(3,minmax(0,1fr)); gap: .36rem; }
  .bottle-trigger { padding-inline: .24rem; }
  .bottle-top .bottle-actions { gap: .28rem; }
  .bottle-top .bottle-actions button { padding-inline: .52rem; }
}
@media (max-width: 365px) {
  .bottle-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .ui-brand small { display: none; }
}
