:root{
  --bg:#f6f6f6;
  --aa-hue: 8;
  --accent:#3ba55d;
  --muted:#888;
}
*{box-sizing:border-box}
body{font-family:Segoe UI, Roboto, "Noto Sans TC", "Microsoft JhengHei", Arial, sans-serif;background:var(--bg);color:#222;margin:0;padding:20px}
header h1{margin:0 0 6px 0;font-size:20px}
header p{margin:0 0 18px;color:var(--muted)}
.legend{display:flex;gap:12px;margin-bottom:12px}
.legend .nutrient{display:flex;align-items:center;justify-content:center;padding:8px 12px;border-radius:8px;background:#fff;box-shadow:0 1px 0 rgba(0,0,0,0.06);cursor:default}
.legend .nutrient .label{font-weight:600;color:#444}
.legend .carb{border-left:6px solid #7b7bd6}
.legend .protein{border-left:6px solid #d65a5a}
.legend .fat{border-left:6px solid #f4a741}

.canvas{position:relative;background:#fff;border-radius:8px;padding:12px;max-width:520px;margin:auto;box-shadow:0 6px 24px rgba(0,0,0,0.06)}
/* Main canvas SVG (digestive tract) keeps the large background. Other inline SVGs should be auto-sized and transparent. */
#svg{display:block;width:100%;height:720px;background:linear-gradient(#fff,#fafafa);border-radius:6px}

/* Inline SVG icons inside tokens should not inherit the page SVG background or full-size height */
svg:not(#svg){
  display:inline-block;
  width:auto;
  height:auto;
  background:transparent;
  border-radius:0;
}

#tokens{position:absolute;left:18px;top:18px;display:flex;flex-direction:column;gap:8px}
.token{padding:10px 14px;border-radius:22px;border:none;background:#fff;box-shadow:0 2px 6px rgba(0,0,0,0.08);cursor:pointer;font-weight:700}
.token.carb{color:#4b45b6}
.token.protein{color:#b93b3b}
.token.fat{color:#b86f18}
.token:active{transform:scale(0.98)}

.moving{position:fixed;z-index:30;pointer-events:none;padding:8px 10px;border-radius:18px;color:#fff;font-weight:700}
.moving.carb{background:linear-gradient(90deg,#6f6fe0,#9b8ef0)}
.moving.protein{background:linear-gradient(90deg,#d85a5a,#f08a8a)}
.moving.fat{background:transparent;padding:2px}

.moving.protein{background:transparent;padding:2px}
.svg-aa{filter:drop-shadow(0 1px 0 rgba(0,0,0,0.06));}
.svg-aa:hover{opacity:0.95}
.protein-child svg{display:block;height:auto}
/* small visual tweak so amino shapes inside moving token are centered */
.moving.protein svg{height:34px}
.moving.child.protein-child svg{height:24px}

/* Starch chain (linked hexagons) and hexagon molecule styles */
.starch-chain{display:flex;gap:6px;align-items:center;padding:6px}
.hex{display:inline-block;width:22px;height:24px;background:linear-gradient(90deg,#6f6fe0,#9b8ef0);clip-path:polygon(25% 0%,75% 0%,100% 50%,75% 100%,25% 100%,0% 50%);box-shadow:0 1px 0 rgba(0,0,0,0.08);}
.hex:before{content:'';display:block;width:100%;height:100%;}
.hex.small{width:12px;height:13px;background:linear-gradient(90deg,#6f6fe0,#9b8ef0);}
.starch-chain .hex{margin-right:-4px}

/* inline-SVG hex styles */
.moving svg{display:block;height:auto;pointer-events:none;background:transparent}
.moving.carb{background:transparent;padding:2px}
.svg-hex{filter:drop-shadow(0 1px 0 rgba(0,0,0,0.06));}
.svg-hex:hover{opacity:0.95}

/* split elements (maltose / glucose units) inside a moving token */
.split-container{display:inline-flex;align-items:center;gap:8px}
.split-mol{display:inline-block;pointer-events:none;opacity:1;background:transparent}
.split-mol svg{display:block;height:auto;background:transparent}
.split-mol{transform:translate(0,0);}

.small-mols{display:flex;gap:6px;align-items:center}
.small-mols .mol{width:10px;height:10px;border-radius:50%;background:transparent;box-shadow:none}
.small-mols .mol.glucose{background:transparent}
.small-mols .hex.small{box-shadow:0 1px 0 rgba(0,0,0,0.08);}
.small-mols .mol.glucose.hex.small{background:linear-gradient(90deg,#6f6fe0,#9b8ef0)}
.small-mols .mol.aa{background: hsl(var(--aa-hue) 65% 50%)}
.small-mols .mol.gly{background:#f0a84a}

#info{position:absolute;right:18px;top:18px;max-width:200px;background:rgba(255,255,255,0.9);padding:8px;border-radius:8px;border:1px solid #eee;font-size:13px;color:#333}

@media (max-width:640px){
  svg{height:640px}
  .canvas{padding:8px}
}
