#apothecary-bench-overlay {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: none;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  background: rgba(4, 8, 16, 0.72);
  backdrop-filter: blur(2px);
}

#apothecary-bench-overlay:not(.hidden) {
  display: flex !important;
}

#apothecary-bench-shell {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: center;
  gap: 14px;
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 14px 12px;
  box-sizing: border-box;
}

#apothecary-bench-inner {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  border: 1px solid #3f6212;
  background: linear-gradient(180deg, #14210a 0%, #0c1608 100%);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.apothecary-bench-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 8px;
  border-bottom: 1px solid rgba(74, 124, 42, 0.45);
  background: rgba(16, 28, 10, 0.95);
}

.apothecary-bench-title {
  font-size: 1rem;
  font-weight: 700;
  color: #dcfce7;
}

.apothecary-bench-close-corner {
  padding: 4px 10px;
  font-size: 1.25rem;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid rgba(74, 124, 42, 0.9);
  background: linear-gradient(180deg, #3f6212 0%, #1a2e05 100%);
  color: #ecfccb;
}

.apothecary-bench-crafting-zone {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 12px 20px;
  gap: 12px;
}

.apothecary-bench-cylinder-wrap {
  position: relative;
  width: min(280px, 70vw);
  height: min(280px, 70vw);
  display: flex;
  align-items: center;
  justify-content: center;
}

.apothecary-bench-cylinder-ring {
  position: absolute;
  inset: 0;
}

.apothecary-chamber-slot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  transform: rotate(var(--chamber-angle)) translateY(-108px) rotate(calc(-1 * var(--chamber-angle)));
  border-radius: 50%;
  border: 2px solid rgba(134, 239, 172, 0.35);
  background: rgba(20, 33, 10, 0.92);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.apothecary-chamber-slot:hover,
.apothecary-chamber-slot:active {
  transform: rotate(var(--chamber-angle)) translateY(-108px) rotate(calc(-1 * var(--chamber-angle)));
}

.apothecary-chamber-slot.apothecary-chamber-open {
  border-color: rgba(187, 247, 208, 0.85);
  box-shadow: 0 0 12px rgba(74, 222, 128, 0.25);
}

.apothecary-chamber-slot.apothecary-chamber-sealed {
  opacity: 0.35;
  cursor: not-allowed;
  border-color: rgba(100, 116, 139, 0.35);
  background: rgba(15, 23, 42, 0.55);
}

.apothecary-bench-brew-btn {
  position: relative;
  z-index: 2;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 2px solid #86efac;
  background: radial-gradient(circle at 35% 30%, #4ade80 0%, #166534 70%);
  color: #052e16;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
}

.apothecary-bench-brew-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.apothecary-bench-brew-qty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}

.apothecary-bench-brew-qty-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(134, 239, 172, 0.45);
  background: rgba(20, 33, 10, 0.92);
  color: #dcfce7;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0;
}

.apothecary-bench-brew-qty-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.apothecary-bench-brew-qty-value {
  width: 52px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(134, 239, 172, 0.45);
  background: rgba(12, 22, 8, 0.95);
  color: #ecfccb;
  text-align: center;
  font: 600 0.95rem/1 JetBrains Mono, monospace;
}

.apothecary-bench-hint {
  margin: 0;
  max-width: 420px;
  text-align: center;
  color: #bbf7d0;
  font-size: 0.88rem;
  line-height: 1.35;
}

.apothecary-bench-hint-muted {
  color: rgba(187, 247, 208, 0.65);
}

.apothecary-bench-inventory-panel,
.apothecary-bench-recipes-panel {
  flex: 0 0 200px;
  width: 200px;
  min-width: 200px;
  max-width: 200px;
  max-height: min(520px, calc(100vh - 40px));
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #30363d;
  background: #161b22;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.apothecary-bench-inventory-heading,
.apothecary-bench-recipes-heading {
  margin: 0 0 8px;
  font-size: 0.98rem;
  font-weight: 600;
  color: #e6edf3;
}

.apothecary-bench-inventory-hint {
  margin: 0 0 8px;
  font-size: 0.75rem;
  color: #8b949e;
  line-height: 1.3;
}

.apothecary-bench-inventory-list {
  flex: 0 1 auto;
  min-height: 0;
  max-height: 240px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 2px;
}

.apothecary-bench-quick-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.apothecary-bench-quick-label {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 600;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.apothecary-bench-quick-row .apothecary-bench-inv-slot {
  border-color: rgba(250, 204, 21, 0.45);
}

.apothecary-bench-inv-grid {
  display: grid;
  grid-template-columns: repeat(4, 44px);
  gap: 6px;
  align-content: start;
  justify-content: start;
}

.apothecary-bench-inv-slot {
  position: relative;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid #30363d;
  border-radius: 8px;
  background: #0d1117;
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.apothecary-bench-inv-slot:hover {
  border-color: #58a6ff;
  background: #161b22;
  transform: none;
}

.apothecary-bench-inv-slot:active {
  transform: none;
}

.apothecary-bench-inv-qty {
  position: absolute;
  right: 3px;
  bottom: 1px;
  font-size: 10px;
  font-weight: 700;
  color: #e2e8f0;
}

.apothecary-bench-recipe-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.apothecary-bench-recipe-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid #30363d;
  background: #0d1117;
  cursor: pointer;
  text-align: left;
  transform: none;
}

.apothecary-bench-recipe-row:hover,
.apothecary-bench-recipe-row:active {
  border-color: #58a6ff;
  background: #161b22;
  transform: none;
}

.apothecary-bench-recipe-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.apothecary-bench-recipe-ingredients {
  font-size: 0.72rem;
  color: #8b949e;
  line-height: 1.25;
}

.apothecary-bench-recipe-icon {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.apothecary-bench-recipe-row-dim {
  opacity: 0.42;
}

.apothecary-bench-recipe-row-active {
  border-color: rgba(74, 222, 128, 0.55);
}

.apothecary-bench-recipe-row-selected {
  box-shadow: inset 0 0 0 1px rgba(134, 239, 172, 0.65);
}

.apothecary-bench-recipe-name {
  font-size: 0.85rem;
  color: #e6edf3;
}

.apothecary-bench-recipes-empty {
  margin: 0;
  color: #8b949e;
  font-size: 0.82rem;
}

.apothecary-bench-drag-ghost {
  position: fixed;
  z-index: 10050;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

/* Global button:hover scale breaks cylinder chamber transforms — exclude chamber slots */
#apothecary-bench-overlay .apothecary-bench-inv-slot:hover,
#apothecary-bench-overlay .apothecary-bench-inv-slot:active,
#apothecary-bench-overlay .apothecary-bench-recipe-row:hover,
#apothecary-bench-overlay .apothecary-bench-recipe-row:active,
#apothecary-bench-overlay .apothecary-bench-brew-qty-btn:hover,
#apothecary-bench-overlay .apothecary-bench-brew-qty-btn:active {
  transform: none;
}

#apothecary-bench-overlay .apothecary-chamber-slot:hover,
#apothecary-bench-overlay .apothecary-chamber-slot:active {
  transform: rotate(var(--chamber-angle)) translateY(-108px) rotate(calc(-1 * var(--chamber-angle)));
}

#apothecary-bench-overlay .apothecary-bench-close-corner:hover {
  background: linear-gradient(180deg, #4a7c1a 0%, #243a08 100%);
}

#apothecary-bench-overlay .apothecary-bench-brew-btn:hover:not(:disabled) {
  background: radial-gradient(circle at 35% 30%, #86efac 0%, #15803d 70%);
}

#apothecary-bench-overlay .apothecary-bench-brew-btn:active:not(:disabled) {
  background: radial-gradient(circle at 35% 30%, #4ade80 0%, #166534 70%);
}

body:has(#apothecary-bench-overlay:not(.hidden)) #inv-item-tooltip {
  z-index: 10100;
}
